Class: Airtel::Pesa::TransactionEnquiry
- Inherits:
-
Object
- Object
- Airtel::Pesa::TransactionEnquiry
- Defined in:
- lib/airtel/pesa/user_enquiry.rb,
lib/airtel/pesa/transaction_enquiry.rb
Constant Summary collapse
- STAGING_URL =
"https://openapiuat.airtel.africa".freeze
- PRODUCTION_URL =
"https://openapi.airtel.africa".freeze
Instance Attribute Summary collapse
-
#phone_number ⇒ Object
readonly
Returns the value of attribute phone_number.
-
#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) ⇒ TransactionEnquiry
constructor
A new instance of TransactionEnquiry.
Constructor Details
#initialize(transaction_id, transaction_country_code, transaction_currency_code) ⇒ TransactionEnquiry
Returns a new instance of TransactionEnquiry.
21 22 23 24 25 |
# File 'lib/airtel/pesa/user_enquiry.rb', line 21 def initialize(phone_number, transaction_country_code, transaction_currency_code) @phone_number = phone_number @transaction_country_code = transaction_country_code @transaction_currency_code = transaction_currency_code end |
Instance Attribute Details
#phone_number ⇒ Object (readonly)
Returns the value of attribute phone_number.
15 16 17 |
# File 'lib/airtel/pesa/user_enquiry.rb', line 15 def phone_number @phone_number end |
#transaction_country_code ⇒ Object (readonly)
Returns the value of attribute transaction_country_code.
15 16 17 |
# File 'lib/airtel/pesa/user_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/user_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/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/user_enquiry.rb', line 17 def self.call(phone_number:, transaction_country_code:, transaction_currency_code:) new(phone_number, 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/user_enquiry.rb', line 27 def call url = URI("#{env_url}/standard/v1/users/#{phone_number}") 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 |