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, DataSessionPage, UsageRecordInstance, UsageRecordList, UsageRecordPage

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ SimContext

Initialize the SimContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    A 34 character string that uniquely identifies this resource.



192
193
194
195
196
197
198
199
200
201
202
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 192

def initialize(version, sid)
  super(version)

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

  # Dependents
  @usage_records = nil
  @data_sessions = nil
end

Instance Method Details

#data_sessionsDataSessionList, DataSessionContext

Access the data_sessions

Returns:



320
321
322
323
324
325
326
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 320

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

  @data_sessions
end

#deleteBoolean

Deletes the SimInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



300
301
302
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 300

def delete
  @version.delete('delete', @uri)
end

#fetchSimInstance

Fetch a SimInstance

Returns:



207
208
209
210
211
212
213
214
215
216
217
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 207

def fetch
  params = Twilio::Values.of({})

  payload = @version.fetch(
      'GET',
      @uri,
      params,
  )

  SimInstance.new(@version, payload, sid: @solution[:sid], )
end

#inspectObject

Provide a detailed, user friendly representation



337
338
339
340
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 337

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

#to_sObject

Provide a user friendly representation



330
331
332
333
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 330

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



267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 267

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)
  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,
  })

  payload = @version.update(
      'POST',
      @uri,
      data: data,
  )

  SimInstance.new(@version, payload, sid: @solution[:sid], )
end

#usage_recordsUsageRecordList, UsageRecordContext

Access the usage_records

Returns:



308
309
310
311
312
313
314
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 308

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

  @usage_records
end