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.



37586
37587
37588
37589
37590
37591
37592
37593
37594
37595
37596
37597
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37586

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.



37584
37585
37586
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37584

def compare_at
  @compare_at
end

#currencyObject (readonly)

Returns the value of attribute currency.



37584
37585
37586
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37584

def currency
  @currency
end

#dutyObject (readonly)

Returns the value of attribute duty.



37584
37585
37586
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37584

def duty
  @duty
end

#includesObject (readonly)

Returns the value of attribute includes.



37584
37585
37586
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37584

def includes
  @includes
end

#itemObject (readonly)

Returns the value of attribute item.



37584
37585
37586
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37584

def item
  @item
end

#statusObject (readonly)

Returns the value of attribute status.



37584
37585
37586
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37584

def status
  @status
end

#vatObject (readonly)

Returns the value of attribute vat.



37584
37585
37586
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37584

def vat
  @vat
end

#vat_nameObject (readonly)

Returns the value of attribute vat_name.



37584
37585
37586
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37584

def vat_name
  @vat_name
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



37603
37604
37605
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37603

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

#to_hashObject



37607
37608
37609
37610
37611
37612
37613
37614
37615
37616
37617
37618
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37607

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



37599
37600
37601
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 37599

def to_json
  JSON.dump(to_hash)
end