Class: Twilio::REST::Supersim::V1::SimContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/supersim/v1/sim.rb,
lib/twilio-ruby/rest/supersim/v1/sim/billing_period.rb,
lib/twilio-ruby/rest/supersim/v1/sim/sim_ip_address.rb

Defined Under Namespace

Classes: BillingPeriodInstance, BillingPeriodList, BillingPeriodListResponse, BillingPeriodPage, BillingPeriodPageMetadata, SimIpAddressInstance, SimIpAddressList, SimIpAddressListResponse, SimIpAddressPage, SimIpAddressPageMetadata

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



253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/twilio-ruby/rest/supersim/v1/sim.rb', line 253

def initialize(version, sid)
    super(version)
    

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

    # Dependents
    @billing_periods = nil
    @sim_ip_addresses = nil
end

Instance Method Details

#billing_periodsBillingPeriodList, BillingPeriodContext

Access the billing_periods

Returns:



401
402
403
404
405
406
407
# File 'lib/twilio-ruby/rest/supersim/v1/sim.rb', line 401

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

#fetchSimInstance

Fetch the SimInstance

Returns:



268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/twilio-ruby/rest/supersim/v1/sim.rb', line 268

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    SimInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end

#fetch_with_metadataSimInstance

Fetch the SimInstanceMetadata

Returns:



287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# File 'lib/twilio-ruby/rest/supersim/v1/sim.rb', line 287

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    sim_instance = SimInstance.new(
        @version,
        response.body,
        sid: @solution[:sid],
    )
    SimInstanceMetadata.new(
        @version,
        sim_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



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

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

#sim_ip_addressesSimIpAddressList, SimIpAddressContext

Access the sim_ip_addresses

Returns:



412
413
414
415
416
417
418
# File 'lib/twilio-ruby/rest/supersim/v1/sim.rb', line 412

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

#to_sObject

Provide a user friendly representation



422
423
424
425
# File 'lib/twilio-ruby/rest/supersim/v1/sim.rb', line 422

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

#update(unique_name: :unset, status: :unset, fleet: :unset, callback_url: :unset, callback_method: :unset, account_sid: :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 resource’s ‘sid` in the URL to address the resource.

  • status (StatusUpdate) (defaults to: :unset)
  • fleet (String) (defaults to: :unset)

    The SID or unique name of the Fleet to which the SIM resource should be assigned.

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

    The URL we should call using the ‘callback_method` after an asynchronous update has finished.

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

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

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

    The SID of the Account to which the Sim resource should belong. The Account SID can only be that of the requesting Account or that of a Subaccount of the requesting Account. Only valid when the Sim resource’s status is new.

Returns:



318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
# File 'lib/twilio-ruby/rest/supersim/v1/sim.rb', line 318

def update(
  unique_name: :unset, 
  status: :unset, 
  fleet: :unset, 
  callback_url: :unset, 
  callback_method: :unset, 
  account_sid: :unset
)

    data = Twilio::Values.of({
        'UniqueName' => unique_name,
        'Status' => status,
        'Fleet' => fleet,
        'CallbackUrl' => callback_url,
        'CallbackMethod' => callback_method,
        'AccountSid' => ,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    SimInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end

#update_with_metadata(unique_name: :unset, status: :unset, fleet: :unset, callback_url: :unset, callback_method: :unset, account_sid: :unset) ⇒ SimInstance

Update the SimInstanceMetadata

Parameters:

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

    An application-defined string that uniquely identifies the resource. It can be used in place of the resource’s ‘sid` in the URL to address the resource.

  • status (StatusUpdate) (defaults to: :unset)
  • fleet (String) (defaults to: :unset)

    The SID or unique name of the Fleet to which the SIM resource should be assigned.

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

    The URL we should call using the ‘callback_method` after an asynchronous update has finished.

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

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

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

    The SID of the Account to which the Sim resource should belong. The Account SID can only be that of the requesting Account or that of a Subaccount of the requesting Account. Only valid when the Sim resource’s status is new.

Returns:



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
386
387
388
389
390
391
392
393
394
395
# File 'lib/twilio-ruby/rest/supersim/v1/sim.rb', line 359

def (
  unique_name: :unset, 
  status: :unset, 
  fleet: :unset, 
  callback_url: :unset, 
  callback_method: :unset, 
  account_sid: :unset
)

    data = Twilio::Values.of({
        'UniqueName' => unique_name,
        'Status' => status,
        'Fleet' => fleet,
        'CallbackUrl' => callback_url,
        'CallbackMethod' => callback_method,
        'AccountSid' => ,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    sim_instance = SimInstance.new(
        @version,
        response.body,
        sid: @solution[:sid],
    )
    SimInstanceMetadata.new(
        @version,
        sim_instance,
        response.headers,
        response.status_code
    )
end