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/usage_record.rb

Overview

PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.

Defined Under Namespace

Classes: 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



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

def initialize(version, sid)
  super(version)

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

  # Dependents
  @usage_records = nil
end

Instance Method Details

#fetchSimInstance

Fetch a SimInstance

Returns:



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

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



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

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)

    The unique_name

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

    The callback_method

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

    The callback_url

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

    The friendly_name

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

    The rate_plan

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

    The status

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

    The commands_callback_method

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

    The commands_callback_url

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

    The sms_fallback_method

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

    The sms_fallback_url

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

    The sms_method

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

    The sms_url

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

    The voice_fallback_method

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

    The voice_fallback_url

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

    The voice_method

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

    The voice_url

Returns:



245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 245

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:



282
283
284
285
286
287
288
289
290
291
# File 'lib/twilio-ruby/rest/wireless/v1/sim.rb', line 282

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

  @usage_records
end