Created
November 4, 2010 21:56
-
-
Save catlike/663281 to your computer and use it in GitHub Desktop.
Cloudvox: Sample usage to list/add/delete SIP accounts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'yaml' | |
require 'rest_client' | |
require 'json' | |
class EditSIPAccount | |
def initialize | |
@cv_config = YAML.load_file 'cloudvox_account.yml' | |
#cloudvox_account.yml format | |
# | |
#domain: <username> | |
#user: <[email protected]> | |
#password: <yourCVpassword> | |
@cloudvox_api = RestClient::Resource.new("https://#{@cv_config['domain']}.cloudvox.com", :user => @cv_config['user'], :password => @cv_config['password']) | |
end | |
def list_sip_accounts | |
@cloudvox_api['/phones.json'].get | |
end | |
def create_sip_account(extension, username, password) | |
#password must be > 6 characters | |
@cloudvox_api['/phones.json'].post :endpoint => {:extension => extension, :username => username, :password => password} | |
end | |
def delete_sip_account(id) | |
@cloudvox_api["/phones/#{id}.json"].delete | |
end | |
end | |
listing = EditSIPAccount.new | |
response = listing.list_sip_accounts | |
puts "#{response.body}" | |
create = EditSIPAccount.new | |
response = create.create_sip_account('223456', 'foobar1', 'qwertyyyyy') | |
puts "#{response.body}" | |
delete = EditSIPAccount.new | |
response = delete.delete_sip_account('585') | |
puts "#{response.body}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment