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



188
189
190
191
192
193
194
195
196
197
198
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 188

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:



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

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

  @data_sessions
end

#fetchSimInstance

Fetch a SimInstance

Returns:



203
204
205
206
207
208
209
210
211
212
213
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 203

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

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

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

#to_sObject

Provide a user friendly representation



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

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) ⇒ 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. Note: the RatePlan of a Sim can only be modified when the Sim has a ‘suspended` or `deactivated` status.

  • 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.

Returns:



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

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

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

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

#usage_recordsUsageRecordList, UsageRecordContext

Access the usage_records

Returns:



295
296
297
298
299
300
301
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 295

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

  @usage_records
end