How to use the mercadopago.response.Response function in mercadopago

To help you get started, we’ve selected a few mercadopago 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 federicobond / pymercadopago / tests / test_response.py View on Github external
def test_response_init(c, res):
    Response(c, res)
github federicobond / pymercadopago / tests / test_response.py View on Github external
def test_response_status_code(c, res):
    res.status_code = 404
    assert Response(c, res).status_code == 404
github federicobond / pymercadopago / tests / test_response.py View on Github external
def test_response_url(c, res):
    res.url = c.base_url + '/users/me'
    assert Response(c, res).url == c.base_url + '/users/me'
github federicobond / pymercadopago / mercadopago / api.py View on Github external
def get(self, id):
        # NOTE: this is actually performing a search with ID and mangling
        # the response data to conform to a single object format.
        # There is no method to retrieve a preapproval by ID at the moment.

        res = self.search(id=id)

        if not res.data['results']:
            raise errors.NotFoundError('could not find preapproval with ID = %s' % id)

        res = Response(self._client.client, res._response)  # pylint: disable=protected-access
        res.data = res.data['results'][0]

        return res
github federicobond / pymercadopago / mercadopago / client.py View on Github external
def _request(self, method, url, **kwargs):
        try:
            res = self._session.request(method, url, **kwargs)
            res.raise_for_status()
        except (requests.ConnectionError, requests.HTTPError) as error:
            self._handle_request_error(error)

        try:
            data = res.json()
            if 'paging' in data:
                return response.PaginatedResponse(self, res)
        except ValueError:
            pass

        return response.Response(self, res)