Class: VoicePulse
- Inherits:
-
Object
- Object
- VoicePulse
- Defined in:
- lib/rubypulse.rb
Instance Method Summary collapse
-
#activatePhoneNumbers ⇒ Object
TODO: activatePhoneNumbers = => @apikey, :PhoneNumbers => Array, :AccountNumber1 => String, :AccountNumber2 => String.
-
#deactivatePhoneNumbers ⇒ Object
TODO: deactivatePhoneNumbers = => @apikey, :PhoneNumbers => Array, :AccountNumber1 => String, :AccountNumber2 => String.
-
#generateReport(dates) ⇒ Object
Requires a single hash in the format: (:ApiKey => String, :StartYear => Integer, :StartMonth => Integer, :StartDay => Integer, :EndYear => Integer, :EndMonth => Integer, :EndDay => Integer, :Filename => String).
-
#getAvailablePhoneNumberAreaCodes(state) ⇒ Object
Requires input of state as a string (two digit code).
-
#getAvailablePhoneNumberRateCenters(state, areacode) ⇒ Object
Requires two strings for input (‘state’, ‘areacode’) and returns a hash of center’ => ‘city’.
-
#getAvailablePhoneNumbers(state, areacode, ratecenter) ⇒ Object
TODO: getAvailablePhoneNumbers = => @apikey, :State => String, :AreaCode => String, :RateCenter => String Requires inputs of state, areacode, and ratecenter as strings.
-
#getAvailablePhoneNumberStates ⇒ Object
TODO: getAvailablePhoneNumberStates = => @apikey Accepts no input and returns an array of available states (two digit codes).
-
#getBalance ⇒ Object
Gets the current balance of the account and returns it as a String.
-
#getCredentials ⇒ Object
TODO: getCredentials = => @apikey Accepts no inputs and returns an array of [login, password] for use in your sip.conf or iax2.conf.
-
#getRate(phonenumber) ⇒ Object
Requires a phone number with no formatting as a String and returns a String for the rate per-minute.
-
#getReport(filename) ⇒ Object
Requires a filename as a String (the one returned from generateReport).
-
#getUser ⇒ Object
Accepts no input and returns and array of [username, email].
-
#initialize ⇒ VoicePulse
constructor
When you create a VoicePulseApi.new class it creates a SOAP::WSDLDriverFactory class called @driver.
-
#refill(ccvcode, amount) ⇒ Object
TODO: Need to test this when account balance gets low Requires a CCV Code (3 digit number from back of Credit Card) and an amount as Strings.
Constructor Details
#initialize ⇒ VoicePulse
When you create a VoicePulseApi.new class it creates a SOAP::WSDLDriverFactory class called @driver. It also creates a variable @apikey to store the ApiKey from VoicePulse.
Example:
obj = VoicePulseApi.new
16 17 18 19 20 |
# File 'lib/rubypulse.rb', line 16 def initialize() wsdl = 'http://connect.voicepulse.com/secure/services/Api0605.asmx?WSDL' @driver = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver @apikey = API_KEY end |
Instance Method Details
#activatePhoneNumbers ⇒ Object
TODO: activatePhoneNumbers = => @apikey, :PhoneNumbers => Array, :AccountNumber1 => String, :AccountNumber2 => String
85 86 87 |
# File 'lib/rubypulse.rb', line 85 def activatePhoneNumbers end |
#deactivatePhoneNumbers ⇒ Object
TODO: deactivatePhoneNumbers = => @apikey, :PhoneNumbers => Array, :AccountNumber1 => String, :AccountNumber2 => String
90 91 92 |
# File 'lib/rubypulse.rb', line 90 def deactivatePhoneNumbers end |
#generateReport(dates) ⇒ Object
Requires a single hash in the format:
(:ApiKey => String, :StartYear => Integer, :StartMonth => Integer, :StartDay => Integer, :EndYear => Integer, :EndMonth => Integer, :EndDay => Integer, :Filename => String)
Example:
datehash = {:ApiKey => @apikey, :StartYear => 2007, :StartMonth => 03, :StartDay => 01, :EndYear => 2007, :EndMonth => 04, :EndDay => 02, :Filename => "vpreport"}
obj.generateReport(datehash) => "vpreport.zip"
Returns the name of the Filename created (will always be a .zip file because of the way VoicePulse processes the report).
29 30 31 32 33 34 35 36 37 |
# File 'lib/rubypulse.rb', line 29 def generateReport(dates) result = @driver.GenerateReport(dates) if result.generateReport.errorCode == "0" then output = result.generateReport.filename else output = "Error Generating Report: #{result.generateReportResult.errorMessage}" end return output end |
#getAvailablePhoneNumberAreaCodes(state) ⇒ Object
Requires input of state as a string (two digit code). Returns list of available area codes.
106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/rubypulse.rb', line 106 def getAvailablePhoneNumberAreaCodes(state) result = @driver.GetAvailablePhoneNumberAreaCodes(:ApiKey => @apikey, :State => state) if result.getAvailablePhoneNumberAreaCodesResult.errorCode == "0" then response = result.getAvailablePhoneNumberAreaCodesResult.items.apiResponseItem @arealist = Array.new response.each do |res| @arealist += res.areaCode.to_a end output = @arealist else output = result.getAvailablePhoneNumberAreaCodesResult.errorMessage end return output end |
#getAvailablePhoneNumberRateCenters(state, areacode) ⇒ Object
Requires two strings for input (‘state’, ‘areacode’) and returns a hash of center’ => ‘city’
122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/rubypulse.rb', line 122 def getAvailablePhoneNumberRateCenters(state, areacode) result = @driver.GetAvailablePhoneNumberRateCenters(:ApiKey => @apikey, :State => state, :AreaCode => areacode) if result.getAvailablePhoneNumberRateCentersResult.errorCode == "0" then response = result.getAvailablePhoneNumberRateCentersResult.items.apiResponseItem @reportlist = Hash.new response.each do |res| @reportlist.update(res.rateCenter => res.city) end output = @reportlist else output = result.getAvailablePhoneNumberRateCentersResult.errorMessage end return output end |
#getAvailablePhoneNumbers(state, areacode, ratecenter) ⇒ Object
TODO: getAvailablePhoneNumbers = => @apikey, :State => String, :AreaCode => String, :RateCenter => String Requires inputs of state, areacode, and ratecenter as strings. Returns and array of available phone numbers.
156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/rubypulse.rb', line 156 def getAvailablePhoneNumbers(state, areacode, ratecenter) result = @driver.GetAvailablePhoneNumbers(:ApiKey => @apikey, :State => state, :AreaCode => areacode, :RateCenter => ratecenter) if result.getAvailablePhoneNumbersResult.errorCode == "0" then response = result.getAvailablePhoneNumbersResult.items.apiResponseItem @numberlist = Array.new response.each do |res| @numberlist += res.phoneNumber.to_a end output = @numberlist else output = result.getAvailablePhoneNumbersResult.errorMessage end return output end |
#getAvailablePhoneNumberStates ⇒ Object
TODO: getAvailablePhoneNumberStates = => @apikey Accepts no input and returns an array of available states (two digit codes)
139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/rubypulse.rb', line 139 def getAvailablePhoneNumberStates result = @driver.GetAvailablePhoneNumberStates(:ApiKey => @apikey) if result.getAvailablePhoneNumberStatesResult.errorCode == "0" then response = result.getAvailablePhoneNumberStatesResult.items.apiResponseItem @statelist = Array.new response.each do |res| @statelist += res.state.to_a end output = @statelist else output = result.getAvailablePhoneNumberStatesResult.errorMessage end return output end |
#getBalance ⇒ Object
Gets the current balance of the account and returns it as a String
56 57 58 59 60 61 62 63 64 |
# File 'lib/rubypulse.rb', line 56 def getBalance result = @driver.GetBalance(:ApiKey => @apikey) if result.getBalanceResult.errorCode == "0" then output = result.getBalanceResult.balance else output = result.getBalanceResult.errorMessage end return output end |
#getCredentials ⇒ Object
TODO: getCredentials = => @apikey Accepts no inputs and returns an array of [login, password] for use in your sip.conf or iax2.conf
173 174 175 176 177 178 179 180 181 |
# File 'lib/rubypulse.rb', line 173 def getCredentials result = @driver.GetCredentials(:ApiKey => @apikey) if result.getCredentialsResult.errorCode == "0" then output = [result.getCredentialsResult.items.apiResponseItem.login, result.getCredentialsResult.items.apiResponseItem.password] else output = "Error Getting FlexRate: #{result.getUserResult.errorMessage}" end return output end |
#getRate(phonenumber) ⇒ Object
Requires a phone number with no formatting as a String and returns a String for the rate per-minute.
67 68 69 70 71 72 73 74 75 |
# File 'lib/rubypulse.rb', line 67 def getRate(phonenumber) result = @driver.GetFlexRate(:ApiKey => @apikey, :PhoneNumber => phonenumber) if result.getFlexRateResult.errorCode == "0" then output = result.getFlexRateResult.flexRate else output = "Error Getting FlexRate: #{result.getFlexRateResult.errorMessage}" end return output end |
#getReport(filename) ⇒ Object
Requires a filename as a String (the one returned from generateReport). Returns a https URL to download the file from.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rubypulse.rb', line 40 def getReport(filename) result = @driver.GetGeneratedReports(:ApiKey => @apikey) if result.getGeneratedReportsResult.errorCode == "0" then response = result.getGeneratedReportsResult.items.apiResponseItem @reportlist = Hash.new response.each do |res| @reportlist.update(res.filename => res.fullPath) end output = @reportlist[filename] else output = result.getGeneratedReportsResult.errorMessage end return output end |
#getUser ⇒ Object
Accepts no input and returns and array of [username, email]
184 185 186 187 188 189 190 191 192 |
# File 'lib/rubypulse.rb', line 184 def getUser result = @driver.GetUser(:ApiKey => @apikey) if result.getUserResult.errorCode == "0" then output = [result.getUserResult.items.apiResponseItem.username, result.getUserResult.items.apiResponseItem.email] else output = "Error Getting FlexRate: #{result.getUserResult.errorMessage}" end return output end |
#refill(ccvcode, amount) ⇒ Object
TODO: Need to test this when account balance gets low Requires a CCV Code (3 digit number from back of Credit Card) and an amount as Strings. Returns success or failure message.
79 80 81 82 |
# File 'lib/rubypulse.rb', line 79 def refill(ccvcode, amount) result = @driver.RefillNow(:ApiKey => @apikey, :CreditCardCode => ccvcode, :Amount => amount) return result.refillNowResult.refillNow end |