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.
45504 45505 45506 45507 45508 45509 45510 45511 45512 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45504 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.
45502 45503 45504 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45502 def price @price end |
#price_source ⇒ Object (readonly)
Returns the value of attribute price_source.
45502 45503 45504 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45502 def price_source @price_source end |
#quantity ⇒ Object (readonly)
Returns the value of attribute quantity.
45502 45503 45504 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45502 def quantity @quantity end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
45502 45503 45504 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45502 def total @total end |
#variant_id ⇒ Object (readonly)
Returns the value of attribute variant_id.
45502 45503 45504 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45502 def variant_id @variant_id end |
Instance Method Details
#copy(incoming = {}) ⇒ Object
45518 45519 45520 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45518 def copy(incoming={}) ShopifyLine.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming))) end |
#to_hash ⇒ Object
45522 45523 45524 45525 45526 45527 45528 45529 45530 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45522 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
45514 45515 45516 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 45514 def to_json JSON.dump(to_hash) end |