class Vend::Airtime
Public Instance Methods
buy(payload)
click to toggle source
# File lib/airvend/airvend_objects/airtime.rb, line 6 def buy(payload) params_hash = { 'ref'=> payload[:ref], 'account'=> payload[:phone], 'networkid'=> mno_id(payload[:mno]), 'type'=> "1", 'amount'=> payload[:amount] } details = {} details.merge!({ 'details'=>params_hash }) api_hash = @airvendObj.hash_req(details) response = vendAdapter(api_hash, details) if response.status == 200 hash = rename_hash(JSON.parse(response.body, { symbolize_names: true })) rename_hash(hash[:details]) hash else produce_error(response) end end