class Africastalking::Airtime
Public Class Methods
buy_airtime(recipients)
click to toggle source
# File lib/africastalking/airtime.rb, line 5 def buy_airtime(recipients) post('/version1/airtime/send', build_airtime(recipients)) end
Also aliased as: buy
Private Class Methods
build_airtime(recipients)
click to toggle source
# File lib/africastalking/airtime.rb, line 12 def build_airtime(recipients) {"username" => Africastalking.config.username, "recipients" => build_recipients(recipients).to_json} end
build_recipient(recipient)
click to toggle source
# File lib/africastalking/airtime.rb, line 16 def build_recipient(recipient) {"phoneNumber" => "#{recipient.fetch(:mobile_number)}", "amount" => "KES #{recipient.fetch(:airtime, 0.0)}"} end
build_recipients(recipients)
click to toggle source
# File lib/africastalking/airtime.rb, line 20 def build_recipients(recipients) airtime_recipients = Array.new recipients.each {|recipient| airtime_recipients << build_recipient(recipient)} airtime_recipients end