Class: Io::Flow::V0::Models::CatalogItemDocument

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

Instance Attribute Summary collapse

Attributes inherited from Document

#discriminator

Instance Method Summary collapse

Methods inherited from Document

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ CatalogItemDocument

Returns a new instance of CatalogItemDocument.



18882
18883
18884
18885
18886
18887
18888
18889
18890
18891
18892
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18882

def initialize(incoming={})
  super(:discriminator => Document::Types::CATALOG_ITEM_DOCUMENT)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:number, :name, :categories, :experiences, :attributes, :images], 'CatalogItemDocument')
  @number = HttpClient::Preconditions.assert_class('number', opts.delete(:number), String)
  @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
  @categories = HttpClient::Preconditions.assert_class('categories', opts.delete(:categories), Array).map { |v| HttpClient::Preconditions.assert_class('categories', v, String) }
  @experiences = HttpClient::Preconditions.assert_class('experiences', opts.delete(:experiences), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ExperienceSummary) ? x : ::Io::Flow::V0::Models::ExperienceSummary.new(x)) }
  @attributes = HttpClient::Preconditions.assert_class('attributes', opts.delete(:attributes), Hash).inject({}) { |h, d| h[d[0]] = HttpClient::Preconditions.assert_class('attributes', d[1], String); h }
  @images = (x = opts.delete(:images); x.is_a?(::Io::Flow::V0::Models::CatalogItemDocumentImages) ? x : ::Io::Flow::V0::Models::CatalogItemDocumentImages.new(x))
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



18880
18881
18882
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18880

def attributes
  @attributes
end

#categoriesObject (readonly)

Returns the value of attribute categories.



18880
18881
18882
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18880

def categories
  @categories
end

#experiencesObject (readonly)

Returns the value of attribute experiences.



18880
18881
18882
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18880

def experiences
  @experiences
end

#imagesObject (readonly)

Returns the value of attribute images.



18880
18881
18882
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18880

def images
  @images
end

#nameObject (readonly)

Returns the value of attribute name.



18880
18881
18882
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18880

def name
  @name
end

#numberObject (readonly)

Returns the value of attribute number.



18880
18881
18882
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18880

def number
  @number
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



18898
18899
18900
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18898

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

#subtype_to_hashObject



18902
18903
18904
18905
18906
18907
18908
18909
18910
18911
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18902

def subtype_to_hash
  {
    :number => number,
    :name => name,
    :categories => categories,
    :experiences => experiences.map { |o| o.to_hash },
    :attributes => attributes,
    :images => images.to_hash
  }
end

#to_jsonObject



18894
18895
18896
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 18894

def to_json
  JSON.dump(to_hash)
end