How to use the mercadopago.abstract_api.API 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 / mercadopago / api.py View on Github external
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

    def cancel(self, id):
        return self.update(id, status='cancelled')

    def pause(self, id):
        return self.update(id, status='paused')


class ShippingOptionAPI(API):
    _base_path = '/shipping_options'

    def get(self, **data):
        return self._client.get(params=data)


class PosAPI(RetrievableAPIResource, CreatableAPIResource,
             UpdatableAPIResource, DeletableAPIResource, ListableAPIResource):
    _base_path = '/pos'


class UsersAPI(API):
    _base_path = '/users'

    def me(self):
        return self._client.get('/me')
github federicobond / pymercadopago / mercadopago / abstract_api.py View on Github external
return self._client.post(json=data)


class UpdatableAPIResource(API):

    def update(self, id, **data):
        return self._client.put('/{id}', {'id': id}, json=data)


class DeletableAPIResource(API):

    def delete(self, id):
        return self._client.delete('/{id}', {'id': id})


class ListableAPIResource(API):

    def list(self, **params):
        return self._client.get(params=params)


class SearchableAPIResource(API):

    def search(self, **params):
        return self._client.get('/search', params=params)
github federicobond / pymercadopago / mercadopago / api.py View on Github external
SearchableAPIResource,
    UpdatableAPIResource,
)
from .client import BaseClient
from .response import Response


class CardAPI(ListableAPIResource, RetrievableAPIResource, CreatableAPIResource,
              UpdatableAPIResource, DeletableAPIResource):
    _base_path = '/v1/customers/{customer_id}/cards'

    def __init__(self, client, customer_id):
        super().__init__(client, path_args={'customer_id': customer_id})


class CardTokenAPI(API):
    _base_path = '/v1/card_tokens'

    def create(self, public_key, **data):
        return self._client.post('/', params={'public_key': public_key}, json=data)

    def get(self, id, public_key):
        return self._client.get('/{id}', {'id': id}, params={'public_key': public_key})

    def update(self, id, public_key, **data):
        return self._client.put('/{id}', {'id': id}, params={'public_key': public_key}, json=data)


class CustomerAPI(RetrievableAPIResource, CreatableAPIResource,
                  UpdatableAPIResource, DeletableAPIResource,
                  SearchableAPIResource):
    _base_path = '/v1/customers'
github federicobond / pymercadopago / mercadopago / api.py View on Github external
class AdvancedPaymentAPI(RetrievableAPIResource, CreatableAPIResource,
                          UpdatableAPIResource, SearchableAPIResource):

    _base_path = '/v1/advanced_payments'

    def refund(self, id):
        return self._client.post('/{id}/refunds', {'id': id})

    def disburses(self, id, **data):
        return self._client.post('/{id}/disburses', {'id': id}, json=data)

    def disbursements(self, id):
        return DisbursementAPI(self._client, id)


class DisbursementAPI(API):
    _base_path = '/v1/advanced_payments/{payment_id}/disbursements'

    def __init__(self, client, payment_id):
        super().__init__(client, path_args={'payment_id': payment_id})

    def refunds(self, id, **data):
        return self._client.post('/{disbursement_id}/refunds', {'disbursement_id': id}, json=data)

    def disburses(self, id, **data):
        return self._client.post('/{disbursement_id}/disburses', {'disbursement_id': id}, json=data)


class ChargebackAPI(RetrievableAPIResource):
    _base_path = '/v1/chargebacks'
github federicobond / pymercadopago / mercadopago / api.py View on Github external
return self._client.post('/config', json=data)

    def config_update(self, **data):
        return self._client.put('/config', json=data)

    def config_get(self):
        return self._client.get('/config')

    def schedule_set(self, **data):
        return self._client.post('/schedule', json=data)

    def schedule_delete(self):
        return self._client.delete('/schedule')


