Class: K2CommonEvents

Inherits:
Webhook show all
Defined in:
lib/k2-connect-ruby/k2_services/payloads/k2_webhooks.rb

Direct Known Subclasses

B2b, Buygoods, MerchantToMerchant, SettlementWebhook

Constant Summary collapse

REFERENCE_EXCEPTIONS =
["Merchant to Merchant Transaction", "Settlement Transfer"]

Instance Attribute Summary collapse

Attributes inherited from Webhook

#created_at, #event_resource, #event_type, #id, #links_resource, #links_self, #resource_id, #topic

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ K2CommonEvents

Returns a new instance of K2CommonEvents.



33
34
35
36
37
38
39
40
# File 'lib/k2-connect-ruby/k2_services/payloads/k2_webhooks.rb', line 33

def initialize(payload)
  super
  @reference = payload.dig('event', 'resource', 'reference') unless REFERENCE_EXCEPTIONS.include?(@event_type)
  @origination_time = payload.dig('event', 'resource', 'origination_time')
  @amount = payload.dig('event', 'resource', 'amount')
  @currency = payload.dig('event', 'resource', 'currency')
  @status = payload.dig('event', 'resource', 'status')
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



27
28
29
# File 'lib/k2-connect-ruby/k2_services/payloads/k2_webhooks.rb', line 27

def amount
  @amount
end

#currencyObject (readonly)

Returns the value of attribute currency.



27
28
29
# File 'lib/k2-connect-ruby/k2_services/payloads/k2_webhooks.rb', line 27

def currency
  @currency
end

#origination_timeObject (readonly)

Returns the value of attribute origination_time.



27
28
29
# File 'lib/k2-connect-ruby/k2_services/payloads/k2_webhooks.rb', line 27

def origination_time
  @origination_time
end

#referenceObject (readonly)

Returns the value of attribute reference.



27
28
29
# File 'lib/k2-connect-ruby/k2_services/payloads/k2_webhooks.rb', line 27

def reference
  @reference
end

#statusObject (readonly)

Returns the value of attribute status.



27
28
29
# File 'lib/k2-connect-ruby/k2_services/payloads/k2_webhooks.rb', line 27

def status
  @status
end