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 unique id of the Account responsible for creating this Call

  • sid (String) (defaults to: nil)

    The Call Sid that uniquely identifies the Call to fetch



517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 517

def initialize(version, payload, account_sid: nil, sid: nil)
  super(version)

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

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

Instance Method Details

#account_sidString

Returns The unique id of the Account responsible for creating this Call.

Returns:

  • (String)

    The unique id of the Account responsible for creating this Call



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

def 
  @properties['account_sid']
end

#annotationString

Returns The annotation provided for the Call.

Returns:

  • (String)

    The annotation provided for the Call



580
581
582
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 580

def annotation
  @properties['annotation']
end

#answered_byString

Returns If this call was initiated with answering machine detection, either ‘human` or `machine`. Empty otherwise.

Returns:

  • (String)

    If this call was initiated with answering machine detection, either ‘human` or `machine`. Empty otherwise.



586
587
588
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 586

def answered_by
  @properties['answered_by']
end

#api_versionString

Returns The API Version the Call was created through.

Returns:

  • (String)

    The API Version the Call was created through



592
593
594
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 592

def api_version
  @properties['api_version']
end

#caller_nameString

Returns If this call was an incoming call to a phone number with Caller ID Lookup enabled, the caller’s name. Empty otherwise.

Returns:

  • (String)

    If this call was an incoming call to a phone number with Caller ID Lookup enabled, the caller’s name. Empty otherwise.



598
599
600
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 598

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:



561
562
563
564
565
566
567
568
569
570
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 561

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

#date_createdTime

Returns The date that this resource was created.

Returns:

  • (Time)

    The date that this resource was created



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

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The date that this resource was last updated.

Returns:

  • (Time)

    The date that this resource was last updated



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

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the CallInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



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

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.



616
617
618
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 616

def direction
  @properties['direction']
end

#durationString

Returns The duration.

Returns:

  • (String)

    The duration



622
623
624
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 622

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.



628
629
630
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 628

def end_time
  @properties['end_time']
end

#feedbackfeedback

Access the feedback

Returns:



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

def feedback
  context.feedback
end

#fetchCallInstance

Fetch a CallInstance

Returns:



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

def fetch
  context.fetch
end

#forwarded_fromString

Returns If this Call was an incoming call forwarded from another number, the forwarding phone number (depends on carrier supporting forwarding). Empty otherwise.

Returns:

  • (String)

    If this Call was an incoming call forwarded from another number, the forwarding phone number (depends on carrier supporting forwarding). Empty otherwise.



634
635
636
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 634

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



640
641
642
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 640

def from
  @properties['from']
end

#from_formattedString

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

Returns:

  • (String)

    The phone number, SIP address or Client identifier that made this Call. Formatted for display.



646
647
648
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 646

def from_formatted
  @properties['from_formatted']
end

#group_sidString

Returns A 34 character Group Sid associated with this Call. Empty if no Group is associated with the Call.

Returns:

  • (String)

    A 34 character Group Sid associated with this Call. Empty if no Group is associated with the Call.



652
653
654
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 652

def group_sid
  @properties['group_sid']
end

#inspectObject

Provide a detailed, user friendly representation



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

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

#notificationsnotifications

Access the notifications

Returns:



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

def notifications
  context.notifications
end

#parent_call_sidString

Returns A 34 character string that uniquely identifies the Call that created this leg.

Returns:

  • (String)

    A 34 character string that uniquely identifies the Call that created this leg.



658
659
660
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 658

def parent_call_sid
  @properties['parent_call_sid']
end

#phone_number_sidString

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

Returns:

  • (String)

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



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

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.



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

def price
  @properties['price']
end

#price_unitString

Returns The currency in which ‘Price` is measured.

Returns:

  • (String)

    The currency in which ‘Price` is measured.



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

def price_unit
  @properties['price_unit']
end

#recordingsrecordings

Access the recordings

Returns:



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

def recordings
  context.recordings
end

#sidString

Returns A 34 character string that uniquely identifies this resource.

Returns:

  • (String)

    A 34 character string that uniquely identifies this resource.



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

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.



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

def start_time
  @properties['start_time']
end

#statusfeedback_summary.Status

Returns The status.

Returns:

  • (feedback_summary.Status)

    The status



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

def status
  @properties['status']
end

#subresource_urisString

Returns Call Instance Subresources.

Returns:

  • (String)

    Call Instance Subresources



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

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



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

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.



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

def to_formatted
  @properties['to_formatted']
end

#to_sObject

Provide a user friendly representation



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

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

    A valid URL that returns TwiML. Twilio will immediately redirect the call to the new TwiML upon execution.

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

    The HTTP method Twilio should use when requesting the URL. Defaults to ‘POST`.

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

    Either ‘canceled` or `completed`. Specifying `canceled` will attempt to hangup calls that are queued or ringing but 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)

    A URL that Twilio will request if an error occurs requesting or executing the TwiML at ‘Url`.

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

    The HTTP method that Twilio should use to request the ‘FallbackUrl`. Must be either `GET` or `POST`. Defaults to `POST`.

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

    A URL that Twilio will request when the call ends to notify your app.

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

    The HTTP method that Twilio should use to request the ‘StatusCallback`. Defaults to `POST`.

Returns:



755
756
757
758
759
760
761
762
763
764
765
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 755

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

#uriString

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

Returns:

  • (String)

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



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

def uri
  @properties['uri']
end