How to use the mercadopago.Client 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_client.py View on Github external
def test_client_init_with_credentials():
    Client('XXX', 'XXX')
github federicobond / pymercadopago / tests / util.py View on Github external
return self.request('DELETE', *args, **kwargs)

    def request(self, *args, **kwargs):
        if not self.expected:
            raise ValueError('did not expect any requests, received %s, %s' % (args, kwargs))

        exp = self.expected.pop(0)
        res = self.returned.pop(0)

        if exp != (args, kwargs):
            raise ValueError('expected:\n  %s\nreceived:\n  %s' % (exp, (args, kwargs)))

        return res


class SpyClient(Client):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self._session = SpySession()

    def force_authenticate(self):
        # just fill the _auth variable with something that has an access token
        self._auth = {'access_token': 'XXX'}


def expect(client, *args, **kwargs):
    # add implicit access_token if we are given an authenticated client
    if client._auth:
        if 'params' not in kwargs:
            kwargs['params'] = {}
        kwargs['params']['access_token'] = 'XXX'