Class: Io::Flow::V0::Models::ShopifyLine

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ShopifyLine

Returns a new instance of ShopifyLine.



41327
41328
41329
41330
41331
41332
41333
41334
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41327

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))
end

Instance Attribute Details

#priceObject (readonly)

Returns the value of attribute price.



41325
41326
41327
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41325

def price
  @price
end

#quantityObject (readonly)

Returns the value of attribute quantity.



41325
41326
41327
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41325

def quantity
  @quantity
end

#totalObject (readonly)

Returns the value of attribute total.



41325
41326
41327
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41325

def total
  @total
end

#variant_idObject (readonly)

Returns the value of attribute variant_id.



41325
41326
41327
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41325

def variant_id
  @variant_id
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



41340
41341
41342
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41340

def copy(incoming={})
  ShopifyLine.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



41344
41345
41346
41347
41348
41349
41350
41351
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41344

def to_hash
  {
    :variant_id => variant_id,
    :quantity => quantity,
    :price => price.to_hash,
    :total => total.to_hash
  }
end

#to_jsonObject



41336
41337
41338
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 41336

def to_json
  JSON.dump(to_hash)
end