Class: Twilio::REST::Wireless::V1::SimContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/wireless/v1/sim.rb,
lib/twilio-ruby/rest/wireless/v1/sim/data_session.rb,
lib/twilio-ruby/rest/wireless/v1/sim/usage_record.rb

Defined Under Namespace

Classes: DataSessionInstance, DataSessionList, DataSessionListResponse, DataSessionPage, DataSessionPageMetadata, UsageRecordInstance, UsageRecordList, UsageRecordListResponse, UsageRecordPage, UsageRecordPageMetadata

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ SimContext

Initialize the SimContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    The SID or the unique_name of the Sim resource to update.



199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 199

def initialize(version, sid)
    super(version)
    

    # Path Solution
    @solution = { sid: sid,  }
    @uri = "/Sims/#{@solution[:sid]}"

    # Dependents
    @data_sessions = nil
    @usage_records = nil
end

Instance Method Details

#data_sessionsDataSessionList, DataSessionContext

Access the data_sessions

Returns:



451
452
453
454
455
456
457
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 451

def data_sessions
  unless @data_sessions
    @data_sessions = DataSessionList.new(
            @version, sim_sid: @solution[:sid], )
  end
  @data_sessions
end

#deleteBoolean

Delete the SimInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



214
215
216
217
218
219
220
221
222
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 214

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 SimInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 227

def 

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

#fetchSimInstance

Fetch the SimInstance

Returns:



246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 246

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    SimInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end

#fetch_with_metadataSimInstance

Fetch the SimInstanceMetadata

Returns:



265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 265

def 

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

#inspectObject

Provide a detailed, user friendly representation



479
480
481
482
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 479

def inspect
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Wireless.V1.SimContext #{context}>"
end

#to_sObject

Provide a user friendly representation



472
473
474
475
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 472

def to_s
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Wireless.V1.SimContext #{context}>"
end

#update(unique_name: :unset, callback_method: :unset, callback_url: :unset, friendly_name: :unset, rate_plan: :unset, status: :unset, commands_callback_method: :unset, commands_callback_url: :unset, sms_fallback_method: :unset, sms_fallback_url: :unset, sms_method: :unset, sms_url: :unset, voice_fallback_method: :unset, voice_fallback_url: :unset, voice_method: :unset, voice_url: :unset, reset_status: :unset, account_sid: :unset) ⇒ SimInstance

Update the SimInstance

