Class: Twilio::REST::Wireless::V1::SimInstance

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/wireless/v1/sim.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, sid: nil) ⇒ SimInstance

Initialize the SimInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • sid (String) (defaults to: nil)

    A 34 character string that uniquely identifies this resource.



351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 351

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

  # Marshaled Properties
  @properties = {
      'sid' => payload['sid'],
      'unique_name' => payload['unique_name'],
      'account_sid' => payload['account_sid'],
      'rate_plan_sid' => payload['rate_plan_sid'],
      'friendly_name' => payload['friendly_name'],
      'iccid' => payload['iccid'],
      'e_id' => payload['e_id'],
      'status' => payload['status'],
      'reset_status' => payload['reset_status'],
      'commands_callback_url' => payload['commands_callback_url'],
      'commands_callback_method' => payload['commands_callback_method'],
      'sms_fallback_method' => payload['sms_fallback_method'],
      'sms_fallback_url' => payload['sms_fallback_url'],
      'sms_method' => payload['sms_method'],
      'sms_url' => payload['sms_url'],
      'voice_fallback_method' => payload['voice_fallback_method'],
      'voice_fallback_url' => payload['voice_fallback_url'],
      'voice_method' => payload['voice_method'],
      'voice_url' => payload['voice_url'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'url' => payload['url'],
      'links' => payload['links'],
      'ip_address' => payload['ip_address'],
  }

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

Instance Method Details

#account_sidString

Returns The unique id of the Account that this Sim belongs to.

Returns:

  • (String)

    The unique id of the Account that this Sim belongs to.



412
413
414
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 412

def 
  @properties['account_sid']
end

#commands_callback_methodString

Returns A string representing the HTTP method to use when making a request to commands_callback_url.

Returns:

  • (String)

    A string representing the HTTP method to use when making a request to commands_callback_url.



460
461
462
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 460

def commands_callback_method
  @properties['commands_callback_method']
end

#commands_callback_urlString

Returns The URL that will receive a webhook when this Sim originates a machine-to-machine Command.

Returns:

  • (String)

    The URL that will receive a webhook when this Sim originates a machine-to-machine Command.



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

def commands_callback_url
  @properties['commands_callback_url']
end

#contextSimContext

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

Returns:

  • (SimContext)

    SimContext for this SimInstance



391
392
393
394
395
396
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 391

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

#data_sessionsdata_sessions

Access the data_sessions

Returns:



636
637
638
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 636

def data_sessions
  context.data_sessions
end

#date_createdTime

Returns The date that this resource was created, given as GMT in ISO 8601 format.

Returns:

  • (Time)

    The date that this resource was created, given as GMT in ISO 8601 format.



514
515
516
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 514

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The date that this resource was last updated, given as GMT in ISO 8601 format.

Returns:

  • (Time)

    The date that this resource was last updated, given as GMT in ISO 8601 format.



520
521
522
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 520

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the SimInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



622
623
624
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 622

def delete
  context.delete
end

#e_idString

Returns The e_id.

Returns:

  • (String)

    The e_id



436
437
438
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 436

def e_id
  @properties['e_id']
end

#fetchSimInstance

Fetch a SimInstance

Returns:



545
546
547
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 545

def fetch
  context.fetch
end

#friendly_nameString

Returns A user-provided string that identifies this resource.

Returns:

  • (String)

    A user-provided string that identifies this resource.



424
425
426
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 424

def friendly_name
  @properties['friendly_name']
end

#iccidString

Returns The ICCID associated with the SIM.

Returns:

  • (String)

    The ICCID associated with the SIM.



430
431
432
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 430

def iccid
  @properties['iccid']
end

#inspectObject

Provide a detailed, user friendly representation



649
650
651
652
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 649

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

#ip_addressString

Returns The ip_address.

Returns:

  • (String)

    The ip_address



538
539
540
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 538

def ip_address
  @properties['ip_address']
end

Returns Each Sim instance resource supports a few subresources, listed here for convenience.

Returns:

  • (String)

    Each Sim instance resource supports a few subresources, listed here for convenience.



532
533
534
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 532

def links
  @properties['links']
end

#rate_plan_sidString

Returns The unique ID of the Rate Plan configured for this Sim.

Returns:

  • (String)

    The unique ID of the Rate Plan configured for this Sim.



418
419
420
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 418

def rate_plan_sid
  @properties['rate_plan_sid']
end

#reset_statussim.ResetStatus

Returns A string representing the connectivity reset status of the Sim.

Returns:

  • (sim.ResetStatus)

    A string representing the connectivity reset status of the Sim.



448
449
450
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 448

def reset_status
  @properties['reset_status']
end

#sidString

Returns A 34 character string that uniquely identifies this resource.

Returns:

  • (String)

    A 34 character string that uniquely identifies this resource.



400
401
402
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 400

def sid
  @properties['sid']
end

#sms_fallback_methodString

Returns The HTTP method Twilio will use when requesting the sms_fallback_url.

Returns:

  • (String)

    The HTTP method Twilio will use when requesting the sms_fallback_url.



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

def sms_fallback_method
  @properties['sms_fallback_method']
end

#sms_fallback_urlString

Returns The URL that Twilio will request if an error occurs retrieving or executing the TwiML requested by sms_url.

Returns:

  • (String)

    The URL that Twilio will request if an error occurs retrieving or executing the TwiML requested by sms_url.



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

def sms_fallback_url
  @properties['sms_fallback_url']
end

#sms_methodString

Returns The HTTP method Twilio will use when requesting the above Url.

Returns:

  • (String)

    The HTTP method Twilio will use when requesting the above Url.



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

def sms_method
  @properties['sms_method']
end

#sms_urlString

Returns The URL Twilio will request when the SIM-connected device send an SMS that is not a Command.

Returns:

  • (String)

    The URL Twilio will request when the SIM-connected device send an SMS that is not a Command.



484
485
486
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 484

def sms_url
  @properties['sms_url']
end

#statussim.Status

Returns A string representing the status of the Sim.

Returns:

  • (sim.Status)

    A string representing the status of the Sim.



442
443
444
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 442

def status
  @properties['status']
end

#to_sObject

Provide a user friendly representation



642
643
644
645
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 642

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

#unique_nameString

Returns A user-provided string that uniquely identifies this resource as an alternative to the sid.

Returns:

  • (String)

    A user-provided string that uniquely identifies this resource as an alternative to the sid.



406
407
408
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 406

def unique_name
  @properties['unique_name']
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) ⇒ SimInstance

