-
Notifications
You must be signed in to change notification settings - Fork 0
Voice API Service
Md. Mazharul islam Mithu edited this page May 4, 2017
·
4 revisions
client = CheckMobi::Resources::Voice::Call.new(
from: 'from_number',
to: 'to_number',
events: [], # array of events, default is [].
notification_callback: 'http://valid_url',
platform: 'web' # allowed values: ios, android, web, desktop
)To add some actions to the call
play_action = CheckMobi::Resources::Voice::Actions::Play.new(
text: 'Any UTF-8 encoded text', # required
loop: 2, # => default 1
voice: 'MAN', # => default WOMAN, allowed values: WOMAN, MAN
language: 'en-AU', # => default is en-US
)
client.events << play_actionsend_dtmf_action = CheckMobi::Resources::Voice::Actions::SendDTMF.new(
text: 'Any UTF-8 encoded text', # required
digits: '1W2',
async: false # => default is true
)
client.events << send_dtmf_actionwait_action = CheckMobi::Resources::Voice::Actions::Wait.new(
length: 2, # => default is 1
)
client.events << wait_actionhangup_action = CheckMobi::Resources::Voice::Actions::Hangup.new(
reason: 'rejected', # => allowed values: rejected, busy
)
client.events << hangup_actionfinally when you are done with adding events,
response = client.perform
details = JSON.parse(response.response_body)if everything is ok,
{
"id":"CAL-ED26AC71-807B-49B1-A81E-3956224A0CDC",
"number_info":
{
"country_code":40,
"country_iso_code":"RO",
"carrier":"Orange",
"is_mobile":true,
"e164_format":"+40XXXXXXXXX",
"formatting":"+40 XXX XXX XXX"
}
}For more info https://checkmobi.com/documentation.html#/place-call
client = resource = CheckMobi::Resources::Voice::CallDetails.new(id: 'id')
response = client.perform
details = JSON.parse(response.response_body)if everything is ok,
{
"request_date": 1433451354,
"to": "+XXXXXXX",
"description": "MX - Orange",
"duration_billed": 0,
"charged_amount": 0,
"charged_rate": 0.0371
}For more details https://checkmobi.com/documentation.html#/call-status
client = CheckMobi::Resources::Voice::HangupCall.new(req_id: 'req_id')
response = client.performif everything is ok,
response.status_code # => 204For more details https://checkmobi.com/documentation.html#/hangup_call