## # This code was generated by # \ / _ _ _| _ _ # | (_)\/(_)(_|\/| |(/_ v1.0.0 # / / # # frozen_string_literal: true module Twilio module REST class Api < Domain class V2010 < Version class AccountContext < InstanceContext class CallContext < InstanceContext ## # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. class PaymentList < ListResource ## # Initialize the PaymentList # @param [Version] version Version that contains the resource # @param [String] account_sid The SID of the # [Account](https://www.twilio.com/docs/iam/api/account) that created the Payments # resource. # @param [String] call_sid The SID of the # [Call](https://www.twilio.com/docs/voice/api/call-resource) the Payments # resource is associated with. This will refer to the call sid that is producing # the payment card (credit/ACH) information thru DTMF. # @return [PaymentList] PaymentList def initialize(version, account_sid: nil, call_sid: nil) super(version) # Path Solution @solution = {account_sid: account_sid, call_sid: call_sid} @uri = "/Accounts/#{@solution[:account_sid]}/Calls/#{@solution[:call_sid]}/Payments.json" end ## # Retrieve a single page of PaymentInstance records from the API. # Request is executed immediately. # @param [String] idempotency_key A unique token for each payment session that # should be provided to maintain idempotency of the session. # @param [String] status_callback The URL we should call using the # `status_callback` to send status information of payment session. # @param [payment.BankAccountType] bank_account_type If Payment source is ACH, # type of bank account. Can be: `consumer-checking`, `consumer-savings`, # `commercial-checking`. The default value is `consumer-checking`. # @param [String] charge_amount If this field is present and greater than `0.0` # payment source will be charged. Otherwise payment source will be tokenized. # @param [String] currency Currency `charge_amount` is in. It's format should be # as specified in [ISO # 4127](http://www.iso.org/iso/home/standards/currency_codes.htm) format. The # default value is `USD`. # @param [String] description Decription of the charge. # @param [String] input Kind of medium customer would enter payment source # information in. Currently only 'DTMF' is supported, which means customer would # use keypad of their phone to enter card number etc. # @param [String] min_postal_code_length If postal code is expected, minimum # length of the postal code. When user enters postal code, this value will be used # to validate. # @param [Hash] parameter Additonal data to be sent over to payment provider. It # has to be a JSON string with only one level object. This parameter can be used # to send information such as customer name, phone number etc. Refer to specific # payment provider's documentation in Twilio console for supported # names/values/format. # @param [String] payment_connector Payment connector that you would like Twilio # to use for processing payments. The default value is `Default`, which means you # need to have at least one payment connector configured in Twilio with name # 'Default'. If not you must provide connector configuration name here. # @param [payment.PaymentMethod] payment_method Payment source type. Can be: # `credit-card`, `ach-debit`. The default value is `credit-card`. # @param [Boolean] postal_code Whether to expect postal code during payment source # data gathering. Can be: `true`, `false`. The default value is `true`. # @param [Boolean] security_code Whether to expect security code during payment # source data gathering. Can be: `true`, `false`. The default value is `true`. # @param [String] timeout The number of seconds that we should allow customer to # enter payment information. Can be an integer between `5` and `600`, inclusive. # The default value is `5`. # @param [payment.TokenType] token_type If tokenization of payment source is # desired, this represents type of token. Can be: `one-time`, `reusable`. The # default value is `reusable`. # @param [String] valid_card_types List of card types accepted with each card # types separated by space. Can be: # `visa`,`nmastercard`,`amex`,`maestro`,`discover`,`optima`,`jcb`,`diners-club`,`enroute`. The default value is `visa mastercard amex`. # @return [PaymentInstance] Newly created PaymentInstance def create(idempotency_key: nil, status_callback: nil, bank_account_type: :unset, charge_amount: :unset, currency: :unset, description: :unset, input: :unset, min_postal_code_length: :unset, parameter: :unset, payment_connector: :unset, payment_method: :unset, postal_code: :unset, security_code: :unset, timeout: :unset, token_type: :unset, valid_card_types: :unset) data = Twilio::Values.of({ 'IdempotencyKey' => idempotency_key, 'StatusCallback' => status_callback, 'BankAccountType' => bank_account_type, 'ChargeAmount' => charge_amount, 'Currency' => currency, 'Description' => description, 'Input' => input, 'MinPostalCodeLength' => min_postal_code_length, 'Parameter' => Twilio.serialize_object(parameter), 'PaymentConnector' => payment_connector, 'PaymentMethod' => payment_method, 'PostalCode' => postal_code, 'SecurityCode' => security_code, 'Timeout' => timeout, 'TokenType' => token_type, 'ValidCardTypes' => valid_card_types, }) payload = @version.create( 'POST', @uri, data: data ) PaymentInstance.new( @version, payload, account_sid: @solution[:account_sid], call_sid: @solution[:call_sid], ) end ## # Provide a user friendly representation def to_s '#' end end ## # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. class PaymentPage < Page ## # Initialize the PaymentPage # @param [Version] version Version that contains the resource # @param [Response] response Response from the API # @param [Hash] solution Path solution for the resource # @return [PaymentPage] PaymentPage def initialize(version, response, solution) super(version, response) # Path Solution @solution = solution end ## # Build an instance of PaymentInstance # @param [Hash] payload Payload response from the API # @return [PaymentInstance] PaymentInstance def get_instance(payload) PaymentInstance.new( @version, payload, account_sid: @solution[:account_sid], call_sid: @solution[:call_sid], ) end ## # Provide a user friendly representation def to_s '' end end ## # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. class PaymentContext < InstanceContext ## # Initialize the PaymentContext # @param [Version] version Version that contains the resource # @param [String] account_sid The SID of the # [Account](https://www.twilio.com/docs/iam/api/account) that will update the # resource. # @param [String] call_sid The SID of the call that will update the resource. This # should be the same call sid that was used to create payments resource. # @param [String] sid The SID of Payments session that needs to be updated. # @return [PaymentContext] PaymentContext def initialize(version, account_sid, call_sid, sid) super(version) # Path Solution @solution = {account_sid: account_sid, call_sid: call_sid, sid: sid, } @uri = "/Accounts/#{@solution[:account_sid]}/Calls/#{@solution[:call_sid]}/Payments/#{@solution[:sid]}.json" end ## # Update the PaymentInstance # @param [String] idempotency_key A unique token for each payment session that # should be provided to maintain idempotency of the session. # @param [String] status_callback The URL we should call using the # `status_callback` to send status information of payment session. # @param [payment.Capture] capture Specific payment source information to expect. # Can be: # `payment-card-number`,`expiration-date`,`security-code`,`postal-code`,`bank-routing-number`,`bank-account-number`. # @param [payment.Status] status Instruction to complete or cancel the # transaction. Can be: `complete`, `cancel.` # @return [PaymentInstance] Updated PaymentInstance def update(idempotency_key: nil, status_callback: nil, capture: :unset, status: :unset) data = Twilio::Values.of({ 'IdempotencyKey' => idempotency_key, 'StatusCallback' => status_callback, 'Capture' => capture, 'Status' => status, }) payload = @version.update( 'POST', @uri, data: data, ) PaymentInstance.new( @version, payload, account_sid: @solution[:account_sid], call_sid: @solution[:call_sid], sid: @solution[:sid], ) end ## # Provide a user friendly representation def to_s context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') "#" end ## # Provide a detailed, user friendly representation def inspect context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') "#" end end ## # PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com. class PaymentInstance < InstanceResource ## # Initialize the PaymentInstance # @param [Version] version Version that contains the resource # @param [Hash] payload payload that contains response from Twilio # @param [String] account_sid The SID of the # [Account](https://www.twilio.com/docs/iam/api/account) that created the Payments # resource. # @param [String] call_sid The SID of the # [Call](https://www.twilio.com/docs/voice/api/call-resource) the Payments # resource is associated with. This will refer to the call sid that is producing # the payment card (credit/ACH) information thru DTMF. # @param [String] sid The SID of Payments session that needs to be updated. # @return [PaymentInstance] PaymentInstance def initialize(version, payload, account_sid: nil, call_sid: nil, sid: nil) super(version) # Marshaled Properties @properties = { 'account_sid' => payload['account_sid'], 'call_sid' => payload['call_sid'], 'sid' => payload['sid'], 'date_created' => Twilio.deserialize_rfc2822(payload['date_created']), 'date_updated' => Twilio.deserialize_rfc2822(payload['date_updated']), 'uri' => payload['uri'], } # Context @instance_context = nil @params = {'account_sid' => account_sid, 'call_sid' => call_sid, 'sid' => sid || @properties['sid'], } end ## # Generate an instance context for the instance, the context is capable of # performing various actions. All instance actions are proxied to the context # @return [PaymentContext] PaymentContext for this PaymentInstance def context unless @instance_context @instance_context = PaymentContext.new( @version, @params['account_sid'], @params['call_sid'], @params['sid'], ) end @instance_context end ## # @return [String] The SID of the Account that created the Payments resource. def account_sid @properties['account_sid'] end ## # @return [String] The SID of the Call the resource is associated with. def call_sid @properties['call_sid'] end ## # @return [String] The SID of the Payments resource. def sid @properties['sid'] end ## # @return [Time] The RFC 2822 date and time in GMT that the resource was created def date_created @properties['date_created'] end ## # @return [Time] The RFC 2822 date and time in GMT that the resource was last updated def date_updated @properties['date_updated'] end ## # @return [String] The URI of the resource, relative to `https://api.twilio.com` def uri @properties['uri'] end ## # Update the PaymentInstance # @param [String] idempotency_key A unique token for each payment session that # should be provided to maintain idempotency of the session. # @param [String] status_callback The URL we should call using the # `status_callback` to send status information of payment session. # @param [payment.Capture] capture Specific payment source information to expect. # Can be: # `payment-card-number`,`expiration-date`,`security-code`,`postal-code`,`bank-routing-number`,`bank-account-number`. # @param [payment.Status] status Instruction to complete or cancel the # transaction. Can be: `complete`, `cancel.` # @return [PaymentInstance] Updated PaymentInstance def update(idempotency_key: nil, status_callback: nil, capture: :unset, status: :unset) context.update( idempotency_key: idempotency_key, status_callback: status_callback, capture: capture, status: status, ) end ## # Provide a user friendly representation def to_s values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") "" end ## # Provide a detailed, user friendly representation def inspect values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") "" end end end end end end end end