Class: Io::Flow::V0::Models::ShopifyLine
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::ShopifyLine
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Instance Attribute Summary collapse
-
#price ⇒ Object
readonly
Returns the value of attribute price.
-
#price_source ⇒ Object
readonly
Returns the value of attribute price_source.
-
#quantity ⇒ Object
readonly
Returns the value of attribute quantity.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
-
#variant_id ⇒ Object
readonly
Returns the value of attribute variant_id.
Instance Method Summary collapse
- #copy(incoming = {}) ⇒ Object
-
#initialize(incoming = {}) ⇒ ShopifyLine
constructor
A new instance of ShopifyLine.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ ShopifyLine
Returns a new instance of ShopifyLine.
49350 49351 49352 49353 49354 49355 49356 49357 49358 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49350 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:variant_id, :quantity, :price, :total], 'ShopifyLine') @variant_id = HttpClient::Preconditions.assert_class('variant_id', opts.delete(:variant_id), Integer) @quantity = HttpClient::Preconditions.assert_class('quantity', opts.delete(:quantity), Integer) @price = (x = opts.delete(:price); x.is_a?(::Io::Flow::V0::Models::ShopifyPrice) ? x : ::Io::Flow::V0::Models::ShopifyPrice.new(x)) @total = (x = opts.delete(:total); x.is_a?(::Io::Flow::V0::Models::ShopifyPrice) ? x : ::Io::Flow::V0::Models::ShopifyPrice.new(x)) @price_source = (x = opts.delete(:price_source); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::PriceSource) ? x : ::Io::Flow::V0::Models::PriceSource.from_json(x))) end |
Instance Attribute Details
#price ⇒ Object (readonly)
Returns the value of attribute price.
49348 49349 49350 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49348 def price @price end |
#price_source ⇒ Object (readonly)
Returns the value of attribute price_source.
49348 49349 49350 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49348 def price_source @price_source end |
#quantity ⇒ Object (readonly)
Returns the value of attribute quantity.
49348 49349 49350 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49348 def quantity @quantity end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
49348 49349 49350 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49348 def total @total end |
#variant_id ⇒ Object (readonly)
Returns the value of attribute variant_id.
49348 49349 49350 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49348 def variant_id @variant_id end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
49364 49365 49366 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49364 def copy(incoming={}) ShopifyLine.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
49368 49369 49370 49371 49372 49373 49374 49375 49376 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49368 def to_hash { :variant_id => variant_id, :quantity => quantity, :price => price.to_hash, :total => total.to_hash, :price_source => price_source.nil? ? nil : price_source.to_hash } end |
#to_json ⇒ Object
49360 49361 49362 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 49360 def to_json JSON.dump(to_hash) end |