Class: Airtel::Pesa::DisbursementTransactionEnquiry
- Inherits:
-
Object
- Object
- Airtel::Pesa::DisbursementTransactionEnquiry
- Defined in:
- lib/airtel/pesa/disbursement_transaction_enquiry.rb
Constant Summary collapse
- STAGING_URL =
"https://openapiuat.airtel.africa".freeze
- PRODUCTION_URL =
"https://openapi.airtel.africa".freeze
Instance Attribute Summary collapse
-
#transaction_country_code ⇒ Object
readonly
Returns the value of attribute transaction_country_code.
-
#transaction_currency_code ⇒ Object
readonly
Returns the value of attribute transaction_currency_code.
-
#transaction_id ⇒ Object
readonly
Returns the value of attribute transaction_id.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(transaction_id, transaction_country_code, transaction_currency_code) ⇒ DisbursementTransactionEnquiry
constructor
A new instance of DisbursementTransactionEnquiry.
Constructor Details
#initialize(transaction_id, transaction_country_code, transaction_currency_code) ⇒ DisbursementTransactionEnquiry
Returns a new instance of DisbursementTransactionEnquiry.
21 22 23 24 25 |
# 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 |
Instance Attribute Details
#transaction_country_code ⇒ Object (readonly)
Returns the value of attribute transaction_country_code.
15 16 17 |
# File 'lib/airtel/pesa/disbursement_transaction_enquiry.rb', line 15 def transaction_country_code @transaction_country_code end |
#transaction_currency_code ⇒ Object (readonly)
Returns the value of attribute transaction_currency_code.
15 16 17 |
# File 'lib/airtel/pesa/disbursement_transaction_enquiry.rb', line 15 def transaction_currency_code @transaction_currency_code end |
#transaction_id ⇒ Object (readonly)
Returns the value of attribute transaction_id.
15 16 17 |
# File 'lib/airtel/pesa/disbursement_transaction_enquiry.rb', line 15 def transaction_id @transaction_id end |
Class Method Details
.call(transaction_id:, transaction_country_code:, transaction_currency_code:) ⇒ Object
17 18 19 |
# 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 |
Instance Method Details
#call ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# 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 |