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)
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 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 create_charge(self, request, idempotency_key=None): """Does a POST request to /Charges. Creates a new charge Args: request (CreateChargeRequest): Request for creating 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' _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, GetChargeResponse.from_dictionary)
def create_transfer(self, request): """Does a POST request to /transfers/recipients. TODO: type endpoint description here. Args: request (CreateTransfer): TODO: type description here. Example: Returns: GetTransfer: 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 = '/transfers/recipients' _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' } # 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, GetTransfer.from_dictionary)