def __init__(self, id=None, value=None, discount_type=None, status=None, created_at=None, cycles=None, deleted_at=None, description=None, subscription=None, subscription_item=None): """Constructor for the GetDiscountResponse class""" # Initialize members of the class self.id = id self.value = value self.discount_type = discount_type self.status = status self.created_at = APIHelper.RFC3339DateTime( created_at) if created_at else None self.cycles = cycles self.deleted_at = APIHelper.RFC3339DateTime( deleted_at) if deleted_at else None self.description = description self.subscription = subscription self.subscription_item = subscription_item
def __init__(self, id=None, name=None, email=None, delinquent=None, created_at=None, updated_at=None, document=None, mtype=None, fb_access_token=None, address=None, metadata=None, phones=None, code=None, fb_id=None): """Constructor for the GetCustomerResponse class""" # Initialize members of the class self.id = id self.name = name self.email = email self.delinquent = delinquent self.created_at = APIHelper.RFC3339DateTime( created_at) if created_at else None self.updated_at = APIHelper.RFC3339DateTime( updated_at) if updated_at else None self.document = document self.mtype = mtype self.fb_access_token = fb_access_token self.address = address self.metadata = metadata self.phones = phones self.fb_id = fb_id self.code = code
def __init__(self, id=None, gateway_id=None, amount=None, status=None, created_at=None, updated_at=None, mtype=None, source=None, target=None, metadata=None, fee=None, funding_date=None, funding_estimated_date=None): """Constructor for the GetWithdrawResponse class""" # Initialize members of the class self.id = id self.gateway_id = gateway_id self.amount = amount self.status = status self.created_at = APIHelper.RFC3339DateTime( created_at) if created_at else None self.updated_at = APIHelper.RFC3339DateTime( updated_at) if updated_at else None self.metadata = metadata self.fee = fee self.funding_date = APIHelper.RFC3339DateTime( funding_date) if funding_date else None self.funding_estimated_date = APIHelper.RFC3339DateTime( funding_estimated_date) if funding_estimated_date else None self.mtype = mtype self.source = source self.target = target
def get_transfers(self): """Does a GET request to /transfers. Gets all transfers Returns: ListTransfers: 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' _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, ListTransfers.from_dictionary)
def __init__(self, id=None, name=None, email=None, document=None, description=None, mtype=None, status=None, created_at=None, updated_at=None, deleted_at=None, default_bank_account=None, gateway_recipients=None, metadata=None): """Constructor for the GetRecipientResponse class""" # Initialize members of the class self.id = id self.name = name self.email = email self.document = document self.description = description self.mtype = mtype self.status = status self.created_at = APIHelper.RFC3339DateTime( created_at) if created_at else None self.updated_at = APIHelper.RFC3339DateTime( updated_at) if updated_at else None self.deleted_at = APIHelper.RFC3339DateTime( deleted_at) if deleted_at else None self.default_bank_account = default_bank_account self.gateway_recipients = gateway_recipients self.metadata = metadata
def __init__(self, id=None, description=None, status=None, created_at=None, updated_at=None, pricing_scheme=None, discounts=None, increments=None, subscription=None, name=None, quantity=None, cycles=None, deleted_at=None): """Constructor for the GetSubscriptionItemResponse class""" # Initialize members of the class self.id = id self.description = description self.status = status self.created_at = APIHelper.RFC3339DateTime( created_at) if created_at else None self.updated_at = APIHelper.RFC3339DateTime( updated_at) if updated_at else None self.pricing_scheme = pricing_scheme self.discounts = discounts self.increments = increments self.subscription = subscription self.name = name self.quantity = quantity self.cycles = cycles self.deleted_at = APIHelper.RFC3339DateTime( deleted_at) if deleted_at else None
def __init__(self, id=None, quantity=None, description=None, used_at=None, created_at=None, status=None, subscription_item=None, deleted_at=None, code=None, group=None): """Constructor for the GetUsageResponse class""" # Initialize members of the class self.id = id self.quantity = quantity self.description = description self.used_at = APIHelper.RFC3339DateTime(used_at) if used_at else None self.created_at = APIHelper.RFC3339DateTime( created_at) if created_at else None self.status = status self.deleted_at = APIHelper.RFC3339DateTime( deleted_at) if deleted_at else None self.subscription_item = subscription_item self.code = code self.group = group
def __init__(self, start_at=None, end_at=None, id=None, billing_at=None, subscription=None, status=None, duration=None, created_at=None, updated_at=None, cycle=None): """Constructor for the GetPeriodResponse class""" # Initialize members of the class self.start_at = APIHelper.RFC3339DateTime( start_at) if start_at else None self.end_at = APIHelper.RFC3339DateTime(end_at) if end_at else None self.id = id self.billing_at = APIHelper.RFC3339DateTime( billing_at) if billing_at else None self.subscription = subscription self.status = status self.duration = duration self.created_at = created_at self.updated_at = updated_at self.cycle = cycle
def __init__(self, id=None, requested_amount=None, approved_amount=None, pgid=None, created_at=None, updated_at=None, payment_date=None, status=None, timeframe=None, recipient=None): """Constructor for the GetAnticipationResponse class""" # Initialize members of the class self.id = id self.requested_amount = requested_amount self.approved_amount = approved_amount self.recipient = recipient self.pgid = pgid self.created_at = APIHelper.RFC3339DateTime( created_at) if created_at else None self.updated_at = APIHelper.RFC3339DateTime( updated_at) if updated_at else None self.payment_date = APIHelper.RFC3339DateTime( payment_date) if payment_date else None self.status = status self.timeframe = timeframe
def __init__(self, id=None, default_payment_method=None, success_url=None, payment_url=None, gateway_affiliation_id=None, accepted_payment_methods=None, status=None, skip_checkout_success_page=None, created_at=None, updated_at=None, customer_editable=None, billingaddress=None, credit_card=None, boleto=None, billing_address_editable=None, shipping=None, shippable=None, currency=None, amount=None, canceled_at=None, customer=None, closed_at=None, expires_at=None, debit_card=None, bank_transfer=None): """Constructor for the GetCheckoutPaymentResponse class""" # Initialize members of the class self.id = id self.amount = amount self.default_payment_method = default_payment_method self.success_url = success_url self.payment_url = payment_url self.gateway_affiliation_id = gateway_affiliation_id self.accepted_payment_methods = accepted_payment_methods self.status = status self.skip_checkout_success_page = skip_checkout_success_page self.created_at = APIHelper.RFC3339DateTime( created_at) if created_at else None self.updated_at = APIHelper.RFC3339DateTime( updated_at) if updated_at else None self.canceled_at = APIHelper.RFC3339DateTime( canceled_at) if canceled_at else None self.customer_editable = customer_editable self.customer = customer self.billingaddress = billingaddress self.credit_card = credit_card self.boleto = boleto self.billing_address_editable = billing_address_editable self.shipping = shipping self.shippable = shippable self.closed_at = APIHelper.RFC3339DateTime( closed_at) if closed_at else None self.expires_at = APIHelper.RFC3339DateTime( expires_at) if expires_at else None self.currency = currency self.debit_card = debit_card self.bank_transfer = bank_transfer
def get_customers(self, name=None, document=None, page=1, size=10, email=None, code=None): """Does a GET request to /customers. Get all Customers Args: name (string, optional): Name of the Customer document (string, optional): Document of the Customer page (int, optional): Current page the the search size (int, optional): Quantity pages of the search email (string, optional): Customer's email code (string, optional): Customer's code Returns: ListCustomersResponse: 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' _query_builder = Configuration.base_uri _query_builder += _url_path _query_parameters = { 'name': name, 'document': document, 'page': page, 'size': size, 'email': email, 'Code': code } _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, ListCustomersResponse.from_dictionary)
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 get_charges_summary(self, status, created_since=None, created_until=None): """Does a GET request to /charges/summary. TODO: type endpoint description here. Args: status (string): TODO: type description here. Example: created_since (datetime, optional): TODO: type description here. Example: created_until (datetime, optional): TODO: type description here. Example: Returns: GetChargesSummaryResponse: 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/summary' _query_builder = Configuration.base_uri _query_builder += _url_path _query_parameters = { 'status': status, '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, GetChargesSummaryResponse.from_dictionary)
def add_query_parameter(self, name, value): """ Add a query parameter to the HttpRequest. Args: name (string): The name of the query parameter. value (string): The value of the query parameter. """ self.query_url = APIHelper.append_url_with_query_parameters( self.query_url, {name: value}) self.query_url = APIHelper.clean_url(self.query_url)
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 __init__(self, id=None, code=None, url=None, amount=None, status=None, payment_method=None, created_at=None, items=None, customer=None, charge=None, installments=None, billing_address=None, subscription=None, cycle=None, shipping=None, metadata=None, due_at=None, canceled_at=None, billing_at=None, seen_at=None, total_discount=None, total_increment=None): """Constructor for the GetInvoiceResponse class""" # Initialize members of the class self.id = id self.code = code self.url = url self.amount = amount self.status = status self.payment_method = payment_method self.created_at = APIHelper.RFC3339DateTime( created_at) if created_at else None self.items = items self.customer = customer self.charge = charge self.installments = installments self.billing_address = billing_address self.subscription = subscription self.cycle = cycle self.shipping = shipping self.metadata = metadata self.due_at = APIHelper.RFC3339DateTime(due_at) if due_at else None self.canceled_at = APIHelper.RFC3339DateTime( canceled_at) if canceled_at else None self.billing_at = APIHelper.RFC3339DateTime( billing_at) if billing_at else None self.seen_at = APIHelper.RFC3339DateTime(seen_at) if seen_at else None self.total_discount = total_discount self.total_increment = total_increment
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 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 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 execute_request(self, request, binary=False): """Executes an HttpRequest. Args: request (HttpRequest): The HttpRequest to execute. binary (bool): A flag which should be set to True if a binary response is expected. Returns: HttpContext: The HttpContext of the request. It contains, both, the request itself and the HttpResponse object. """ # Invoke the on before request HttpCallBack if specified if self.http_call_back != None: self.http_call_back.on_before_request(request) # Add global headers to request request.headers = APIHelper.merge_dicts(self.global_headers, request.headers) # Invoke the API call to fetch the response. func = self.http_client.execute_as_binary if binary else self.http_client.execute_as_string response = func(request) context = HttpContext(request, response) # Invoke the on after response HttpCallBack if specified if self.http_call_back != None: self.http_call_back.on_after_response(context) return context
def __init__(self, bank=None, instructions=None, due_at=None): """Constructor for the CreateCheckoutBoletoPaymentRequest class""" # Initialize members of the class self.bank = bank self.instructions = instructions self.due_at = APIHelper.RFC3339DateTime(due_at) if due_at else None
def __init__(self, start_at=None, end_at=None, id=None, billing_at=None, subscription=None): """Constructor for the GetPeriodResponse class""" # Initialize members of the class self.start_at = APIHelper.RFC3339DateTime( start_at) if start_at else None self.end_at = APIHelper.RFC3339DateTime(end_at) if end_at else None self.id = id self.billing_at = APIHelper.RFC3339DateTime( billing_at) if billing_at else None self.subscription = subscription
def __init__(self, amount=None, timeframe=None, payment_date=None): """Constructor for the CreateAnticipationRequest class""" # Initialize members of the class self.amount = amount self.timeframe = timeframe self.payment_date = APIHelper.RFC3339DateTime( payment_date) if payment_date else None
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 __init__(self, name=None, start_at=None, end_at=None): """Constructor for the CreateTransactionReportFileRequest class""" # Initialize members of the class self.name = name self.start_at = APIHelper.RFC3339DateTime( start_at) if start_at else None self.end_at = end_at
def __init__(self, id=None, name=None, description=None, url=None, statement_descriptor=None, interval=None, interval_count=None, billing_type=None, payment_methods=None, installments=None, status=None, currency=None, created_at=None, updated_at=None, items=None, billing_days=None, shippable=None, metadata=None, trial_period_days=None, minimum_price=None, deleted_at=None): """Constructor for the GetPlanResponse class""" # Initialize members of the class self.id = id self.name = name self.description = description self.url = url self.statement_descriptor = statement_descriptor self.interval = interval self.interval_count = interval_count self.billing_type = billing_type self.payment_methods = payment_methods self.installments = installments self.status = status self.currency = currency self.created_at = APIHelper.RFC3339DateTime(created_at) if created_at else None self.updated_at = APIHelper.RFC3339DateTime(updated_at) if updated_at else None self.items = items self.billing_days = billing_days self.shippable = shippable self.metadata = metadata self.trial_period_days = trial_period_days self.minimum_price = minimum_price self.deleted_at = APIHelper.RFC3339DateTime(deleted_at) if deleted_at else None