Class: Io::Flow::V0::Models::PaymentRequestForm

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ PaymentRequestForm

Returns a new instance of PaymentRequestForm.



58806
58807
58808
58809
58810
58811
58812
58813
58814
58815
58816
58817
58818
58819
58820
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58806

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:amount, :currency, :order_information, :device_details, :return_url], 'PaymentRequestForm')
  @amount = HttpClient::Preconditions.assert_class('amount', HttpClient::Helper.to_big_decimal(opts.delete(:amount)), BigDecimal)
  @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String)
  @order_information = (x = opts.delete(:order_information); x.is_a?(::Io::Flow::V0::Models::OrderInformation) ? x : ::Io::Flow::V0::Models::OrderInformation.from_json(x))
  @device_details = (x = opts.delete(:device_details); x.is_a?(::Io::Flow::V0::Models::DeviceDetails) ? x : ::Io::Flow::V0::Models::DeviceDetails.from_json(x))
  @locale = (x = opts.delete(:locale); x.nil? ? nil : HttpClient::Preconditions.assert_class('locale', x, String))
  @return_url = HttpClient::Preconditions.assert_class('return_url', opts.delete(:return_url), String)
  @attributes = (x = opts.delete(:attributes); x.nil? ? nil : HttpClient::Preconditions.assert_class('attributes', x, Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h })
  @reference = (x = opts.delete(:reference); x.nil? ? nil : HttpClient::Preconditions.assert_class('reference', x, String))
  @payment_method_data = (x = opts.delete(:payment_method_data); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PaymentMethodData) ? x : ::Io::Flow::V0::Models::PaymentMethodData.from_json(x)))
  @supported_actions = (x = opts.delete(:supported_actions); x.nil? ? nil : HttpClient::Preconditions.assert_class('supported_actions', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::PaymentActionType) ? x : ::Io::Flow::V0::Models::PaymentActionType.apply(x)) })
  @payment_capture_option = (x = opts.delete(:payment_capture_option); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PaymentCaptureOption) ? x : ::Io::Flow::V0::Models::PaymentCaptureOption.from_json(x)))
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



58804
58805
58806
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58804

def amount
  @amount
end

#attributesObject (readonly)

Returns the value of attribute attributes.



58804
58805
58806
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58804

def attributes
  @attributes
end

#currencyObject (readonly)

Returns the value of attribute currency.



58804
58805
58806
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58804

def currency
  @currency
end

#device_detailsObject (readonly)

Returns the value of attribute device_details.



58804
58805
58806
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58804

def device_details
  @device_details
end

#localeObject (readonly)

Returns the value of attribute locale.



58804
58805
58806
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58804

def locale
  @locale
end

#order_informationObject (readonly)

Returns the value of attribute order_information.



58804
58805
58806
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58804

def order_information
  @order_information
end

#payment_capture_optionObject (readonly)

Returns the value of attribute payment_capture_option.



58804
58805
58806
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58804

def payment_capture_option
  @payment_capture_option
end

#payment_method_dataObject (readonly)

Returns the value of attribute payment_method_data.



58804
58805
58806
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58804

def payment_method_data
  @payment_method_data
end

#referenceObject (readonly)

Returns the value of attribute reference.



58804
58805
58806
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58804

def reference
  @reference
end

#return_urlObject (readonly)

Returns the value of attribute return_url.



58804
58805
58806
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58804

def return_url
  @return_url
end

#supported_actionsObject (readonly)

Returns the value of attribute supported_actions.



58804
58805
58806
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58804

def supported_actions
  @supported_actions
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



58826
58827
58828
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58826

def copy(incoming={})
  PaymentRequestForm.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



58830
58831
58832
58833
58834
58835
58836
58837
58838
58839
58840
58841
58842
58843
58844
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58830

def to_hash
  {
    :amount => amount.to_f.to_s,
    :currency => currency,
    :order_information => order_information.to_hash,
    :device_details => device_details.to_hash,
    :locale => locale,
    :return_url => return_url,
    :attributes => attributes.nil? ? nil : attributes,
    :reference => reference,
    :payment_method_data => payment_method_data.nil? ? nil : payment_method_data.to_hash,
    :supported_actions => supported_actions.nil? ? nil : supported_actions.map { |o| o.value },
    :payment_capture_option => payment_capture_option.nil? ? nil : payment_capture_option.to_hash
  }
end

#to_jsonObject



58822
58823
58824
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58822

def to_json
  JSON.dump(to_hash)
end