Class: Plivo::Resources::CallInterface
Constant Summary
Constants included
from Utils
Utils::TYPE_WHITELIST
Instance Method Summary
collapse
-
#cancel_request(call_uuid) ⇒ Object
-
#create(from, to, answer_url, options = nil) ⇒ Call
-
#delete(call_uuid) ⇒ Object
-
#each ⇒ Object
-
#each_live ⇒ Object
-
#each_queued ⇒ Object
-
#get(call_uuid) ⇒ Object
-
#get_live(call_uuid) ⇒ Object
-
#get_queued(call_uuid) ⇒ Object
-
#initialize(client, resource_list_json = nil) ⇒ CallInterface
constructor
A new instance of CallInterface.
-
#list(options = nil) ⇒ Object
-
#list_live(options = nil) ⇒ Object
-
#list_queued ⇒ Object
-
#play(call_uuid, urls, options = nil) ⇒ Object
-
#record(call_uuid, options = nil) ⇒ Object
-
#send_digits(call_uuid, digits, leg = nil) ⇒ Object
-
#speak(call_uuid, text, options = nil) ⇒ Object
-
#stop_play(call_uuid) ⇒ Object
-
#stop_record(call_uuid, url = nil) ⇒ Object
-
#stop_speak(call_uuid) ⇒ Object
-
#update(call_uuid, details) ⇒ Call
Methods included from Utils
GetSortedQueryParamString?, compute_signatureV3?, expected_type?, expected_value?, generate_url?, getMapFromQueryString?, is_one_among_string_url?, multi_valid_param?, raise_invalid_request, valid_account?, valid_date_format?, valid_mainaccount?, valid_multiple_destination_integers?, valid_multiple_destination_nos?, valid_param?, valid_range?, valid_signature?, valid_signatureV3?, valid_subaccount?, valid_url?
Constructor Details
#initialize(client, resource_list_json = nil) ⇒ CallInterface
Returns a new instance of CallInterface.
244
245
246
247
248
249
250
|
# File 'lib/plivo/resources/calls.rb', line 244
def initialize(client, resource_list_json = nil)
@_name = 'Call'
@_resource_type = Call
@_identifier_string = 'call_uuid'
super
@_is_voice_request = true
end
|
Instance Method Details
#cancel_request(call_uuid) ⇒ Object
575
576
577
578
|
# File 'lib/plivo/resources/calls.rb', line 575
def cancel_request(call_uuid)
valid_param?(:call_uuid, call_uuid, [String, Symbol], true)
Call.new(@_client, resource_id: call_uuid).cancel_request
end
|
#create(from, to, answer_url, options = nil) ⇒ Call
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
# File 'lib/plivo/resources/calls.rb', line 280
def create(from, to, answer_url, options = nil)
valid_param?(:from, from, [String, Symbol, Integer], true)
valid_param?(:to, to, Array, true)
to.each do |to_num|
valid_param?(:to_num, to_num, [Integer, String, Symbol], true)
end
valid_param?(:answer_url, answer_url, [String, Symbol], true)
params = {
from: from,
to: to.join('<'),
answer_url: answer_url,
}
return perform_create(params, false) if options.nil?
perform_create(params.merge(options), false)
end
|
#delete(call_uuid) ⇒ Object
486
487
488
489
|
# File 'lib/plivo/resources/calls.rb', line 486
def delete(call_uuid)
valid_param?(:call_uuid, call_uuid, [String, Symbol], true)
Call.new(@_client, resource_id: call_uuid).delete
end
|
#each ⇒ Object
401
402
403
404
405
406
407
408
409
|
# File 'lib/plivo/resources/calls.rb', line 401
def each
offset = 0
loop do
call_list = list(offset: offset)
call_list[:objects].each { |call| yield call }
offset += 20
return unless call_list.length == 20
end
end
|
#each_live ⇒ Object
460
461
462
463
|
# File 'lib/plivo/resources/calls.rb', line 460
def each_live
call_list = list_live
call_list[:calls].each { |call| yield call }
end
|
#each_queued ⇒ Object
465
466
467
468
|
# File 'lib/plivo/resources/calls.rb', line 465
def each_queued
call_queued = list_queued
call_queued[:calls].each { |call| yield call}
end
|
#get(call_uuid) ⇒ Object
303
304
305
306
|
# File 'lib/plivo/resources/calls.rb', line 303
def get(call_uuid)
valid_param?(:call_uuid, call_uuid, [String, Symbol], true)
perform_get(call_uuid)
end
|
#get_live(call_uuid) ⇒ Object
309
310
311
|
# File 'lib/plivo/resources/calls.rb', line 309
def get_live(call_uuid)
perform_get(call_uuid, status: 'live')
end
|
#get_queued(call_uuid) ⇒ Object
314
315
316
|
# File 'lib/plivo/resources/calls.rb', line 314
def get_queued(call_uuid)
perform_get(call_uuid, status: 'queued')
end
|
#list(options = nil) ⇒ Object
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
|
# File 'lib/plivo/resources/calls.rb', line 346
def list(options = nil)
return perform_list if options.nil?
valid_param?(:options, options, Hash, true)
raise_invalid_request("Offset can't be negative") if options.key?(:offset) && options[:offset] < 0
if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0)
raise_invalid_request('The maximum number of results that can be '\
"fetched is 20. limit can't be more than 20 or less than 1")
end
params = i[
bill_duration
bill_duration__gt
bill_duration__gte
bill_duration__lt
bill_duration__lte
call_direction
end_time
end_time__gt
end_time__gte
end_time__lt
end_time__lte
from_number
hangup_cause_code
hangup_source
limit
offset
parent_call_uuid
subaccount
to_number
stir_verification
].reduce({}) do |result_hash, param|
if options.key?(param)
if param == :call_direction
if valid_param?(:call_direction, options[:call_direction],
[String, Symbol], true, %w[inbound outbound])
result_hash[:call_direction] = options[:call_direction]
end
elsif i[offset limit hangup_cause_code].include?(param)
if valid_param?(param, options[param], [Integer, Integer], true)
result_hash[param] = options[param]
end
elsif valid_param?(param, options[param], [String, Symbol], true)
result_hash[param] = options[param]
end
end
result_hash
end
perform_list(params)
end
|
#list_live(options = nil) ⇒ Object
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
|
# File 'lib/plivo/resources/calls.rb', line 419
def list_live(options = nil)
if options.nil?
options = {}
else
valid_param?(:options, options, Hash, true)
end
params = {}
params[:status] = 'live'
params_expected = i[
from_number to_number
]
params_expected.each do |param|
if options.key?(param) &&
valid_param?(param, options[param], [String, Symbol], true)
params[param] = options[param]
end
end
if options.key?(:call_direction) &&
valid_param?(:call_direction, options[:call_direction],
[String, Symbol], true, %w[inbound outbound])
params[:call_direction] = options[:call_direction]
end
perform_list_without_object(params)
{
api_id: @api_id,
calls: @calls
}
end
|
#list_queued ⇒ Object
452
453
454
455
456
457
458
|
# File 'lib/plivo/resources/calls.rb', line 452
def list_queued
perform_list_without_object(status: 'queued')
{
api_id: @api_id,
calls: @calls
}
end
|
#play(call_uuid, urls, options = nil) ⇒ Object
535
536
537
538
539
|
# File 'lib/plivo/resources/calls.rb', line 535
def play(call_uuid, urls, options = nil)
valid_param?(:call_uuid, call_uuid, [String, Symbol], true)
valid_param?(:urls, urls, Array, true)
Call.new(@_client, resource_id: call_uuid).play(urls, options)
end
|
#record(call_uuid, options = nil) ⇒ Object
511
512
513
514
515
516
517
518
|
# File 'lib/plivo/resources/calls.rb', line 511
def record(call_uuid, options = nil)
valid_param?(:call_uuid, call_uuid, [String, Symbol], true)
response = Call.new(@_client, resource_id: call_uuid).record(options)
return Base::Response.new(Hash["api_id" => response.api_id,
"recording_id" => response.recording_id,
"message" => response.message,
"url" => response.url])
end
|
#send_digits(call_uuid, digits, leg = nil) ⇒ Object
569
570
571
572
|
# File 'lib/plivo/resources/calls.rb', line 569
def send_digits(call_uuid, digits, leg = nil)
valid_param?(:call_uuid, call_uuid, [String, Symbol], true)
Call.new(@_client, resource_id: call_uuid).send_digits(digits, leg)
end
|
#speak(call_uuid, text, options = nil) ⇒ Object
555
556
557
558
|
# File 'lib/plivo/resources/calls.rb', line 555
def speak(call_uuid, text, options = nil)
valid_param?(:call_uuid, call_uuid, [String, Symbol], true)
Call.new(@_client, resource_id: call_uuid).speak(text, options)
end
|
#stop_play(call_uuid) ⇒ Object
542
543
544
545
|
# File 'lib/plivo/resources/calls.rb', line 542
def stop_play(call_uuid)
valid_param?(:call_uuid, call_uuid, [String, Symbol], true)
Call.new(@_client, resource_id: call_uuid).stop_play
end
|
#stop_record(call_uuid, url = nil) ⇒ Object
522
523
524
525
|
# File 'lib/plivo/resources/calls.rb', line 522
def stop_record(call_uuid, url = nil)
valid_param?(:call_uuid, call_uuid, [String, Symbol], true)
Call.new(@_client, resource_id: call_uuid).stop_record(url)
end
|
#stop_speak(call_uuid) ⇒ Object
561
562
563
564
|
# File 'lib/plivo/resources/calls.rb', line 561
def stop_speak(call_uuid)
valid_param?(:call_uuid, call_uuid, [String, Symbol], true)
Call.new(@_client, resource_id: call_uuid).stop_speak
end
|
#update(call_uuid, details) ⇒ Call
480
481
482
483
|
# File 'lib/plivo/resources/calls.rb', line 480
def update(call_uuid, details)
valid_param?(:call_uuid, call_uuid, [String, Symbol], true)
Call.new(@_client, resource_id: call_uuid).update(details)
end
|