def send_request(self, method, url, headers=None,
                     data=None, is_retry=False):
        """Send requests to Abode."""
        if not self._token:
            self.login()

        if not headers:
            headers = {}

        headers['Authorization'] = 'Bearer ' + self._oauth_token
        headers['ABODE-API-KEY'] = self._token

        try:
            response = getattr(self._session, method)(
                url, headers=headers, json=data)

            if response and response.status_code < 400:
                return response
        except RequestException:
            _LOGGER.info("Abode connection reset...")

        if not is_retry:
            # Delete our current token and try again -- will force a login
            # attempt.
            self._token = None

            return self.send_request(method, url, headers, data, True)

        raise AbodeException((ERROR.REQUEST))
def send_request ( self , method , url , headers = None , data = None , is_retry = False ) : if not self . _token : self . login ( ) if not headers : headers = { } headers [ 'Authorization' ] = 'Bearer ' + self . _oauth_token headers [ 'ABODE-API-KEY' ] = self . _token try : response = getattr ( self . _session , method ) ( url , headers = headers , json = data ) if response and response . status_code < 400 : return response except RequestException : _LOGGER . info ( "Abode connection reset..." ) if not is_retry : self . _token = None return self . send_request ( method , url , headers , data , True ) raise AbodeException ( ( ERROR . REQUEST ) )
Send requests to Abode.