Class: Io::Flow::V0::Models::LocalItem

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

Overview

The Local Item represents all of the data for a given item that is localized to a given experience.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ LocalItem

Returns a new instance of LocalItem.



48661
48662
48663
48664
48665
48666
48667
48668
48669
48670
48671
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48661

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :experience, :item, :pricing, :status], 'LocalItem')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @experience = (x = opts.delete(:experience); x.is_a?(::Io::Flow::V0::Models::ExperienceSummary) ? x : ::Io::Flow::V0::Models::ExperienceSummary.new(x))
  @center = (x = opts.delete(:center); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::CenterSummary) ? x : ::Io::Flow::V0::Models::CenterSummary.new(x)))
  @item = (x = opts.delete(:item); x.is_a?(::Io::Flow::V0::Models::CatalogItemReference) ? x : ::Io::Flow::V0::Models::CatalogItemReference.new(x))
  @pricing = (x = opts.delete(:pricing); x.is_a?(::Io::Flow::V0::Models::LocalItemPricing) ? x : ::Io::Flow::V0::Models::LocalItemPricing.new(x))
  @status = (x = opts.delete(:status); x.is_a?(::Io::Flow::V0::Models::SubcatalogItemStatus) ? x : ::Io::Flow::V0::Models::SubcatalogItemStatus.apply(x))
  @attributes = (x = opts.delete(:attributes); x.nil? ? nil : HttpClient::Preconditions.assert_class('attributes', x, Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h })
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

#centerObject (readonly)

Returns the value of attribute center.



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

def center
  @center
end

#experienceObject (readonly)

Returns the value of attribute experience.



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

def experience
  @experience
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#itemObject (readonly)

Returns the value of attribute item.



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

def item
  @item
end

#pricingObject (readonly)

Returns the value of attribute pricing.



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

def pricing
  @pricing
end

#statusObject (readonly)

Returns the value of attribute status.



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

def status
  @status
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



48677
48678
48679
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48677

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

#to_hashObject



48681
48682
48683
48684
48685
48686
48687
48688
48689
48690
48691
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48681

def to_hash
  {
    :id => id,
    :experience => experience.to_hash,
    :center => center.nil? ? nil : center.to_hash,
    :item => item.to_hash,
    :pricing => pricing.to_hash,
    :status => status.value,
    :attributes => attributes.nil? ? nil : attributes
  }
end

#to_jsonObject



48673
48674
48675
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 48673

def to_json
  JSON.dump(to_hash)
end