Class: Io::Flow::V0::Models::AllocationLineSummary

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

A line-based view of order financials.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ AllocationLineSummary

Returns a new instance of AllocationLineSummary.



26429
26430
26431
26432
26433
26434
26435
26436
26437
26438
26439
26440
26441
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26429

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:line_items, :shipping, :subtotal, :discount, :duties, :tax, :tax_subsidy, :duties_subsidy, :total], 'AllocationLineSummary')
  @line_items = HttpClient::Preconditions.assert_class('line_items', opts.delete(:line_items), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::AllocationLineSummaryLineItem) ? x : ::Io::Flow::V0::Models::AllocationLineSummaryLineItem.new(x)) }
  @shipping = (x = opts.delete(:shipping); x.is_a?(::Io::Flow::V0::Models::AllocationLineSummaryShipping) ? x : ::Io::Flow::V0::Models::AllocationLineSummaryShipping.new(x))
  @subtotal = (x = opts.delete(:subtotal); x.is_a?(::Io::Flow::V0::Models::MoneyWithBase) ? x : ::Io::Flow::V0::Models::MoneyWithBase.new(x))
  @discount = (x = opts.delete(:discount); x.is_a?(::Io::Flow::V0::Models::MoneyWithBase) ? x : ::Io::Flow::V0::Models::MoneyWithBase.new(x))
  @duties = (x = opts.delete(:duties); x.is_a?(::Io::Flow::V0::Models::MoneyWithBase) ? x : ::Io::Flow::V0::Models::MoneyWithBase.new(x))
  @tax = (x = opts.delete(:tax); x.is_a?(::Io::Flow::V0::Models::MoneyWithBase) ? x : ::Io::Flow::V0::Models::MoneyWithBase.new(x))
  @tax_subsidy = (x = opts.delete(:tax_subsidy); x.is_a?(::Io::Flow::V0::Models::MoneyWithBase) ? x : ::Io::Flow::V0::Models::MoneyWithBase.new(x))
  @duties_subsidy = (x = opts.delete(:duties_subsidy); x.is_a?(::Io::Flow::V0::Models::MoneyWithBase) ? x : ::Io::Flow::V0::Models::MoneyWithBase.new(x))
  @total = (x = opts.delete(:total); x.is_a?(::Io::Flow::V0::Models::MoneyWithBase) ? x : ::Io::Flow::V0::Models::MoneyWithBase.new(x))
end

Instance Attribute Details

#discountObject (readonly)

Returns the value of attribute discount.



26427
26428
26429
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26427

def discount
  @discount
end

#dutiesObject (readonly)

Returns the value of attribute duties.



26427
26428
26429
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26427

def duties
  @duties
end

#duties_subsidyObject (readonly)

Returns the value of attribute duties_subsidy.



26427
26428
26429
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26427

def duties_subsidy
  @duties_subsidy
end

#line_itemsObject (readonly)

Returns the value of attribute line_items.



26427
26428
26429
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26427

def line_items
  @line_items
end

#shippingObject (readonly)

Returns the value of attribute shipping.



26427
26428
26429
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26427

def shipping
  @shipping
end

#subtotalObject (readonly)

Returns the value of attribute subtotal.



26427
26428
26429
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26427

def subtotal
  @subtotal
end

#taxObject (readonly)

Returns the value of attribute tax.



26427
26428
26429
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26427

def tax
  @tax
end

#tax_subsidyObject (readonly)

Returns the value of attribute tax_subsidy.



26427
26428
26429
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26427

def tax_subsidy
  @tax_subsidy
end

#totalObject (readonly)

Returns the value of attribute total.



26427
26428
26429
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26427

def total
  @total
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



26447
26448
26449
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26447

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

#to_hashObject



26451
26452
26453
26454
26455
26456
26457
26458
26459
26460
26461
26462
26463
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26451

def to_hash
  {
    :line_items => line_items.map { |o| o.to_hash },
    :shipping => shipping.to_hash,
    :subtotal => subtotal.to_hash,
    :discount => discount.to_hash,
    :duties => duties.to_hash,
    :tax => tax.to_hash,
    :tax_subsidy => tax_subsidy.to_hash,
    :duties_subsidy => duties_subsidy.to_hash,
    :total => total.to_hash
  }
end

#to_jsonObject



26443
26444
26445
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 26443

def to_json
  JSON.dump(to_hash)
end