Class: Twilio::REST::Api::V2010::AccountContext::CallInstance

Inherits:
InstanceResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/api/v2010/account/call.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, account_sid: nil, sid: nil) ⇒ CallInstance

Initialize the CallInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • account_sid (String) (defaults to: nil)

    The SID of the Account that created this Call resource.

  • sid (String) (defaults to: nil)

    The SID of the Call resource to fetch.



620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 620

def initialize(version, payload , account_sid: nil, sid: nil)
    super(version)
    
    # Marshaled Properties
    @properties = { 
        'sid' => payload['sid'],
        'date_created' => Twilio.deserialize_rfc2822(payload['date_created']),
        'date_updated' => Twilio.deserialize_rfc2822(payload['date_updated']),
        'parent_call_sid' => payload['parent_call_sid'],
        'account_sid' => payload['account_sid'],
        'to' => payload['to'],
        'to_formatted' => payload['to_formatted'],
        'from' => payload['from'],
        'from_formatted' => payload['from_formatted'],
        'phone_number_sid' => payload['phone_number_sid'],
        'status' => payload['status'],
        'start_time' => Twilio.deserialize_rfc2822(payload['start_time']),
        'end_time' => Twilio.deserialize_rfc2822(payload['end_time']),
        'duration' => payload['duration'],
        'price' => payload['price'],
        'price_unit' => payload['price_unit'],
        'direction' => payload['direction'],
        'answered_by' => payload['answered_by'],
        'api_version' => payload['api_version'],
        'forwarded_from' => payload['forwarded_from'],
        'group_sid' => payload['group_sid'],
        'caller_name' => payload['caller_name'],
        'queue_time' => payload['queue_time'],
        'trunk_sid' => payload['trunk_sid'],
        'uri' => payload['uri'],
        'subresource_uris' => payload['subresource_uris'],
    }

    # Context
    @instance_context = nil
    @params = { 'account_sid' =>   ,'sid' => sid  || @properties['sid']  , }
end

Instance Method Details

#account_sidString

Returns The SID of the [Account](www.twilio.com/docs/iam/api/account) that created this Call resource.

Returns:



695
696
697
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 695

def 
    @properties['account_sid']
end

#answered_byString

Returns Either ‘human` or `machine` if this call was initiated with answering machine detection. Empty otherwise.

Returns:

  • (String)

    Either ‘human` or `machine` if this call was initiated with answering machine detection. Empty otherwise.



773
774
775
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 773

def answered_by
    @properties['answered_by']
end

#api_versionString

Returns The API version used to create the call.

Returns:

  • (String)

    The API version used to create the call.



779
780
781
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 779

def api_version
    @properties['api_version']
end

#caller_nameString

Returns The caller’s name if this call was an incoming call to a phone number with caller ID Lookup enabled. Otherwise, empty.

Returns:

  • (String)

    The caller’s name if this call was an incoming call to a phone number with caller ID Lookup enabled. Otherwise, empty.



797
798
799
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 797

def caller_name
    @properties['caller_name']
end

#contextCallContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



662
663
664
665
666
667
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 662

def context
    unless @instance_context
        @instance_context = CallContext.new(@version , @params['account_sid'], @params['sid'])
    end
    @instance_context
end

#date_createdTime

Returns The date and time in UTC that this resource was created specified in [RFC 2822](www.ietf.org/rfc/rfc2822.txt) format.

Returns:



677
678
679
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 677

def date_created
    @properties['date_created']
end

#date_updatedTime

Returns The date and time in UTC that this resource was last updated, specified in [RFC 2822](www.ietf.org/rfc/rfc2822.txt) format.

Returns:



683
684
685
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 683

def date_updated
    @properties['date_updated']
end

#deleteBoolean

Delete the CallInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



828
829
830
831
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 828

def delete

    context.delete
end

#directionString

