def __call__(self, method, url, codes=(200, 201, 202, 204, 207), auth=None, headers=None, **kwargs):
        """
        Make an API call.  Most parameters are passed directly to :mod:`requests`.

        Set codes to a list of valid HTTP response codes -- an exception is raised if the response does not match.

        If authentication is required, set ``auth`` to one of the :class:`Auth` constants.

        Args:
            method (str): HTTP request method
            url (str): full URL to connect to
            codes (int list): expected HTTP response codes for success
            auth (Auth): authentication type to be included
            headers (dict): additional headers to be included
            kwargs (dict): any extra parameters to pass to :func:`requests.request`

        Returns:
            requests.Response: response object provided by :mod:`requests`

        Raises:
            .SkypeAuthException: if an authentication rate limit is reached
            .SkypeApiException: if a successful status code is not received
        """
        self.verifyToken(auth)
        if not headers:
            headers = {}
        if auth == self.Auth.SkypeToken:
            headers["X-SkypeToken"] = self.tokens["skype"]
        elif auth == self.Auth.Authorize:
            headers["Authorization"] = "skype_token {0}".format(self.tokens["skype"])
        elif auth == self.Auth.RegToken:
            headers["RegistrationToken"] = self.tokens["reg"]
        if os.getenv("SKPY_DEBUG_HTTP"):
            print("<= [{0}] {1} {2}".format(datetime.now().strftime("%d/%m %H:%M:%S"), method, url))
            print(pformat(kwargs))
        resp = self.sess.request(method, url, headers=headers, **kwargs)
        if os.getenv("SKPY_DEBUG_HTTP"):
            print("=> [{0}] {1}".format(datetime.now().strftime("%d/%m %H:%M:%S"), resp.status_code))
            print(pformat(dict(resp.headers)))
            try:
                print(pformat(resp.json()))
            except ValueError:
                print(resp.text)
        if resp.status_code not in codes:
            if resp.status_code == 429:
                raise SkypeAuthException("Auth rate limit exceeded", resp)
            raise SkypeApiException("{0} response from {1} {2}".format(resp.status_code, method, url), resp)
        return resp
def __call__ ( self , method , url , codes = ( 200 , 201 , 202 , 204 , 207 ) , auth = None , headers = None , ** kwargs ) : self . verifyToken ( auth ) if not headers : headers = { } if auth == self . Auth . SkypeToken : headers [ "X-SkypeToken" ] = self . tokens [ "skype" ] elif auth == self . Auth . Authorize : headers [ "Authorization" ] = "skype_token {0}" . format ( self . tokens [ "skype" ] ) elif auth == self . Auth . RegToken : headers [ "RegistrationToken" ] = self . tokens [ "reg" ] if os . getenv ( "SKPY_DEBUG_HTTP" ) : print ( "<= [{0}] {1} {2}" . format ( datetime . now ( ) . strftime ( "%d/%m %H:%M:%S" ) , method , url ) ) print ( pformat ( kwargs ) ) resp = self . sess . request ( method , url , headers = headers , ** kwargs ) if os . getenv ( "SKPY_DEBUG_HTTP" ) : print ( "=> [{0}] {1}" . format ( datetime . now ( ) . strftime ( "%d/%m %H:%M:%S" ) , resp . status_code ) ) print ( pformat ( dict ( resp . headers ) ) ) try : print ( pformat ( resp . json ( ) ) ) except ValueError : print ( resp . text ) if resp . status_code not in codes : if resp . status_code == 429 : raise SkypeAuthException ( "Auth rate limit exceeded" , resp ) raise SkypeApiException ( "{0} response from {1} {2}" . format ( resp . status_code , method , url ) , resp ) return resp
Make an API call.  Most parameters are passed directly to :mod:`requests`.

        Set codes to a list of valid HTTP response codes -- an exception is raised if the response does not match.

        If authentication is required, set ``auth`` to one of the :class:`Auth` constants.

        Args:
            method (str): HTTP request method
            url (str): full URL to connect to
            codes (int list): expected HTTP response codes for success
            auth (Auth): authentication type to be included
            headers (dict): additional headers to be included
            kwargs (dict): any extra parameters to pass to :func:`requests.request`

        Returns:
            requests.Response: response object provided by :mod:`requests`

        Raises:
            .SkypeAuthException: if an authentication rate limit is reached
            .SkypeApiException: if a successful status code is not received