Class: K2ConnectRuby::K2Services::Payloads::Webhooks::TransferWebhook

Inherits:
K2CommonEvents show all
Includes:
ActiveModel::Validations
Defined in:
lib/k2-connect-ruby/k2_services/payloads/webhooks/transfer_webhook.rb

Constant Summary

Constants inherited from K2CommonEvents

K2CommonEvents::REFERENCE_EXCEPTIONS

Instance Attribute Summary collapse

Attributes inherited from K2CommonEvents

#amount, #currency, #origination_time, #reference, #status

Attributes inherited from K2Webhooks

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

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ TransferWebhook

Returns a new instance of TransferWebhook.



24
25
26
27
28
29
30
31
# File 'lib/k2-connect-ruby/k2_services/payloads/webhooks/transfer_webhook.rb', line 24

def initialize(payload)
  super
  # Destination
  @disbursements = payload.dig("event", "resource", "disbursements")
  @destination_type = payload.dig("event", "resource", "destination", "type")
  @destination_reference = payload.dig("event", "resource", "destination", "resource", "reference")
  destination_assets(payload)
end

Instance Attribute Details

#destination_account_nameObject (readonly)

Returns the value of attribute destination_account_name.



12
13
14
# File 'lib/k2-connect-ruby/k2_services/payloads/webhooks/transfer_webhook.rb', line 12

def 
  @destination_account_name
end

#destination_account_numberObject (readonly)

Returns the value of attribute destination_account_number.



12
13
14
# File 'lib/k2-connect-ruby/k2_services/payloads/webhooks/transfer_webhook.rb', line 12

def 
  @destination_account_number
end

#destination_bank_branch_refObject (readonly)

Returns the value of attribute destination_bank_branch_ref.



12
13
14
# File 'lib/k2-connect-ruby/k2_services/payloads/webhooks/transfer_webhook.rb', line 12

def destination_bank_branch_ref
  @destination_bank_branch_ref
end

#destination_first_nameObject (readonly)

Returns the value of attribute destination_first_name.



12
13
14
# File 'lib/k2-connect-ruby/k2_services/payloads/webhooks/transfer_webhook.rb', line 12

def destination_first_name
  @destination_first_name
end

#destination_last_nameObject (readonly)

Returns the value of attribute destination_last_name.



12
13
14
# File 'lib/k2-connect-ruby/k2_services/payloads/webhooks/transfer_webhook.rb', line 12

def destination_last_name
  @destination_last_name
end

#destination_networkObject (readonly)

Returns the value of attribute destination_network.



12
13
14
# File 'lib/k2-connect-ruby/k2_services/payloads/webhooks/transfer_webhook.rb', line 12

def destination_network
  @destination_network
end

#destination_phone_numberObject (readonly)

Returns the value of attribute destination_phone_number.



12
13
14
# File 'lib/k2-connect-ruby/k2_services/payloads/webhooks/transfer_webhook.rb', line 12

def destination_phone_number
  @destination_phone_number
end

#destination_referenceObject (readonly)

Returns the value of attribute destination_reference.



12
13
14
# File 'lib/k2-connect-ruby/k2_services/payloads/webhooks/transfer_webhook.rb', line 12

def destination_reference
  @destination_reference
end

#destination_transfer_methodObject (readonly)

Returns the value of attribute destination_transfer_method.



12
13
14
# File 'lib/k2-connect-ruby/k2_services/payloads/webhooks/transfer_webhook.rb', line 12

def destination_transfer_method
  @destination_transfer_method
end

#destination_typeObject (readonly)

Returns the value of attribute destination_type.



12
13
14
# File 'lib/k2-connect-ruby/k2_services/payloads/webhooks/transfer_webhook.rb', line 12

def destination_type
  @destination_type
end

#disbursementsObject (readonly)

Returns the value of attribute disbursements.



12
13
14
# File 'lib/k2-connect-ruby/k2_services/payloads/webhooks/transfer_webhook.rb', line 12

def disbursements
  @disbursements
end

Instance Method Details

#destination_assets(payload) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/k2-connect-ruby/k2_services/payloads/webhooks/transfer_webhook.rb', line 33

def destination_assets(payload)
  if @destination_type.eql?("Mobile Wallet")
    @destination_network = payload.dig("event", "resource", "destination", "resource", "network")
    @destination_last_name = payload.dig("event", "resource", "destination", "resource", "last_name")
    @destination_first_name = payload.dig("event", "resource", "destination", "resource", "first_name")
    @destination_phone_number = payload.dig("event", "resource", "destination", "resource", "phone_number")
  elsif @destination_type.eql?("Bank Account")
    @destination_account_name = payload.dig("event", "resource", "destination", "resource", "account_name")
    @destination_account_number = payload.dig("event", "resource", "destination", "resource", "account_number")
    @destination_bank_branch_ref = payload.dig("event", "resource", "destination", "resource", "bank_branch_ref")
    @destination_transfer_method = payload.dig("event", "resource", "destination", "resource", "transfer_method")
  end
end