How to use the mercadopago.response.PaginatedResponse 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_is_last_page(c, res):
    res.data['paging']['total'] = 20
    res.data['paging']['limit'] = 10
    res.data['paging']['offset'] = 10

    response = PaginatedResponse(c, res)
    assert response.has_next() is False
    assert response.has_prev() is True
github federicobond / pymercadopago / tests / test_response.py View on Github external
def test_response_is_first_page(c, res):
    res.data['paging']['total'] = 100
    res.data['paging']['offset'] = 0

    response = PaginatedResponse(c, res)
    assert response.has_next() is True
    assert response.has_prev() is False
github federicobond / pymercadopago / tests / test_response.py View on Github external
def test_response_has_next_prev(c, res):
    response = PaginatedResponse(c, res)
    assert response.has_next() is True
    assert response.has_prev() is False
github federicobond / pymercadopago / tests / test_response.py View on Github external
def test_paginated_response_is_iterable(c, res):
    response = PaginatedResponse(c, res)
    assert list(iter(response)) == res.data['results']
github federicobond / pymercadopago / tests / test_response.py View on Github external
def test_response_next(c, res):
    res.data['paging']['total'] = 100

    response = PaginatedResponse(c, res)

    expect(c, 'GET', '/v1/payments/search', params={'offset': 10})
    response.next()
github federicobond / pymercadopago / tests / test_response.py View on Github external
def test_paginated_response_paging(c, res):
    res.data['paging']['total'] = 20
    res.data['paging']['limit'] = 10
    res.data['paging']['offset'] = 0

    response = PaginatedResponse(c, res)
    assert response.total == 20
    assert response.limit == 10
    assert response.offset == 0
github federicobond / pymercadopago / tests / test_response.py View on Github external
def test_response_prev(c, res):
    res.data['paging']['total'] = 100
    res.data['paging']['offset'] = 20

    response = PaginatedResponse(c, res)

    expect(c, 'GET', '/v1/payments/search', params={'offset': 10})
    response.prev()
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)