Class: Twilio::REST::Api::V2010::AccountContext::AvailablePhoneNumberCountryContext::TollFreeList

Inherits:
ListResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/api/v2010/account/available_phone_number/toll_free.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, account_sid: nil, country_code: nil) ⇒ TollFreeList

Initialize the TollFreeList

Parameters:

  • version (Version)

    Version that contains the resource

  • account_sid (String) (defaults to: nil)

    The 34 character string that uniquely identifies your account.

  • country_code (String) (defaults to: nil)

    The ISO Country code to lookup phone numbers for.



23
24
25
26
27
28
29
# File 'lib/twilio-ruby/rest/api/v2010/account/available_phone_number/toll_free.rb', line 23

def initialize(version, account_sid: nil, country_code: nil)
  super(version)

  # Path Solution
  @solution = {account_sid: , country_code: country_code}
  @uri = "/Accounts/#{@solution[:account_sid]}/AvailablePhoneNumbers/#{@solution[:country_code]}/TollFree.json"
end

Instance Method Details

#eachObject

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



222
223
224
225
226
227
228
229
230
# File 'lib/twilio-ruby/rest/api/v2010/account/available_phone_number/toll_free.rb', line 222

def each
  limits = @version.read_limits

  page = self.page(page_size: limits[:page_size], )

  @version.stream(page,
                  limit: limits[:limit],
                  page_limit: limits[:page_limit]).each {|x| yield x}
end

#get_page(target_url) ⇒ Page

Retrieve a single page of TollFreeInstance records from the API. Request is executed immediately.

Parameters:

  • target_url (String)

    API-generated URL for the requested results page

Returns:

  • (Page)

    Page of TollFreeInstance



332
333
334
335
336
337
338
# File 'lib/twilio-ruby/rest/api/v2010/account/available_phone_number/toll_free.rb', line 332

def get_page(target_url)
  response = @version.domain.request(
      'GET',
      target_url
  )
  TollFreePage.new(@version, response, @solution)
end

#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) ⇒ Array

