class Airtel::Pesa::DisbursementTransactionEnquiry
Constants
- PRODUCTION_URL
- STAGING_URL
Attributes
transaction_country_code[R]
transaction_currency_code[R]
transaction_id[R]
Public Class Methods
call(transaction_id:, transaction_country_code:, transaction_currency_code:)
click to toggle source
# File lib/airtel/pesa/disbursement_transaction_enquiry.rb, line 17 def self.call(transaction_id:, transaction_country_code:, transaction_currency_code:) new(transaction_id, transaction_country_code, transaction_currency_code).call end
new(transaction_id, transaction_country_code, transaction_currency_code)
click to toggle source
# File lib/airtel/pesa/disbursement_transaction_enquiry.rb, line 21 def initialize(transaction_id, transaction_country_code, transaction_currency_code) @transaction_id = transaction_id @transaction_country_code = transaction_country_code @transaction_currency_code = transaction_currency_code end
Public Instance Methods
call()
click to toggle source
# File lib/airtel/pesa/disbursement_transaction_enquiry.rb, line 27 def call url = URI("#{env_url}/standard/v1/disbursements/#{transaction_id}") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Get.new(url) request["Authorization"] = "Bearer #{token}" request["X-Country"] = transaction_country_code request["X-Currency"] = transaction_currency_code response = http.request(request) parsed_response = JSON.parse(response.read_body) result = Airtel::Pesa.to_recursive_ostruct(parsed_response) OpenStruct.new(result: result, error: nil) rescue JSON::ParserError => error OpenStruct.new(result: nil, error: error) end
Private Instance Methods
env_url()
click to toggle source
# File lib/airtel/pesa/disbursement_transaction_enquiry.rb, line 49 def env_url return STAGING_URL Airtel::Pesa.configuration.env == 'staging' return PRODUCTION_URL Airtel::Pesa.configuration.env == 'production' end
token()
click to toggle source
# File lib/airtel/pesa/disbursement_transaction_enquiry.rb, line 54 def token Airtel::Pesa::Authorization.call.result.access_token end