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.



48648
48649
48650
48651
48652
48653
48654
48655
48656
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48648

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

#priceObject (readonly)

Returns the value of attribute price.



48646
48647
48648
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48646

def price
  @price
end

#price_sourceObject (readonly)

Returns the value of attribute price_source.



48646
48647
48648
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48646

def price_source
  @price_source
end

#quantityObject (readonly)

Returns the value of attribute quantity.



48646
48647
48648
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48646

def quantity
  @quantity
end

#totalObject (readonly)

Returns the value of attribute total.



48646
48647
48648
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48646

def total
  @total
end

#variant_idObject (readonly)

Returns the value of attribute variant_id.



48646
48647
48648
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48646

def variant_id
  @variant_id
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



48662
48663
48664
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48662

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

#to_hashObject



48666
48667
48668
48669
48670
48671
48672
48673
48674
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48666

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_jsonObject



48658
48659
48660
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48658

def to_json
  JSON.dump(to_hash)
end