Class: Io::Flow::V0::Models::RefundUpserted

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



28912
28913
28914
28915
28916
28917
28918
28919
28920
28921
28922
28923
28924
28925
28926
28927
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28912

def initialize(incoming={})
  super(:discriminator => Event::Types::REFUND_UPSERTED)
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:event_id, :timestamp, :organization, :key, :authorization_key, :amount, :currency, :captures, :created_at], 'RefundUpserted')
  @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)
  @authorization_key = HttpClient::Preconditions.assert_class('authorization_key', opts.delete(:authorization_key), String)
  @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)
  @captures = HttpClient::Preconditions.assert_class('captures', opts.delete(:captures), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::RefundCaptureSummary) ? x : ::Io::Flow::V0::Models::RefundCaptureSummary.new(x)) }
  @created_at = HttpClient::Preconditions.assert_class('created_at', HttpClient::Helper.to_date_time_iso8601(opts.delete(:created_at)), DateTime)
  @order_number = (x = opts.delete(:order_number); x.nil? ? nil : HttpClient::Preconditions.assert_class('order_number', x, String))
  @rma_key = (x = opts.delete(:rma_key); x.nil? ? nil : HttpClient::Preconditions.assert_class('rma_key', x, String))
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



28910
28911
28912
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28910

def amount
  @amount
end

#authorization_keyObject (readonly)

Returns the value of attribute authorization_key.



28910
28911
28912
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28910

def authorization_key
  @authorization_key
end

#capturesObject (readonly)

Returns the value of attribute captures.



28910
28911
28912
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28910

def captures
  @captures
end

#created_atObject (readonly)

Returns the value of attribute created_at.



28910
28911
28912
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28910

def created_at
  @created_at
end

#currencyObject (readonly)

Returns the value of attribute currency.



28910
28911
28912
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28910

def currency
  @currency
end

#event_idObject (readonly)

Returns the value of attribute event_id.



28910
28911
28912
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28910

def event_id
  @event_id
end

#keyObject (readonly)

Returns the value of attribute key.



28910
28911
28912
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28910

def key
  @key
end

#order_numberObject (readonly)

Returns the value of attribute order_number.



28910
28911
28912
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28910

def order_number
  @order_number
end

#organizationObject (readonly)

Returns the value of attribute organization.



28910
28911
28912
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28910

def organization
  @organization
end

#rma_keyObject (readonly)

Returns the value of attribute rma_key.



28910
28911
28912
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28910

def rma_key
  @rma_key
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



28910
28911
28912
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28910

def timestamp
  @timestamp
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



28933
28934
28935
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28933

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

#subtype_to_hashObject



28937
28938
28939
28940
28941
28942
28943
28944
28945
28946
28947
28948
28949
28950
28951
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28937

def subtype_to_hash
  {
    :event_id => event_id,
    :timestamp => timestamp,
    :organization => organization,
    :key => key,
    :authorization_key => authorization_key,
    :amount => amount,
    :currency => currency,
    :captures => captures.map { |o| o.to_hash },
    :created_at => created_at,
    :order_number => order_number,
    :rma_key => rma_key
  }
end

#to_jsonObject



28929
28930
28931
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 28929

def to_json
  JSON.dump(to_hash)
end