Class: Io::Flow::V0::Models::CatalogItemUpserted

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

Instance Attribute Summary collapse

Attributes inherited from Event

#discriminator

Instance Method Summary collapse

Methods inherited from Event

#to_hash

Constructor Details

#initialize(incoming = {}) ⇒ CatalogItemUpserted

Returns a new instance of CatalogItemUpserted.



10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10832

def initialize(incoming={})
  super(:discriminator => Event::Types::CATALOG_ITEM_UPSERTED)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:event_id, :timestamp, :organization, :number, :catalog, :locale, :name, :currency, :price, :categories, :attributes, :dimensions, :images], 'CatalogItemUpserted')
  @event_id = HttpClient::Preconditions.assert_class('event_id', opts.delete(:event_id), String)
  @timestamp = HttpClient::Preconditions.assert_class('timestamp', HttpClient::Helper.to_date_time_iso8601(opts.delete(:timestamp)), DateTime)
  @organization = HttpClient::Preconditions.assert_class('organization', opts.delete(:organization), String)
  @number = HttpClient::Preconditions.assert_class('number', opts.delete(:number), String)
  @catalog = HttpClient::Preconditions.assert_class('catalog', opts.delete(:catalog), String)
  @locale = HttpClient::Preconditions.assert_class('locale', opts.delete(:locale), String)
  @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
  @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String)
  @price = HttpClient::Preconditions.assert_class('price', opts.delete(:price), Numeric)
  @categories = HttpClient::Preconditions.assert_class('categories', opts.delete(:categories), Array).map { |v| HttpClient::Preconditions.assert_class('categories', v, String) }
  @description = (x = opts.delete(:description); x.nil? ? nil : HttpClient::Preconditions.assert_class('description', x, String))
  @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 }
  @dimensions = HttpClient::Preconditions.assert_class('dimensions', HttpClient::Helper.to_object(opts.delete(:dimensions)), Hash)
  @images = HttpClient::Preconditions.assert_class('images', opts.delete(:images), Array).map { |v| HttpClient::Preconditions.assert_class('images', HttpClient::Helper.to_object(v), Hash) }
end

Instance Attribute Details

#attributes ⇒ Object (readonly)

Returns the value of attribute attributes.



10830
10831
10832
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10830

def attributes
  @attributes
end

#catalog ⇒ Object (readonly)

Returns the value of attribute catalog.



10830
10831
10832
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10830

def catalog
  @catalog
end

#categories ⇒ Object (readonly)

Returns the value of attribute categories.



10830
10831
10832
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10830

def categories
  @categories
end

#currency ⇒ Object (readonly)

Returns the value of attribute currency.



10830
10831
10832
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10830

def currency
  @currency
end

#description ⇒ Object (readonly)

Returns the value of attribute description.



10830
10831
10832
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10830

def description
  @description
end

#dimensions ⇒ Object (readonly)

Returns the value of attribute dimensions.



10830
10831
10832
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10830

def dimensions
  @dimensions
end

#event_id ⇒ Object (readonly)

Returns the value of attribute event_id.



10830
10831
10832
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10830

def event_id
  @event_id
end

#images ⇒ Object (readonly)

Returns the value of attribute images.



10830
10831
10832
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10830

def images
  @images
end

#locale ⇒ Object (readonly)

Returns the value of attribute locale.



10830
10831
10832
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10830

def locale
  @locale
end

#name ⇒ Object (readonly)

Returns the value of attribute name.



10830
10831
10832
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10830

def name
  @name
end

#number ⇒ Object (readonly)

Returns the value of attribute number.



10830
10831
10832
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10830

def number
  @number
end

#organization ⇒ Object (readonly)

Returns the value of attribute organization.



10830
10831
10832
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10830

def organization
  @organization
end

#price ⇒ Object (readonly)

Returns the value of attribute price.



10830
10831
10832
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10830

def price
  @price
end

#timestamp ⇒ Object (readonly)

Returns the value of attribute timestamp.



10830
10831
10832
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10830

def timestamp
  @timestamp
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



10856
10857
10858
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10856

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

#subtype_to_hash ⇒ Object



10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10860

def subtype_to_hash
  {
    :event_id => event_id,
    :timestamp => timestamp,
    :organization => organization,
    :number => number,
    :catalog => catalog,
    :locale => locale,
    :name => name,
    :currency => currency,
    :price => price,
    :categories => categories,
    :description => description,
    :attributes => attributes,
    :dimensions => dimensions,
    :images => images
  }
end

#to_json ⇒ Object



10852
10853
10854
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 10852

def to_json
  JSON.dump(to_hash)
end