class Io::Flow::V0::Models::PaymentRequest

Attributes

amount[R]
attributes[R]
available_payment_methods[R]
created_at[R]
currency[R]
device_details[R]
id[R]
last_payment_failure[R]
locale[R]
next_action[R]
order_information[R]
payment_capture_option[R]
payment_information[R]
reference[R]
return_url[R]
review[R]
status[R]
supported_actions[R]
updated_at[R]

Public Class Methods

new(incoming={}) click to toggle source
# 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

Public Instance Methods

copy(incoming={}) click to toggle source
# 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_hash() click to toggle source
# 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_json() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 58626
def to_json
  JSON.dump(to_hash)
end