How to use the smartcar.requester function in smartcar

To help you get started, we’ve selected a few smartcar examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github smartcar / python-sdk / tests / test_requester.py View on Github external
def test_unknown_error(self):
        self.queue(401, unknown_field='unknown error')
        try:
            smartcar.requester.call('GET', self.URL)
        except smartcar.AuthenticationException as err:
            self.assertEqual(err.message, 'Unknown error')
github smartcar / python-sdk / tests / test_requester.py View on Github external
def check(self, exception):

        self.assertRaisesRegexp(exception, self.EXPECTED,
                                smartcar.requester.call, 'GET', self.URL)
github smartcar / python-sdk / smartcar / smartcar.py View on Github external
scope (list): list of permissions to return compatibility info for

        Returns:
            boolean: true if the vehicle is compatible

        Raises:
            SmartcarException

        """
        method = 'GET'
        url = const.API_URL + '/compatibility'
        query = {
            'vin': vin,
            'scope': " ".join(scope)
        }
        response = requester.call(method, url, params=query, auth=self.auth).json()
        return response['compatible']
github smartcar / python-sdk / smartcar / smartcar.py View on Github external
Returns:
            dict: dict containing the access and refresh token

        Raises:
            SmartcarException

        """
        method = 'POST'
        url = const.AUTH_URL
        data = {
            'grant_type': 'authorization_code',
            'code': code,
            'redirect_uri': self.redirect_uri,
        }
        response = requester.call(method, url, data=data, auth=self.auth).json()
        return set_expiration(response)
github smartcar / python-sdk / smartcar / api.py View on Github external
def permissions(self, **params):
        """ Sends a request to /permissions

        Args:
            **params: parameters for the request

        Returns:
            Reponse: response from the request to the Smartcar API

        """
        url = self._format('permissions')
        return requester.call('GET', url, headers=self.auth, params=params)
github smartcar / python-sdk / smartcar / api.py View on Github external
endpoint (str): the Smartcar endpoint of interest
            action (str): action to be taken
            **kwargs: information to put into the body of the request

        Returns:
            Response: response from the request to the Smartcar API

        """
        url = self._format(endpoint)
        headers = self.auth
        json = { 'action': action }
        for k,v in kwargs.items():
            if v:
                json[k] = v

        return requester.call('POST', url, json=json, headers=headers)