Class: Io::Flow::V0::Models::ShopifyVariantPriceMetafield

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

Overview

The shopify variant metafield defines the individual metafield values we write into Shopify for each variant. This model was introduced to enable server side rendering of content (e.g. the price on the product detail page). Each field in this model is available as its own metafield within a namespace named ‘price_abc’ where abc is a unique, short identifier for an experience.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ShopifyVariantPriceMetafield

Returns a new instance of ShopifyVariantPriceMetafield.



37512
37513
37514
37515
37516
37517
37518
37519
37520
37521
37522
37523
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37512

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:item, :currency, :status], 'ShopifyVariantPriceMetafield')
  @item = HttpClient::Preconditions.assert_class('item', opts.delete(:item), String)
  @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String)
  @includes = (x = opts.delete(:includes); x.nil? ? nil : HttpClient::Preconditions.assert_class('includes', x, String))
  @vat = (x = opts.delete(:vat); x.nil? ? nil : HttpClient::Preconditions.assert_class('vat', x, String))
  @vat_name = (x = opts.delete(:vat_name); x.nil? ? nil : HttpClient::Preconditions.assert_class('vat_name', x, String))
  @duty = (x = opts.delete(:duty); x.nil? ? nil : HttpClient::Preconditions.assert_class('duty', x, String))
  @compare_at = (x = opts.delete(:compare_at); x.nil? ? nil : HttpClient::Preconditions.assert_class('compare_at', x, String))
  @status = (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::SubcatalogItemStatus) ? x : ::Io::Flow::V0::Models::SubcatalogItemStatus.apply(x))
end

Instance Attribute Details

#compare_atObject (readonly)

Returns the value of attribute compare_at.



37510
37511
37512
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37510

def compare_at
  @compare_at
end

#currencyObject (readonly)

Returns the value of attribute currency.



37510
37511
37512
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37510

def currency
  @currency
end

#dutyObject (readonly)

Returns the value of attribute duty.



37510
37511
37512
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37510

def duty
  @duty
end

#includesObject (readonly)

Returns the value of attribute includes.



37510
37511
37512
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37510

def includes
  @includes
end

#itemObject (readonly)

Returns the value of attribute item.



37510
37511
37512
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37510

def item
  @item
end

#statusObject (readonly)

Returns the value of attribute status.



37510
37511
37512
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37510

def status
  @status
end

#vatObject (readonly)

Returns the value of attribute vat.



37510
37511
37512
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37510

def vat
  @vat
end

#vat_nameObject (readonly)

Returns the value of attribute vat_name.



37510
37511
37512
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37510

def vat_name
  @vat_name
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



37529
37530
37531
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37529

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

#to_hashObject



37533
37534
37535
37536
37537
37538
37539
37540
37541
37542
37543
37544
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37533

def to_hash
  {
    :item => item,
    :currency => currency,
    :includes => includes,
    :vat => vat,
    :vat_name => vat_name,
    :duty => duty,
    :compare_at => compare_at,
    :status => status.value
  }
end

#to_jsonObject



37525
37526
37527
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37525

def to_json
  JSON.dump(to_hash)
end