Class: Io::Flow::V0::Models::OrderQuoteLine
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::OrderQuoteLine
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Same interface as experience order_summary_line_item with additional attributes needed by order_quote
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.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#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.
-
#unit_price ⇒ Object
readonly
Returns the value of attribute unit_price.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ OrderQuoteLine
constructor
A new instance of OrderQuoteLine.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ OrderQuoteLine
Returns a new instance of OrderQuoteLine.
53111 53112 53113 53114 53115 53116 53117 53118 53119 53120 53121 53122 53123 53124 53125 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53111 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:id, :item, :quantity, :unit_price, :total, :price_attributes, :attributes], 'OrderQuoteLine') @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String) @item = (x = opts.delete(:item); x.is_a?(::Io::Flow::V0::Models::OrderSummaryItem) ? x : ::Io::Flow::V0::Models::OrderSummaryItem.new(x)) @errors = (x = opts.delete(:errors); x.nil? ? nil : HttpClient::Preconditions.assert_class('errors', x, Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::OrderQuoteLineError) ? x : ::Io::Flow::V0::Models::OrderQuoteLineError.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::OrderQuoteLineDiscount) ? x : ::Io::Flow::V0::Models::OrderQuoteLineDiscount.new(x))) @tax = (x = opts.delete(:tax); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderQuoteSummaryTax) ? x : ::Io::Flow::V0::Models::OrderQuoteSummaryTax.new(x))) @duty = (x = opts.delete(:duty); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderQuoteSummaryDuty) ? x : ::Io::Flow::V0::Models::OrderQuoteSummaryDuty.new(x))) @unit_price = (x = opts.delete(:unit_price); x.is_a?(::Io::Flow::V0::Models::OrderQuotePrice) ? x : ::Io::Flow::V0::Models::OrderQuotePrice.from_json(x)) @total = (x = opts.delete(:total); x.is_a?(::Io::Flow::V0::Models::OrderQuotePrice) ? x : ::Io::Flow::V0::Models::OrderQuotePrice.from_json(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::OrderQuotePriceStandard) ? x : ::Io::Flow::V0::Models::OrderQuotePriceStandard.new(x)); h } @attributes = HttpClient::Preconditions.assert_class('attributes', opts.delete(:attributes), 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.
53109 53110 53111 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53109 def attributes @attributes end |
#discount ⇒ Object (readonly)
Returns the value of attribute discount.
53109 53110 53111 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53109 def discount @discount end |
#duty ⇒ Object (readonly)
Returns the value of attribute duty.
53109 53110 53111 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53109 def duty @duty end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
53109 53110 53111 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53109 def errors @errors end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
53109 53110 53111 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53109 def id @id end |
#item ⇒ Object (readonly)
Returns the value of attribute item.
53109 53110 53111 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53109 def item @item end |
#price_attributes ⇒ Object (readonly)
Returns the value of attribute price_attributes.
53109 53110 53111 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53109 def price_attributes @price_attributes end |
#quantity ⇒ Object (readonly)
Returns the value of attribute quantity.
53109 53110 53111 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53109 def quantity @quantity end |
#tax ⇒ Object (readonly)
Returns the value of attribute tax.
53109 53110 53111 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53109 def tax @tax end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
53109 53110 53111 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53109 def total @total end |
#unit_price ⇒ Object (readonly)
Returns the value of attribute unit_price.
53109 53110 53111 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53109 def unit_price @unit_price end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
53131 53132 53133 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53131 def copy(incoming={}) OrderQuoteLine.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
53135 53136 53137 53138 53139 53140 53141 53142 53143 53144 53145 53146 53147 53148 53149 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53135 def to_hash { :id => id, :item => item.to_hash, :errors => errors.nil? ? nil : errors.map { |o| o.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, :unit_price => unit_price.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 } end |
#to_json ⇒ Object
53127 53128 53129 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 53127 def to_json JSON.dump(to_hash) end |