class Io::Flow::V0::Models::ChannelTransaction

Attributes

created_at[R]
currency[R]
discounts[R]
fees[R]
gross[R]
id[R]
identifiers[R]
net[R]
order[R]
parent[R]
payment_request[R]
source[R]
statement[R]
updated_at[R]
withholdings[R]

Public Class Methods

new(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 35644
def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :currency, :source, :gross, :net, :created_at, :updated_at], 'ChannelTransaction')
  @statement = (x = opts.delete(:statement); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::BillingChannelStatementReference) ? x : ::Io::Flow::V0::Models::BillingChannelStatementReference.new(x)))
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @order = (x = opts.delete(:order); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::BillingChannelOrderSummary) ? x : ::Io::Flow::V0::Models::BillingChannelOrderSummary.new(x)))
  @payment_request = (x = opts.delete(:payment_request); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::BillingChannelPaymentRequestReference) ? x : ::Io::Flow::V0::Models::BillingChannelPaymentRequestReference.new(x)))
  @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String)
  @source = (x = opts.delete(:source); x.is_a?(::Io::Flow::V0::Models::TransactionSource) ? x : ::Io::Flow::V0::Models::TransactionSource.apply(x))
  @parent = (x = opts.delete(:parent); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::ParentTransactionSummary) ? x : ::Io::Flow::V0::Models::ParentTransactionSummary.new(x)))
  @gross = HttpClient::Preconditions.assert_class('gross', HttpClient::Helper.to_big_decimal(opts.delete(:gross)), BigDecimal)
  @fees = HttpClient::Preconditions.assert_class('fees', (x = opts.delete(:fees); x.nil? ? [] : x), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::FeeDeduction) ? x : ::Io::Flow::V0::Models::FeeDeduction.new(x)) }
  @withholdings = HttpClient::Preconditions.assert_class('withholdings', (x = opts.delete(:withholdings); x.nil? ? [] : x), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::WithholdingDeduction) ? x : ::Io::Flow::V0::Models::WithholdingDeduction.new(x)) }
  @discounts = HttpClient::Preconditions.assert_class('discounts', (x = opts.delete(:discounts); x.nil? ? [] : x), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::BillingDiscount) ? x : ::Io::Flow::V0::Models::BillingDiscount.new(x)) }
  @net = HttpClient::Preconditions.assert_class('net', HttpClient::Helper.to_big_decimal(opts.delete(:net)), BigDecimal)
  @identifiers = HttpClient::Preconditions.assert_class('identifiers', (x = opts.delete(:identifiers); x.nil? ? {} : x), Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('identifiers', d[1], String); h }
  @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)
end

Public Instance Methods

copy(incoming={}) click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 35668
def copy(incoming={})
  ChannelTransaction.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 35672
def to_hash
  {
    :statement => statement.nil? ? nil : statement.to_hash,
    :id => id,
    :order => order.nil? ? nil : order.to_hash,
    :payment_request => payment_request.nil? ? nil : payment_request.to_hash,
    :currency => currency,
    :source => source.value,
    :parent => parent.nil? ? nil : parent.to_hash,
    :gross => gross.to_f.to_s,
    :fees => fees.map { |o| o.to_hash },
    :withholdings => withholdings.map { |o| o.to_hash },
    :discounts => discounts.map { |o| o.to_hash },
    :net => net.to_f.to_s,
    :identifiers => identifiers,
    :created_at => created_at,
    :updated_at => updated_at
  }
end
to_json() click to toggle source
# File lib/flow_commerce/flow_api_v0_client.rb, line 35664
def to_json
  JSON.dump(to_hash)
end