Method: K2ConnectRuby::K2Utilities::K2ProcessResult#check_type

Defined in:
lib/k2-connect-ruby/k2_utilities/k2_process_result.rb

#check_type(payload) ⇒ Object

Check the Event Type.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/k2-connect-ruby/k2_utilities/k2_process_result.rb', line 12

def check_type(payload)
  result_type = payload.dig('data', 'type')
  case result_type
    # Incoming Payments
  when 'incoming_payment'
    incoming_payments = K2ConnectRuby::K2Services::Payloads::Transactions::IncomingPayment.new(payload)
    return incoming_payments
    # Outgoing Payments
  when 'payment'
    outgoing_payments = K2ConnectRuby::K2Services::Payloads::Transactions::OutgoingPayment.new(payload)
    return outgoing_payments
  when 'settlement_transfer'
    transfer = K2ConnectRuby::K2Services::Payloads::Transactions::Transfer.new(payload)
    return transfer
  else
    raise ArgumentError, 'No Other Specified Payment Type!'
  end
end