Returns A string describing the direction of the call. Can be: ‘inbound` for inbound calls, `outbound-api` for calls initiated via the REST API or `outbound-dial` for calls initiated by a `<Dial>` verb. Using [Elastic SIP Trunking](www.twilio.com/docs/sip-trunking), the values can be [`trunking-terminating`](www.twilio.com/docs/sip-trunking#termination) for outgoing calls from your communications infrastructure to the PSTN or [`trunking-originating`](www.twilio.com/docs/sip-trunking#origination) for incoming calls to your communications infrastructure from the PSTN.

Returns:



767
768
769
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 767

def direction
    @properties['direction']
end

#durationString

Returns The length of the call in seconds. This value is empty for busy, failed, unanswered, or ongoing calls.

Returns:

  • (String)

    The length of the call in seconds. This value is empty for busy, failed, unanswered, or ongoing calls.



749
750
751
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 749

def duration
    @properties['duration']
end

#end_timeTime

Returns The time the call ended, given as UTC in [RFC 2822](www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format. Empty if the call did not complete successfully.

Returns:



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

def end_time
    @properties['end_time']
end

#eventsevents

Access the events

Returns:



881
882
883
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 881

def events
    context.events
end

#fetchCallInstance

Fetch the CallInstance

Returns:



836
837
838
839
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 836

def fetch

    context.fetch
end

#forwarded_fromString

Returns The forwarding phone number if this call was an incoming call forwarded from another number (depends on carrier supporting forwarding). Otherwise, empty.

Returns:

  • (String)

    The forwarding phone number if this call was an incoming call forwarded from another number (depends on carrier supporting forwarding). Otherwise, empty.



785
786
787
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 785

def forwarded_from
    @properties['forwarded_from']
end

#fromString

Returns The phone number, SIP address, Client identifier or SIM SID that made this call. Phone numbers are in [E.164](www.twilio.com/docs/glossary/what-e164) format (e.g., +16175551212). SIP addresses are formatted as ‘[email protected]`. Client identifiers are formatted `client:name`. SIM SIDs are formatted as `sim:sid`.

Returns:

  • (String)

    The phone number, SIP address, Client identifier or SIM SID that made this call. Phone numbers are in [E.164](www.twilio.com/docs/glossary/what-e164) format (e.g., +16175551212). SIP addresses are formatted as ‘[email protected]`. Client identifiers are formatted `client:name`. SIM SIDs are formatted as `sim:sid`.



713
714
715
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 713

def from
    @properties['from']
end

#from_formattedString

Returns The calling phone number, SIP address, or Client identifier formatted for display. Non-North American phone numbers are in [E.164](www.twilio.com/docs/glossary/what-e164) format (e.g., +442071838750).

Returns:

  • (String)

    The calling phone number, SIP address, or Client identifier formatted for display. Non-North American phone numbers are in [E.164](www.twilio.com/docs/glossary/what-e164) format (e.g., +442071838750).



719
720
721
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 719

def from_formatted
    @properties['from_formatted']
end

#group_sidString

Returns The Group SID associated with this call. If no Group is associated with the call, the field is empty.

Returns:

  • (String)

    The Group SID associated with this call. If no Group is associated with the call, the field is empty.



791
792
793
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 791

def group_sid
    @properties['group_sid']
end

#inspectObject

Provide a detailed, user friendly representation



950
951
952
953
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 950

def inspect
    values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.Api.V2010.CallInstance #{values}>"
end

#notificationsnotifications

Access the notifications

Returns:



930
931
932
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 930

def notifications
    context.notifications
end

#parent_call_sidString

Returns The SID that identifies the call that created this leg.

Returns:

  • (String)

    The SID that identifies the call that created this leg.



689
690
691
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 689

def parent_call_sid
    @properties['parent_call_sid']
end

#paymentspayments

Access the payments

Returns:



916
917
918
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 916

def payments
    context.payments
end

#phone_number_sidString

Returns If the call was inbound, this is the SID of the IncomingPhoneNumber resource that received the call. If the call was outbound, it is the SID of the OutgoingCallerId resource from which the call was placed.

Returns:

  • (String)

    If the call was inbound, this is the SID of the IncomingPhoneNumber resource that received the call. If the call was outbound, it is the SID of the OutgoingCallerId resource from which the call was placed.



725
726
727
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 725

def phone_number_sid
    @properties['phone_number_sid']
end

#priceString

Returns The charge for this call, in the currency associated with the account. Populated after the call is completed. May not be immediately available. The price associated with a call only reflects the charge for connectivity. Charges for other call-related features such as Answering Machine Detection, Text-To-Speech, and SIP REFER are not included in this value.

Returns:

  • (String)

    The charge for this call, in the currency associated with the account. Populated after the call is completed. May not be immediately available. The price associated with a call only reflects the charge for connectivity. Charges for other call-related features such as Answering Machine Detection, Text-To-Speech, and SIP REFER are not included in this value.



755
756
757
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 755

def price
    @properties['price']
end

#price_unitString

Returns The currency in which ‘Price` is measured, in [ISO 4127](www.iso.org/iso/home/standards/currency_codes.htm) format (e.g., `USD`, `EUR`, `JPY`). Always capitalized for calls.

