class Io::Flow::V0::Models::OrderPayment

An Order Payment represents an individual payment applied to an order. The type of the payment can be used to further lookup transaction level detail

Attributes

address[R]
attributes[R]
date[R]
description[R]
id[R]
merchant_of_record[R]
method[R]
reference[R]
total[R]
type[R]

Public Class Methods

new(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 52609
def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :type, :reference, :description, :total], 'OrderPayment')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @type = (x = opts.delete(:type); x.is_a?(::Io::Flow::V0::Models::OrderPaymentType) ? x : ::Io::Flow::V0::Models::OrderPaymentType.apply(x))
  @merchant_of_record = (x = (x = opts.delete(:merchant_of_record); x.nil? ? "flow" : x); x.is_a?(::Io::Flow::V0::Models::MerchantOfRecord) ? x : ::Io::Flow::V0::Models::MerchantOfRecord.apply(x))
  @reference = HttpClient::Preconditions.assert_class('reference', opts.delete(:reference), String)
  @description = HttpClient::Preconditions.assert_class('description', opts.delete(:description), String)
  @total = (x = opts.delete(:total); x.is_a?(::Io::Flow::V0::Models::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x))
  @address = (x = opts.delete(:address); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::BillingAddress) ? x : ::Io::Flow::V0::Models::BillingAddress.new(x)))
  @date = (x = opts.delete(:date); x.nil? ? nil : HttpClient::Preconditions.assert_class('date', HttpClient::Helper.to_date_time_iso8601(x), DateTime))
  @attributes = HttpClient::Preconditions.assert_class('attributes', (x = opts.delete(:attributes); x.nil? ? {} : x), Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h }
  @method = (x = opts.delete(:method); x.nil? ? nil : HttpClient::Preconditions.assert_class('method', x, String))
end

Public Instance Methods

copy(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 52628
def copy(incoming={})
  OrderPayment.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 52632
def to_hash
  {
    :id => id,
    :type => type.value,
    :merchant_of_record => merchant_of_record.value,
    :reference => reference,
    :description => description,
    :total => total.to_hash,
    :address => address.nil? ? nil : address.to_hash,
    :date => date,
    :attributes => attributes,
    :method => method
  }
end
to_json() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 52624
def to_json
  JSON.dump(to_hash)
end