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

from_json, #to_hash

Constructor Details

#initialize(incoming = {}) ⇒ CatalogItemUpserted

Returns a new instance of CatalogItemUpserted.



31600
31601
31602
31603
31604
31605
31606
31607
31608
31609
31610
31611
31612
31613
31614
31615
31616
31617
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31600

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, :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)
  @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

#attributesObject (readonly)

Returns the value of attribute attributes.



31598
31599
31600
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31598

def attributes
  @attributes
end

#categoriesObject (readonly)

Returns the value of attribute categories.



31598
31599
31600
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31598

def categories
  @categories
end

#currencyObject (readonly)

Returns the value of attribute currency.



31598
31599
31600
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31598

def currency
  @currency
end

#descriptionObject (readonly)

Returns the value of attribute description.



31598
31599
31600
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31598

def description
  @description
end

#dimensionsObject (readonly)

Returns the value of attribute dimensions.



31598
31599
31600
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31598

def dimensions
  @dimensions
end

#event_idObject (readonly)

Returns the value of attribute event_id.



31598
31599
31600
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31598

def event_id
  @event_id
end

#imagesObject (readonly)

Returns the value of attribute images.



31598
31599
31600
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31598

def images
  @images
end

#localeObject (readonly)

Returns the value of attribute locale.



31598
31599
31600
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31598

def locale
  @locale
end

#nameObject (readonly)

Returns the value of attribute name.



31598
31599
31600
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31598

def name
  @name
end

#numberObject (readonly)

Returns the value of attribute number.



31598
31599
31600
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31598

def number
  @number
end

#organizationObject (readonly)

Returns the value of attribute organization.



31598
31599
31600
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31598

def organization
  @organization
end

#priceObject (readonly)

Returns the value of attribute price.



31598
31599
31600
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31598

def price
  @price
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



31598
31599
31600
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31598

def timestamp
  @timestamp
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



31623
31624
31625
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31623

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

#subtype_to_hashObject



31627
31628
31629
31630
31631
31632
31633
31634
31635
31636
31637
31638
31639
31640
31641
31642
31643
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31627

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

#to_jsonObject



31619
31620
31621
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 31619

def to_json
  JSON.dump(to_hash)
end