def list(per_page=None, page=None): """ List of payments. You have to handle pagination manually :param page: the page number :type page: int|None :param per_page: number of payment per page. It's a good practice to increase this number if you know that you will need a lot of payments. :type per_page: int|None :return A collection of payment :rtype resources.APIResourceCollection """ # Comprehension dict are not supported in Python 2.6-. You can use this commented line instead of the current # line when you drop support for Python 2.6. # pagination = {key: value for (key, value) in [('page', page), ('per_page', per_page)] if value} pagination = dict( (key, value) for (key, value) in [('page', page), ('per_page', per_page)] if value) http_client = HttpClient() response, _ = http_client.get( routes.url(routes.PAYMENT_RESOURCE, pagination=pagination)) return resources.APIResourceCollection(resources.Payment, **response)
def list(customer, per_page=None, page=None): """ List of cards. You have to handle pagination manually for the moment. :param customer: the customer id or object :type customer: string|Customer :param page: the page number :type page: int|None :param per_page: number of customers per page. It's a good practice to increase this number if you know that you will need a lot of payments. :type per_page: int|None :return A collection of cards :rtype resources.APIResourceCollection """ if isinstance(customer, resources.Customer): customer = customer.id # Comprehension dict are not supported in Python 2.6-. You can use this commented line instead of the current # line when you drop support for Python 2.6. # pagination = {key: value for (key, value) in [('page', page), ('per_page', per_page)] if value} pagination = dict((key, value) for (key, value) in [('page', page), ('per_page', per_page)] if value) http_client = HttpClient() response, _ = http_client.get(routes.url(routes.CARD_RESOURCE, customer_id=customer, pagination=pagination)) return resources.APIResourceCollection(resources.Card, **response)
def list(customer, per_page=None, page=None): """ List of cards. You have to handle pagination manually for the moment. :param customer: the customer id or object :type customer: string|Customer :param page: the page number :type page: int|None :param per_page: number of customers per page. It's a good practice to increase this number if you know that you will need a lot of payments. :type per_page: int|None :return A collection of cards :rtype resources.APIResourceCollection """ if isinstance(customer, resources.Customer): customer = customer.id # Comprehension dict are not supported in Python 2.6-. You can use this commented line instead of the current # line when you drop support for Python 2.6. # pagination = {key: value for (key, value) in [('page', page), ('per_page', per_page)] if value} pagination = dict( (key, value) for (key, value) in [('page', page), ('per_page', per_page)] if value) http_client = HttpClient() response, _ = http_client.get( routes.url(routes.CARD_RESOURCE, customer_id=customer, pagination=pagination)) return resources.APIResourceCollection(resources.Card, **response)
def get_consistent_resource(self): """ :return a payment that you can trust. :rtype Payment """ http_client = HttpClient() response, _ = http_client.get(routes.url(routes.PAYMENT_RESOURCE, resource_id=self.id)) return Payment(**response)
def get_consistent_resource(self): """ :return a payment that you can trust. :rtype Payment """ http_client = HttpClient() response, _ = http_client.get( routes.url(routes.PAYMENT_RESOURCE, resource_id=self.id)) return Payment(**response)
def get_consistent_resource(self): """ :return a refund that you can trust. :rtype Refund """ http_client = HttpClient() response, _ = http_client.get( routes.url(routes.REFUND_RESOURCE, resource_id=self.id, payment_id=self.payment_id) ) return Refund(**response)
def get_consistent_resource(self): """ :return a refund that you can trust. :rtype Refund """ http_client = HttpClient() response, _ = http_client.get( routes.url(routes.REFUND_RESOURCE, resource_id=self.id, payment_id=self.payment_id)) return Refund(**response)
def retrieve(customer_id): """ Retrieve a customer from its id. :param customer_id: The customer id :type customer_id: string :return: The customer resource :rtype: resources.Customer """ http_client = HttpClient() response, __ = http_client.get(routes.url(routes.CUSTOMER_RESOURCE, resource_id=customer_id)) return resources.Customer(**response)
def retrieve(payment_id): """ Retrieve a payment from its id. :param payment_id: The payment id :type payment_id: string :return: The payment resource :rtype: resources.Payment """ http_client = HttpClient() response, __ = http_client.get(routes.url(routes.RETRIEVE_PAYMENT, payment_id=payment_id)) return resources.Payment(**response)
def retrieve(customer_id): """ Retrieve a customer from its id. :param customer_id: The customer id :type customer_id: string :return: The customer resource :rtype: resources.Customer """ http_client = HttpClient() response, __ = http_client.get( routes.url(routes.CUSTOMER_RESOURCE, resource_id=customer_id)) return resources.Customer(**response)
def retrieve(payment_id): """ Retrieve a payment from its id. :param payment_id: The payment id :type payment_id: string :return: The payment resource :rtype: resources.Payment """ http_client = HttpClient() response, __ = http_client.get( routes.url(routes.PAYMENT_RESOURCE, resource_id=payment_id)) return resources.Payment(**response)
def list(payment): """ List all the refunds for a payment. :param payment: The payment object or the payment id :type payment: resources.Payment|string :return: A collection of refunds :rtype resources.APIResourceCollection """ if isinstance(payment, resources.Payment): payment = payment.id http_client = HttpClient() response, _ = http_client.get(routes.url(routes.LIST_REFUNDS, payment_id=payment)) return resources.APIResourceCollection(resources.Refund, **response)
def list(payment): """ List all the refunds for a payment. :param payment: The payment object or the payment id :type payment: resources.Payment|string :return: A collection of refunds :rtype resources.APIResourceCollection """ if isinstance(payment, resources.Payment): payment = payment.id http_client = HttpClient() response, _ = http_client.get( routes.url(routes.REFUND_RESOURCE, payment_id=payment)) return resources.APIResourceCollection(resources.Refund, **response)
def retrieve(payment, refund_id): """ Retrieve a refund from a payment and the refund id. :param payment: The payment id or the payment object :type payment: resources.Payment|string :param refund_id: The refund id :type refund_id: string :return: The refund resource :rtype: resources.Refund """ if isinstance(payment, resources.Payment): payment = payment.id http_client = HttpClient() response, _ = http_client.get(routes.url(routes.RETRIEVE_REFUND, payment_id=payment, refund_id=refund_id)) return resources.Refund(**response)
def retrieve(customer, card_id): """ Retrieve a card from its id. :param customer: The customer id or object :type customer: string|Customer :param card_id: The card id :type card_id: string :return: The customer resource :rtype: resources.Card """ if isinstance(customer, resources.Customer): customer = customer.id http_client = HttpClient() response, __ = http_client.get(routes.url(routes.CARD_RESOURCE, resource_id=card_id, customer_id=customer)) return resources.Card(**response)
def retrieve(payment, refund_id): """ Retrieve a refund from a payment and the refund id. :param payment: The payment id or the payment object :type payment: resources.Payment|string :param refund_id: The refund id :type refund_id: string :return: The refund resource :rtype: resources.Refund """ if isinstance(payment, resources.Payment): payment = payment.id http_client = HttpClient() response, _ = http_client.get( routes.url(routes.REFUND_RESOURCE, resource_id=refund_id, payment_id=payment)) return resources.Refund(**response)
def list(per_page=None, page=None): """ List of payments. You have to handle pagination manually :param page: the page number :type page: int|None :param per_page: number of payment per page. It's a good practice to increase this number if you know that you will need a lot of payments. :type per_page: int|None :return A collection of payment :rtype resources.APIResourceCollection """ # Comprehension dict are not supported in Python 2.6-. You can use this commented line instead of the current # line when you drop support for Python 2.6. # pagination = {key: value for (key, value) in [('page', page), ('per_page', per_page)] if value} pagination = dict((key, value) for (key, value) in [('page', page), ('per_page', per_page)] if value) http_client = HttpClient() response, _ = http_client.get(routes.url(routes.LIST_PAYMENTS, pagination)) return resources.APIResourceCollection(resources.Payment, **response)
def retrieve(customer, card_id): """ Retrieve a card from its id. :param customer: The customer id or object :type customer: string|Customer :param card_id: The card id :type card_id: string :return: The customer resource :rtype: resources.Card """ if isinstance(customer, resources.Customer): customer = customer.id http_client = HttpClient() response, __ = http_client.get( routes.url(routes.CARD_RESOURCE, resource_id=card_id, customer_id=customer)) return resources.Card(**response)