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_user_agent(self):
self.queue(200)
smartcar.requester.call('GET', self.URL)
self.assertRegexpMatches(
responses.calls[0].request.headers['User-Agent'],
r'^Smartcar\/(\d+\.\d+\.\d+) \((\w+); (\w+)\) Python v(\d+\.\d+\.\d+)$')
def user(self, **params):
""" Sends a request to /user
Args:
**params: parameters for the request
Returns:
Response: response from the request to the Smartcar API
"""
url = '{}/{}'.format(const.API_URL, 'user')
return requester.call('GET', url, headers=self.auth, params=params)
def get(self, endpoint):
""" Sends GET requests to Smartcar API
Args:
endpoint (str): the Smartcar endpoint of interest
Returns:
Response: response from the request to the Smartcar API
"""
url = self._format(endpoint)
headers = self.auth
headers[const.UNIT_SYSTEM_HEADER] = self.unit_system
return requester.call('GET', url, headers=headers)
access object
Returns:
dict: dict containing access and refresh token
Raises:
SmartcarException
"""
method = 'POST'
url = const.AUTH_URL
data = {
'grant_type': 'refresh_token',
'refresh_token': refresh_token
}
response = requester.call(method, url, data=data, auth=self.auth).json()
return set_expiration(response)