Update the SimInstance

Parameters:

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

    A user-provided string that uniquely identifies this resource as an alternative to the ‘Sid`.

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

    The HTTP method Twilio will use when making a request to the callback URL (valid options are GET or POST). Defaults to POST.

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

    Twilio will make a request to this URL when the Sim has finished updating. In the case of a transition from the Sim’s ‘new` status to its `ready` status, or from any status to its `deactivated` status, you will receive two callbacks. One when the Sim moves to its intermediary status (`ready` or `deactivated`), and a second when it transitions to its final status (`active` or `canceled`).

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

    A user-provided string that identifies this resource. Non-unique.

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

    The Sid or UniqueName of the [RatePlan](www.twilio.com/docs/api/wireless/rest-api/rate-plan) that this Sim should use.

  • status (sim.Status) (defaults to: :unset)

    A string representing the status of the Sim. Valid options depend on the current state of the Sim, but may include ‘ready`, `active`, `suspended` or `deactivated`.

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

    A string representing the HTTP method to use when making a request to ‘CommandsCallbackUrl`. Can be one of `POST` or `GET`. Defaults to `POST`.

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

    The URL that will receive a webhook when this Sim originates a [Command](www.twilio.com/docs/api/wireless/rest-api/command). Your server should respond with an HTTP status code in the 200 range; any response body will be ignored.

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

    The HTTP method Twilio will use when requesting the sms_fallback_url. Either ‘GET` or `POST`.

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

    The URL that Twilio will request if an error occurs retrieving or executing the TwiML requested by ‘sms_url`.

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

    The HTTP method Twilio will use when requesting the above Url. Either ‘GET` or `POST`.

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

    The URL Twilio will request when the SIM-connected device sends an SMS message that is not a [Command](www.twilio.com/docs/api/wireless/rest-api/command).

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

    The HTTP method Twilio will use when requesting the voice_fallback_url. Either ‘GET` or `POST`.

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

    The URL that Twilio will request if an error occurs retrieving or executing the TwiML requested by ‘voice_url`.

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

    The HTTP method Twilio will use when requesting the above Url. Either ‘GET` or `POST`.

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

    The URL Twilio will request when the SIM-connected device makes a call.

  • reset_status (sim.ResetStatus) (defaults to: :unset)

    Pass ‘resetting` to initiate a connectivity reset on a Sim, this is the only valid value for this parameter.

Returns:



597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 597

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)
  context.update(
      unique_name: unique_name,
      callback_method: callback_method,
      callback_url: callback_url,
      friendly_name: friendly_name,
      rate_plan: rate_plan,
      status: status,
      commands_callback_method: commands_callback_method,
      commands_callback_url: commands_callback_url,
      sms_fallback_method: sms_fallback_method,
      sms_fallback_url: sms_fallback_url,
      sms_method: sms_method,
      sms_url: sms_url,
      voice_fallback_method: voice_fallback_method,
      voice_fallback_url: voice_fallback_url,
      voice_method: voice_method,
      voice_url: voice_url,
      reset_status: reset_status,
  )
end

#urlString

Returns The URL for this resource.

Returns:

  • (String)

    The URL for this resource.



526
527
528
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 526

def url
  @properties['url']
end

#usage_recordsusage_records

Access the usage_records

Returns:



629
630
631
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 629

def usage_records
  context.usage_records
end

#voice_fallback_methodString

Returns The HTTP method Twilio will use when requesting the voice_fallback_url.

Returns:

  • (String)

    The HTTP method Twilio will use when requesting the voice_fallback_url.



490
491
492
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 490

def voice_fallback_method
  @properties['voice_fallback_method']
end

#voice_fallback_urlString

Returns The URL that Twilio will request if an error occurs retrieving or executing the TwiML requested by voice_url.

Returns:

  • (String)

    The URL that Twilio will request if an error occurs retrieving or executing the TwiML requested by voice_url.



496
497
498
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 496

def voice_fallback_url
  @properties['voice_fallback_url']
end

#voice_methodString

Returns The HTTP method Twilio will use when requesting the above Url.

Returns:

  • (String)

    The HTTP method Twilio will use when requesting the above Url.



502
503
504
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 502

def voice_method
  @properties['voice_method']
end

#voice_urlString

Returns The URL Twilio will request when the SIM-connected device makes a call.

Returns:

  • (String)

    The URL Twilio will request when the SIM-connected device makes a call.



508
509
510
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 508

def voice_url
  @properties['voice_url']
end