How to use the smartcar.const.API_URL 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_vehicle.py View on Github external
def queue(self, method, endpoint, body=None, query=None, headers=None):
        """ queue a mock response """
        url = '/'.join((smartcar.const.API_URL, 'vehicles',
                        self.vehicle_id, endpoint))
        if query:
            query_string = '&'.join(
                k + '=' + str(v) for k, v in query.items()
            )
            url += '?' + query_string
        if not body:
            body = {}
        if not headers:
            headers = {}

        responses.add(method, url,
                      json=body,
                      match_querystring=bool(query),
                      headers=headers)
github smartcar / python-sdk / tests / test_smartcar.py View on Github external
def test_is_compatible(self):
        fake_vin = 'vin'
        scope = ['read_odometer', 'read_location']

        query = { 'vin': fake_vin, 'scope': 'read_odometer read_location' }
        responses.add('GET', smartcar.const.API_URL + '/compatibility?' + urlencode(query), json={
            'compatible': True
        }, match_querystring=True)
        actual = self.client.is_compatible(fake_vin, scope)
        self.assertTrue(actual)
github smartcar / python-sdk / smartcar / api.py View on Github external
def vehicles(self, **params):
        """ Sends a request to /vehicles

        Args:
            **params: parameters for the request

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

        """
        url = '{}/{}'.format(const.API_URL, 'vehicles')
        return requester.call('GET', url, headers=self.auth, params=params)
github smartcar / python-sdk / smartcar / api.py View on Github external
def _format(self, endpoint):
        """ Generates the formated URL

        Args:
            endpoint (str): the Smartcar endpoint of interest

        Returns:
            str: formatted url

        """
        return '{}/vehicles/{}/{}'.format(const.API_URL, self.vehicle_id, endpoint)
github smartcar / python-sdk / smartcar / smartcar.py View on Github external
def is_compatible(self, vin, scope):
        """ Determine if a vehicle is compatible with Smartcar

        Args:
            vin (str): the VIN of the vehicle
            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']