Class: Io::Flow::V0::Models::AuthorizationUpserted

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

Returns a new instance of AuthorizationUpserted.



16833
16834
16835
16836
16837
16838
16839
16840
16841
16842
16843
16844
16845
16846
16847
16848
16849
16850
16851
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16833

def initialize(incoming={})
  super(:discriminator => Event::Types::AUTHORIZATION_UPSERTED)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:event_id, :timestamp, :organization, :key, :card, :amount, :currency, :customer, :attributes, :result, :created_at], 'AuthorizationUpserted')
  @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)
  @key = HttpClient::Preconditions.assert_class('key', opts.delete(:key), String)
  @order_number = (x = opts.delete(:order_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('order_number', x, String))
  @card = (x = opts.delete(:card); x.is_a?(::Io::Flow::V0::Models::ExpandableCard) ? x : ::Io::Flow::V0::Models::ExpandableCard.from_json(x))
  @amount = HttpClient::Preconditions.assert_class('amount', HttpClient::Helper.to_big_decimal(opts.delete(:amount)), BigDecimal)
  @currency = HttpClient::Preconditions.assert_class('currency', opts.delete(:currency), String)
  @customer = (x = opts.delete(:customer); x.is_a?(::Io::Flow::V0::Models::Customer) ? x : ::Io::Flow::V0::Models::Customer.new(x))
  @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 }
  @destination = (x = opts.delete(:destination); x.nil? ? nil : (x = x; x.is_a?(::Io::Flow::V0::Models::Address) ? x : ::Io::Flow::V0::Models::Address.new(x)))
  @result = (x = opts.delete(:result); x.is_a?(::Io::Flow::V0::Models::AuthorizationResult) ? x : ::Io::Flow::V0::Models::AuthorizationResult.new(x))
  @ip = (x = opts.delete(:ip); x.nil? ? nil : HttpClient::Preconditions.assert_class('ip', x, String))
  @created_at = HttpClient::Preconditions.assert_class('created_at', HttpClient::Helper.to_date_time_iso8601(opts.delete(:created_at)), DateTime)
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



16831
16832
16833
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16831

def amount
  @amount
end

#attributesObject (readonly)

Returns the value of attribute attributes.



16831
16832
16833
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16831

def attributes
  @attributes
end

#cardObject (readonly)

Returns the value of attribute card.



16831
16832
16833
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16831

def card
  @card
end

#created_atObject (readonly)

Returns the value of attribute created_at.



16831
16832
16833
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16831

def created_at
  @created_at
end

#currencyObject (readonly)

Returns the value of attribute currency.



16831
16832
16833
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16831

def currency
  @currency
end

#customerObject (readonly)

Returns the value of attribute customer.



16831
16832
16833
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16831

def customer
  @customer
end

#destinationObject (readonly)

Returns the value of attribute destination.



16831
16832
16833
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16831

def destination
  @destination
end

#event_idObject (readonly)

Returns the value of attribute event_id.



16831
16832
16833
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16831

def event_id
  @event_id
end

#ipObject (readonly)

Returns the value of attribute ip.



16831
16832
16833
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16831

def ip
  @ip
end

#keyObject (readonly)

Returns the value of attribute key.



16831
16832
16833
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16831

def key
  @key
end

#order_numberObject (readonly)

Returns the value of attribute order_number.



16831
16832
16833
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16831

def order_number
  @order_number
end

#organizationObject (readonly)

Returns the value of attribute organization.



16831
16832
16833
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16831

def organization
  @organization
end

#resultObject (readonly)

Returns the value of attribute result.



16831
16832
16833
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16831

def result
  @result
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



16831
16832
16833
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16831

def timestamp
  @timestamp
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



16857
16858
16859
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16857

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

#subtype_to_hashObject



16861
16862
16863
16864
16865
16866
16867
16868
16869
16870
16871
16872
16873
16874
16875
16876
16877
16878
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16861

def subtype_to_hash
  {
    :event_id => event_id,
    :timestamp => timestamp,
    :organization => organization,
    :key => key,
    :order_number => order_number,
    :card => card.to_hash,
    :amount => amount,
    :currency => currency,
    :customer => customer.to_hash,
    :attributes => attributes,
    :destination => destination.nil? ? nil : destination.to_hash,
    :result => result.to_hash,
    :ip => ip,
    :created_at => created_at
  }
end

#to_jsonObject



16853
16854
16855
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 16853

def to_json
  JSON.dump(to_hash)
end