class Application
Constants
- HTTP_CREATED
- HTTP_OK
Public Class Methods
new(username, apikey)
click to toggle source
Set debug flag to to true to view response body
# File lib/AfricasTalking/Application.rb, line 7 def initialize username, apikey @username = username @apikey = apikey end
Public Instance Methods
fetchApplicationData()
click to toggle source
# File lib/AfricasTalking/Application.rb, line 12 def fetchApplicationData url = getUserDataUrl() + '?username='+@username+'' response = sendNormalRequest(url) # if (@response_code == HTTP_OK ) result = JSON.parse(response, :quirky_mode =>true) return ApplicationDataResponse.new result["balance"] else raise AfricasTalkingException, response end end
Private Instance Methods
getApiHost()
click to toggle source
# File lib/AfricasTalking/Application.rb, line 30 def getApiHost() if(@username == "sandbox") return "https://api.sandbox.africastalking.com" else return "https://api.africastalking.com" end end
getUserDataUrl()
click to toggle source
# File lib/AfricasTalking/Application.rb, line 26 def getUserDataUrl() return getApiHost() + "/version1/user" end