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

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

Instance Method Summary collapse

Constructor Details

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

Initialize the NationalList

Parameters:

  • version (Version)

    Version that contains the resource



29
30
31
32
33
34
35
36
# File 'lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/national.rb', line 29

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]}/National.json"
    
end

Instance Method Details

#eachObject

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



210
211
212
213
214
215
216
217
218
# File 'lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/national.rb', line 210

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 NationalInstance records from the API. Request is executed immediately.

Parameters:

  • target_url (String)

    API-generated URL for the requested results page

Returns:

  • (Page)

    Page of NationalInstance



283
284
285
286
287
288
289
# File 'lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/national.rb', line 283

def get_page(target_url)
    response = @version.domain.request(
        'GET',
        target_url
    )
NationalPage.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 NationalInstance 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)

    The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.

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

    Matching pattern to identify phone numbers. This pattern can be between 2 and 16 characters long and allows all digits (0-9) and all non-diacritic latin alphabet letters (a-z, A-Z). It accepts four meta-characters: ‘*`, `%`, `+`, `$`. The `*` and `%` meta-characters can appear multiple times in the pattern. To match wildcards at the beginning or end of the pattern, use `*` to match any single character or `%` to match a sequence of characters. If you use the wildcard patterns, it must include at least two non-meta-characters, and wildcards cannot be used between non-meta-characters. To match the beginning of a pattern, start the pattern with `+`. To match the end of the pattern, append the pattern with `$`. These meta-characters can’t be adjacent to each other.

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

    Whether the phone numbers can receive text messages. Can be: true or false.

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

    Whether the phone numbers can receive MMS messages. Can be: true or false.

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

    Whether the phone numbers can receive calls. Can be: true or false.

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

    Whether to exclude phone numbers that require an [Address](www.twilio.com/docs/usage/api/address). Can be: true or false and the default is false.

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

    Whether to exclude phone numbers that require a local [Address](www.twilio.com/docs/usage/api/address). Can be: true or false and the default is false.

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

    Whether to exclude phone numbers that require a foreign [Address](www.twilio.com/docs/usage/api/address). Can be: true or false and the default is false.

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

    Whether to read phone numbers that are new to the Twilio platform. Can be: true or false and the 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. Applies to only phone numbers in the US and Canada.

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

    Given a latitude/longitude pair ‘lat,long` find geographically close numbers within distance miles. Applies to only phone numbers in the US and Canada.

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

    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.

  • 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. Applies to only phone numbers in the US and Canada.

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

    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.

  • 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 in_lata to be set as well. Applies to only phone numbers in the US and Canada.

  • 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. Applies to only phone numbers in the US and Canada.

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

    Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.

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

    Whether the phone numbers can receive faxes. Can be: 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



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/national.rb', line 67

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

#list_with_metadata(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

Returns Array of up to limit results.

Parameters:

  • 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



175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/national.rb', line 175

def (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)
    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,
        
        'PageSize' => limits[:page_size],
    });
    headers = Twilio::Values.of({})

    response = @version.page('GET', @uri, params: params, headers: headers)

    .new(@version, response, @solution, limits[:limit])
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 NationalInstance records from the API. Request is executed immediately.

Parameters:

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

    The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.

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

    Matching pattern to identify phone numbers. This pattern can be between 2 and 16 characters long and allows all digits (0-9) and all non-diacritic latin alphabet letters (a-z, A-Z). It accepts four meta-characters: ‘*`, `%`, `+`, `$`. The `*` and `%` meta-characters can appear multiple times in the pattern. To match wildcards at the beginning or end of the pattern, use `*` to match any single character or `%` to match a sequence of characters. If you use the wildcard patterns, it must include at least two non-meta-characters, and wildcards cannot be used between non-meta-characters. To match the beginning of a pattern, start the pattern with `+`. To match the end of the pattern, append the pattern with `$`. These meta-characters can’t be adjacent to each other.

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

    Whether the phone numbers can receive text messages. Can be: true or false.

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

    Whether the phone numbers can receive MMS messages. Can be: true or false.

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

    Whether the phone numbers can receive calls. Can be: true or false.

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

    Whether to exclude phone numbers that require an [Address](www.twilio.com/docs/usage/api/address). Can be: true or false and the default is false.

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

    Whether to exclude phone numbers that require a local [Address](www.twilio.com/docs/usage/api/address). Can be: true or false and the default is false.

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

    Whether to exclude phone numbers that require a foreign [Address](www.twilio.com/docs/usage/api/address). Can be: true or false and the default is false.

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

    Whether to read phone numbers that are new to the Twilio platform. Can be: true or false and the 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. Applies to only phone numbers in the US and Canada.

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

    Given a latitude/longitude pair ‘lat,long` find geographically close numbers within distance miles. Applies to only phone numbers in the US and Canada.

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

    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.

  • 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. Applies to only phone numbers in the US and Canada.

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

    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.

  • 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 in_lata to be set as well. Applies to only phone numbers in the US and Canada.

  • 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. Applies to only phone numbers in the US and Canada.

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

    Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.

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

    Whether the phone numbers can receive faxes. Can be: 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 NationalInstance



245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# File 'lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/national.rb', line 245

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,
    })
    headers = Twilio::Values.of({})
    
    

    response = @version.page('GET', @uri, params: params, headers: headers)

    NationalPage.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 Instance 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)

    The area code of the phone numbers to read. Applies to only phone numbers in the US and Canada.

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

    Matching pattern to identify phone numbers. This pattern can be between 2 and 16 characters long and allows all digits (0-9) and all non-diacritic latin alphabet letters (a-z, A-Z). It accepts four meta-characters: ‘*`, `%`, `+`, `$`. The `*` and `%` meta-characters can appear multiple times in the pattern. To match wildcards at the beginning or end of the pattern, use `*` to match any single character or `%` to match a sequence of characters. If you use the wildcard patterns, it must include at least two non-meta-characters, and wildcards cannot be used between non-meta-characters. To match the beginning of a pattern, start the pattern with `+`. To match the end of the pattern, append the pattern with `$`. These meta-characters can’t be adjacent to each other.

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

    Whether the phone numbers can receive text messages. Can be: true or false.

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

    Whether the phone numbers can receive MMS messages. Can be: true or false.

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

    Whether the phone numbers can receive calls. Can be: true or false.

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

    Whether to exclude phone numbers that require an [Address](www.twilio.com/docs/usage/api/address). Can be: true or false and the default is false.

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

    Whether to exclude phone numbers that require a local [Address](www.twilio.com/docs/usage/api/address). Can be: true or false and the default is false.

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

    Whether to exclude phone numbers that require a foreign [Address](www.twilio.com/docs/usage/api/address). Can be: true or false and the default is false.

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

    Whether to read phone numbers that are new to the Twilio platform. Can be: true or false and the 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. Applies to only phone numbers in the US and Canada.

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

    Given a latitude/longitude pair ‘lat,long` find geographically close numbers within distance miles. Applies to only phone numbers in the US and Canada.

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

    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.

  • 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. Applies to only phone numbers in the US and Canada.

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

    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.

  • 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 in_lata to be set as well. Applies to only phone numbers in the US and Canada.

  • 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. Applies to only phone numbers in the US and Canada.

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

    Limit results to a particular locality or city. Given a phone number, search within the same Locality as that number.

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

    Whether the phone numbers can receive faxes. Can be: 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



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/national.rb', line 121

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



294
295
296
# File 'lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/national.rb', line 294

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