Class: Io::Flow::V0::Models::OrderSummaryLineItem
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::OrderSummaryLineItem
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#discount ⇒ Object
readonly
Returns the value of attribute discount.
-
#duty ⇒ Object
readonly
Returns the value of attribute duty.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#item ⇒ Object
readonly
Returns the value of attribute item.
-
#price_attributes ⇒ Object
readonly
Returns the value of attribute price_attributes.
-
#quantity ⇒ Object
readonly
Returns the value of attribute quantity.
-
#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 = {}) ⇒ OrderSummaryLineItem
constructor
A new instance of OrderSummaryLineItem.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ OrderSummaryLineItem
Returns a new instance of OrderSummaryLineItem.
50489 50490 50491 50492 50493 50494 50495 50496 50497 50498 50499 50500 50501 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50489 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:item, :quantity, :total, :price_attributes], 'OrderSummaryLineItem') @id = (x = opts.delete(:id); x.nil? ? nil : HttpClient::Preconditions.assert_class('id', x, String)) @item = (x = opts.delete(:item); x.is_a?(::Io::Flow::V0::Models::OrderSummaryItem) ? x : ::Io::Flow::V0::Models::OrderSummaryItem.new(x)) @quantity = HttpClient::Preconditions.assert_class('quantity', opts.delete(:quantity), Integer) @discount = (x = opts.delete(:discount); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Price) ? x : ::Io::Flow::V0::Models::Price.new(x))) @tax = (x = opts.delete(:tax); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderSummaryLevy) ? x : ::Io::Flow::V0::Models::OrderSummaryLevy.new(x))) @duty = (x = opts.delete(:duty); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderSummaryLevy) ? x : ::Io::Flow::V0::Models::OrderSummaryLevy.new(x))) @total = (x = opts.delete(:total); x.is_a?(::Io::Flow::V0::Models::Price) ? x : ::Io::Flow::V0::Models::Price.new(x)) @price_attributes = HttpClient::Preconditions.assert_class('price_attributes', opts.delete(:price_attributes), Hash).inject({}) { |h, d| h[d[0]] = (x = d[1]; x.is_a?(::Io::Flow::V0::Models::Price) ? x : ::Io::Flow::V0::Models::Price.new(x)); 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
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
50487 50488 50489 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50487 def attributes @attributes end |
#discount ⇒ Object (readonly)
Returns the value of attribute discount.
50487 50488 50489 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50487 def discount @discount end |
#duty ⇒ Object (readonly)
Returns the value of attribute duty.
50487 50488 50489 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50487 def duty @duty end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
50487 50488 50489 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50487 def id @id end |
#item ⇒ Object (readonly)
Returns the value of attribute item.
50487 50488 50489 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50487 def item @item end |
#price_attributes ⇒ Object (readonly)
Returns the value of attribute price_attributes.
50487 50488 50489 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50487 def price_attributes @price_attributes end |
#quantity ⇒ Object (readonly)
Returns the value of attribute quantity.
50487 50488 50489 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50487 def quantity @quantity end |
#tax ⇒ Object (readonly)
Returns the value of attribute tax.
50487 50488 50489 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50487 def tax @tax end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
50487 50488 50489 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50487 def total @total end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
50507 50508 50509 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50507 def copy(incoming={}) OrderSummaryLineItem.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
50511 50512 50513 50514 50515 50516 50517 50518 50519 50520 50521 50522 50523 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50511 def to_hash { :id => id, :item => item.to_hash, :quantity => quantity, :discount => discount.nil? ? nil : discount.to_hash, :tax => tax.nil? ? nil : tax.to_hash, :duty => duty.nil? ? nil : duty.to_hash, :total => total.to_hash, :price_attributes => price_attributes.inject({}) { |hash, o| hash[o[0]] = o[1].nil? ? nil : o[1].to_hash; hash }, :attributes => attributes.nil? ? nil : attributes } end |
#to_json ⇒ Object
50503 50504 50505 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 50503 def to_json JSON.dump(to_hash) end |