Class: Io::Flow::V0::Models::TransactionUpserted

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

Returns a new instance of TransactionUpserted.



71952
71953
71954
71955
71956
71957
71958
71959
71960
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71952

def initialize(incoming={})
  super(:discriminator => Event::Types::TRANSACTION_UPSERTED)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:event_id, :timestamp, :organization, :transaction], 'TransactionUpserted')
  @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)
  @transaction = (x = opts.delete(:transaction); x.is_a?(::Io::Flow::V0::Models::Transaction) ? x : ::Io::Flow::V0::Models::Transaction.new(x))
end

Instance Attribute Details

#event_idObject (readonly)

Returns the value of attribute event_id.



71950
71951
71952
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71950

def event_id
  @event_id
end

#organizationObject (readonly)

Returns the value of attribute organization.



71950
71951
71952
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71950

def organization
  @organization
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



71950
71951
71952
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71950

def timestamp
  @timestamp
end

#transactionObject (readonly)

Returns the value of attribute transaction.



71950
71951
71952
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71950

def transaction
  @transaction
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



71966
71967
71968
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71966

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

#subtype_to_hashObject



71970
71971
71972
71973
71974
71975
71976
71977
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71970

def subtype_to_hash
  {
    :event_id => event_id,
    :timestamp => timestamp,
    :organization => organization,
    :transaction => transaction.to_hash
  }
end

#to_jsonObject



71962
71963
71964
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 71962

def to_json
  JSON.dump(to_hash)
end