Skip to content

Instantly share code, notes, and snippets.

@catlike
Created November 4, 2010 21:56
Show Gist options
  • Save catlike/663281 to your computer and use it in GitHub Desktop.
Save catlike/663281 to your computer and use it in GitHub Desktop.
Cloudvox: Sample usage to list/add/delete SIP accounts
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