SDK in Ruby for CALLR API
Install via Rubygems
gem install callr
Or get sources from Github
Gem
require 'callr'
api = CALLR::Api.new('login', 'password')
Source
load 'lib/callr.rb'
api = CALLR::Api.new('login', 'password')
begin
api = CALLR::Api.new('login', 'password')
api.call('sms.send', 'SMS')
rescue CALLR::CallrException, CALLR::CallrLocalException => e
puts "ERROR: #{e.code}"
puts "MESSAGE: #{e.msg}"
puts "DATA: ", e.data
end
api.set_login_as('user', 'foo') # login as user foo
api.set_login_as('account', 'foo') # login as account foo
api.set_login_as(nil, nil) # Remove login-as
result = api.call('sms.send', 'SMS', '+33123456789', 'Hello world!', nil)
Method
Your sender must have been authorized and respect the sms_sender format
result = api.call('sms.send', 'Your Brand', '+33123456789', 'Hello world!', nil)
Method
result = api.call('sms.send', '', '+33123456789', 'Hello world!', nil)
Method
optionSMS = { :force_encoding => 'GSM' }
result = api.call('sms.send', '', '+33123456789', 'Hello world!', optionSMS)
Method
Objects
text = 'Some super mega ultra long text to test message longer than 160 characters ' +
'Some super mega ultra long text to test message longer than 160 characters ' +
'Some super mega ultra long text to test message longer than 160 characters'
result = api.call('sms.send', 'SMS', '+33123456789', text, nil)
Method
optionSMS = { :nature => 'ALERTING' }
result = api.call('sms.send', 'SMS', '+33123456789', 'Hello world!', optionSMS)
Method
Objects
optionSMS = { :user_data => '42' }
result = api.call('sms.send', 'SMS', '+33123456789', 'Hello world!', optionSMS)
Method
Objects
optionSMS = {
:push_dlr_enabled => true,
:push_dlr_url => 'http://yourdomain.com/push_delivery_path',
# :push_dlr_url_auth => 'login:password' # needed if you use Basic HTTP Authentication
}
result = api.call('sms.send', 'SMS', '+33123456789', 'Hello world!', optionSMS)
Method
Objects
Do not set a sender if you want to receive replies - we will automatically use a shortcode.
optionSMS = {
:push_mo_enabled => true,
:push_mo_url => 'http://yourdomain.com/mo_delivery_path',
# :push_mo_url_auth => 'login:password' # needed if you use Basic HTTP Authentication
}
result = api.call('sms.send', '', '+33123456789', 'Hello world!', optionSMS)
Method
Objects
result = api.call('sms.get', 'SMSHASH')
Method
Objects
result = api.call('sms.get_settings')
Method
Objects
Add options that you want to change in the object
settings = {
:push_dlr_enabled => true,
:push_dlr_url => 'http://yourdomain.com/push_delivery_path',
:push_mo_enabled => true,
:push_mo_url => 'http://yourdomain.com/mo_delivery_path'
}
result = api.call('sms.set_settings', settings)
Returns the updated settings.
Method
Objects
options = {
:url => 'http://yourdomain.com/realtime_callback_url'
}
result = api.call('apps.create', 'REALTIME10', 'Your app name', options)
Method
Objects
target = {
:number => '+33132456789',
:timeout => 30
}
callOptions = {
:cdr_field => '42',
:cli => 'BLOCKED'
}
result = api.call('dialr/call.realtime', 'appHash', target, callOptions)
Method
Objects
result = api.call('apps.assign_did', 'appHash', 'DID ID')
Method
Objects
result = api.call('did/areacode.countries')
Method
Objects
result = api.call('did/areacode.get_list', 'US', nil)
Method
Objects
result = api.call('did/areacode.types', 'US')
Method
Objects
result = api.call('did/store.buy_order', 'OrderToken')
Method
Objects
result = api.call('did/store.cancel_order', 'OrderToken')
Method
result = api.call('did/store.cancel_subscription', 'DID ID')
Method
result = api.call('did/store.get_quota_status')
Method
Objects
result = api.call('did/store.get_quote', 0, 'GOLD', 1)
Method
*Objects/
result = api.call('did/store.reserve', 0, 'GOLD', 1, 'RANDOM')
Method
Objects
result = api.call('did/store.view_order', 'OrderToken')
Method
Objects
params = { :open => true }
access = []
result = api.call('conference/10.create_room', 'room name', params, access)
Method
Objects
result = api.call('conference/10.assign_did', 'Room ID', 'DID ID')
Method
params = { :open => true }
access = [
{ :pin => '1234', :level => 'GUEST' },
{ :pin => '4321', :level => 'ADMIN', :phone_number => '+33123456789' }
]
result = api.call('conference/10.create_room', 'room name', params, access)
Method
Objects
result = api.call('conference/10.call_room_access', 'Room Access ID', 'BLOCKED', true)
Method
result = api.call('media/library.get_list', nil)
Method
result = api.call('media/library.create', 'name')
Method
media_id = 0
result = api.call('media/library.set_content', media_id, 'text', 'base64_audio_data')
Method
media_id = 0
result = api.call('media/tts.set_content', media_id, 'Hello world!', 'TTS-EN-GB_SERENA', nil)
Method
from = 'YYYY-MM-DD HH:MM:SS'
to = 'YYYY-MM-DD HH:MM:SS'
result = api.call('cdr.get', 'OUT', from, to, nil, nil)
Method
Objects
target = {
:number => '+33123456789',
:timeout => 30
}
messages = [131, 132, 'TTS|TTS_EN-GB_SERENA|Hello world! how are you ? I hope you enjoy this call. good bye.']
options = {
:cdr_field => 'userData',
:cli => 'BLOCKED',
:loop => 2
}
result = api.call('sendr/simple.broadcast_1', target, messages, options)
target = {
:number => '+33123456789',
:timeout => 30
}
messages = [131, 132, 134]
result = api.call('sendr/simple.broadcast_1', target, messages, nil)
Method
Objects