Class: Twilio::REST::Voice::V1::ByocTrunkContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ ByocTrunkContext

Initialize the ByocTrunkContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    The Twilio-provided string that uniquely identifies the BYOC Trunk resource to update.



269
270
271
272
273
274
275
276
277
278
# File 'lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb', line 269

def initialize(version, sid)
    super(version)
    

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

    
end

Instance Method Details

#deleteBoolean

Delete the ByocTrunkInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



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

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 ByocTrunkInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# File 'lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb', line 295

def 

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

#fetchByocTrunkInstance

Fetch the ByocTrunkInstance

Returns:



314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
# File 'lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb', line 314

def fetch

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

#fetch_with_metadataByocTrunkInstance

Fetch the ByocTrunkInstanceMetadata

Returns:



333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# File 'lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb', line 333

def 

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

#inspectObject

Provide a detailed, user friendly representation



477
478
479
480
# File 'lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb', line 477

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

#to_sObject

Provide a user friendly representation



470
471
472
473
# File 'lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb', line 470

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

#update(friendly_name: :unset, voice_url: :unset, voice_method: :unset, voice_fallback_url: :unset, voice_fallback_method: :unset, status_callback_url: :unset, status_callback_method: :unset, cnam_lookup_enabled: :unset, connection_policy_sid: :unset, from_domain_sid: :unset) ⇒ ByocTrunkInstance

Update the ByocTrunkInstance

Parameters:

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

    A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.

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

    The URL we should call when the BYOC Trunk receives a call.

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

    The HTTP method we should use to call voice_url

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

    The URL that we should call when an error occurs while retrieving or executing the TwiML requested by voice_url.

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

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

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

    The URL that we should call to pass status parameters (such as call ended) to your application.

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

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

  • cnam_lookup_enabled (Boolean) (defaults to: :unset)

    Whether Caller ID Name (CNAM) lookup is enabled for the trunk. If enabled, all inbound calls to the BYOC 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.

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

    The SID of the Connection Policy that Twilio will use when routing traffic to your communications infrastructure.

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

    The SID of the SIP Domain that should be used in the From header of originating calls sent to your SIP infrastructure. If your SIP infrastructure allows users to \"call back\" an incoming call, configure this with a [SIP Domain](www.twilio.com/docs/voice/api/sending-sip) to ensure proper routing. If not configured, the from domain will default to \"sip.twilio.com\".

Returns:



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
396
397
398
399
400
401
402
403
404
405
406
# File 'lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb', line 368

def update(
    friendly_name: :unset, 
    voice_url: :unset, 
    voice_method: :unset, 
    voice_fallback_url: :unset, 
    voice_fallback_method: :unset, 
    status_callback_url: :unset, 
    status_callback_method: :unset, 
    cnam_lookup_enabled: :unset, 
    connection_policy_sid: :unset, 
    from_domain_sid: :unset
)

    data = Twilio::Values.of({
        'FriendlyName' => friendly_name,
        'VoiceUrl' => voice_url,
        'VoiceMethod' => voice_method,
        'VoiceFallbackUrl' => voice_fallback_url,
        'VoiceFallbackMethod' => voice_fallback_method,
        'StatusCallbackUrl' => status_callback_url,
        'StatusCallbackMethod' => status_callback_method,
        'CnamLookupEnabled' => cnam_lookup_enabled,
        'ConnectionPolicySid' => connection_policy_sid,
        'FromDomainSid' => from_domain_sid,
    })

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

#update_with_metadata(friendly_name: :unset, voice_url: :unset, voice_method: :unset, voice_fallback_url: :unset, voice_fallback_method: :unset, status_callback_url: :unset, status_callback_method: :unset, cnam_lookup_enabled: :unset, connection_policy_sid: :unset, from_domain_sid: :unset) ⇒ ByocTrunkInstance

Update the ByocTrunkInstanceMetadata

Parameters:

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

    A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.

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

    The URL we should call when the BYOC Trunk receives a call.

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

    The HTTP method we should use to call voice_url

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

    The URL that we should call when an error occurs while retrieving or executing the TwiML requested by voice_url.

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

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

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

    The URL that we should call to pass status parameters (such as call ended) to your application.

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

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

  • cnam_lookup_enabled (Boolean) (defaults to: :unset)

    Whether Caller ID Name (CNAM) lookup is enabled for the trunk. If enabled, all inbound calls to the BYOC 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.

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

    The SID of the Connection Policy that Twilio will use when routing traffic to your communications infrastructure.

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

    The SID of the SIP Domain that should be used in the From header of originating calls sent to your SIP infrastructure. If your SIP infrastructure allows users to \"call back\" an incoming call, configure this with a [SIP Domain](www.twilio.com/docs/voice/api/sending-sip) to ensure proper routing. If not configured, the from domain will default to \"sip.twilio.com\".

Returns:



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
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
# File 'lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb', line 421

def (
  friendly_name: :unset, 
  voice_url: :unset, 
  voice_method: :unset, 
  voice_fallback_url: :unset, 
  voice_fallback_method: :unset, 
  status_callback_url: :unset, 
  status_callback_method: :unset, 
  cnam_lookup_enabled: :unset, 
  connection_policy_sid: :unset, 
  from_domain_sid: :unset
)

    data = Twilio::Values.of({
        'FriendlyName' => friendly_name,
        'VoiceUrl' => voice_url,
        'VoiceMethod' => voice_method,
        'VoiceFallbackUrl' => voice_fallback_url,
        'VoiceFallbackMethod' => voice_fallback_method,
        'StatusCallbackUrl' => status_callback_url,
        'StatusCallbackMethod' => status_callback_method,
        'CnamLookupEnabled' => cnam_lookup_enabled,
        'ConnectionPolicySid' => connection_policy_sid,
        'FromDomainSid' => from_domain_sid,
    })

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