Class: Twilio::REST::Api::V2010::AccountContext::CallContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/api/v2010/account/call.rb,
lib/twilio-ruby/rest/api/v2010/account/call/event.rb,
lib/twilio-ruby/rest/api/v2010/account/call/siprec.rb,
lib/twilio-ruby/rest/api/v2010/account/call/stream.rb,
lib/twilio-ruby/rest/api/v2010/account/call/payment.rb,
lib/twilio-ruby/rest/api/v2010/account/call/recording.rb,
lib/twilio-ruby/rest/api/v2010/account/call/notification.rb,
lib/twilio-ruby/rest/api/v2010/account/call/transcription.rb,
lib/twilio-ruby/rest/api/v2010/account/call/user_defined_message.rb,
lib/twilio-ruby/rest/api/v2010/account/call/user_defined_message_subscription.rb

Defined Under Namespace

Classes: EventInstance, EventList, EventPage, NotificationContext, NotificationInstance, NotificationList, NotificationPage, PaymentContext, PaymentInstance, PaymentList, PaymentPage, RecordingContext, RecordingInstance, RecordingList, RecordingPage, SiprecContext, SiprecInstance, SiprecList, SiprecPage, StreamContext, StreamInstance, StreamList, StreamPage, TranscriptionContext, TranscriptionInstance, TranscriptionList, TranscriptionPage, UserDefinedMessageInstance, UserDefinedMessageList, UserDefinedMessagePage, UserDefinedMessageSubscriptionContext, UserDefinedMessageSubscriptionInstance, UserDefinedMessageSubscriptionList, UserDefinedMessageSubscriptionPage

Instance Method Summary collapse

Constructor Details

#initialize(version, account_sid, sid) ⇒ CallContext

Initialize the CallContext

Parameters:

  • Version that contains the resource

  • The SID of the [Account](www.twilio.com/docs/iam/api/account) that created the Call resource(s) to update.

  • The Twilio-provided string that uniquely identifies the Call resource to update



330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 330

def initialize(version, , sid)
    super(version)

    # Path Solution
    @solution = { account_sid: , sid: sid,  }
    @uri = "/Accounts/#{@solution[:account_sid]}/Calls/#{@solution[:sid]}.json"

    # Dependents
    @events = nil
    @user_defined_messages = nil
    @transcriptions = nil
    @siprec = nil
    @user_defined_message_subscriptions = nil
    @payments = nil
    @recordings = nil
    @notifications = nil
    @streams = nil
end

Instance Method Details

#deleteBoolean

Delete the CallInstance

Returns:

  • True if delete succeeds, false otherwise



351
352
353
354
355
356
357
358
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 351

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    @version.delete('DELETE', @uri, headers: headers)
end

#eventsEventList, EventContext

Access the events

Returns:



435
436
437
438
439
440
441
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 435

def events
  unless @events
    @events = EventList.new(
            @version, account_sid: @solution[:account_sid], call_sid: @solution[:sid], )
  end
  @events
end

#fetchCallInstance

Fetch the CallInstance

Returns:

  • Fetched CallInstance



363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 363

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    CallInstance.new(
        @version,
        payload,
        account_sid: @solution[:account_sid],
        sid: @solution[:sid],
    )
end

#inspectObject

Provide a detailed, user friendly representation



596
597
598
599
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 596

def inspect
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Api.V2010.CallContext #{context}>"
end

#notifications(sid = :unset) ⇒ NotificationList, NotificationContext

Access the notifications

Returns:

  • if sid was passed.

Raises:



552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 552

