class Twilio::REST::Voice::V1::ByocTrunkList

Public Class Methods

new(version) click to toggle source

Initialize the ByocTrunkList @param [Version] version Version that contains the resource @return [ByocTrunkList] ByocTrunkList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb
18 def initialize(version)
19   super(version)
20 
21   # Path Solution
22   @solution = {}
23   @uri = "/ByocTrunks"
24 end

Public Instance Methods

create(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) click to toggle source

Create the ByocTrunkInstance @param [String] friendly_name A descriptive string that you create to describe

the resource. It is not unique and can be up to 255 characters long.

@param [String] voice_url The URL we should call when the BYOC Trunk receives a

call.

@param [String] voice_method The HTTP method we should use to call `voice_url`.

Can be: `GET` or `POST`.

@param [String] voice_fallback_url The URL that we should call when an error

occurs while retrieving or executing the TwiML from `voice_url`.

@param [String] voice_fallback_method The HTTP method we should use to call

`voice_fallback_url`. Can be: `GET` or `POST`.

@param [String] status_callback_url The URL that we should call to pass status

parameters (such as call ended) to your application.

@param [String] status_callback_method The HTTP method we should use to call

`status_callback_url`. Can be: `GET` or `POST`.

@param [Boolean] cnam_lookup_enabled 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}[https://www.twilio.com/docs/sip-trunking#CNAM] for more information.

@param [String] connection_policy_sid The SID of the Connection Policy that

Twilio will use when routing traffic to your communications infrastructure.

@param [String] from_domain_sid 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}[https://www.twilio.com/docs/voice/api/sending-sip] to ensure
proper routing. If not configured, the from domain will default to
"sip.twilio.com".

@return [ByocTrunkInstance] Created ByocTrunkInstance

   # File lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb
56 def create(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)
57   data = Twilio::Values.of({
58       'FriendlyName' => friendly_name,
59       'VoiceUrl' => voice_url,
60       'VoiceMethod' => voice_method,
61       'VoiceFallbackUrl' => voice_fallback_url,
62       'VoiceFallbackMethod' => voice_fallback_method,
63       'StatusCallbackUrl' => status_callback_url,
64       'StatusCallbackMethod' => status_callback_method,
65       'CnamLookupEnabled' => cnam_lookup_enabled,
66       'ConnectionPolicySid' => connection_policy_sid,
67       'FromDomainSid' => from_domain_sid,
68   })
69 
70   payload = @version.create('POST', @uri, data: data)
71 
72   ByocTrunkInstance.new(@version, payload, )
73 end
each() { |x| ... } click to toggle source

When passed a block, yields ByocTrunkInstance records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.

    # File lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb
113 def each
114   limits = @version.read_limits
115 
116   page = self.page(page_size: limits[:page_size], )
117 
118   @version.stream(page,
119                   limit: limits[:limit],
120                   page_limit: limits[:page_limit]).each {|x| yield x}
121 end
get_page(target_url) click to toggle source

Retrieve a single page of ByocTrunkInstance records from the API. Request is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page of ByocTrunkInstance

    # File lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb
147 def get_page(target_url)
148   response = @version.domain.request(
149       'GET',
150       target_url
151   )
152   ByocTrunkPage.new(@version, response, @solution)
153 end
list(limit: nil, page_size: nil) click to toggle source

Lists ByocTrunkInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [Integer] limit Upper limit for the number of records to return. stream()

guarantees to never return more than limit.  Default is no limit

@param [Integer] page_size Number of records to fetch per request, when

not set will use the default value of 50 records.  If no page_size is defined
but a limit is defined, stream() will attempt to read the limit with the most
efficient page size, i.e. min(limit, 1000)

@return [Array] Array of up to limit results

   # File lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb
86 def list(limit: nil, page_size: nil)
87   self.stream(limit: limit, page_size: page_size).entries
88 end
page(page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of ByocTrunkInstance records from the API. Request is executed immediately. @param [String] page_token PageToken provided by the API @param [Integer] page_number Page Number, this value is simply for client state @param [Integer] page_size Number of records to return, defaults to 50 @return [Page] Page of ByocTrunkInstance

    # File lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb
130 def page(page_token: :unset, page_number: :unset, page_size: :unset)
131   params = Twilio::Values.of({
132       'PageToken' => page_token,
133       'Page' => page_number,
134       'PageSize' => page_size,
135   })
136 
137   response = @version.page('GET', @uri, params: params)
138 
139   ByocTrunkPage.new(@version, response, @solution)
140 end
stream(limit: nil, page_size: nil) click to toggle source

Streams ByocTrunkInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [Integer] limit Upper limit for the number of records to return. stream()

guarantees to never return more than limit. Default is no limit.

@param [Integer] page_size Number of records to fetch per request, when

not set will use the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the limit with the most
efficient page size, i.e. min(limit, 1000)

@return [Enumerable] Enumerable that will yield up to limit results

    # File lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb
101 def stream(limit: nil, page_size: nil)
102   limits = @version.read_limits(limit, page_size)
103 
104   page = self.page(page_size: limits[:page_size], )
105 
106   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
107 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb
157 def to_s
158   '#<Twilio.Voice.V1.ByocTrunkList>'
159 end