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)

    The SID of the Sim resource to fetch.



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

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:



326
327
328
329
330
331
332
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 326

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, false otherwise



306
307
308
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 306

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

#fetchSimInstance

Fetch a SimInstance

Returns:



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

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



343
344
345
346
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 343

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

#to_sObject

Provide a user friendly representation



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

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)

    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 use to call ‘callback_url`. Can be: `POST` or `GET`, and the default is `POST`.

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

    The URL we 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 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/wireless/api/rate-plan) that this SIM should use.

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

    The new status of the resource. Can be: ‘ready`, `active`, `suspended` or `deactivated`; however the SIM might support additional values.

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

    The HTTP method we use to call ‘commands_callback_url`. Can be: `POST` or `GET`, and the default is `POST`.

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

    The URL we call using the ‘commands_callback_method` when the SIM originates a [Command](www.twilio.com/docs/wireless/api/commands). 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 use to call ‘sms_fallback_url`. Can be: `GET` or `POST`.

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

    The URL we 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 use to call ‘sms_url`. Can be: `GET` or `POST`.

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

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

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

    The HTTP method we use to call ‘voice_fallback_url`. Can be: `GET` or `POST`.

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

    The URL we call using the ‘voice_fallback_method` when an error occurs while retrieving or executing the TwiML requested from `voice_url`.

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

    The HTTP method we use when we call ‘voice_url`. Can be: `GET` or `POST`.

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

    The URL we call using the ‘voice_method` when the SIM-connected device makes a voice call.

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

    Initiate a connectivity reset on the SIM. Set to ‘resetting` to initiate a connectivity reset on the SIM. No other value is valid.

Returns:



273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 273

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:



314
315
316
317
318
319
320
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 314

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

  @usage_records
end