Class: Io::Flow::V0::Models::ShopifyOrderPriceAttributesMetafield

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

Overview

Model to represent item’s price attributes metafield

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ShopifyOrderPriceAttributesMetafield

Returns a new instance of ShopifyOrderPriceAttributesMetafield.



63230
63231
63232
63233
63234
63235
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 63230

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:item_number, :price_attributes], 'ShopifyOrderPriceAttributesMetafield')
  @item_number = HttpClient::Preconditions.assert_class('item_number', opts.delete(:item_number), String)
  @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::PriceWithBase) ? x : ::Io::Flow::V0::Models::PriceWithBase.new(x)); h }
end

Instance Attribute Details

#item_numberObject (readonly)

Returns the value of attribute item_number.



63228
63229
63230
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 63228

def item_number
  @item_number
end

#price_attributesObject (readonly)

Returns the value of attribute price_attributes.



63228
63229
63230
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 63228

def price_attributes
  @price_attributes
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



63241
63242
63243
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 63241

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

#to_hashObject



63245
63246
63247
63248
63249
63250
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 63245

def to_hash
  {
    :item_number => item_number,
    :price_attributes => price_attributes.inject({}) { |hash, o| hash[o[0]] = o[1].nil? ? nil : o[1].to_hash; hash }
  }
end

#to_jsonObject



63237
63238
63239
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 63237

def to_json
  JSON.dump(to_hash)
end