Returns:



761
762
763
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 761

def price_unit
    @properties['price_unit']
end

#queue_timeString

Returns The wait time in milliseconds before the call is placed.

Returns:

  • (String)

    The wait time in milliseconds before the call is placed.



803
804
805
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 803

def queue_time
    @properties['queue_time']
end

#recordingsrecordings

Access the recordings

Returns:



923
924
925
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 923

def recordings
    context.recordings
end

#sidString

Returns The unique string that we created to identify this Call resource.

Returns:

  • (String)

    The unique string that we created to identify this Call resource.



671
672
673
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 671

def sid
    @properties['sid']
end

#siprecsiprec

Access the siprec

Returns:



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

def siprec
    context.siprec
end

#start_timeTime

Returns The start time of the call, given as UTC in [RFC 2822](www.php.net/manual/en/class.datetime.php#datetime.constants.rfc2822) format. Empty if the call has not yet been dialed.

Returns:



737
738
739
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 737

def start_time
    @properties['start_time']
end

#statusStatus

Returns:

  • (Status)


731
732
733
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 731

def status
    @properties['status']
end

#streamsstreams

Access the streams

Returns:



937
938
939
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 937

def streams
    context.streams
end

#subresource_urisHash

Returns A list of subresources available to this call, identified by their URIs relative to ‘api.twilio.com`.

Returns:

  • (Hash)

    A list of subresources available to this call, identified by their URIs relative to ‘api.twilio.com`.



821
822
823
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 821

def subresource_uris
    @properties['subresource_uris']
end

#toString

Returns The phone number, SIP address, Client identifier or SIM SID that received this call. Phone numbers are in [E.164](www.twilio.com/docs/glossary/what-e164) format (e.g., +16175551212). SIP addresses are formatted as ‘[email protected]`. Client identifiers are formatted `client:name`. SIM SIDs are formatted as `sim:sid`.

Returns:

  • (String)

    The phone number, SIP address, Client identifier or SIM SID that received this call. Phone numbers are in [E.164](www.twilio.com/docs/glossary/what-e164) format (e.g., +16175551212). SIP addresses are formatted as ‘[email protected]`. Client identifiers are formatted `client:name`. SIM SIDs are formatted as `sim:sid`.



701
702
703
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 701

def to
    @properties['to']
end

#to_formattedString

Returns The phone number, SIP address or Client identifier that received this call. Formatted for display. Non-North American phone numbers are in [E.164](www.twilio.com/docs/glossary/what-e164) format (e.g., +442071838750).

Returns:

  • (String)

    The phone number, SIP address or Client identifier that received this call. Formatted for display. Non-North American phone numbers are in [E.164](www.twilio.com/docs/glossary/what-e164) format (e.g., +442071838750).



707
708
709
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 707

def to_formatted
    @properties['to_formatted']
end

#to_sObject

Provide a user friendly representation



943
944
945
946
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 943

def to_s
    values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.Api.V2010.CallInstance #{values}>"
end

#transcriptionstranscriptions

Access the transcriptions

Returns:



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

def transcriptions
    context.transcriptions
end

#trunk_sidString

Returns The unique identifier of the trunk resource that was used for this call. The field is empty if the call was not made using a SIP trunk or if the call is not terminated.

Returns:

  • (String)

    The unique identifier of the trunk resource that was used for this call. The field is empty if the call was not made using a SIP trunk or if the call is not terminated.



809
810
811
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 809

def trunk_sid
    @properties['trunk_sid']
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](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 (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:



853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 853

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
)

    context.update(
        url: url, 
        method: method, 
        status: status, 
        fallback_url: fallback_url, 
        fallback_method: fallback_method, 
        status_callback: status_callback, 
        status_callback_method: status_callback_method, 
        twiml: twiml, 
        time_limit: time_limit, 
    )
end

#uriString

Returns The URI of this resource, relative to ‘api.twilio.com`.

Returns:

  • (String)

    The URI of this resource, relative to ‘api.twilio.com`.



815
816
817
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 815

def uri
    @properties['uri']
end

#user_defined_message_subscriptionsuser_defined_message_subscriptions

Access the user_defined_message_subscriptions

Returns:



909
910
911
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 909

def user_defined_message_subscriptions
    context.user_defined_message_subscriptions
end

#user_defined_messagesuser_defined_messages

Access the user_defined_messages

Returns:



888
889
890
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 888

def user_defined_messages
    context.user_defined_messages
end