Beispiel #1
0
    def create_invoice(self,
                       subscription_id,
                       cycle_id,
                       request=None,
                       idempotency_key=None):
        """Does a POST request to /subscriptions/{subscription_id}/cycles/{cycle_id}/pay.

        Create an Invoice

        Args:
            subscription_id (string): Subscription Id
            cycle_id (string): Cycle Id
            request (CreateInvoiceRequest, optional): TODO: type description
                here. Example: 
            idempotency_key (string, optional): TODO: type description here.
                Example: 

        Returns:
            GetInvoiceResponse: Response from the API. 

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/subscriptions/{subscription_id}/cycles/{cycle_id}/pay'
        _url_path = APIHelper.append_url_with_template_parameters(
            _url_path, {
                'subscription_id': subscription_id,
                'cycle_id': cycle_id
            })
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare headers
        _headers = {
            'accept': 'application/json',
            'content-type': 'application/json; charset=utf-8',
            'idempotency-key': idempotency_key
        }

        # Prepare and execute request
        _request = self.http_client.post(
            _query_url,
            headers=_headers,
            parameters=APIHelper.json_serialize(request))
        BasicAuth.apply(_request)
        _context = self.execute_request(_request)
        self.validate_response(_context)

        # Return appropriate type
        return APIHelper.json_deserialize(_context.response.raw_body,
                                          GetInvoiceResponse.from_dictionary)
Beispiel #2
0
    def update_plan_item(self,
                         plan_id,
                         plan_item_id,
                         body,
                         idempotency_key=None):
        """Does a PUT request to /plans/{plan_id}/items/{plan_item_id}.

        Updates a plan item

        Args:
            plan_id (string): Plan id
            plan_item_id (string): Plan item id
            body (UpdatePlanItemRequest): Request for updating the plan item
            idempotency_key (string, optional): TODO: type description here.
                Example: 

        Returns:
            GetPlanItemResponse: Response from the API. 

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/plans/{plan_id}/items/{plan_item_id}'
        _url_path = APIHelper.append_url_with_template_parameters(
            _url_path, {
                'plan_id': plan_id,
                'plan_item_id': plan_item_id
            })
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare headers
        _headers = {
            'accept': 'application/json',
            'content-type': 'application/json; charset=utf-8',
            'idempotency-key': idempotency_key
        }

        # Prepare and execute request
        _request = self.http_client.put(
            _query_url,
            headers=_headers,
            parameters=APIHelper.json_serialize(body))
        BasicAuth.apply(_request)
        _context = self.execute_request(_request)
        self.validate_response(_context)

        # Return appropriate type
        return APIHelper.json_deserialize(_context.response.raw_body,
                                          GetPlanItemResponse.from_dictionary)
    def update_charge_payment_method(self,
                                     charge_id,
                                     request,
                                     idempotency_key=None):
        """Does a PATCH request to /charges/{charge_id}/payment-method.

        Updates a charge's payment method

        Args:
            charge_id (string): Charge id
            request (UpdateChargePaymentMethodRequest): Request for updating
                the payment method from a charge
            idempotency_key (string, optional): TODO: type description here.
                Example: 

        Returns:
            GetChargeResponse: Response from the API. 

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/charges/{charge_id}/payment-method'
        _url_path = APIHelper.append_url_with_template_parameters(
            _url_path, {'charge_id': charge_id})
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare headers
        _headers = {
            'accept': 'application/json',
            'content-type': 'application/json; charset=utf-8',
            'idempotency-key': idempotency_key
        }

        # Prepare and execute request
        _request = self.http_client.patch(
            _query_url,
            headers=_headers,
            parameters=APIHelper.json_serialize(request))
        BasicAuth.apply(_request)
        _context = self.execute_request(_request)
        self.validate_response(_context)

        # Return appropriate type
        return APIHelper.json_deserialize(_context.response.raw_body,
                                          GetChargeResponse.from_dictionary)
    def update_recipient_transfer_settings(self,
                                           recipient_id,
                                           request,
                                           idempotency_key=None):
        """Does a PATCH request to /recipients/{recipient_id}/transfer-settings.

        TODO: type endpoint description here.

        Args:
            recipient_id (string): Recipient Identificator
            request (UpdateTransferSettingsRequest): TODO: type description
                here. Example: 
            idempotency_key (string, optional): TODO: type description here.
                Example: 

        Returns:
            GetRecipientResponse: Response from the API. 

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/recipients/{recipient_id}/transfer-settings'
        _url_path = APIHelper.append_url_with_template_parameters(
            _url_path, {'recipient_id': recipient_id})
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare headers
        _headers = {
            'accept': 'application/json',
            'content-type': 'application/json; charset=utf-8',
            'idempotency-key': idempotency_key
        }

        # Prepare and execute request
        _request = self.http_client.patch(
            _query_url,
            headers=_headers,
            parameters=APIHelper.json_serialize(request))
        BasicAuth.apply(_request)
        _context = self.execute_request(_request)
        self.validate_response(_context)

        # Return appropriate type
        return APIHelper.json_deserialize(_context.response.raw_body,
                                          GetRecipientResponse.from_dictionary)
    def get_cards(self,
                  customer_id,
                  page=None,
                  size=None):
        """Does a GET request to /customers/{customer_id}/cards.

        Get all cards from a customer

        Args:
            customer_id (string): Customer Id
            page (int, optional): Page number
            size (int, optional): Page size

        Returns:
            ListCardsResponse: Response from the API. 

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/customers/{customer_id}/cards'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 
            'customer_id': customer_id
        })
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_parameters = {
            'page': page,
            'size': size
        }
        _query_builder = APIHelper.append_url_with_query_parameters(_query_builder,
            _query_parameters, Configuration.array_serialization)
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare headers
        _headers = {
            'accept': 'application/json'
        }

        # Prepare and execute request
        _request = self.http_client.get(_query_url, headers=_headers)
        BasicAuth.apply(_request)
        _context = self.execute_request(_request)
        self.validate_response(_context)

        # Return appropriate type
        return APIHelper.json_deserialize(_context.response.raw_body, ListCardsResponse.from_dictionary)
    def get_anticipation_limits(self,
                                recipient_id,
                                timeframe,
                                payment_date):
        """Does a GET request to /recipients/{recipient_id}/anticipation_limits.

        Gets the anticipation limits for a recipient

        Args:
            recipient_id (string): Recipient id
            timeframe (string): Timeframe
            payment_date (datetime): Anticipation payment date

        Returns:
            GetAnticipationLimitResponse: Response from the API. 

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/recipients/{recipient_id}/anticipation_limits'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 
            'recipient_id': recipient_id
        })
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_parameters = {
            'timeframe': timeframe,
            'payment_date': APIHelper.when_defined(APIHelper.RFC3339DateTime, payment_date)
        }
        _query_builder = APIHelper.append_url_with_query_parameters(_query_builder,
            _query_parameters, Configuration.array_serialization)
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare headers
        _headers = {
            'accept': 'application/json'
        }

        # Prepare and execute request
        _request = self.http_client.get(_query_url, headers=_headers)
        BasicAuth.apply(_request)
        _context = self.execute_request(_request)
        self.validate_response(_context)

        # Return appropriate type
        return APIHelper.json_deserialize(_context.response.raw_body, GetAnticipationLimitResponse.from_dictionary)
    def renew_card(self,
                   customer_id,
                   card_id,
                   idempotency_key=None):
        """Does a POST request to /customers/{customer_id}/cards/{card_id}/renew.

        Renew a card

        Args:
            customer_id (string): Customer id
            card_id (string): Card Id
            idempotency_key (string, optional): TODO: type description here.
                Example: 

        Returns:
            GetCardResponse: Response from the API. 

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/customers/{customer_id}/cards/{card_id}/renew'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 
            'customer_id': customer_id,
            'card_id': card_id
        })
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare headers
        _headers = {
            'accept': 'application/json',
            'idempotency-key': idempotency_key
        }

        # Prepare and execute request
        _request = self.http_client.post(_query_url, headers=_headers)
        BasicAuth.apply(_request)
        _context = self.execute_request(_request)
        self.validate_response(_context)

        # Return appropriate type
        return APIHelper.json_deserialize(_context.response.raw_body, GetCardResponse.from_dictionary)
    def delete_order_item(self, order_id, item_id, idempotency_key=None):
        """Does a DELETE request to /orders/{orderId}/items/{itemId}.

        TODO: type endpoint description here.

        Args:
            order_id (string): Order Id
            item_id (string): Item Id
            idempotency_key (string, optional): TODO: type description here.
                Example: 

        Returns:
            GetOrderItemResponse: Response from the API. 

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/orders/{orderId}/items/{itemId}'
        _url_path = APIHelper.append_url_with_template_parameters(
            _url_path, {
                'orderId': order_id,
                'itemId': item_id
            })
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare headers
        _headers = {
            'accept': 'application/json',
            'idempotency-key': idempotency_key
        }

        # Prepare and execute request
        _request = self.http_client.delete(_query_url, headers=_headers)
        BasicAuth.apply(_request)
        _context = self.execute_request(_request)
        self.validate_response(_context)

        # Return appropriate type
        return APIHelper.json_deserialize(_context.response.raw_body,
                                          GetOrderItemResponse.from_dictionary)
    def create_token(self,
                     public_key,
                     request,
                     idempotency_key=None):
        """Does a POST request to /tokens?appId={public_key}.

        TODO: type endpoint description here.

        Args:
            public_key (string): Public key
            request (CreateTokenRequest): Request for creating a token
            idempotency_key (string, optional): TODO: type description here.
                Example: 

        Returns:
            GetTokenResponse: Response from the API. 

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/tokens?appId={public_key}'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 
            'public_key': public_key
        })
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare headers
        _headers = {
            'accept': 'application/json',
            'content-type': 'application/json; charset=utf-8',
            'idempotency-key': idempotency_key
        }

        # Prepare and execute request
        _request = self.http_client.post(_query_url, headers=_headers, parameters=APIHelper.json_serialize(request))
        _context = self.execute_request(_request)
        self.validate_response(_context)

        # Return appropriate type
        return APIHelper.json_deserialize(_context.response.raw_body, GetTokenResponse.from_dictionary)
    def get_address(self,
                    customer_id,
                    address_id):
        """Does a GET request to /customers/{customer_id}/addresses/{address_id}.

        Get a customer's address

        Args:
            customer_id (string): Customer id
            address_id (string): Address Id

        Returns:
            GetAddressResponse: Response from the API. 

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/customers/{customer_id}/addresses/{address_id}'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 
            'customer_id': customer_id,
            'address_id': address_id
        })
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare headers
        _headers = {
            'accept': 'application/json'
        }

        # Prepare and execute request
        _request = self.http_client.get(_query_url, headers=_headers)
        BasicAuth.apply(_request)
        _context = self.execute_request(_request)
        self.validate_response(_context)

        # Return appropriate type
        return APIHelper.json_deserialize(_context.response.raw_body, GetAddressResponse.from_dictionary)
    def get_withdraw_by_id(self,
                           recipient_id,
                           withdrawal_id):
        """Does a GET request to /recipients/{recipient_id}/withdrawals/{withdrawal_id}.

        TODO: type endpoint description here.

        Args:
            recipient_id (string): TODO: type description here. Example: 
            withdrawal_id (string): TODO: type description here. Example: 

        Returns:
            GetWithdrawResponse: Response from the API. 

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/recipients/{recipient_id}/withdrawals/{withdrawal_id}'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 
            'recipient_id': recipient_id,
            'withdrawal_id': withdrawal_id
        })
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare headers
        _headers = {
            'accept': 'application/json'
        }

        # Prepare and execute request
        _request = self.http_client.get(_query_url, headers=_headers)
        BasicAuth.apply(_request)
        _context = self.execute_request(_request)
        self.validate_response(_context)

        # Return appropriate type
        return APIHelper.json_deserialize(_context.response.raw_body, GetWithdrawResponse.from_dictionary)
    def get_token(self,
                  id,
                  public_key):
        """Does a GET request to /tokens/{id}?appId={public_key}.

        Gets a token from its id

        Args:
            id (string): Token id
            public_key (string): Public key

        Returns:
            GetTokenResponse: Response from the API. 

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/tokens/{id}?appId={public_key}'
        _url_path = APIHelper.append_url_with_template_parameters(_url_path, { 
            'id': id,
            'public_key': public_key
        })
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare headers
        _headers = {
            'accept': 'application/json'
        }

        # Prepare and execute request
        _request = self.http_client.get(_query_url, headers=_headers)
        _context = self.execute_request(_request)
        self.validate_response(_context)

        # Return appropriate type
        return APIHelper.json_deserialize(_context.response.raw_body, GetTokenResponse.from_dictionary)
    def get_recipient_by_code(self, code):
        """Does a GET request to /recipients/code/{code}.

        Retrieves recipient information

        Args:
            code (string): Recipient code

        Returns:
            GetRecipientResponse: Response from the API. 

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/recipients/code/{code}'
        _url_path = APIHelper.append_url_with_template_parameters(
            _url_path, {'code': code})
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare headers
        _headers = {'accept': 'application/json'}

        # Prepare and execute request
        _request = self.http_client.get(_query_url, headers=_headers)
        BasicAuth.apply(_request)
        _context = self.execute_request(_request)
        self.validate_response(_context)

        # Return appropriate type
        return APIHelper.json_deserialize(_context.response.raw_body,
                                          GetRecipientResponse.from_dictionary)
    def get_anticipations(self,
                          recipient_id,
                          page=None,
                          size=None,
                          status=None,
                          timeframe=None,
                          payment_date_since=None,
                          payment_date_until=None,
                          created_since=None,
                          created_until=None):
        """Does a GET request to /recipients/{recipient_id}/anticipations.

        Retrieves a paginated list of anticipations from a recipient

        Args:
            recipient_id (string): Recipient id
            page (int, optional): Page number
            size (int, optional): Page size
            status (string, optional): Filter for anticipation status
            timeframe (string, optional): Filter for anticipation timeframe
            payment_date_since (datetime, optional): Filter for start range
                for anticipation payment date
            payment_date_until (datetime, optional): Filter for end range for
                anticipation payment date
            created_since (datetime, optional): Filter for start range for
                anticipation creation date
            created_until (datetime, optional): Filter for end range for
                anticipation creation date

        Returns:
            ListAnticipationResponse: Response from the API. 

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        # Prepare query URL
        _url_path = '/recipients/{recipient_id}/anticipations'
        _url_path = APIHelper.append_url_with_template_parameters(
            _url_path, {'recipient_id': recipient_id})
        _query_builder = Configuration.base_uri
        _query_builder += _url_path
        _query_parameters = {
            'page':
            page,
            'size':
            size,
            'status':
            status,
            'timeframe':
            timeframe,
            'payment_date_since':
            APIHelper.when_defined(APIHelper.RFC3339DateTime,
                                   payment_date_since),
            'payment_date_until':
            APIHelper.when_defined(APIHelper.RFC3339DateTime,
                                   payment_date_until),
            'created_since':
            APIHelper.when_defined(APIHelper.RFC3339DateTime, created_since),
            'created_until':
            APIHelper.when_defined(APIHelper.RFC3339DateTime, created_until)
        }
        _query_builder = APIHelper.append_url_with_query_parameters(
            _query_builder, _query_parameters,
            Configuration.array_serialization)
        _query_url = APIHelper.clean_url(_query_builder)

        # Prepare headers
        _headers = {'accept': 'application/json'}

        # Prepare and execute request
        _request = self.http_client.get(_query_url, headers=_headers)
        BasicAuth.apply(_request)
        _context = self.execute_request(_request)
        self.validate_response(_context)

        # Return appropriate type
        return APIHelper.json_deserialize(
            _context.response.raw_body,
            ListAnticipationResponse.from_dictionary)