Class: Io::Flow::V0::Models::HarmonizedItemUpserted

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 = {}) ⇒ HarmonizedItemUpserted

Returns a new instance of HarmonizedItemUpserted.



16347
16348
16349
16350
16351
16352
16353
16354
16355
16356
16357
16358
16359
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16347

def initialize(incoming={})
  super(:discriminator => Event::Types::HARMONIZED_ITEM_UPSERTED)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:event_id, :timestamp, :organization, :number, :name, :categories, :attributes], 'HarmonizedItemUpserted')
  @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)
  @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) }
  @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 }
  @description = (x = opts.delete(:description); x.nil? ? nil : HttpClient::Preconditions.assert_class('description', x, String))
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



16345
16346
16347
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16345

def attributes
  @attributes
end

#categoriesObject (readonly)

Returns the value of attribute categories.



16345
16346
16347
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16345

def categories
  @categories
end

#descriptionObject (readonly)

Returns the value of attribute description.



16345
16346
16347
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16345

def description
  @description
end

#event_idObject (readonly)

Returns the value of attribute event_id.



16345
16346
16347
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16345

def event_id
  @event_id
end

#nameObject (readonly)

Returns the value of attribute name.



16345
16346
16347
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16345

def name
  @name
end

#numberObject (readonly)

Returns the value of attribute number.



16345
16346
16347
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16345

def number
  @number
end

#organizationObject (readonly)

Returns the value of attribute organization.



16345
16346
16347
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16345

def organization
  @organization
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



16345
16346
16347
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16345

def timestamp
  @timestamp
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



16365
16366
16367
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16365

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

#subtype_to_hashObject



16369
16370
16371
16372
16373
16374
16375
16376
16377
16378
16379
16380
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16369

def subtype_to_hash
  {
    :event_id => event_id,
    :timestamp => timestamp,
    :organization => organization,
    :number => number,
    :name => name,
    :categories => categories,
    :attributes => attributes,
    :description => description
  }
end

#to_jsonObject



16361
16362
16363
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16361

def to_json
  JSON.dump(to_hash)
end