Class: Peperusha::TransactionReversal

Inherits:
Object
  • Object
show all
Includes:
Interactor
Defined in:
lib/peperusha/transaction_reversal.rb

Instance Method Summary collapse

Instance Method Details

#callObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/peperusha/transaction_reversal.rb', line 18

def call
  path = '/mpesa/reversal/v1/request'
  response = Peperusha::Client.invoke_post_request(token, path, attributes)

  if response.status == 200
    data = JSON.parse(response.body)
    context.body = data
  else
    client_errors = Peperusha::Client.build_errors_collection(response)
    context.fail!(errors: client_errors)
  end
end