class Twilio::REST::Voice::V1::DialingPermissionsList::CountryList

PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.

Public Class Methods

new(version) click to toggle source

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

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/voice/v1/dialing_permissions/country.rb
21 def initialize(version)
22   super(version)
23 
24   # Path Solution
25   @solution = {}
26   @uri = "/DialingPermissions/Countries"
27 end

Public Instance Methods

each() { |x| ... } click to toggle source

When passed a block, yields CountryInstance 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/dialing_permissions/country.rb
116 def each
117   limits = @version.read_limits
118 
119   page = self.page(page_size: limits[:page_size], )
120 
121   @version.stream(page,
122                   limit: limits[:limit],
123                   page_limit: limits[:page_limit]).each {|x| yield x}
124 end
get_page(target_url) click to toggle source

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

    # File lib/twilio-ruby/rest/voice/v1/dialing_permissions/country.rb
172 def get_page(target_url)
173   response = @version.domain.request(
174       'GET',
175       target_url
176   )
177   CountryPage.new(@version, response, @solution)
178 end
list(iso_code: :unset, continent: :unset, country_code: :unset, low_risk_numbers_enabled: :unset, high_risk_special_numbers_enabled: :unset, high_risk_tollfraud_numbers_enabled: :unset, limit: nil, page_size: nil) click to toggle source

Lists CountryInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [String] iso_code Filter to retrieve the country permissions by

specifying the {ISO country
code}[https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2]

@param [String] continent Filter to retrieve the country permissions by

specifying the continent

@param [String] country_code Filter the results by specified {country

codes}[https://www.itu.int/itudoc/itu-t/ob-lists/icc/e164_763.html]

@param [Boolean] low_risk_numbers_enabled Filter to retrieve the country

permissions with dialing to low-risk numbers enabled. Can be: `true` or `false`.

@param [Boolean] high_risk_special_numbers_enabled Filter to retrieve the

country permissions with dialing to high-risk special service numbers enabled.
Can be: `true` or `false`

@param [Boolean] high_risk_tollfraud_numbers_enabled Filter to retrieve the

country permissions with dialing to high-risk {toll
fraud}[https://www.twilio.com/learn/voice-and-video/toll-fraud] numbers enabled.
Can be: `true` or `false`.

@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/dialing_permissions/country.rb
56 def list(iso_code: :unset, continent: :unset, country_code: :unset, low_risk_numbers_enabled: :unset, high_risk_special_numbers_enabled: :unset, high_risk_tollfraud_numbers_enabled: :unset, limit: nil, page_size: nil)
57   self.stream(
58       iso_code: iso_code,
59       continent: continent,
60       country_code: country_code,
61       low_risk_numbers_enabled: low_risk_numbers_enabled,
62       high_risk_special_numbers_enabled: high_risk_special_numbers_enabled,
63       high_risk_tollfraud_numbers_enabled: high_risk_tollfraud_numbers_enabled,
64       limit: limit,
65       page_size: page_size
66   ).entries
67 end
page(iso_code: :unset, continent: :unset, country_code: :unset, low_risk_numbers_enabled: :unset, high_risk_special_numbers_enabled: :unset, high_risk_tollfraud_numbers_enabled: :unset, page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of CountryInstance records from the API. Request is executed immediately. @param [String] iso_code Filter to retrieve the country permissions by

specifying the {ISO country
code}[https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2]

@param [String] continent Filter to retrieve the country permissions by

specifying the continent

@param [String] country_code Filter the results by specified {country

codes}[https://www.itu.int/itudoc/itu-t/ob-lists/icc/e164_763.html]

@param [Boolean] low_risk_numbers_enabled Filter to retrieve the country

permissions with dialing to low-risk numbers enabled. Can be: `true` or `false`.

@param [Boolean] high_risk_special_numbers_enabled Filter to retrieve the

country permissions with dialing to high-risk special service numbers enabled.
Can be: `true` or `false`

@param [Boolean] high_risk_tollfraud_numbers_enabled Filter to retrieve the

country permissions with dialing to high-risk {toll
fraud}[https://www.twilio.com/learn/voice-and-video/toll-fraud] numbers enabled.
Can be: `true` or `false`.

@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 CountryInstance

    # File lib/twilio-ruby/rest/voice/v1/dialing_permissions/country.rb
149 def page(iso_code: :unset, continent: :unset, country_code: :unset, low_risk_numbers_enabled: :unset, high_risk_special_numbers_enabled: :unset, high_risk_tollfraud_numbers_enabled: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
150   params = Twilio::Values.of({
151       'IsoCode' => iso_code,
152       'Continent' => continent,
153       'CountryCode' => country_code,
154       'LowRiskNumbersEnabled' => low_risk_numbers_enabled,
155       'HighRiskSpecialNumbersEnabled' => high_risk_special_numbers_enabled,
156       'HighRiskTollfraudNumbersEnabled' => high_risk_tollfraud_numbers_enabled,
157       'PageToken' => page_token,
158       'Page' => page_number,
159       'PageSize' => page_size,
160   })
161 
162   response = @version.page('GET', @uri, params: params)
163 
164   CountryPage.new(@version, response, @solution)
165 end
stream(iso_code: :unset, continent: :unset, country_code: :unset, low_risk_numbers_enabled: :unset, high_risk_special_numbers_enabled: :unset, high_risk_tollfraud_numbers_enabled: :unset, limit: nil, page_size: nil) click to toggle source

Streams CountryInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [String] iso_code Filter to retrieve the country permissions by

specifying the {ISO country
code}[https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2]

@param [String] continent Filter to retrieve the country permissions by

specifying the continent

@param [String] country_code Filter the results by specified {country

codes}[https://www.itu.int/itudoc/itu-t/ob-lists/icc/e164_763.html]

@param [Boolean] low_risk_numbers_enabled Filter to retrieve the country

permissions with dialing to low-risk numbers enabled. Can be: `true` or `false`.

@param [Boolean] high_risk_special_numbers_enabled Filter to retrieve the

country permissions with dialing to high-risk special service numbers enabled.
Can be: `true` or `false`

@param [Boolean] high_risk_tollfraud_numbers_enabled Filter to retrieve the

country permissions with dialing to high-risk {toll
fraud}[https://www.twilio.com/learn/voice-and-video/toll-fraud] numbers enabled.
Can be: `true` or `false`.

@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/dialing_permissions/country.rb
 96 def stream(iso_code: :unset, continent: :unset, country_code: :unset, low_risk_numbers_enabled: :unset, high_risk_special_numbers_enabled: :unset, high_risk_tollfraud_numbers_enabled: :unset, limit: nil, page_size: nil)
 97   limits = @version.read_limits(limit, page_size)
 98 
 99   page = self.page(
100       iso_code: iso_code,
101       continent: continent,
102       country_code: country_code,
103       low_risk_numbers_enabled: low_risk_numbers_enabled,
104       high_risk_special_numbers_enabled: high_risk_special_numbers_enabled,
105       high_risk_tollfraud_numbers_enabled: high_risk_tollfraud_numbers_enabled,
106       page_size: limits[:page_size],
107   )
108 
109   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
110 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/voice/v1/dialing_permissions/country.rb
182 def to_s
183   '#<Twilio.Voice.V1.CountryList>'
184 end