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.



30210
30211
30212
30213
30214
30215
30216
30217
30218
30219
30220
30221
30222
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30210

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.



30208
30209
30210
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30208

def discount
  @discount
end

#dutiesObject (readonly)

Returns the value of attribute duties.



30208
30209
30210
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30208

def duties
  @duties
end

#duties_subsidyObject (readonly)

Returns the value of attribute duties_subsidy.



30208
30209
30210
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30208

def duties_subsidy
  @duties_subsidy
end

#line_itemsObject (readonly)

Returns the value of attribute line_items.



30208
30209
30210
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30208

def line_items
  @line_items
end

#shippingObject (readonly)

Returns the value of attribute shipping.



30208
30209
30210
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30208

def shipping
  @shipping
end

#subtotalObject (readonly)

Returns the value of attribute subtotal.



30208
30209
30210
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30208

def subtotal
  @subtotal
end

#taxObject (readonly)

Returns the value of attribute tax.



30208
30209
30210
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30208

def tax
  @tax
end

#tax_subsidyObject (readonly)

Returns the value of attribute tax_subsidy.



30208
30209
30210
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30208

def tax_subsidy
  @tax_subsidy
end

#totalObject (readonly)

Returns the value of attribute total.



30208
30209
30210
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30208

def total
  @total
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



30228
30229
30230
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30228

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

#to_hashObject



30232
30233
30234
30235
30236
30237
30238
30239
30240
30241
30242
30243
30244
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30232

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



30224
30225
30226
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 30224

def to_json
  JSON.dump(to_hash)
end