Class: Twilio::REST::Trunking::V1::TrunkContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/trunking/v1/trunk.rb,
lib/twilio-ruby/rest/trunking/v1/trunk/recording.rb,
lib/twilio-ruby/rest/trunking/v1/trunk/phone_number.rb,
lib/twilio-ruby/rest/trunking/v1/trunk/credential_list.rb,
lib/twilio-ruby/rest/trunking/v1/trunk/origination_url.rb,
lib/twilio-ruby/rest/trunking/v1/trunk/ip_access_control_list.rb

Defined Under Namespace

Classes: CredentialListContext, CredentialListInstance, CredentialListInstanceMetadata, CredentialListList, CredentialListListResponse, CredentialListPage, CredentialListPageMetadata, IpAccessControlListContext, IpAccessControlListInstance, IpAccessControlListInstanceMetadata, IpAccessControlListList, IpAccessControlListListResponse, IpAccessControlListPage, IpAccessControlListPageMetadata, OriginationUrlContext, OriginationUrlInstance, OriginationUrlInstanceMetadata, OriginationUrlList, OriginationUrlListResponse, OriginationUrlPage, OriginationUrlPageMetadata, PhoneNumberContext, PhoneNumberInstance, PhoneNumberInstanceMetadata, PhoneNumberList, PhoneNumberListResponse, PhoneNumberPage, PhoneNumberPageMetadata, RecordingContext, RecordingInstance, RecordingInstanceMetadata, RecordingList, RecordingListResponse, RecordingPage, RecordingPageMetadata

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ TrunkContext

Initialize the TrunkContext

Parameters:

  • Version that contains the resource

  • The unique string that we created to identify the OriginationUrl resource to update.



257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 257

def initialize(version, sid)
    super(version)
    

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

    # Dependents
    @recordings = nil
    @credentials_lists = nil
    @ip_access_control_lists = nil
    @phone_numbers = nil
    @origination_urls = nil
end

Instance Method Details

#credentials_lists(sid = :unset) ⇒ CredentialListList, CredentialListContext

Access the credentials_lists

Returns:

  • if sid was passed.

Raises:



462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 462

