Perform a request to the ZoneMinder API.

def _zm_request(self, method, api_url, data=None,
                    timeout=DEFAULT_TIMEOUT) -> dict:
        """Perform a request to the ZoneMinder API."""
        try:
            # Since the API uses sessions that expire, sometimes we need to
            # re-auth if the call fails.
            for _ in range(ZoneMinder.LOGIN_RETRIES):
                req = requests.request(
                    method, urljoin(self._server_url, api_url), data=data,
                    cookies=self._cookies, timeout=timeout,
                    verify=self._verify_ssl)

                if not req.ok:
                    self.login()
                else:
                    break

            else:
                _LOGGER.error('Unable to get API response from ZoneMinder')

            try:
                return req.json()
            except ValueError:
                _LOGGER.exception('JSON decode exception caught while'
                                  'attempting to decode "%s"', req.text)
                return {}
        except requests.exceptions.ConnectionError:
            _LOGGER.exception('Unable to connect to ZoneMinder')
            return {}