Lists TollFreeInstance records from the API as a list. Unlike stream(), this operation is eager and will load ‘limit` records into memory before returning.

Parameters:

  • area_code (String) (defaults to: :unset)

    Find phone numbers in the specified area code. (US and Canada only)

  • contains (String) (defaults to: :unset)

    A pattern on which to match phone numbers. Valid characters are ‘’*‘` and `[0-9a-zA-Z]`. The `’*‘` character will match any single digit. See [Example 2](www.twilio.com/docs/api/rest/available-phone-numbers#local-get-basic-example-2) and [Example 3](www.twilio.com/docs/api/rest/available-phone-numbers#local-get-basic-example-3) below. NOTE: Patterns must be at least two characters long.

  • sms_enabled (Boolean) (defaults to: :unset)

    This indicates whether the phone numbers can receive text messages. Possible values are ‘true` or `false`.

  • mms_enabled (Boolean) (defaults to: :unset)

    This indicates whether the phone numbers can receive MMS messages. Possible values are ‘true` or `false`.

  • voice_enabled (Boolean) (defaults to: :unset)

    This indicates whether the phone numbers can receive calls. Possible values are ‘true` or `false`.

  • exclude_all_address_required (Boolean) (defaults to: :unset)

    Indicates whether the response includes phone numbers which require any [Address](www.twilio.com/docs/usage/api/addresses). Possible values are ‘true` or `false`. If not specified, the default is `false`, and results could include phone numbers with an Address required.

  • exclude_local_address_required (Boolean) (defaults to: :unset)

    Indicates whether the response includes phone numbers which require a local [Address](www.twilio.com/docs/usage/api/addresses). Possible values are ‘true` or `false`. If not specified, the default is `false`, and results could include phone numbers with a local Address required.

  • exclude_foreign_address_required (Boolean) (defaults to: :unset)

    Indicates whether the response includes phone numbers which require a foreign [Address](www.twilio.com/docs/usage/api/addresses). Possible values are ‘true` or `false`. If not specified, the default is `false`, and results could include phone numbers with a foreign Address required.

  • beta (Boolean) (defaults to: :unset)

    Include phone numbers new to the Twilio platform. Possible values are either ‘true` or `false`. Default is `true`.

  • near_number (String) (defaults to: :unset)

    Given a phone number, find a geographically close number within ‘Distance` miles. Distance defaults to 25 miles. *Limited to US and Canadian phone numbers.*

  • near_lat_long (String) (defaults to: :unset)

    Given a latitude/longitude pair ‘lat,long` find geographically close numbers within `Distance` miles. *Limited to US and Canadian phone numbers.*

  • distance (String) (defaults to: :unset)

    Specifies the search radius for a ‘Near-` query in miles. If not specified this defaults to 25 miles. Maximum searchable distance is 500 miles. *Limited to US and Canadian phone numbers.*

  • in_postal_code (String) (defaults to: :unset)

    Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. *Limited to US and Canadian phone numbers.*

  • in_region (String) (defaults to: :unset)

    Limit results to a particular region (i.e. State/Province). Given a phone number, search within the same Region as that number. *Limited to US and Canadian phone numbers.*

  • in_rate_center (String) (defaults to: :unset)

    Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires InLata to be set as well. *Limited to US and Canadian phone numbers.*

  • in_lata (String) (defaults to: :unset)

    Limit results to a specific Local access and transport area ([LATA](en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. *Limited to US and Canadian phone numbers.*

  • in_locality (String) (defaults to: :unset)

    Limit results to a particular locality (i.e. City). Given a phone number, search within the same Locality as that number.

  • fax_enabled (Boolean) (defaults to: :unset)

    This indicates whether the phone numbers can receive faxes. Possible values are ‘true` or `false`.

  • limit (Integer) (defaults to: nil)

    Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit

  • page_size (Integer) (defaults to: nil)

    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)

Returns:

  • (Array)

    Array of up to limit results



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/twilio-ruby/rest/api/v2010/account/available_phone_number/toll_free.rb', line 98

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)
  self.stream(
      area_code: area_code,
      contains: contains,
      sms_enabled: sms_enabled,
      mms_enabled: mms_enabled,
      voice_enabled: voice_enabled,
      exclude_all_address_required: exclude_all_address_required,
      exclude_local_address_required: exclude_local_address_required,
      exclude_foreign_address_required: exclude_foreign_address_required,
      beta: beta,
      near_number: near_number,
      near_lat_long: near_lat_long,
      distance: distance,
      in_postal_code: in_postal_code,
      in_region: in_region,
      in_rate_center: in_rate_center,
      in_lata: in_lata,
      in_locality: in_locality,
      fax_enabled: fax_enabled,
      limit: limit,
      page_size: page_size
  ).entries
end

#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) ⇒ Page

Retrieve a single page of TollFreeInstance records from the API. Request is executed immediately.

Parameters:

  • area_code (String) (defaults to: :unset)

    Find phone numbers in the specified area code. (US and Canada only)

  • contains (String) (defaults to: :unset)

    A pattern on which to match phone numbers. Valid characters are ‘’*‘` and `[0-9a-zA-Z]`. The `’*‘` character will match any single digit. See [Example 2](www.twilio.com/docs/api/rest/available-phone-numbers#local-get-basic-example-2) and [Example 3](www.twilio.com/docs/api/rest/available-phone-numbers#local-get-basic-example-3) below. NOTE: Patterns must be at least two characters long.

  • sms_enabled (Boolean) (defaults to: :unset)

    This indicates whether the phone numbers can receive text messages. Possible values are ‘true` or `false`.

  • mms_enabled (Boolean) (defaults to: :unset)

    This indicates whether the phone numbers can receive MMS messages. Possible values are ‘true` or `false`.

  • voice_enabled (Boolean) (defaults to: :unset)

    This indicates whether the phone numbers can receive calls. Possible values are ‘true` or `false`.

  • exclude_all_address_required (Boolean) (defaults to: :unset)

    Indicates whether the response includes phone numbers which require any [Address](www.twilio.com/docs/usage/api/addresses). Possible values are ‘true` or `false`. If not specified, the default is `false`, and results could include phone numbers with an Address required.

  • exclude_local_address_required (Boolean) (defaults to: :unset)

    Indicates whether the response includes phone numbers which require a local [Address](www.twilio.com/docs/usage/api/addresses). Possible values are ‘true` or `false`. If not specified, the default is `false`, and results could include phone numbers with a local Address required.

  • exclude_foreign_address_required (Boolean) (defaults to: :unset)

    Indicates whether the response includes phone numbers which require a foreign [Address](www.twilio.com/docs/usage/api/addresses). Possible values are ‘true` or `false`. If not specified, the default is `false`, and results could include phone numbers with a foreign Address required.

  • beta (Boolean) (defaults to: :unset)

    Include phone numbers new to the Twilio platform. Possible values are either ‘true` or `false`. Default is `true`.

  • near_number (String) (defaults to: :unset)

    Given a phone number, find a geographically close number within ‘Distance` miles. Distance defaults to 25 miles. *Limited to US and Canadian phone numbers.*

  • near_lat_long (String) (defaults to: :unset)

    Given a latitude/longitude pair ‘lat,long` find geographically close numbers within `Distance` miles. *Limited to US and Canadian phone numbers.*

  • distance (String) (defaults to: :unset)

    Specifies the search radius for a ‘Near-` query in miles. If not specified this defaults to 25 miles. Maximum searchable distance is 500 miles. *Limited to US and Canadian phone numbers.*

  • in_postal_code (String) (defaults to: :unset)

    Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. *Limited to US and Canadian phone numbers.*

  • in_region (String) (defaults to: :unset)

    Limit results to a particular region (i.e. State/Province). Given a phone number, search within the same Region as that number. *Limited to US and Canadian phone numbers.*

  • in_rate_center (String) (defaults to: :unset)

    Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires InLata to be set as well. *Limited to US and Canadian phone numbers.*

  • in_lata (String) (defaults to: :unset)

    Limit results to a specific Local access and transport area ([LATA](en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. *Limited to US and Canadian phone numbers.*

  • in_locality (String) (defaults to: :unset)

    Limit results to a particular locality (i.e. City). Given a phone number, search within the same Locality as that number.

  • fax_enabled (Boolean) (defaults to: :unset)

    This indicates whether the phone numbers can receive faxes. Possible values are ‘true` or `false`.

  • page_token (String) (defaults to: :unset)

    PageToken provided by the API

  • page_number (Integer) (defaults to: :unset)

    Page Number, this value is simply for client state

  • page_size (Integer) (defaults to: :unset)

    Number of records to return, defaults to 50

Returns:

  • (Page)

    Page of TollFreeInstance



295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'lib/twilio-ruby/rest/api/v2010/account/available_phone_number/toll_free.rb', line 295

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)
  params = Twilio::Values.of({
      'AreaCode' => area_code,
      'Contains' => contains,
      'SmsEnabled' => sms_enabled,
      'MmsEnabled' => mms_enabled,
      'VoiceEnabled' => voice_enabled,
      'ExcludeAllAddressRequired' => exclude_all_address_required,
      'ExcludeLocalAddressRequired' => exclude_local_address_required,
      'ExcludeForeignAddressRequired' => exclude_foreign_address_required,
      'Beta' => beta,
      'NearNumber' => near_number,
      'NearLatLong' => near_lat_long,
      'Distance' => distance,
      'InPostalCode' => in_postal_code,
      'InRegion' => in_region,
      'InRateCenter' => in_rate_center,
      'InLata' => in_lata,
      'InLocality' => in_locality,
      'FaxEnabled' => fax_enabled,
      'PageToken' => page_token,
      'Page' => page_number,
      'PageSize' => page_size,
  })
  response = @version.page(
      'GET',
      @uri,
      params
  )
  TollFreePage.new(@version, response, @solution)
end

#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) ⇒ Enumerable

Streams TollFreeInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached.

Parameters:

  • area_code (String) (defaults to: :unset)

    Find phone numbers in the specified area code. (US and Canada only)

  • contains (String) (defaults to: :unset)

    A pattern on which to match phone numbers. Valid characters are ‘’*‘` and `[0-9a-zA-Z]`. The `’*‘` character will match any single digit. See [Example 2](www.twilio.com/docs/api/rest/available-phone-numbers#local-get-basic-example-2) and [Example 3](www.twilio.com/docs/api/rest/available-phone-numbers#local-get-basic-example-3) below. NOTE: Patterns must be at least two characters long.

  • sms_enabled (Boolean) (defaults to: :unset)

    This indicates whether the phone numbers can receive text messages. Possible values are ‘true` or `false`.

  • mms_enabled (Boolean) (defaults to: :unset)

    This indicates whether the phone numbers can receive MMS messages. Possible values are ‘true` or `false`.

  • voice_enabled (Boolean) (defaults to: :unset)

    This indicates whether the phone numbers can receive calls. Possible values are ‘true` or `false`.

  • exclude_all_address_required (Boolean) (defaults to: :unset)

    Indicates whether the response includes phone numbers which require any [Address](www.twilio.com/docs/usage/api/addresses). Possible values are ‘true` or `false`. If not specified, the default is `false`, and results could include phone numbers with an Address required.

  • exclude_local_address_required (Boolean) (defaults to: :unset)

    Indicates whether the response includes phone numbers which require a local [Address](www.twilio.com/docs/usage/api/addresses). Possible values are ‘true` or `false`. If not specified, the default is `false`, and results could include phone numbers with a local Address required.

  • exclude_foreign_address_required (Boolean) (defaults to: :unset)

    Indicates whether the response includes phone numbers which require a foreign [Address](www.twilio.com/docs/usage/api/addresses). Possible values are ‘true` or `false`. If not specified, the default is `false`, and results could include phone numbers with a foreign Address required.

  • beta (Boolean) (defaults to: :unset)

    Include phone numbers new to the Twilio platform. Possible values are either ‘true` or `false`. Default is `true`.

  • near_number (String) (defaults to: :unset)

    Given a phone number, find a geographically close number within ‘Distance` miles. Distance defaults to 25 miles. *Limited to US and Canadian phone numbers.*

  • near_lat_long (String) (defaults to: :unset)

    Given a latitude/longitude pair ‘lat,long` find geographically close numbers within `Distance` miles. *Limited to US and Canadian phone numbers.*

  • distance (String) (defaults to: :unset)

    Specifies the search radius for a ‘Near-` query in miles. If not specified this defaults to 25 miles. Maximum searchable distance is 500 miles. *Limited to US and Canadian phone numbers.*

  • in_postal_code (String) (defaults to: :unset)

    Limit results to a particular postal code. Given a phone number, search within the same postal code as that number. *Limited to US and Canadian phone numbers.*

  • in_region (String) (defaults to: :unset)

    Limit results to a particular region (i.e. State/Province). Given a phone number, search within the same Region as that number. *Limited to US and Canadian phone numbers.*

  • in_rate_center (String) (defaults to: :unset)

    Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires InLata to be set as well. *Limited to US and Canadian phone numbers.*

  • in_lata (String) (defaults to: :unset)

    Limit results to a specific Local access and transport area ([LATA](en.wikipedia.org/wiki/Local_access_and_transport_area)). Given a phone number, search within the same [LATA](en.wikipedia.org/wiki/Local_access_and_transport_area) as that number. *Limited to US and Canadian phone numbers.*

  • in_locality (String) (defaults to: :unset)

    Limit results to a particular locality (i.e. City). Given a phone number, search within the same Locality as that number.

  • fax_enabled (Boolean) (defaults to: :unset)

    This indicates whether the phone numbers can receive faxes. Possible values are ‘true` or `false`.

  • limit (Integer) (defaults to: nil)

    Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit.

  • page_size (Integer) (defaults to: nil)

    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)

Returns:

  • (Enumerable)

    Enumerable that will yield up to limit results



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/twilio-ruby/rest/api/v2010/account/available_phone_number/toll_free.rb', line 190

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)
  limits = @version.read_limits(limit, page_size)

  page = self.page(
      area_code: area_code,
      contains: contains,
      sms_enabled: sms_enabled,
      mms_enabled: mms_enabled,
      voice_enabled: voice_enabled,
      exclude_all_address_required: exclude_all_address_required,
      exclude_local_address_required: exclude_local_address_required,
      exclude_foreign_address_required: exclude_foreign_address_required,
      beta: beta,
      near_number: near_number,
      near_lat_long: near_lat_long,
      distance: distance,
      in_postal_code: in_postal_code,
      in_region: in_region,
      in_rate_center: in_rate_center,
      in_lata: in_lata,
      in_locality: in_locality,
      fax_enabled: fax_enabled,
      page_size: limits[:page_size],
  )

  @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
end

#to_sObject

Provide a user friendly representation



342
343
344
# File 'lib/twilio-ruby/rest/api/v2010/account/available_phone_number/toll_free.rb', line 342

def to_s
  '#<Twilio.Api.V2010.TollFreeList>'
end