Class: SettlementWebhook

Inherits:
K2CommonEvents show all
Defined in:
lib/k2-connect-ruby/k2_services/payloads/webhooks/settlement_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 Webhook

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

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ SettlementWebhook

Returns a new instance of SettlementWebhook.



14
15
16
17
18
19
20
21
# File 'lib/k2-connect-ruby/k2_services/payloads/webhooks/settlement_webhook.rb', line 14

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.



2
3
4
# File 'lib/k2-connect-ruby/k2_services/payloads/webhooks/settlement_webhook.rb', line 2

def 
  @destination_account_name
end

#destination_account_numberObject (readonly)

Returns the value of attribute destination_account_number.



2
3
4
# File 'lib/k2-connect-ruby/k2_services/payloads/webhooks/settlement_webhook.rb', line 2

def 
  @destination_account_number
end

#destination_bank_branch_refObject (readonly)

Returns the value of attribute destination_bank_branch_ref.



2
3
4
# File 'lib/k2-connect-ruby/k2_services/payloads/webhooks/settlement_webhook.rb', line 2

def destination_bank_branch_ref
  @destination_bank_branch_ref
end

#destination_first_nameObject (readonly)

Returns the value of attribute destination_first_name.



2
3
4
# File 'lib/k2-connect-ruby/k2_services/payloads/webhooks/settlement_webhook.rb', line 2

def destination_first_name
  @destination_first_name
end

#destination_last_nameObject (readonly)

Returns the value of attribute destination_last_name.



2
3
4
# File 'lib/k2-connect-ruby/k2_services/payloads/webhooks/settlement_webhook.rb', line 2

def destination_last_name
  @destination_last_name
end

#destination_networkObject (readonly)

Returns the value of attribute destination_network.



2
3
4
# File 'lib/k2-connect-ruby/k2_services/payloads/webhooks/settlement_webhook.rb', line 2

def destination_network
  @destination_network
end

#destination_phone_numberObject (readonly)

Returns the value of attribute destination_phone_number.



2
3
4
# File 'lib/k2-connect-ruby/k2_services/payloads/webhooks/settlement_webhook.rb', line 2

def destination_phone_number
  @destination_phone_number
end

#destination_referenceObject (readonly)

Returns the value of attribute destination_reference.



2
3
4
# File 'lib/k2-connect-ruby/k2_services/payloads/webhooks/settlement_webhook.rb', line 2

def destination_reference
  @destination_reference
end

#destination_settlement_methodObject (readonly)

Returns the value of attribute destination_settlement_method.



2
3
4
# File 'lib/k2-connect-ruby/k2_services/payloads/webhooks/settlement_webhook.rb', line 2

def destination_settlement_method
  @destination_settlement_method
end

#destination_typeObject (readonly)

Returns the value of attribute destination_type.



2
3
4
# File 'lib/k2-connect-ruby/k2_services/payloads/webhooks/settlement_webhook.rb', line 2

def destination_type
  @destination_type
end

#disbursementsObject (readonly)

Returns the value of attribute disbursements.



2
3
4
# File 'lib/k2-connect-ruby/k2_services/payloads/webhooks/settlement_webhook.rb', line 2

def disbursements
  @disbursements
end

Instance Method Details

#destination_assets(payload) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/k2-connect-ruby/k2_services/payloads/webhooks/settlement_webhook.rb', line 23

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_settlement_method = payload.dig('event', 'resource', 'destination', 'resource', 'settlement_method')
  end
end