Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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')
def check(self, exception):
self.assertRaisesRegexp(exception, self.EXPECTED,
smartcar.requester.call, 'GET', self.URL)
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']
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)
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)
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)