Class: Io::Flow::V0::Models::PaymentRequest

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 = {}) ⇒ PaymentRequest

Returns a new instance of PaymentRequest.



58602
58603
58604
58605
58606
58607
58608
58609
58610
58611
58612
58613
58614
58615
58616
58617
58618
58619
58620
58621
58622
58623
58624
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58602

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :status, :created_at, :updated_at, :available_payment_methods, :amount, :currency, :order_information, :device_details, :return_url, :payment_information, :supported_actions], 'PaymentRequest')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @status = (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::PaymentStatus) ? x : ::Io::Flow::V0::Models::PaymentStatus.apply(x))
  @created_at = HttpClient::Preconditions.assert_class('created_at', HttpClient::Helper.to_date_time_iso8601(opts.delete(:created_at)), DateTime)
  @updated_at = HttpClient::Preconditions.assert_class('updated_at', HttpClient::Helper.to_date_time_iso8601(opts.delete(:updated_at)), DateTime)
  @available_payment_methods = HttpClient::Preconditions.assert_class('available_payment_methods', opts.delete(:available_payment_methods), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::PaymentPaymentMethod) ? x : ::Io::Flow::V0::Models::PaymentPaymentMethod.new(x)) }
  @last_payment_failure = (x = opts.delete(:last_payment_failure); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PaymentFailure) ? x : ::Io::Flow::V0::Models::PaymentFailure.new(x)))
  @next_action = (x = opts.delete(:next_action); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Action) ? x : ::Io::Flow::V0::Models::Action.from_json(x)))
  @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_information = (x = opts.delete(:payment_information); x.is_a?(::Io::Flow::V0::Models::PaymentInformation) ? x : ::Io::Flow::V0::Models::PaymentInformation.new(x))
  @supported_actions = HttpClient::Preconditions.assert_class('supported_actions', opts.delete(:supported_actions), 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)))
  @review = (x = opts.delete(:review); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PaymentRequestReview) ? x : ::Io::Flow::V0::Models::PaymentRequestReview.new(x)))
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



58600
58601
58602
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58600

def amount
  @amount
end

#attributesObject (readonly)

Returns the value of attribute attributes.



58600
58601
58602
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58600

def attributes
  @attributes
end

#available_payment_methodsObject (readonly)

Returns the value of attribute available_payment_methods.



58600
58601
58602
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58600

def available_payment_methods
  @available_payment_methods
end

#created_atObject (readonly)

Returns the value of attribute created_at.



58600
58601
58602
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58600

def created_at
  @created_at
end

#currencyObject (readonly)

Returns the value of attribute currency.



58600
58601
58602
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58600

def currency
  @currency
end

#device_detailsObject (readonly)

Returns the value of attribute device_details.



58600
58601
58602
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58600

def device_details
  @device_details
end

#idObject (readonly)

Returns the value of attribute id.



58600
58601
58602
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58600

def id
  @id
end

#last_payment_failureObject (readonly)

Returns the value of attribute last_payment_failure.



58600
58601
58602
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58600

def last_payment_failure
  @last_payment_failure
end

#localeObject (readonly)

Returns the value of attribute locale.



58600
58601
58602
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58600

def locale
  @locale
end

#next_actionObject (readonly)

Returns the value of attribute next_action.



58600
58601
58602
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58600

def next_action
  @next_action
end

#order_informationObject (readonly)

Returns the value of attribute order_information.



58600
58601
58602
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58600

def order_information
  @order_information
end

#payment_capture_optionObject (readonly)

Returns the value of attribute payment_capture_option.



58600
58601
58602
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58600

def payment_capture_option
  @payment_capture_option
end

#payment_informationObject (readonly)

Returns the value of attribute payment_information.



58600
58601
58602
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58600

def payment_information
  @payment_information
end

#referenceObject (readonly)

Returns the value of attribute reference.



58600
58601
58602
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58600

def reference
  @reference
end

#return_urlObject (readonly)

Returns the value of attribute return_url.



58600
58601
58602
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58600

def return_url
  @return_url
end

#reviewObject (readonly)

Returns the value of attribute review.



58600
58601
58602
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58600

def review
  @review
end

#statusObject (readonly)

Returns the value of attribute status.



58600
58601
58602
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58600

def status
  @status
end

#supported_actionsObject (readonly)

Returns the value of attribute supported_actions.



58600
58601
58602
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58600

def supported_actions
  @supported_actions
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



58600
58601
58602
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58600

def updated_at
  @updated_at
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



58630
58631
58632
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58630

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

#to_hashObject



58634
58635
58636
58637
58638
58639
58640
58641
58642
58643
58644
58645
58646
58647
58648
58649
58650
58651
58652
58653
58654
58655
58656
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58634

def to_hash
  {
    :id => id,
    :status => status.value,
    :created_at => created_at,
    :updated_at => updated_at,
    :available_payment_methods => available_payment_methods.map { |o| o.to_hash },
    :last_payment_failure => last_payment_failure.nil? ? nil : last_payment_failure.to_hash,
    :next_action => next_action.nil? ? nil : next_action.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_information => payment_information.to_hash,
    :supported_actions => supported_actions.map { |o| o.value },
    :payment_capture_option => payment_capture_option.nil? ? nil : payment_capture_option.to_hash,
    :review => review.nil? ? nil : review.to_hash
  }
end

#to_jsonObject



58626
58627
58628
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 58626

def to_json
  JSON.dump(to_hash)
end