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
657
# 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'],
      'annotation' => payload['annotation'],
      '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 that created this resource.

Returns:

  • (String)

    The SID of the Account that created this resource



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

def 
  @properties['account_sid']
end

#annotationString

Returns The annotation provided for the call.

Returns:

  • (String)

    The annotation provided for the call



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

def annotation
  @properties['annotation']
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.



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

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



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

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.



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

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:



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

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

#date_createdTime

Returns The RFC 2822 date and time in GMT that this resource was created.

Returns:

  • (Time)

    The RFC 2822 date and time in GMT that this resource was created



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

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The RFC 2822 date and time in GMT that this resource was last updated.

Returns:

  • (Time)

    The RFC 2822 date and time in GMT that this resource was last updated



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

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Delete the CallInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise



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

def delete
  context.delete
end

#directionString

Returns A string describing the direction of the call. ‘inbound` for inbound calls, `outbound-api` for calls initiated via the REST API or `outbound-dial` for calls initiated by a `Dial` verb.

Returns:

  • (String)

    A string describing the direction of the call. ‘inbound` for inbound calls, `outbound-api` for calls initiated via the REST API or `outbound-dial` for calls initiated by a `Dial` verb.



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

def direction
  @properties['direction']
end

#durationString

Returns The length of the call in seconds.

Returns:

  • (String)

    The length of the call in seconds.



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

def duration
  @properties['duration']
end

#end_timeTime

Returns The end time of the call. Null if the call did not complete successfully.

Returns:

  • (Time)

    The end time of the call. Null if the call did not complete successfully.



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

def end_time
  @properties['end_time']
end

#eventsevents

Access the events

Returns:



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

def events
  context.events
end

#feedbackfeedback

Access the feedback

Returns:



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

def feedback
  context.feedback
end

#fetchCallInstance

Fetch the CallInstance

Returns:



842
843
844
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 842

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.



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

def forwarded_from
  @properties['forwarded_from']
end

#fromString

Returns The phone number, SIP address or Client identifier that made this call. Phone numbers are in E.164 format (e.g., +16175551212). SIP addresses are formatted as ‘[email protected]`. Client identifiers are formatted `client:name`.

Returns:

  • (String)

    The phone number, SIP address or Client identifier that made this call. Phone numbers are in E.164 format (e.g., +16175551212). SIP addresses are formatted as ‘[email protected]`. Client identifiers are formatted `client:name`.



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

def from
  @properties['from']
end

#from_formattedString

Returns The calling phone number, SIP address, or Client identifier formatted for display.

Returns:

  • (String)

    The calling phone number, SIP address, or Client identifier formatted for display.



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

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.



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

def group_sid
  @properties['group_sid']
end

#inspectObject

Provide a detailed, user friendly representation



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

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

#notificationsnotifications

Access the notifications

Returns:



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

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.



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

def parent_call_sid
  @properties['parent_call_sid']
end

#paymentspayments

Access the payments

Returns:



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

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.



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

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.

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.



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

def price
  @properties['price']
end

#price_unitString

Returns The currency in which ‘Price` is measured.

Returns:

  • (String)

    The currency in which ‘Price` is measured.



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

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.



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

def queue_time
  @properties['queue_time']
end

#recordingsrecordings

Access the recordings

Returns:



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

def recordings
  context.recordings
end

#sidString

Returns The unique string that identifies this resource.

Returns:

  • (String)

    The unique string that identifies this resource



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

def sid
  @properties['sid']
end

#start_timeTime

Returns The start time of the call. Null if the call has not yet been dialed.

Returns:

  • (Time)

    The start time of the call. Null if the call has not yet been dialed.



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

def start_time
  @properties['start_time']
end

#statuscall.Status

Returns The status of this call.

Returns:

  • (call.Status)

    The status of this call.



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

def status
  @properties['status']
end

#subresource_urisString

Returns A list of related subresources identified by their relative URIs.

Returns:

  • (String)

    A list of related subresources identified by their relative URIs



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

def subresource_uris
  @properties['subresource_uris']
end

#toString

Returns The phone number, SIP address or Client identifier that received this call. Phone numbers are in E.164 format (e.g., +16175551212). SIP addresses are formatted as ‘[email protected]`. Client identifiers are formatted `client:name`.

Returns:

  • (String)

    The phone number, SIP address or Client identifier that received this call. Phone numbers are in E.164 format (e.g., +16175551212). SIP addresses are formatted as ‘[email protected]`. Client identifiers are formatted `client:name`.



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

def to
  @properties['to']
end

#to_formattedString

Returns The phone number, SIP address or Client identifier that received this call. Formatted for display.

Returns:

  • (String)

    The phone number, SIP address or Client identifier that received this call. Formatted for display.



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

def to_formatted
  @properties['to_formatted']
end

#to_sObject

Provide a user friendly representation



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

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

#trunk_sidString

Returns The (optional) unique identifier of the trunk resource that was used for this call.

Returns:

  • (String)

    The (optional) unique identifier of the trunk resource that was used for this call.



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

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) ⇒ 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

Returns:



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

def update(url: :unset, method: :unset, status: :unset, fallback_url: :unset, fallback_method: :unset, status_callback: :unset, status_callback_method: :unset, twiml: :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,
  )
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`



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

def uri
  @properties['uri']
end