def notifications(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return NotificationContext.new(@version, @solution[:account_sid], @solution[:sid],sid )
    end

    unless @notifications
        @notifications = NotificationList.new(
            @version, account_sid: @solution[:account_sid], call_sid: @solution[:sid], )
    end

 @notifications
end

#payments(sid = :unset) ⇒ PaymentList, PaymentContext

Access the payments

Returns:

  • if sid was passed.

Raises:



514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 514

def payments(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return PaymentContext.new(@version, @solution[:account_sid], @solution[:sid],sid )
    end

    unless @payments
        @payments = PaymentList.new(
            @version, account_sid: @solution[:account_sid], call_sid: @solution[:sid], )
    end

 @payments
end

#recordings(sid = :unset) ⇒ RecordingList, RecordingContext

Access the recordings

Returns:

  • if sid was passed.

Raises:



533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 533

def recordings(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return RecordingContext.new(@version, @solution[:account_sid], @solution[:sid],sid )
    end

    unless @recordings
        @recordings = RecordingList.new(
            @version, account_sid: @solution[:account_sid], call_sid: @solution[:sid], )
    end

 @recordings
end

#siprec(sid = :unset) ⇒ SiprecList, SiprecContext

Access the siprec

Returns:

  • if sid was passed.

Raises:



476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 476

def siprec(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return SiprecContext.new(@version, @solution[:account_sid], @solution[:sid],sid )
    end

    unless @siprec
        @siprec = SiprecList.new(
            @version, account_sid: @solution[:account_sid], call_sid: @solution[:sid], )
    end

 @siprec
end

#streams(sid = :unset) ⇒ StreamList, StreamContext

Access the streams

Returns:

  • if sid was passed.

Raises:



571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 571

def streams(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return StreamContext.new(@version, @solution[:account_sid], @solution[:sid],sid )
    end

    unless @streams
        @streams = StreamList.new(
            @version, account_sid: @solution[:account_sid], call_sid: @solution[:sid], )
    end

 @streams
end

#to_sObject

Provide a user friendly representation



589
590
591
592
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 589

def to_s
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Api.V2010.CallContext #{context}>"
end

#transcriptions(sid = :unset) ⇒ TranscriptionList, TranscriptionContext

Access the transcriptions

Returns:

  • if sid was passed.

Raises:



457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 457

def transcriptions(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return TranscriptionContext.new(@version, @solution[:account_sid], @solution[:sid],sid )
    end

    unless @transcriptions
        @transcriptions = TranscriptionList.new(
            @version, account_sid: @solution[:account_sid], call_sid: @solution[:sid], )
    end

 @transcriptions
end

#update(url: :unset, method: :unset, status: :unset, fallback_url: :unset, fallback_method: :unset, status_callback: :unset, status_callback_method: :unset, twiml: :unset, time_limit: :unset) ⇒ CallInstance

Update the CallInstance

Parameters:

  • (defaults to: :unset)

    The absolute URL that returns the TwiML instructions for the call. We will call this URL using the method when the call connects. For more information, see the [Url Parameter](www.twilio.com/docs/voice/make-calls#specify-a-url-parameter) section in [Making Calls](www.twilio.com/docs/voice/make-calls).

  • (defaults to: :unset)

    The HTTP method we should use when calling the url. Can be: GET or POST and the default is POST. If an application_sid parameter is present, this parameter is ignored.

  • (defaults to: :unset)
  • (defaults to: :unset)

    The URL that we call using the fallback_method if an error occurs when requesting or executing the TwiML at url. If an application_sid parameter is present, this parameter is ignored.

  • (defaults to: :unset)

    The HTTP method that we should use to request the fallback_url. Can be: GET or POST and the default is POST. If an application_sid parameter is present, this parameter is ignored.

  • (defaults to: :unset)

    The URL we should call using the status_callback_method to send status information to your application. If no status_callback_event is specified, we will send the completed status. If an application_sid parameter is present, this parameter is ignored. URLs must contain a valid hostname (underscores are not permitted).

  • (defaults to: :unset)

    The HTTP method we should use when requesting the status_callback URL. Can be: GET or POST and the default is POST. If an application_sid parameter is present, this parameter is ignored.

  • (defaults to: :unset)

    TwiML instructions for the call Twilio will use without fetching Twiml from url. Twiml and url parameters are mutually exclusive

  • (defaults to: :unset)

    The maximum duration of the call in seconds. Constraints depend on account and configuration.

Returns:

  • Updated CallInstance



392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 392

def update(
    url: :unset, 
    method: :unset, 
    status: :unset, 
    fallback_url: :unset, 
    fallback_method: :unset, 
    status_callback: :unset, 
    status_callback_method: :unset, 
    twiml: :unset, 
    time_limit: :unset
)

    data = Twilio::Values.of({
        'Url' => url,
        'Method' => method,
        'Status' => status,
        'FallbackUrl' => fallback_url,
        'FallbackMethod' => fallback_method,
        'StatusCallback' => status_callback,
        'StatusCallbackMethod' => status_callback_method,
        'Twiml' => twiml,
        'TimeLimit' => time_limit,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    CallInstance.new(
        @version,
        payload,
        account_sid: @solution[:account_sid],
        sid: @solution[:sid],
    )
end

#user_defined_message_subscriptions(sid = :unset) ⇒ UserDefinedMessageSubscriptionList, UserDefinedMessageSubscriptionContext

Access the user_defined_message_subscriptions

Returns:

  • if sid was passed.

Raises:



495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 495

def user_defined_message_subscriptions(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return UserDefinedMessageSubscriptionContext.new(@version, @solution[:account_sid], @solution[:sid],sid )
    end

    unless @user_defined_message_subscriptions
        @user_defined_message_subscriptions = UserDefinedMessageSubscriptionList.new(
            @version, account_sid: @solution[:account_sid], call_sid: @solution[:sid], )
    end

 @user_defined_message_subscriptions
end

#user_defined_messagesUserDefinedMessageList, UserDefinedMessageContext

Access the user_defined_messages

Returns:



446
447
448
449
450
451
452
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 446

def user_defined_messages
  unless @user_defined_messages
    @user_defined_messages = UserDefinedMessageList.new(
            @version, account_sid: @solution[:account_sid], call_sid: @solution[:sid], )
  end
  @user_defined_messages
end