class Twilio::REST::Api::V2010::AccountContext::SipList::DomainList

Public Class Methods

new(version, account_sid: nil) click to toggle source

Initialize the DomainList @param [Version] version Version that contains the resource @param [String] account_sid A 34 character string that uniquely identifies this

resource.

@return [DomainList] DomainList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/api/v2010/account/sip/domain.rb
22 def initialize(version, account_sid: nil)
23   super(version)
24 
25   # Path Solution
26   @solution = {account_sid: account_sid}
27   @uri = "/Accounts/#{@solution[:account_sid]}/SIP/Domains.json"
28 end

Public Instance Methods

create(domain_name: nil, friendly_name: :unset, voice_url: :unset, voice_method: :unset, voice_fallback_url: :unset, voice_fallback_method: :unset, voice_status_callback_url: :unset, voice_status_callback_method: :unset, sip_registration: :unset, emergency_calling_enabled: :unset, secure: :unset, byoc_trunk_sid: :unset, emergency_caller_sid: :unset) click to toggle source

Create the DomainInstance @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 `sip.twilio.com`.

@param [String] friendly_name A descriptive string that you created to describe

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

@param [String] voice_url The URL we should when the domain 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] voice_status_callback_url The URL that we should call to pass

status parameters (such as call ended) to your application.

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

call `voice_status_callback_url`. Can be: `GET` or `POST`.

@param [Boolean] sip_registration Whether to allow SIP Endpoints to register

with the domain to receive calls. Can be `true` or `false`. `true` allows SIP
Endpoints to register with the domain to receive calls, `false` does not.

@param [Boolean] emergency_calling_enabled Whether emergency calling is enabled

for the domain. If enabled, allows emergency calls on the domain from phone
numbers with validated addresses.

@param [Boolean] secure Whether secure SIP is enabled for the domain. If

enabled, TLS will be enforced and SRTP will be negotiated on all incoming calls
to this sip domain.

@param [String] byoc_trunk_sid The SID of the BYOC Trunk(Bring Your Own Carrier)

resource that the Sip Domain will be associated with.

@param [String] emergency_caller_sid Whether an emergency caller sid is

configured for the domain. If present, this phone number will be used as the
callback for the emergency call.

@return [DomainInstance] Created DomainInstance

    # File lib/twilio-ruby/rest/api/v2010/account/sip/domain.rb
143 def create(domain_name: nil, friendly_name: :unset, voice_url: :unset, voice_method: :unset, voice_fallback_url: :unset, voice_fallback_method: :unset, voice_status_callback_url: :unset, voice_status_callback_method: :unset, sip_registration: :unset, emergency_calling_enabled: :unset, secure: :unset, byoc_trunk_sid: :unset, emergency_caller_sid: :unset)
144   data = Twilio::Values.of({
145       'DomainName' => domain_name,
146       'FriendlyName' => friendly_name,
147       'VoiceUrl' => voice_url,
148       'VoiceMethod' => voice_method,
149       'VoiceFallbackUrl' => voice_fallback_url,
150       'VoiceFallbackMethod' => voice_fallback_method,
151       'VoiceStatusCallbackUrl' => voice_status_callback_url,
152       'VoiceStatusCallbackMethod' => voice_status_callback_method,
153       'SipRegistration' => sip_registration,
154       'EmergencyCallingEnabled' => emergency_calling_enabled,
155       'Secure' => secure,
156       'ByocTrunkSid' => byoc_trunk_sid,
157       'EmergencyCallerSid' => emergency_caller_sid,
158   })
159 
160   payload = @version.create('POST', @uri, data: data)
161 
162   DomainInstance.new(@version, payload, account_sid: @solution[:account_sid], )
163 end
each() { |x| ... } click to toggle source

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

   # File lib/twilio-ruby/rest/api/v2010/account/sip/domain.rb
68 def each
69   limits = @version.read_limits
70 
71   page = self.page(page_size: limits[:page_size], )
72 
73   @version.stream(page,
74                   limit: limits[:limit],
75                   page_limit: limits[:page_limit]).each {|x| yield x}
76 end
get_page(target_url) click to toggle source

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

    # File lib/twilio-ruby/rest/api/v2010/account/sip/domain.rb
102 def get_page(target_url)
103   response = @version.domain.request(
104       'GET',
105       target_url
106   )
107   DomainPage.new(@version, response, @solution)
108 end
list(limit: nil, page_size: nil) click to toggle source

Lists DomainInstance 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/api/v2010/account/sip/domain.rb
41 def list(limit: nil, page_size: nil)
42   self.stream(limit: limit, page_size: page_size).entries
43 end
page(page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

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

   # File lib/twilio-ruby/rest/api/v2010/account/sip/domain.rb
85 def page(page_token: :unset, page_number: :unset, page_size: :unset)
86   params = Twilio::Values.of({
87       'PageToken' => page_token,
88       'Page' => page_number,
89       'PageSize' => page_size,
90   })
91 
92   response = @version.page('GET', @uri, params: params)
93 
94   DomainPage.new(@version, response, @solution)
95 end
stream(limit: nil, page_size: nil) click to toggle source

Streams DomainInstance 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/api/v2010/account/sip/domain.rb
56 def stream(limit: nil, page_size: nil)
57   limits = @version.read_limits(limit, page_size)
58 
59   page = self.page(page_size: limits[:page_size], )
60 
61   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
62 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/api/v2010/account/sip/domain.rb
167 def to_s
168   '#<Twilio.Api.V2010.DomainList>'
169 end