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.



1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1052

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'],
        'stir_verstat' => payload['stir_verstat'],
        '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_sid ⇒ String

Returns The SID of the Account that created this Call resource.

Returns:

  • (String) —

    The SID of the Account that created this Call resource.



1129
1130
1131
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1129

def 
    @properties['account_sid']
end

#answered_by ⇒ String

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.



1207
1208
1209
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1207

def answered_by
    @properties['answered_by']
end

#api_version ⇒ String

Returns The API version used to create the call.

Returns:

  • (String) —

    The API version used to create the call.



1213
1214
1215
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1213

def api_version
    @properties['api_version']
end

#caller_name ⇒ String

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.



1231
1232
1233
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1231

def caller_name
    @properties['caller_name']
end

#context ⇒ CallContext

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

Returns:



1096
1097
1098
1099
1100
1101
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1096

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

#date_created ⇒ Time

Returns The date and time in UTC that this resource was created specified in RFC 2822 format.

Returns:

  • (Time) —

    The date and time in UTC that this resource was created specified in RFC 2822 format.



1111
1112
1113
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1111

def date_created
    @properties['date_created']
end

#date_updated ⇒ Time

Returns The date and time in UTC that this resource was last updated, specified in RFC 2822 format.

Returns:

  • (Time) —

    The date and time in UTC that this resource was last updated, specified in RFC 2822 format.



1117
1118
1119
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1117

def date_updated
    @properties['date_updated']
end

#delete ⇒ Boolean

Delete the CallInstance

Returns:

  • (Boolean) —

    True if delete succeeds, false otherwise



1268
1269
1270
1271
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1268

def delete

    context.delete
end

#direction ⇒ String

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, the values can be trunking-terminating for outgoing calls from your communications infrastructure to the PSTN or trunking-originating for incoming calls to your communications infrastructure from the PSTN.

Returns:

  • (String) —

    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, the values can be trunking-terminating for outgoing calls from your communications infrastructure to the PSTN or trunking-originating for incoming calls to your communications infrastructure from the PSTN.



1201
1202
1203
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1201

def direction
    @properties['direction']
end

#duration ⇒ String

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.



1183
1184
1185
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1183

def duration
    @properties['duration']
end

#end_time ⇒ Time

Returns The time the call ended, given as UTC in RFC 2822 format. Empty if the call did not complete successfully.

Returns:

  • (Time) —

    The time the call ended, given as UTC in RFC 2822 format. Empty if the call did not complete successfully.



1177
1178
1179
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1177

def end_time
    @properties['end_time']
end

#events ⇒ events

Access the events

Returns:



1321
1322
1323
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1321

def events
    context.events
end

#fetch ⇒ CallInstance

Fetch the CallInstance

Returns:



1276
1277
1278
1279
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1276

def fetch

    context.fetch
end

#forwarded_from ⇒ String

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.



1219
1220
1221
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1219

def forwarded_from
    @properties['forwarded_from']
end

#from ⇒ String

Returns The phone number, SIP address, Client identifier or SIM SID 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. 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 format (e.g., +16175551212). SIP addresses are formatted as [email protected]. Client identifiers are formatted client:name. SIM SIDs are formatted as sim:sid.



1147
1148
1149
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1147

def from
    @properties['from']
end

#from_formatted ⇒ String

Returns The calling phone number, SIP address, or Client identifier formatted for display. Non-North American phone numbers are in E.164 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 format (e.g., +442071838750).



1153
1154
1155
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1153

def from_formatted
    @properties['from_formatted']
end

#group_sid ⇒ String

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.



1225
1226
1227
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1225

def group_sid
    @properties['group_sid']
end

#inspect ⇒ Object

Provide a detailed, user friendly representation



1390
1391
1392
1393
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1390

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

#notifications ⇒ notifications

Access the notifications

Returns:



1370
1371
1372
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1370

def notifications
    context.notifications
end

#parent_call_sid ⇒ String

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

Returns:

  • (String) —

    The SID that identifies the call that created this leg.



1123
1124
1125
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1123

def parent_call_sid
    @properties['parent_call_sid']
end

#payments ⇒ payments

Access the payments

Returns:



1356
1357
1358
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1356

