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/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: FeedbackContext, FeedbackInstance, FeedbackList, FeedbackPage, NotificationContext, NotificationInstance, NotificationList, NotificationPage, 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](www.twilio.com/docs/api/rest/account) that created the Call resource(s) to fetch.

  • sid (String)

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



401
402
403
404
405
406
407
408
409
410
411
412
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 401

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
end

Instance Method Details

#deleteBoolean

Deletes the CallInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



417
418
419
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 417

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

#feedbackFeedbackList, FeedbackContext

Access the feedback



534
535
536
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 534

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

#fetchCallInstance

Fetch a CallInstance

Returns:



424
425
426
427
428
429
430
431
432
433
434
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 424

def fetch
  params = Twilio::Values.of({})

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

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

#inspectObject

Provide a detailed, user friendly representation



547
548
549
550
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 547

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)


512
513
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 512

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

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

Access the recordings

Returns:

Raises:

  • (ArgumentError)


490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 490

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



540
541
542
543
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 540

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) ⇒ 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](www.twilio.com/docs/voice/make-calls#specify-a-url-parameter) section in [Making Calls](www.twilio.com/docs/voice/make-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.

Returns:



466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 466

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

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

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