Class: Io::Flow::V0::Models::Transaction
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::Transaction
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#discounts ⇒ Object
readonly
Returns the value of attribute discounts.
-
#fees ⇒ Object
readonly
Returns the value of attribute fees.
-
#gross ⇒ Object
readonly
Returns the value of attribute gross.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#identifiers ⇒ Object
readonly
Returns the value of attribute identifiers.
-
#net ⇒ Object
readonly
Returns the value of attribute net.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#payment_request ⇒ Object
readonly
Returns the value of attribute payment_request.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#statement ⇒ Object
readonly
Returns the value of attribute statement.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
-
#withholdings ⇒ Object
readonly
Returns the value of attribute withholdings.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ Transaction
constructor
A new instance of Transaction.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ Transaction
Returns a new instance of Transaction.
71841 71842 71843 71844 71845 71846 71847 71848 71849 71850 71851 71852 71853 71854 71855 71856 71857 71858 71859 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71841 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:id, :currency, :source, :gross, :net, :created_at, :updated_at], 'Transaction') @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 |
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
71839 71840 71841 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71839 def created_at @created_at end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
71839 71840 71841 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71839 def currency @currency end |
#discounts ⇒ Object (readonly)
Returns the value of attribute discounts.
71839 71840 71841 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71839 def discounts @discounts end |
#fees ⇒ Object (readonly)
Returns the value of attribute fees.
71839 71840 71841 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71839 def fees @fees end |
#gross ⇒ Object (readonly)
Returns the value of attribute gross.
71839 71840 71841 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71839 def gross @gross end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
71839 71840 71841 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71839 def id @id end |
#identifiers ⇒ Object (readonly)
Returns the value of attribute identifiers.
71839 71840 71841 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71839 def identifiers @identifiers end |
#net ⇒ Object (readonly)
Returns the value of attribute net.
71839 71840 71841 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71839 def net @net end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
71839 71840 71841 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71839 def order @order end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
71839 71840 71841 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71839 def parent @parent end |
#payment_request ⇒ Object (readonly)
Returns the value of attribute payment_request.
71839 71840 71841 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71839 def payment_request @payment_request end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
71839 71840 71841 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71839 def source @source end |
#statement ⇒ Object (readonly)
Returns the value of attribute statement.
71839 71840 71841 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71839 def statement @statement end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
71839 71840 71841 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71839 def updated_at @updated_at end |
#withholdings ⇒ Object (readonly)
Returns the value of attribute withholdings.
71839 71840 71841 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71839 def withholdings @withholdings end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
71865 71866 71867 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71865 def copy(incoming={}) Transaction.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
71869 71870 71871 71872 71873 71874 71875 71876 71877 71878 71879 71880 71881 71882 71883 71884 71885 71886 71887 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71869 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 ⇒ Object
71861 71862 71863 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71861 def to_json JSON.dump(to_hash) end |