Parameters:

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

    An application-defined string that uniquely identifies the resource. It can be used in place of the sid in the URL path to address the resource.

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

    The HTTP method we should use to call callback_url. Can be: POST or GET. The default is POST.

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

    The URL we should call using the callback_url when the SIM has finished updating. When the SIM transitions from new to ready or from any status to deactivated, we call this URL when the status changes to an intermediate status (ready or deactivated) and again when the status changes to its final status (active or canceled).

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

    A descriptive string that you create to describe the Sim resource. It does not need to be unique.

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

    The SID or unique name of the [RatePlan resource](www.twilio.com/docs/iot/wireless/api/rateplan-resource) to which the Sim resource should be assigned.

  • status (Status) (defaults to: :unset)
  • commands_callback_method (String) (defaults to: :unset)

    The HTTP method we should use to call commands_callback_url. Can be: POST or GET. The default is POST.

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

    The URL we should call using the commands_callback_method when the SIM sends a [Command](www.twilio.com/docs/iot/wireless/api/command-resource). Your server should respond with an HTTP status code in the 200 range; any response body is ignored.

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

    The HTTP method we should use to call sms_fallback_url. Can be: GET or POST. Default is POST.

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

    The URL we should call using the sms_fallback_method when an error occurs while retrieving or executing the TwiML requested from sms_url.

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

    The HTTP method we should use to call sms_url. Can be: GET or POST. Default is POST.

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

    The URL we should call using the sms_method when the SIM-connected device sends an SMS message that is not a [Command](www.twilio.com/docs/iot/wireless/api/command-resource).

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

    Deprecated.

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

    Deprecated.

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

    Deprecated.

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

    Deprecated.

  • reset_status (ResetStatus) (defaults to: :unset)
  • account_sid (String) (defaults to: :unset)

    The SID of the [Account](www.twilio.com/docs/iam/api/account) to which the Sim resource should belong. The Account SID can only be that of the requesting Account or that of a [Subaccount](www.twilio.com/docs/iam/api/subaccounts) of the requesting Account. Only valid when the Sim resource’s status is new. For more information, see the [Move SIMs between Subaccounts documentation](www.twilio.com/docs/iot/wireless/api/sim-resource#move-sims-between-subaccounts).

Returns:



308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 308

def update(
    unique_name: :unset, 
    callback_method: :unset, 
    callback_url: :unset, 
    friendly_name: :unset, 
    rate_plan: :unset, 
    status: :unset, 
    commands_callback_method: :unset, 
    commands_callback_url: :unset, 
    sms_fallback_method: :unset, 
    sms_fallback_url: :unset, 
    sms_method: :unset, 
    sms_url: :unset, 
    voice_fallback_method: :unset, 
    voice_fallback_url: :unset, 
    voice_method: :unset, 
    voice_url: :unset, 
    reset_status: :unset, 
    account_sid: :unset
)

    data = Twilio::Values.of({
        'UniqueName' => unique_name,
        'CallbackMethod' => callback_method,
        'CallbackUrl' => callback_url,
        'FriendlyName' => friendly_name,
        'RatePlan' => rate_plan,
        'Status' => status,
        'CommandsCallbackMethod' => commands_callback_method,
        'CommandsCallbackUrl' => commands_callback_url,
        'SmsFallbackMethod' => sms_fallback_method,
        'SmsFallbackUrl' => sms_fallback_url,
        'SmsMethod' => sms_method,
        'SmsUrl' => sms_url,
        'VoiceFallbackMethod' => voice_fallback_method,
        'VoiceFallbackUrl' => voice_fallback_url,
        'VoiceMethod' => voice_method,
        'VoiceUrl' => voice_url,
        'ResetStatus' => reset_status,
        'AccountSid' => ,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    SimInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end

#update_with_metadata(unique_name: :unset, callback_method: :unset, callback_url: :unset, friendly_name: :unset, rate_plan: :unset, status: :unset, commands_callback_method: :unset, commands_callback_url: :unset, sms_fallback_method: :unset, sms_fallback_url: :unset, sms_method: :unset, sms_url: :unset, voice_fallback_method: :unset, voice_fallback_url: :unset, voice_method: :unset, voice_url: :unset, reset_status: :unset, account_sid: :unset) ⇒ SimInstance

Update the SimInstanceMetadata

Parameters:

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

    An application-defined string that uniquely identifies the resource. It can be used in place of the sid in the URL path to address the resource.

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

    The HTTP method we should use to call callback_url. Can be: POST or GET. The default is POST.

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

    The URL we should call using the callback_url when the SIM has finished updating. When the SIM transitions from new to ready or from any status to deactivated, we call this URL when the status changes to an intermediate status (ready or deactivated) and again when the status changes to its final status (active or canceled).

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

    A descriptive string that you create to describe the Sim resource. It does not need to be unique.

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

    The SID or unique name of the [RatePlan resource](www.twilio.com/docs/iot/wireless/api/rateplan-resource) to which the Sim resource should be assigned.

  • status (Status) (defaults to: :unset)
  • commands_callback_method (String) (defaults to: :unset)

    The HTTP method we should use to call commands_callback_url. Can be: POST or GET. The default is POST.

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

    The URL we should call using the commands_callback_method when the SIM sends a [Command](www.twilio.com/docs/iot/wireless/api/command-resource). Your server should respond with an HTTP status code in the 200 range; any response body is ignored.

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

    The HTTP method we should use to call sms_fallback_url. Can be: GET or POST. Default is POST.

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

    The URL we should call using the sms_fallback_method when an error occurs while retrieving or executing the TwiML requested from sms_url.

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

    The HTTP method we should use to call sms_url. Can be: GET or POST. Default is POST.

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

    The URL we should call using the sms_method when the SIM-connected device sends an SMS message that is not a [Command](www.twilio.com/docs/iot/wireless/api/command-resource).

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

    Deprecated.

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

    Deprecated.

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

    Deprecated.

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

    Deprecated.

  • reset_status (ResetStatus) (defaults to: :unset)
  • account_sid (String) (defaults to: :unset)

    The SID of the [Account](www.twilio.com/docs/iam/api/account) to which the Sim resource should belong. The Account SID can only be that of the requesting Account or that of a [Subaccount](www.twilio.com/docs/iam/api/subaccounts) of the requesting Account. Only valid when the Sim resource’s status is new. For more information, see the [Move SIMs between Subaccounts documentation](www.twilio.com/docs/iot/wireless/api/sim-resource#move-sims-between-subaccounts).

Returns:



385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 385

def (
  unique_name: :unset, 
  callback_method: :unset, 
  callback_url: :unset, 
  friendly_name: :unset, 
  rate_plan: :unset, 
  status: :unset, 
  commands_callback_method: :unset, 
  commands_callback_url: :unset, 
  sms_fallback_method: :unset, 
  sms_fallback_url: :unset, 
  sms_method: :unset, 
  sms_url: :unset, 
  voice_fallback_method: :unset, 
  voice_fallback_url: :unset, 
  voice_method: :unset, 
  voice_url: :unset, 
  reset_status: :unset, 
  account_sid: :unset
)

    data = Twilio::Values.of({
        'UniqueName' => unique_name,
        'CallbackMethod' => callback_method,
        'CallbackUrl' => callback_url,
        'FriendlyName' => friendly_name,
        'RatePlan' => rate_plan,
        'Status' => status,
        'CommandsCallbackMethod' => commands_callback_method,
        'CommandsCallbackUrl' => commands_callback_url,
        'SmsFallbackMethod' => sms_fallback_method,
        'SmsFallbackUrl' => sms_fallback_url,
        'SmsMethod' => sms_method,
        'SmsUrl' => sms_url,
        'VoiceFallbackMethod' => voice_fallback_method,
        'VoiceFallbackUrl' => voice_fallback_url,
        'VoiceMethod' => voice_method,
        'VoiceUrl' => voice_url,
        'ResetStatus' => reset_status,
        'AccountSid' => ,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    sim_instance = SimInstance.new(
        @version,
        response.body,
        sid: @solution[:sid],
    )
    SimInstanceMetadata.new(
        @version,
        sim_instance,
        response.headers,
        response.status_code
    )
end

#usage_recordsUsageRecordList, UsageRecordContext

Access the usage_records

Returns:



462
463
464
465
466
467
468
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 462

def usage_records
  unless @usage_records
    @usage_records = UsageRecordList.new(
            @version, sim_sid: @solution[:sid], )
  end
  @usage_records
end