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, EventListResponse, EventPage, EventPageMetadata, NotificationContext, NotificationInstance, NotificationInstanceMetadata, NotificationList, NotificationListResponse, NotificationPage, NotificationPageMetadata, PaymentContext, PaymentInstance, PaymentInstanceMetadata, PaymentList, PaymentListResponse, PaymentPage, PaymentPageMetadata, RecordingContext, RecordingInstance, RecordingInstanceMetadata, RecordingList, RecordingListResponse, RecordingPage, RecordingPageMetadata, SiprecContext, SiprecInstance, SiprecInstanceMetadata, SiprecList, SiprecListResponse, SiprecPage, SiprecPageMetadata, StreamContext, StreamInstance, StreamInstanceMetadata, StreamList, StreamListResponse, StreamPage, StreamPageMetadata, TranscriptionContext, TranscriptionInstance, TranscriptionInstanceMetadata, TranscriptionList, TranscriptionListResponse, TranscriptionPage, TranscriptionPageMetadata, UserDefinedMessageInstance, UserDefinedMessageList, UserDefinedMessageListResponse, UserDefinedMessagePage, UserDefinedMessagePageMetadata, UserDefinedMessageSubscriptionContext, UserDefinedMessageSubscriptionInstance, UserDefinedMessageSubscriptionInstanceMetadata, UserDefinedMessageSubscriptionList, UserDefinedMessageSubscriptionListResponse, UserDefinedMessageSubscriptionPage, UserDefinedMessageSubscriptionPageMetadata

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 update.

  • sid (String)

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



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

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:

  • (Boolean)

    True if delete succeeds, false otherwise



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

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    

    @version.delete('DELETE', @uri, headers: headers)
end

#delete_with_metadataBoolean

Delete the CallInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 565

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
      response = @version.('DELETE', @uri, headers: headers)
      call_instance = CallInstance.new(
          @version,
          response.body,
          account_sid: @solution[:account_sid],
          sid: @solution[:sid],
      )
      CallInstanceMetadata.new(@version, call_instance, response.headers, response.status_code)
end

#eventsEventList, EventContext

Access the events

Returns:



739
740
741
742
743
744
745
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 739

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:



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 584

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

#fetch_with_metadataCallInstance

Fetch the CallInstanceMetadata

Returns:



604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 604

def 

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

#inspectObject

Provide a detailed, user friendly representation



900
901
902
903
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 900

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)


856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 856

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)


818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 818

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)


837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 837

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:

Raises:

  • (ArgumentError)


780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 780

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:

Raises:

  • (ArgumentError)


875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 875

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



893
894
895
896
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 893

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:

Raises:

  • (ArgumentError)


761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 761

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:

  • 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 (UpdateStatus) (defaults to: :unset)
  • 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:



639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 639

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

#update_with_metadata(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 CallInstanceMetadata

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 (UpdateStatus) (defaults to: :unset)
  • 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:



690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 690

def (
  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', })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    call_instance = CallInstance.new(
        @version,
        response.body,
        account_sid: @solution[:account_sid],
        sid: @solution[:sid],
    )
    CallInstanceMetadata.new(
        @version,
        call_instance,
        response.headers,
        response.status_code
    )
end

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

Access the user_defined_message_subscriptions

Returns:

Raises:

  • (ArgumentError)


799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 799

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:



750
751
752
753
754
755
756
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 750

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