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

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

Instance Method Summary collapse

Constructor Details

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

Initialize the SharedCostList

Parameters:

  • version (Version)

    Version that contains the resource

  • account_sid (String) (defaults to: nil)

    The account_sid

  • country_code (String) (defaults to: nil)

    The ISO-3166-1 country code of the country.


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

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

Instance Method Details

#eachObject

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


219
220
221
222
223
224
225
226
227
# File 'lib/twilio-ruby/rest/api/v2010/account/available_phone_number/shared_cost.rb', line 219

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

Parameters:

  • target_url (String)

    API-generated URL for the requested results page

Returns:

  • (Page)

    Page of SharedCostInstance


325
326
327
328
329
330
331
# File 'lib/twilio-ruby/rest/api/v2010/account/available_phone_number/shared_cost.rb', line 325

def get_page(target_url)
  response = @version.domain.request(
      'GET',
      target_url
  )
  SharedCostPage.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 SharedCostInstance 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 and 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. 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. 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. 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). Given a phone number, search within the same LATA 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


97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/twilio-ruby/rest/api/v2010/account/available_phone_number/shared_cost.rb', line 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)
  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 SharedCostInstance 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 and 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. 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. 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. 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). Given a phone number, search within the same LATA 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 SharedCostInstance


290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/twilio-ruby/rest/api/v2010/account/available_phone_number/shared_cost.rb', line 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)
  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)

  SharedCostPage.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 SharedCostInstance 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 and 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. 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. 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. 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). Given a phone number, search within the same LATA 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


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/shared_cost.rb', line 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)
  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


335
336
337
# File 'lib/twilio-ruby/rest/api/v2010/account/available_phone_number/shared_cost.rb', line 335

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