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



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

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.



150
151
152
153
154
155
156
157
158
# File 'lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/national.rb', line 150

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



220
221
222
223
224
225
226
# File 'lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/national.rb', line 220

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)

    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](www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.

  • 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



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

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 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)

    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](www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.

  • 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



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/national.rb', line 185

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: params)

    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)

    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](www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-2) and [Example 3](www.twilio.com/docs/phone-numbers/api/availablephonenumber-resource#local-get-basic-example-3). If specified, this value must have at least two characters.

  • 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



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

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



231
232
233
# File 'lib/twilio-ruby/rest/api/v2010/account/available_phone_number_country/national.rb', line 231

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