class Twilio::REST::Trunking::V1::TrunkList

Public Class Methods

new(version) click to toggle source

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

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

Public Instance Methods

create(friendly_name: :unset, domain_name: :unset, disaster_recovery_url: :unset, disaster_recovery_method: :unset, transfer_mode: :unset, secure: :unset, cnam_lookup_enabled: :unset) click to toggle source

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

the resource. It can be up to 64 characters long.

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

@param [String] disaster_recovery_url 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}[https://www.twilio.com/docs/sip-trunking#disaster-recovery] for more
information.

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

the `disaster_recovery_url`. Can be: `GET` or `POST`.

@param [trunk.TransferSetting] transfer_mode The call transfer settings for the

trunk. Can be: `enable-all`, `sip-only` and `disable-all`. See
{Transfer}[https://www.twilio.com/docs/sip-trunking/call-transfer] for more
information.

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

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

@return [TrunkInstance] Created TrunkInstance

   # File lib/twilio-ruby/rest/trunking/v1/trunk.rb
58 def create(friendly_name: :unset, domain_name: :unset, disaster_recovery_url: :unset, disaster_recovery_method: :unset, transfer_mode: :unset, secure: :unset, cnam_lookup_enabled: :unset)
59   data = Twilio::Values.of({
60       'FriendlyName' => friendly_name,
61       'DomainName' => domain_name,
62       'DisasterRecoveryUrl' => disaster_recovery_url,
63       'DisasterRecoveryMethod' => disaster_recovery_method,
64       'TransferMode' => transfer_mode,
65       'Secure' => secure,
66       'CnamLookupEnabled' => cnam_lookup_enabled,
67   })
68 
69   payload = @version.create('POST', @uri, data: data)
70 
71   TrunkInstance.new(@version, payload, )
72 end
each() { |x| ... } click to toggle source

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

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

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

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

Lists TrunkInstance 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/trunking/v1/trunk.rb
85 def list(limit: nil, page_size: nil)
86   self.stream(limit: limit, page_size: page_size).entries
87 end
page(page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of TrunkInstance 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 TrunkInstance

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

Streams TrunkInstance 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/trunking/v1/trunk.rb
100 def stream(limit: nil, page_size: nil)
101   limits = @version.read_limits(limit, page_size)
102 
103   page = self.page(page_size: limits[:page_size], )
104 
105   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
106 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/trunking/v1/trunk.rb
156 def to_s
157   '#<Twilio.Trunking.V1.TrunkList>'
158 end