def payments
    context.payments
end

#phone_number_sid ⇒ String

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.



1159
1160
1161
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1159

def phone_number_sid
    @properties['phone_number_sid']
end

#price ⇒ String

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.



1189
1190
1191
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1189

def price
    @properties['price']
end

#price_unit ⇒ String

Returns The currency in which Price is measured, in ISO 4127 format (e.g., USD, EUR, JPY). Always capitalized for calls.

Returns:

  • (String) —

    The currency in which Price is measured, in ISO 4127 format (e.g., USD, EUR, JPY). Always capitalized for calls.



1195
1196
1197
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1195

def price_unit
    @properties['price_unit']
end

#queue_time ⇒ String

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

Returns:

  • (String) —

    The wait time in milliseconds before the call is placed.



1237
1238
1239
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1237

def queue_time
    @properties['queue_time']
end

#recordings ⇒ recordings

Access the recordings

Returns:



1363
1364
1365
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1363

def recordings
    context.recordings
end

#sid ⇒ String

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.



1105
1106
1107
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1105

def sid
    @properties['sid']
end

#siprec ⇒ siprec

Access the siprec

Returns:



1342
1343
1344
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1342

def siprec
    context.siprec
end

#start_time ⇒ Time

Returns The start time of the call, given as UTC in RFC 2822 format. Empty if the call has not yet been dialed.

Returns:

  • (Time) —

    The start time of the call, given as UTC in RFC 2822 format. Empty if the call has not yet been dialed.



1171
1172
1173
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1171

def start_time
    @properties['start_time']
end

#status ⇒ Status

Returns:

  • (Status)


1165
1166
1167
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1165

def status
    @properties['status']
end

#stir_verstat ⇒ String

Returns The STIR/SHAKEN verification status of the call, for example TN-Validation-Passed-A. Empty if the incoming call had no STIR/SHAKEN information.

Returns:

  • (String) —

    The STIR/SHAKEN verification status of the call, for example TN-Validation-Passed-A. Empty if the incoming call had no STIR/SHAKEN information.



1243
1244
1245
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1243

def stir_verstat
    @properties['stir_verstat']
end

#streams ⇒ streams

Access the streams

Returns:



1377
1378
1379
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1377

def streams
    context.streams
end

#subresource_uris ⇒ Hash

Returns A list of subresources available to this call, identified by their URIs relative to https://api.twilio.com.

Returns:

  • (Hash) —

    A list of subresources available to this call, identified by their URIs relative to https://api.twilio.com.



1261
1262
1263
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1261

def subresource_uris
    @properties['subresource_uris']
end

#to ⇒ String

Returns The phone number, SIP address, Client identifier or SIM SID 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. 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 format (e.g., +16175551212). SIP addresses are formatted as [email protected]. Client identifiers are formatted client:name. SIM SIDs are formatted as sim:sid.



1135
1136
1137
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1135

def to
    @properties['to']
end

#to_formatted ⇒ String

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 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 format (e.g., +442071838750).



1141
1142
1143
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1141

def to_formatted
    @properties['to_formatted']
end

#to_s ⇒ Object

Provide a user friendly representation



1383
1384
1385
1386
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1383

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

#transcriptions ⇒ transcriptions

Access the transcriptions

Returns:



1335
1336
1337
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1335

def transcriptions
    context.transcriptions
end

#trunk_sid ⇒ String

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.



1249
1250
1251
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1249

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 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:



1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1293

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

#uri ⇒ String

Returns The URI of this resource, relative to https://api.twilio.com.

Returns:

  • (String) —

    The URI of this resource, relative to https://api.twilio.com.



1255
1256
1257
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1255

def uri
    @properties['uri']
end

#user_defined_message_subscriptions ⇒ user_defined_message_subscriptions

Access the user_defined_message_subscriptions

Returns:



1349
1350
1351
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1349

def user_defined_message_subscriptions
    context.user_defined_message_subscriptions
end

#user_defined_messages ⇒ user_defined_messages

Access the user_defined_messages

Returns:



1328
1329
1330
# File 'lib/twilio-ruby/rest/api/v2010/account/call.rb', line 1328

def user_defined_messages
    context.user_defined_messages
end