Class: Io::Flow::V0::Models::Hs6CodeUpserted

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

Overview

Event raised whenever an HS-6 code is assigned to an item

Instance Attribute Summary collapse

Attributes inherited from Event

#discriminator

Instance Method Summary collapse

Methods inherited from Event

#to_hash

Constructor Details

#initialize(incoming = {}) ⇒ Hs6CodeUpserted

Returns a new instance of Hs6CodeUpserted.



13716
13717
13718
13719
13720
13721
13722
13723
13724
13725
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13716

def initialize(incoming={})
  super(:discriminator => Event::Types::HS6_CODE_UPSERTED)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:event_id, :timestamp, :organization, :number, :code], 'Hs6CodeUpserted')
  @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)
  @code = HttpClient::Preconditions.assert_class('code', opts.delete(:code), String)
end

Instance Attribute Details

#code ⇒ Object (readonly)

Returns the value of attribute code.



13714
13715
13716
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13714

def code
  @code
end

#event_id ⇒ Object (readonly)

Returns the value of attribute event_id.



13714
13715
13716
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13714

def event_id
  @event_id
end

#number ⇒ Object (readonly)

Returns the value of attribute number.



13714
13715
13716
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13714

def number
  @number
end

#organization ⇒ Object (readonly)

Returns the value of attribute organization.



13714
13715
13716
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13714

def organization
  @organization
end

#timestamp ⇒ Object (readonly)

Returns the value of attribute timestamp.



13714
13715
13716
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13714

def timestamp
  @timestamp
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



13731
13732
13733
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13731

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

#subtype_to_hash ⇒ Object



13735
13736
13737
13738
13739
13740
13741
13742
13743
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13735

def subtype_to_hash
  {
    :event_id => event_id,
    :timestamp => timestamp,
    :organization => organization,
    :number => number,
    :code => code
  }
end

#to_json ⇒ Object



13727
13728
13729
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 13727

def to_json
  JSON.dump(to_hash)
end