Sha256: 9a27b8b38c665f46cd9eabe67a0a77c7b24ea9ec4c75501e6fd15926ba444af6
Contents?: true
Size: 926 Bytes
Versions: 17
Compression:
Stored size: 926 Bytes
Contents
class Application include AfricasTalking HTTP_CREATED = 201 HTTP_OK = 200 #Set debug flag to to true to view response body def initialize username, apikey @username = username @apikey = apikey end 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 def getUserDataUrl() return getApiHost() + "/version1/user" end def getApiHost() if(@username == "sandbox") return "https://api.sandbox.africastalking.com" else return "https://api.africastalking.com" end end end class ApplicationDataResponse attr_reader :balance def initialize balance_ @balance = balance_ end end
Version data entries
17 entries across 17 versions & 1 rubygems