class Twilio::REST::Api::V2010::AccountContext::AvailablePhoneNumberCountryContext::TollFreeList
Public Class Methods
Initialize the TollFreeList
@param [Version] version Version
that contains the resource @param [String] account_sid The account_sid @param [String] country_code The
{ISO-3166-1}[https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2] country code of the country.
@return [TollFreeList] TollFreeList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/api/v2010/account/available_phone_number/toll_free.rb 24 def initialize(version, account_sid: nil, country_code: nil) 25 super(version) 26 27 # Path Solution 28 @solution = {account_sid: account_sid, country_code: country_code} 29 @uri = "/Accounts/#{@solution[:account_sid]}/AvailablePhoneNumbers/#{@solution[:country_code]}/TollFree.json" 30 end
Public Instance Methods
When passed a block, yields TollFreeInstance
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/available_phone_number/toll_free.rb 219 def each 220 limits = @version.read_limits 221 222 page = self.page(page_size: limits[:page_size], ) 223 224 @version.stream(page, 225 limit: limits[:limit], 226 page_limit: limits[:page_limit]).each {|x| yield x} 227 end
Retrieve a single page of TollFreeInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of TollFreeInstance
# File lib/twilio-ruby/rest/api/v2010/account/available_phone_number/toll_free.rb 325 def get_page(target_url) 326 response = @version.domain.request( 327 'GET', 328 target_url 329 ) 330 TollFreePage.new(@version, response, @solution) 331 end
Lists TollFreeInstance
records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [String] area_code The area code of the phone numbers to read. Applies to
only phone numbers in the US and Canada.
@param [String] contains The pattern on which to match phone numbers. Valid
characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see {Example 2}[https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2] and {Example 3}[https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3]. If specified, this value must have at least two characters.
@param [Boolean] sms_enabled Whether the phone numbers can receive text
messages. Can be: `true` or `false`.
@param [Boolean] mms_enabled Whether the phone numbers can receive MMS messages.
Can be: `true` or `false`.
@param [Boolean] voice_enabled Whether the phone numbers can receive calls. Can
be: `true` or `false`.
@param [Boolean] exclude_all_address_required Whether to exclude phone numbers
that require an {Address}[https://www.twilio.com/docs/usage/api/address]. Can be: `true` or `false` and the default is `false`.
@param [Boolean] exclude_local_address_required Whether to exclude phone numbers
that require a local {Address}[https://www.twilio.com/docs/usage/api/address]. Can be: `true` or `false` and the default is `false`.
@param [Boolean] exclude_foreign_address_required Whether to exclude phone
numbers that require a foreign {Address}[https://www.twilio.com/docs/usage/api/address]. Can be: `true` or `false` and the default is `false`.
@param [Boolean] beta Whether to read phone numbers that are new to the Twilio
platform. Can be: `true` or `false` and the default is `true`.
@param [String] near_number Given a phone number, find a geographically close
number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
@param [String] near_lat_long Given a latitude/longitude pair `lat,long` find
geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
@param [String] distance The search radius, in miles, for a `near_` query. Can
be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
@param [String] in_postal_code Limit results to a particular postal code. Given
a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
@param [String] in_region Limit results to a particular region, state, or
province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
@param [String] in_rate_center Limit results to a specific rate center, or given
a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
@param [String] in_lata Limit results to a specific local access and transport
area ({LATA}[https://en.wikipedia.org/wiki/Local_access_and_transport_area]). Given a phone number, search within the same {LATA}[https://en.wikipedia.org/wiki/Local_access_and_transport_area] as that number. Applies to only phone numbers in the US and Canada.
@param [String] in_locality Limit results to a particular locality or city.
Given a phone number, search within the same Locality as that number.
@param [Boolean] fax_enabled Whether the phone numbers can receive faxes. 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/api/v2010/account/available_phone_number/toll_free.rb 97 def list(area_code: :unset, contains: :unset, sms_enabled: :unset, mms_enabled: :unset, voice_enabled: :unset, exclude_all_address_required: :unset, exclude_local_address_required: :unset, exclude_foreign_address_required: :unset, beta: :unset, near_number: :unset, near_lat_long: :unset, distance: :unset, in_postal_code: :unset, in_region: :unset, in_rate_center: :unset, in_lata: :unset, in_locality: :unset, fax_enabled: :unset, limit: nil, page_size: nil) 98 self.stream( 99 area_code: area_code, 100 contains: contains, 101 sms_enabled: sms_enabled, 102 mms_enabled: mms_enabled, 103 voice_enabled: voice_enabled, 104 exclude_all_address_required: exclude_all_address_required, 105 exclude_local_address_required: exclude_local_address_required, 106 exclude_foreign_address_required: exclude_foreign_address_required, 107 beta: beta, 108 near_number: near_number, 109 near_lat_long: near_lat_long, 110 distance: distance, 111 in_postal_code: in_postal_code, 112 in_region: in_region, 113 in_rate_center: in_rate_center, 114 in_lata: in_lata, 115 in_locality: in_locality, 116 fax_enabled: fax_enabled, 117 limit: limit, 118 page_size: page_size 119 ).entries 120 end
Retrieve a single page of TollFreeInstance
records from the API. Request
is executed immediately. @param [String] area_code The area code of the phone numbers to read. Applies to
only phone numbers in the US and Canada.
@param [String] contains The pattern on which to match phone numbers. Valid
characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see {Example 2}[https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2] and {Example 3}[https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3]. If specified, this value must have at least two characters.
@param [Boolean] sms_enabled Whether the phone numbers can receive text
messages. Can be: `true` or `false`.
@param [Boolean] mms_enabled Whether the phone numbers can receive MMS messages.
Can be: `true` or `false`.
@param [Boolean] voice_enabled Whether the phone numbers can receive calls. Can
be: `true` or `false`.
@param [Boolean] exclude_all_address_required Whether to exclude phone numbers
that require an {Address}[https://www.twilio.com/docs/usage/api/address]. Can be: `true` or `false` and the default is `false`.
@param [Boolean] exclude_local_address_required Whether to exclude phone numbers
that require a local {Address}[https://www.twilio.com/docs/usage/api/address]. Can be: `true` or `false` and the default is `false`.
@param [Boolean] exclude_foreign_address_required Whether to exclude phone
numbers that require a foreign {Address}[https://www.twilio.com/docs/usage/api/address]. Can be: `true` or `false` and the default is `false`.
@param [Boolean] beta Whether to read phone numbers that are new to the Twilio
platform. Can be: `true` or `false` and the default is `true`.
@param [String] near_number Given a phone number, find a geographically close
number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
@param [String] near_lat_long Given a latitude/longitude pair `lat,long` find
geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
@param [String] distance The search radius, in miles, for a `near_` query. Can
be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
@param [String] in_postal_code Limit results to a particular postal code. Given
a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
@param [String] in_region Limit results to a particular region, state, or
province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
@param [String] in_rate_center Limit results to a specific rate center, or given
a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
@param [String] in_lata Limit results to a specific local access and transport
area ({LATA}[https://en.wikipedia.org/wiki/Local_access_and_transport_area]). Given a phone number, search within the same {LATA}[https://en.wikipedia.org/wiki/Local_access_and_transport_area] as that number. Applies to only phone numbers in the US and Canada.
@param [String] in_locality Limit results to a particular locality or city.
Given a phone number, search within the same Locality as that number.
@param [Boolean] fax_enabled Whether the phone numbers can receive faxes. 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 TollFreeInstance
# File lib/twilio-ruby/rest/api/v2010/account/available_phone_number/toll_free.rb 290 def page(area_code: :unset, contains: :unset, sms_enabled: :unset, mms_enabled: :unset, voice_enabled: :unset, exclude_all_address_required: :unset, exclude_local_address_required: :unset, exclude_foreign_address_required: :unset, beta: :unset, near_number: :unset, near_lat_long: :unset, distance: :unset, in_postal_code: :unset, in_region: :unset, in_rate_center: :unset, in_lata: :unset, in_locality: :unset, fax_enabled: :unset, page_token: :unset, page_number: :unset, page_size: :unset) 291 params = Twilio::Values.of({ 292 'AreaCode' => area_code, 293 'Contains' => contains, 294 'SmsEnabled' => sms_enabled, 295 'MmsEnabled' => mms_enabled, 296 'VoiceEnabled' => voice_enabled, 297 'ExcludeAllAddressRequired' => exclude_all_address_required, 298 'ExcludeLocalAddressRequired' => exclude_local_address_required, 299 'ExcludeForeignAddressRequired' => exclude_foreign_address_required, 300 'Beta' => beta, 301 'NearNumber' => near_number, 302 'NearLatLong' => near_lat_long, 303 'Distance' => distance, 304 'InPostalCode' => in_postal_code, 305 'InRegion' => in_region, 306 'InRateCenter' => in_rate_center, 307 'InLata' => in_lata, 308 'InLocality' => in_locality, 309 'FaxEnabled' => fax_enabled, 310 'PageToken' => page_token, 311 'Page' => page_number, 312 'PageSize' => page_size, 313 }) 314 315 response = @version.page('GET', @uri, params: params) 316 317 TollFreePage.new(@version, response, @solution) 318 end
Streams TollFreeInstance
records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [String] area_code The area code of the phone numbers to read. Applies to
only phone numbers in the US and Canada.
@param [String] contains The pattern on which to match phone numbers. Valid
characters are `*`, `0-9`, `a-z`, and `A-Z`. The `*` character matches any single digit. For examples, see {Example 2}[https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2] and {Example 3}[https://www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3]. If specified, this value must have at least two characters.
@param [Boolean] sms_enabled Whether the phone numbers can receive text
messages. Can be: `true` or `false`.
@param [Boolean] mms_enabled Whether the phone numbers can receive MMS messages.
Can be: `true` or `false`.
@param [Boolean] voice_enabled Whether the phone numbers can receive calls. Can
be: `true` or `false`.
@param [Boolean] exclude_all_address_required Whether to exclude phone numbers
that require an {Address}[https://www.twilio.com/docs/usage/api/address]. Can be: `true` or `false` and the default is `false`.
@param [Boolean] exclude_local_address_required Whether to exclude phone numbers
that require a local {Address}[https://www.twilio.com/docs/usage/api/address]. Can be: `true` or `false` and the default is `false`.
@param [Boolean] exclude_foreign_address_required Whether to exclude phone
numbers that require a foreign {Address}[https://www.twilio.com/docs/usage/api/address]. Can be: `true` or `false` and the default is `false`.
@param [Boolean] beta Whether to read phone numbers that are new to the Twilio
platform. Can be: `true` or `false` and the default is `true`.
@param [String] near_number Given a phone number, find a geographically close
number within `distance` miles. Distance defaults to 25 miles. Applies to only phone numbers in the US and Canada.
@param [String] near_lat_long Given a latitude/longitude pair `lat,long` find
geographically close numbers within `distance` miles. Applies to only phone numbers in the US and Canada.
@param [String] distance The search radius, in miles, for a `near_` query. Can
be up to `500` and the default is `25`. Applies to only phone numbers in the US and Canada.
@param [String] in_postal_code Limit results to a particular postal code. Given
a phone number, search within the same postal code as that number. Applies to only phone numbers in the US and Canada.
@param [String] in_region Limit results to a particular region, state, or
province. Given a phone number, search within the same region as that number. Applies to only phone numbers in the US and Canada.
@param [String] in_rate_center Limit results to a specific rate center, or given
a phone number search within the same rate center as that number. Requires `in_lata` to be set as well. Applies to only phone numbers in the US and Canada.
@param [String] in_lata Limit results to a specific local access and transport
area ({LATA}[https://en.wikipedia.org/wiki/Local_access_and_transport_area]). Given a phone number, search within the same {LATA}[https://en.wikipedia.org/wiki/Local_access_and_transport_area] as that number. Applies to only phone numbers in the US and Canada.
@param [String] in_locality Limit results to a particular locality or city.
Given a phone number, search within the same Locality as that number.
@param [Boolean] fax_enabled Whether the phone numbers can receive faxes. 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/api/v2010/account/available_phone_number/toll_free.rb 187 def stream(area_code: :unset, contains: :unset, sms_enabled: :unset, mms_enabled: :unset, voice_enabled: :unset, exclude_all_address_required: :unset, exclude_local_address_required: :unset, exclude_foreign_address_required: :unset, beta: :unset, near_number: :unset, near_lat_long: :unset, distance: :unset, in_postal_code: :unset, in_region: :unset, in_rate_center: :unset, in_lata: :unset, in_locality: :unset, fax_enabled: :unset, limit: nil, page_size: nil) 188 limits = @version.read_limits(limit, page_size) 189 190 page = self.page( 191 area_code: area_code, 192 contains: contains, 193 sms_enabled: sms_enabled, 194 mms_enabled: mms_enabled, 195 voice_enabled: voice_enabled, 196 exclude_all_address_required: exclude_all_address_required, 197 exclude_local_address_required: exclude_local_address_required, 198 exclude_foreign_address_required: exclude_foreign_address_required, 199 beta: beta, 200 near_number: near_number, 201 near_lat_long: near_lat_long, 202 distance: distance, 203 in_postal_code: in_postal_code, 204 in_region: in_region, 205 in_rate_center: in_rate_center, 206 in_lata: in_lata, 207 in_locality: in_locality, 208 fax_enabled: fax_enabled, 209 page_size: limits[:page_size], 210 ) 211 212 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 213 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/api/v2010/account/available_phone_number/toll_free.rb 335 def to_s 336 '#<Twilio.Api.V2010.TollFreeList>' 337 end