class AccountAPI(API):
    _base_path = '/v1/account'

    @property
    def bank_report(self):
        return BankReportAPI(self._client)

    @property
    def settlement_report(self):
        return SettlementReportAPI(self._client)


class SiteAPI(ListableAPIResource):
    _base_path = '/sites'


class Client(BaseClient):
github federicobond / pymercadopago / mercadopago / api.py View on Github external
return self.update(id, status='paused')


class ShippingOptionAPI(API):
    _base_path = '/shipping_options'

    def get(self, **data):
        return self._client.get(params=data)


class PosAPI(RetrievableAPIResource, CreatableAPIResource,
             UpdatableAPIResource, DeletableAPIResource, ListableAPIResource):
    _base_path = '/pos'


class UsersAPI(API):
    _base_path = '/users'

    def me(self):
        return self._client.get('/me')

    def account_balance(self, user_id=None):
        if user_id is None:
            user_id = self.me().data['id']

        return self._client.get('/{user_id}/mercadopago_account/balance', {
            'user_id': user_id
        })

    def test_user_create(self, site_id):
        return self._client.post('/test_user', json={'site_id': site_id})
github federicobond / pymercadopago / mercadopago / abstract_api.py View on Github external
return '<{} at {}>'.format(self.__class__.__name__, self._base_path)


class RetrievableAPIResource(API):

    def get(self, id):
        return self._client.get('/{id}', {'id': id})


class CreatableAPIResource(API):

    def create(self, **data):
        return self._client.post(json=data)


class UpdatableAPIResource(API):

    def update(self, id, **data):
        return self._client.put('/{id}', {'id': id}, json=data)


class DeletableAPIResource(API):

    def delete(self, id):
        return self._client.delete('/{id}', {'id': id})


class ListableAPIResource(API):

    def list(self, **params):
        return self._client.get(params=params)
github federicobond / pymercadopago / mercadopago / abstract_api.py View on Github external
_base_path = None

    def __init__(self, client, path_args={}):
        self._client = client.for_base_path(self._base_path, path_args)

    def __repr__(self):
        return '<{} at {}>'.format(self.__class__.__name__, self._base_path)


class RetrievableAPIResource(API):

    def get(self, id):
        return self._client.get('/{id}', {'id': id})


class CreatableAPIResource(API):

    def create(self, **data):
        return self._client.post(json=data)


class UpdatableAPIResource(API):

    def update(self, id, **data):
        return self._client.put('/{id}', {'id': id}, json=data)


class DeletableAPIResource(API):

    def delete(self, id):
        return self._client.delete('/{id}', {'id': id})
github federicobond / pymercadopago / mercadopago / abstract_api.py View on Github external
return self._client.get('/{id}', {'id': id})


class CreatableAPIResource(API):

    def create(self, **data):
        return self._client.post(json=data)


class UpdatableAPIResource(API):

    def update(self, id, **data):
        return self._client.put('/{id}', {'id': id}, json=data)


class DeletableAPIResource(API):

    def delete(self, id):
        return self._client.delete('/{id}', {'id': id})


class ListableAPIResource(API):

    def list(self, **params):
        return self._client.get(params=params)


class SearchableAPIResource(API):

    def search(self, **params):
        return self._client.get('/search', params=params)
github federicobond / pymercadopago / mercadopago / abstract_api.py View on Github external
from __future__ import unicode_literals


class API:
    _base_path = None

    def __init__(self, client, path_args={}):
        self._client = client.for_base_path(self._base_path, path_args)

    def __repr__(self):
        return '<{} at {}>'.format(self.__class__.__name__, self._base_path)


class RetrievableAPIResource(API):

    def get(self, id):
        return self._client.get('/{id}', {'id': id})


class CreatableAPIResource(API):

    def create(self, **data):
        return self._client.post(json=data)


class UpdatableAPIResource(API):

    def update(self, id, **data):
        return self._client.put('/{id}', {'id': id}, json=data)