Class: Io::Flow::V0::Models::OrderSummaryItem
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::OrderSummaryItem
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#discount ⇒ Object
readonly
Returns the value of attribute discount.
-
#duty ⇒ Object
readonly
Returns the value of attribute duty.
-
#image ⇒ Object
readonly
Returns the value of attribute image.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
-
#price_attributes ⇒ Object
readonly
Returns the value of attribute price_attributes.
-
#tax ⇒ Object
readonly
Returns the value of attribute tax.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ OrderSummaryItem
constructor
A new instance of OrderSummaryItem.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ OrderSummaryItem
Returns a new instance of OrderSummaryItem.
54288 54289 54290 54291 54292 54293 54294 54295 54296 54297 54298 54299 54300 54301 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54288 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:number, :name, :attributes, :price, :price_attributes], 'OrderSummaryItem') @number = HttpClient::Preconditions.assert_class('number', opts.delete(:number), String) @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String) @description = (x = opts.delete(:description); x.nil? ? nil : HttpClient::Preconditions.assert_class('description', x, String)) @attributes = HttpClient::Preconditions.assert_class('attributes', opts.delete(:attributes), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::CheckoutItemContentAttribute) ? x : ::Io::Flow::V0::Models::CheckoutItemContentAttribute.new(x)) } @image = (x = opts.delete(:image); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::OrderSummaryImage) ? x : ::Io::Flow::V0::Models::OrderSummaryImage.new(x))) @price = (x = opts.delete(:price); x.is_a?(::Io::Flow::V0::Models::Price) ? x : ::Io::Flow::V0::Models::Price.new(x)) @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))) @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 } end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
54286 54287 54288 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54286 def attributes @attributes end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
54286 54287 54288 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54286 def description @description end |
#discount ⇒ Object (readonly)
Returns the value of attribute discount.
54286 54287 54288 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54286 def discount @discount end |
#duty ⇒ Object (readonly)
Returns the value of attribute duty.
54286 54287 54288 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54286 def duty @duty end |
#image ⇒ Object (readonly)
Returns the value of attribute image.
54286 54287 54288 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54286 def image @image end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
54286 54287 54288 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54286 def name @name end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
54286 54287 54288 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54286 def number @number end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
54286 54287 54288 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54286 def price @price end |
#price_attributes ⇒ Object (readonly)
Returns the value of attribute price_attributes.
54286 54287 54288 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54286 def price_attributes @price_attributes end |
#tax ⇒ Object (readonly)
Returns the value of attribute tax.
54286 54287 54288 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54286 def tax @tax end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
54307 54308 54309 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54307 def copy(incoming={}) OrderSummaryItem.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
54311 54312 54313 54314 54315 54316 54317 54318 54319 54320 54321 54322 54323 54324 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54311 def to_hash { :number => number, :name => name, :description => description, :attributes => attributes.map { |o| o.to_hash }, :image => image.nil? ? nil : image.to_hash, :price => price.to_hash, :discount => discount.nil? ? nil : discount.to_hash, :tax => tax.nil? ? nil : tax.to_hash, :duty => duty.nil? ? nil : duty.to_hash, :price_attributes => price_attributes.inject({}) { |hash, o| hash[o[0]] = o[1].nil? ? nil : o[1].to_hash; hash } } end |
#to_json ⇒ Object
54303 54304 54305 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 54303 def to_json JSON.dump(to_hash) end |