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

#to_hash

Constructor Details

#initialize(incoming = {}) ⇒ HarmonizedItemUpserted

Returns a new instance of HarmonizedItemUpserted.



13284
13285
13286
13287
13288
13289
13290
13291
13292
13293
13294
13295
13296
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13284

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

#attributes ⇒ Object (readonly)

Returns the value of attribute attributes.



13282
13283
13284
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13282

def attributes
  @attributes
end

#categories ⇒ Object (readonly)

Returns the value of attribute categories.



13282
13283
13284
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13282

def categories
  @categories
end

#description ⇒ Object (readonly)

Returns the value of attribute description.



13282
13283
13284
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13282

def description
  @description
end

#event_id ⇒ Object (readonly)

Returns the value of attribute event_id.



13282
13283
13284
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13282

def event_id
  @event_id
end

#name ⇒ Object (readonly)

Returns the value of attribute name.



13282
13283
13284
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13282

def name
  @name
end

#number ⇒ Object (readonly)

Returns the value of attribute number.



13282
13283
13284
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13282

def number
  @number
end

#organization ⇒ Object (readonly)

Returns the value of attribute organization.



13282
13283
13284
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13282

def organization
  @organization
end

#timestamp ⇒ Object (readonly)

Returns the value of attribute timestamp.



13282
13283
13284
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13282

def timestamp
  @timestamp
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



13302
13303
13304
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13302

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

#subtype_to_hash ⇒ Object



13306
13307
13308
13309
13310
13311
13312
13313
13314
13315
13316
13317
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13306

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

#to_json ⇒ Object



13298
13299
13300
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13298

def to_json
  JSON.dump(to_hash)
end