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/payment.rb,
lib/twilio-ruby/rest/api/v2010/account/call/feedback.rb,
lib/twilio-ruby/rest/api/v2010/account/call/recording.rb,
lib/twilio-ruby/rest/api/v2010/account/call/notification.rb

Defined Under Namespace

Classes: EventInstance, EventList, EventPage, FeedbackContext, FeedbackInstance, FeedbackList, FeedbackPage, NotificationContext, NotificationInstance, NotificationList, NotificationPage, PaymentContext, PaymentInstance, PaymentList, PaymentPage, RecordingContext, RecordingInstance, RecordingList, RecordingPage

Instance Method Summary collapse

Constructor Details

#initialize(version, account_sid, sid) ⇒ CallContext

Initialize the CallContext

Parameters:

  • version (Version)

    Version that contains the resource

  • account_sid (String)

    The SID of the Account that created the Call resource(s) to fetch.

  • sid (String)

    The SID of the Call resource to fetch.


432
433
434
435
436
437
438
439
440
441
442
443
444
445
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 432

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

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

  # Dependents
  @recordings = nil
  @notifications = nil
  @feedback = nil
  @events = nil
  @payments = nil
end

Instance Method Details

#deleteBoolean

Delete the CallInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise


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

def delete
   @version.delete('DELETE', @uri)
end

#eventsEventList, EventContext

Access the events

Returns:


571
572
573
574
575
576
577
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 571

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

  @events
end

#feedbackFeedbackList, FeedbackContext

Access the feedback


563
564
565
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 563

def feedback
  FeedbackContext.new(@version, @solution[:account_sid], @solution[:sid], )
end

#fetchCallInstance

Fetch the CallInstance

Returns:


457
458
459
460
461
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 457

def fetch
  payload = @version.fetch('GET', @uri)

  CallInstance.new(@version, payload, account_sid: @solution[:account_sid], sid: @solution[:sid], )
end

#inspectObject

Provide a detailed, user friendly representation


610
611
612
613
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 610

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:

Raises:

  • (ArgumentError)

541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 541

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:

Raises:

  • (ArgumentError)

583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 583

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:

Raises:

  • (ArgumentError)

519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 519

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

#to_sObject

Provide a user friendly representation


603
604
605
606
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 603

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

  • url (String) (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 section in Making Calls.

  • method (String) (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.

  • status (call.UpdateStatus) (defaults to: :unset)

    The new status of the resource. Can be: `canceled` or `completed`. Specifying `canceled` will attempt to hang up calls that are queued or ringing; however, it will not affect calls already in progress. Specifying `completed` will attempt to hang up a call even if it's already in progress.

  • fallback_url (String) (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.

  • fallback_method (String) (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.

  • status_callback (String) (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).

  • status_callback_method (String) (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.

  • twiml (String) (defaults to: :unset)

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

  • time_limit (String) (defaults to: :unset)

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

Returns:


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

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,
  })

  payload = @version.update('POST', @uri, data: data)

  CallInstance.new(@version, payload, account_sid: @solution[:account_sid], sid: @solution[:sid], )
end