Here are the examples of the python api gocardless.request.Request taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
3 Examples
3
Example 1
Project: gocardless-legacy-python Source File: test_request.py
@mock.patch('gocardless.request.requests')
def test_perform_passes_params_through(self, mock_requests):
params = {'x': 'y'}
request = gocardless.request.Request('get', 'http://test.com', params)
mock_requests.get.return_value.content = '{"a": "b"}'
request.perform()
mock_requests.get.assert_called_once_with(mock.ANY, headers=mock.ANY,
params=params)
0
Example 2
def _request(self, method, path, **kwargs):
"""
Send a request to the GoCardless API servers.
:param method: the HTTP method to use (e.g. +:get+, +:post+)
:param path: the path fragment of the URL
"""
request_url = self.get_base_url() + path
request = Request(method, request_url, params=kwargs.get("params"))
logger.debug("Executing request to {0}".format(request_url))
if 'auth' in kwargs:
# If using HTTP basic auth, let requests handle it
request.use_http_auth(*kwargs['auth'])
else:
# Default to using bearer auth with the access token
request.use_bearer_auth(self._access_token)
request.set_payload(kwargs.get('data'))
response = request.perform()
if type(response) == dict and "errors" in response.keys():
raise ClientError("Error calling api, message was ",
response["errors"])
if type(response) == dict and "error" in response.keys():
raise ClientError("Error calling api, message was ",
response["error"])
return response
0
Example 3
def setUp(self):
self.request = gocardless.request.Request('get', 'http://test.com')