Class: Io::Flow::V0::Models::OrderSummary

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

Overview

The order summary is a view of the order summary object with the order prices flattened to keys.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ OrderSummary

Returns a new instance of OrderSummary.



50339
50340
50341
50342
50343
50344
50345
50346
50347
50348
50349
50350
50351
50352
50353
50354
50355
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50339

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:number, :subtotal, :total, :lines], 'OrderSummary')
  @number = HttpClient::Preconditions.assert_class('number', opts.delete(:number), String)
  @subtotal = (x = opts.delete(:subtotal); x.is_a?(::Io::Flow::V0::Models::OrderSummaryPriceDetail) ? x : ::Io::Flow::V0::Models::OrderSummaryPriceDetail.new(x))
  @shipping = (x = opts.delete(:shipping); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderSummaryPriceDetail) ? x : ::Io::Flow::V0::Models::OrderSummaryPriceDetail.new(x)))
  @tax = (x = opts.delete(:tax); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderSummaryPriceDetail) ? x : ::Io::Flow::V0::Models::OrderSummaryPriceDetail.new(x)))
  @duty = (x = opts.delete(:duty); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderSummaryPriceDetail) ? x : ::Io::Flow::V0::Models::OrderSummaryPriceDetail.new(x)))
  @insurance = (x = opts.delete(:insurance); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderSummaryPriceDetail) ? x : ::Io::Flow::V0::Models::OrderSummaryPriceDetail.new(x)))
  @discount = (x = opts.delete(:discount); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderSummaryPriceDetail) ? x : ::Io::Flow::V0::Models::OrderSummaryPriceDetail.new(x)))
  @surcharges = (x = opts.delete(:surcharges); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderSummaryPriceDetail) ? x : ::Io::Flow::V0::Models::OrderSummaryPriceDetail.new(x)))
  @adjustment = (x = opts.delete(:adjustment); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderSummaryPriceDetail) ? x : ::Io::Flow::V0::Models::OrderSummaryPriceDetail.new(x)))
  @total = (x = opts.delete(:total); x.is_a?(::Io::Flow::V0::Models::OrderSummaryPriceDetail) ? x : ::Io::Flow::V0::Models::OrderSummaryPriceDetail.new(x))
  @lines = HttpClient::Preconditions.assert_class('lines', opts.delete(:lines), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::OrderSummaryLineItem) ? x : ::Io::Flow::V0::Models::OrderSummaryLineItem.new(x)) }
  @identifiers = (x = opts.delete(:identifiers); x.nil? ? nil : HttpClient::Preconditions.assert_class('identifiers', x, Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('identifiers', d[1], String); h })
  @attributes = (x = opts.delete(:attributes); x.nil? ? nil : HttpClient::Preconditions.assert_class('attributes', x, Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h })
end

Instance Attribute Details

#adjustmentObject (readonly)

Returns the value of attribute adjustment.



50337
50338
50339
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50337

def adjustment
  @adjustment
end

#attributesObject (readonly)

Returns the value of attribute attributes.



50337
50338
50339
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50337

def attributes
  @attributes
end

#discountObject (readonly)

Returns the value of attribute discount.



50337
50338
50339
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50337

def discount
  @discount
end

#dutyObject (readonly)

Returns the value of attribute duty.



50337
50338
50339
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50337

def duty
  @duty
end

#identifiersObject (readonly)

Returns the value of attribute identifiers.



50337
50338
50339
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50337

def identifiers
  @identifiers
end

#insuranceObject (readonly)

Returns the value of attribute insurance.



50337
50338
50339
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50337

def insurance
  @insurance
end

#linesObject (readonly)

Returns the value of attribute lines.



50337
50338
50339
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50337

def lines
  @lines
end

#numberObject (readonly)

Returns the value of attribute number.



50337
50338
50339
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50337

def number
  @number
end

#shippingObject (readonly)

Returns the value of attribute shipping.



50337
50338
50339
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50337

def shipping
  @shipping
end

#subtotalObject (readonly)

Returns the value of attribute subtotal.



50337
50338
50339
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50337

def subtotal
  @subtotal
end

#surchargesObject (readonly)

Returns the value of attribute surcharges.



50337
50338
50339
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50337

def surcharges
  @surcharges
end

#taxObject (readonly)

Returns the value of attribute tax.



50337
50338
50339
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50337

def tax
  @tax
end

#totalObject (readonly)

Returns the value of attribute total.



50337
50338
50339
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50337

def total
  @total
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



50361
50362
50363
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50361

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

#to_hashObject



50365
50366
50367
50368
50369
50370
50371
50372
50373
50374
50375
50376
50377
50378
50379
50380
50381
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50365

def to_hash
  {
    :number => number,
    :subtotal => subtotal.to_hash,
    :shipping => shipping.nil? ? nil : shipping.to_hash,
    :tax => tax.nil? ? nil : tax.to_hash,
    :duty => duty.nil? ? nil : duty.to_hash,
    :insurance => insurance.nil? ? nil : insurance.to_hash,
    :discount => discount.nil? ? nil : discount.to_hash,
    :surcharges => surcharges.nil? ? nil : surcharges.to_hash,
    :adjustment => adjustment.nil? ? nil : adjustment.to_hash,
    :total => total.to_hash,
    :lines => lines.map { |o| o.to_hash },
    :identifiers => identifiers.nil? ? nil : identifiers,
    :attributes => attributes.nil? ? nil : attributes
  }
end

#to_jsonObject



50357
50358
50359
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50357

def to_json
  JSON.dump(to_hash)
end