Class: Io::Flow::V0::Models::OrderSummary
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::OrderSummary
- 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
-
#adjustment ⇒ Object
readonly
Returns the value of attribute adjustment.
-
#discount ⇒ Object
readonly
Returns the value of attribute discount.
-
#duty ⇒ Object
readonly
Returns the value of attribute duty.
-
#identifiers ⇒ Object
readonly
Returns the value of attribute identifiers.
-
#insurance ⇒ Object
readonly
Returns the value of attribute insurance.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#shipping ⇒ Object
readonly
Returns the value of attribute shipping.
-
#subtotal ⇒ Object
readonly
Returns the value of attribute subtotal.
-
#surcharges ⇒ Object
readonly
Returns the value of attribute surcharges.
-
#tax ⇒ Object
readonly
Returns the value of attribute tax.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ OrderSummary
constructor
A new instance of OrderSummary.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ OrderSummary
Returns a new instance of OrderSummary.
40120 40121 40122 40123 40124 40125 40126 40127 40128 40129 40130 40131 40132 40133 40134 40135 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40120 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 }) end |
Instance Attribute Details
#adjustment ⇒ Object (readonly)
Returns the value of attribute adjustment.
40118 40119 40120 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40118 def adjustment @adjustment end |
#discount ⇒ Object (readonly)
Returns the value of attribute discount.
40118 40119 40120 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40118 def discount @discount end |
#duty ⇒ Object (readonly)
Returns the value of attribute duty.
40118 40119 40120 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40118 def duty @duty end |
#identifiers ⇒ Object (readonly)
Returns the value of attribute identifiers.
40118 40119 40120 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40118 def identifiers @identifiers end |
#insurance ⇒ Object (readonly)
Returns the value of attribute insurance.
40118 40119 40120 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40118 def insurance @insurance end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
40118 40119 40120 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40118 def lines @lines end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
40118 40119 40120 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40118 def number @number end |
#shipping ⇒ Object (readonly)
Returns the value of attribute shipping.
40118 40119 40120 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40118 def shipping @shipping end |
#subtotal ⇒ Object (readonly)
Returns the value of attribute subtotal.
40118 40119 40120 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40118 def subtotal @subtotal end |
#surcharges ⇒ Object (readonly)
Returns the value of attribute surcharges.
40118 40119 40120 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40118 def surcharges @surcharges end |
#tax ⇒ Object (readonly)
Returns the value of attribute tax.
40118 40119 40120 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40118 def tax @tax end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
40118 40119 40120 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40118 def total @total end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
40141 40142 40143 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40141 def copy(incoming={}) OrderSummary.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
40145 40146 40147 40148 40149 40150 40151 40152 40153 40154 40155 40156 40157 40158 40159 40160 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40145 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 } end |
#to_json ⇒ Object
40137 40138 40139 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 40137 def to_json JSON.dump(to_hash) end |