def credentials_lists(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return CredentialListContext.new(@version, @solution[:sid],sid )
    end

    unless @credentials_lists
        @credentials_lists = CredentialListList.new(
            @version, trunk_sid: @solution[:sid], )
    end

 @credentials_lists
end

#deleteBoolean

Delete the TrunkInstance

Returns:

  • True if delete succeeds, false otherwise



275
276
277
278
279
280
281
282
283
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 275

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    

    @version.delete('DELETE', @uri, headers: headers)
end

#delete_with_metadataBoolean

Delete the TrunkInstanceMetadata

Returns:

  • True if delete succeeds, false otherwise



288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 288

def 

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

#fetchTrunkInstance

Fetch the TrunkInstance

Returns:

  • Fetched TrunkInstance



307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 307

def fetch

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

#fetch_with_metadataTrunkInstance

Fetch the TrunkInstanceMetadata

Returns:

  • Fetched TrunkInstance



326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 326

def 

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

#inspectObject

Provide a detailed, user friendly representation



544
545
546
547
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 544

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

#ip_access_control_lists(sid = :unset) ⇒ IpAccessControlListList, IpAccessControlListContext

Access the ip_access_control_lists

Returns:

  • if sid was passed.

Raises:



481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 481

def ip_access_control_lists(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return IpAccessControlListContext.new(@version, @solution[:sid],sid )
    end

    unless @ip_access_control_lists
        @ip_access_control_lists = IpAccessControlListList.new(
            @version, trunk_sid: @solution[:sid], )
    end

 @ip_access_control_lists
end

#origination_urls(sid = :unset) ⇒ OriginationUrlList, OriginationUrlContext

Access the origination_urls

Returns:

  • if sid was passed.

Raises:



519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 519

def origination_urls(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return OriginationUrlContext.new(@version, @solution[:sid],sid )
    end

    unless @origination_urls
        @origination_urls = OriginationUrlList.new(
            @version, trunk_sid: @solution[:sid], )
    end

 @origination_urls
end

#phone_numbers(sid = :unset) ⇒ PhoneNumberList, PhoneNumberContext

Access the phone_numbers

Returns:

  • if sid was passed.

Raises:



500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 500

def phone_numbers(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return PhoneNumberContext.new(@version, @solution[:sid],sid )
    end

    unless @phone_numbers
        @phone_numbers = PhoneNumberList.new(
            @version, trunk_sid: @solution[:sid], )
    end

 @phone_numbers
end

#recordingsRecordingList, RecordingContext

Access the recordings

Returns:



452
453
454
455
456
457
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 452

def recordings
    RecordingContext.new(
            @version,
            @solution[:sid]
            )
end

#to_sObject

Provide a user friendly representation



537
538
539
540
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 537

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

#update(friendly_name: :unset, domain_name: :unset, disaster_recovery_url: :unset, disaster_recovery_method: :unset, transfer_mode: :unset, secure: :unset, cnam_lookup_enabled: :unset, transfer_caller_id: :unset) ⇒ TrunkInstance

Update the TrunkInstance

Parameters:

  • (defaults to: :unset)

    A descriptive string that you create to describe the resource. It can be up to 64 characters long.

  • (defaults to: :unset)

    The unique address you reserve on Twilio to which you route your SIP traffic. Domain names can contain letters, digits, and - and must end with pstn.twilio.com. See [Termination Settings](www.twilio.com/docs/sip-trunking#termination) for more information.

  • (defaults to: :unset)

    The URL we should call using the disaster_recovery_method if an error occurs while sending SIP traffic towards the configured Origination URL. We retrieve TwiML from the URL and execute the instructions like any other normal TwiML call. See [Disaster Recovery](www.twilio.com/docs/sip-trunking#disaster-recovery) for more information.

  • (defaults to: :unset)

    The HTTP method we should use to call the disaster_recovery_url. Can be: GET or POST.

  • (defaults to: :unset)
  • (defaults to: :unset)

    Whether Secure Trunking is enabled for the trunk. If enabled, all calls going through the trunk will be secure using SRTP for media and TLS for signaling. If disabled, then RTP will be used for media. See [Secure Trunking](www.twilio.com/docs/sip-trunking#securetrunking) for more information.

  • (defaults to: :unset)

    Whether Caller ID Name (CNAM) lookup should be enabled for the trunk. If enabled, all inbound calls to the SIP Trunk from the United States and Canada automatically perform a CNAM Lookup and display Caller ID data on your phone. See [CNAM Lookups](www.twilio.com/docs/sip-trunking#CNAM) for more information.

  • (defaults to: :unset)

Returns:

  • Updated TrunkInstance



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
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 359

def update(
    friendly_name: :unset, 
    domain_name: :unset, 
    disaster_recovery_url: :unset, 
    disaster_recovery_method: :unset, 
    transfer_mode: :unset, 
    secure: :unset, 
    cnam_lookup_enabled: :unset, 
    transfer_caller_id: :unset
)

    data = Twilio::Values.of({
        'FriendlyName' => friendly_name,
        'DomainName' => domain_name,
        'DisasterRecoveryUrl' => disaster_recovery_url,
        'DisasterRecoveryMethod' => disaster_recovery_method,
        'TransferMode' => transfer_mode,
        'Secure' => secure,
        'CnamLookupEnabled' => cnam_lookup_enabled,
        'TransferCallerId' => transfer_caller_id,
    })

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

#update_with_metadata(friendly_name: :unset, domain_name: :unset, disaster_recovery_url: :unset, disaster_recovery_method: :unset, transfer_mode: :unset, secure: :unset, cnam_lookup_enabled: :unset, transfer_caller_id: :unset) ⇒ TrunkInstance

Update the TrunkInstanceMetadata

Parameters:

  • (defaults to: :unset)

    A descriptive string that you create to describe the resource. It can be up to 64 characters long.

  • (defaults to: :unset)

    The unique address you reserve on Twilio to which you route your SIP traffic. Domain names can contain letters, digits, and - and must end with pstn.twilio.com. See [Termination Settings](www.twilio.com/docs/sip-trunking#termination) for more information.

  • (defaults to: :unset)

    The URL we should call using the disaster_recovery_method if an error occurs while sending SIP traffic towards the configured Origination URL. We retrieve TwiML from the URL and execute the instructions like any other normal TwiML call. See [Disaster Recovery](www.twilio.com/docs/sip-trunking#disaster-recovery) for more information.

  • (defaults to: :unset)

    The HTTP method we should use to call the disaster_recovery_url. Can be: GET or POST.

  • (defaults to: :unset)
  • (defaults to: :unset)

    Whether Secure Trunking is enabled for the trunk. If enabled, all calls going through the trunk will be secure using SRTP for media and TLS for signaling. If disabled, then RTP will be used for media. See [Secure Trunking](www.twilio.com/docs/sip-trunking#securetrunking) for more information.

  • (defaults to: :unset)

    Whether Caller ID Name (CNAM) lookup should be enabled for the trunk. If enabled, all inbound calls to the SIP Trunk from the United States and Canada automatically perform a CNAM Lookup and display Caller ID data on your phone. See [CNAM Lookups](www.twilio.com/docs/sip-trunking#CNAM) for more information.

  • (defaults to: :unset)

Returns:

  • Updated TrunkInstance



406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
# File 'lib/twilio-ruby/rest/trunking/v1/trunk.rb', line 406

def (
  friendly_name: :unset, 
  domain_name: :unset, 
  disaster_recovery_url: :unset, 
  disaster_recovery_method: :unset, 
  transfer_mode: :unset, 
  secure: :unset, 
  cnam_lookup_enabled: :unset, 
  transfer_caller_id: :unset
)

    data = Twilio::Values.of({
        'FriendlyName' => friendly_name,
        'DomainName' => domain_name,
        'DisasterRecoveryUrl' => disaster_recovery_url,
        'DisasterRecoveryMethod' => disaster_recovery_method,
        'TransferMode' => transfer_mode,
        'Secure' => secure,
        'CnamLookupEnabled' => cnam_lookup_enabled,
        'TransferCallerId' => transfer_caller_id,
    })

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