class Twilio::REST::Api::V2010::AccountContext::IncomingPhoneNumberList
Public Class Methods
Initialize the IncomingPhoneNumberList
@param [Version] version Version
that contains the resource @param [String] account_sid The SID of the
{Account}[https://www.twilio.com/docs/iam/api/account] that created this IncomingPhoneNumber resource.
@return [IncomingPhoneNumberList] IncomingPhoneNumberList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb 22 def initialize(version, account_sid: nil) 23 super(version) 24 25 # Path Solution 26 @solution = {account_sid: account_sid} 27 @uri = "/Accounts/#{@solution[:account_sid]}/IncomingPhoneNumbers.json" 28 29 # Components 30 @local = nil 31 @mobile = nil 32 @toll_free = nil 33 end
Public Instance Methods
Create the IncomingPhoneNumberInstance
@param [String] api_version The API version to use for incoming calls made to
the new phone number. The default is `2010-04-01`.
@param [String] friendly_name A descriptive string that you created to describe
the new phone number. It can be up to 64 characters long. By default, this is a formatted version of the new phone number.
@param [String] sms_application_sid The SID of the application that should
handle SMS messages sent to the new phone number. If an `sms_application_sid` is present, we ignore all of the `sms_*_url` urls and use those set on the application.
@param [String] sms_fallback_method The HTTP
method that we should use to call
`sms_fallback_url`. Can be: `GET` or `POST` and defaults to `POST`.
@param [String] sms_fallback_url The URL that we should call when an error
occurs while requesting or executing the TwiML defined by `sms_url`.
@param [String] sms_method The HTTP
method that we should use to call `sms_url`.
Can be: `GET` or `POST` and defaults to `POST`.
@param [String] sms_url The URL we should call when the new phone number
receives an incoming SMS message.
@param [String] status_callback The URL we should call using the
`status_callback_method` to send status information to your application.
@param [String] status_callback_method The HTTP
method we should use to call
`status_callback`. Can be: `GET` or `POST` and defaults to `POST`.
@param [String] voice_application_sid The SID of the application we should use
to handle calls to the new phone number. If a `voice_application_sid` is present, we ignore all of the voice urls and use only those set on the application. Setting a `voice_application_sid` will automatically delete your `trunk_sid` and vice versa.
@param [Boolean] voice_caller_id_lookup Whether to lookup the caller's name from
the CNAM database and post it to your app. Can be: `true` or `false` and defaults to `false`.
@param [String] voice_fallback_method The HTTP
method that we should use to call
`voice_fallback_url`. Can be: `GET` or `POST` and defaults to `POST`.
@param [String] voice_fallback_url The URL that we should call when an error
occurs retrieving or executing the TwiML requested by `url`.
@param [String] voice_method The HTTP
method that we should use to call
`voice_url`. Can be: `GET` or `POST` and defaults to `POST`.
@param [String] voice_url The URL that we should call to answer a call to the
new phone number. The `voice_url` will not be called if a `voice_application_sid` or a `trunk_sid` is set.
@param [incoming_phone_number.EmergencyStatus] emergency_status The
configuration status parameter that determines whether the new phone number is enabled for emergency calling.
@param [String] emergency_address_sid The SID of the emergency address
configuration to use for emergency calling from the new phone number.
@param [String] trunk_sid The SID of the Trunk we should use to handle calls to
the new phone number. If a `trunk_sid` is present, we ignore all of the voice urls and voice applications and use only those set on the Trunk. Setting a `trunk_sid` will automatically delete your `voice_application_sid` and vice versa.
@param [String] identity_sid The SID of the Identity resource that we should
associate with the new phone number. Some regions require an identity to meet local regulations.
@param [String] address_sid The SID of the Address resource we should associate
with the new phone number. Some regions require addresses to meet local regulations.
@param [incoming_phone_number.VoiceReceiveMode] voice_receive_mode The
configuration parameter for the new phone number to receive incoming voice calls or faxes. Can be: `fax` or `voice` and defaults to `voice`.
@param [String] bundle_sid The SID of the Bundle resource that you associate
with the phone number. Some regions require a Bundle to meet local Regulations.
@param [String] phone_number The phone number to purchase specified in
{E.164}[https://www.twilio.com/docs/glossary/what-e164] format. E.164 phone numbers consist of a + followed by the country code and subscriber number without punctuation characters. For example, +14155551234.
@param [String] area_code The desired area code for your new incoming phone
number. Can be any three-digit, US or Canada area code. We will provision an available phone number within this area code for you. **You must provide an `area_code` or a `phone_number`.** (US and Canada only).
@return [IncomingPhoneNumberInstance] Created IncomingPhoneNumberInstance
# File lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb 232 def create(api_version: :unset, friendly_name: :unset, sms_application_sid: :unset, sms_fallback_method: :unset, sms_fallback_url: :unset, sms_method: :unset, sms_url: :unset, status_callback: :unset, status_callback_method: :unset, voice_application_sid: :unset, voice_caller_id_lookup: :unset, voice_fallback_method: :unset, voice_fallback_url: :unset, voice_method: :unset, voice_url: :unset, emergency_status: :unset, emergency_address_sid: :unset, trunk_sid: :unset, identity_sid: :unset, address_sid: :unset, voice_receive_mode: :unset, bundle_sid: :unset, phone_number: :unset, area_code: :unset) 233 data = Twilio::Values.of({ 234 'PhoneNumber' => phone_number, 235 'AreaCode' => area_code, 236 'ApiVersion' => api_version, 237 'FriendlyName' => friendly_name, 238 'SmsApplicationSid' => sms_application_sid, 239 'SmsFallbackMethod' => sms_fallback_method, 240 'SmsFallbackUrl' => sms_fallback_url, 241 'SmsMethod' => sms_method, 242 'SmsUrl' => sms_url, 243 'StatusCallback' => status_callback, 244 'StatusCallbackMethod' => status_callback_method, 245 'VoiceApplicationSid' => voice_application_sid, 246 'VoiceCallerIdLookup' => voice_caller_id_lookup, 247 'VoiceFallbackMethod' => voice_fallback_method, 248 'VoiceFallbackUrl' => voice_fallback_url, 249 'VoiceMethod' => voice_method, 250 'VoiceUrl' => voice_url, 251 'EmergencyStatus' => emergency_status, 252 'EmergencyAddressSid' => emergency_address_sid, 253 'TrunkSid' => trunk_sid, 254 'IdentitySid' => identity_sid, 255 'AddressSid' => address_sid, 256 'VoiceReceiveMode' => voice_receive_mode, 257 'BundleSid' => bundle_sid, 258 }) 259 260 payload = @version.create('POST', @uri, data: data) 261 262 IncomingPhoneNumberInstance.new(@version, payload, account_sid: @solution[:account_sid], ) 263 end
When passed a block, yields IncomingPhoneNumberInstance
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/incoming_phone_number.rb 106 def each 107 limits = @version.read_limits 108 109 page = self.page(page_size: limits[:page_size], ) 110 111 @version.stream(page, 112 limit: limits[:limit], 113 page_limit: limits[:page_limit]).each {|x| yield x} 114 end
Retrieve a single page of IncomingPhoneNumberInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of IncomingPhoneNumberInstance
# File lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb 154 def get_page(target_url) 155 response = @version.domain.request( 156 'GET', 157 target_url 158 ) 159 IncomingPhoneNumberPage.new(@version, response, @solution) 160 end
Lists IncomingPhoneNumberInstance
records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [Boolean] beta Whether to include phone numbers new to the Twilio
platform. Can be: `true` or `false` and the default is `true`.
@param [String] friendly_name A string that identifies the IncomingPhoneNumber
resources to read.
@param [String] phone_number The phone numbers of the IncomingPhoneNumber
resources to read. You can specify partial numbers and use '*' as a wildcard for any digit.
@param [String] origin Whether to include phone numbers based on their origin.
Can be: `twilio` or `hosted`. By default, phone numbers of all origin are included.
@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/incoming_phone_number.rb 56 def list(beta: :unset, friendly_name: :unset, phone_number: :unset, origin: :unset, limit: nil, page_size: nil) 57 self.stream( 58 beta: beta, 59 friendly_name: friendly_name, 60 phone_number: phone_number, 61 origin: origin, 62 limit: limit, 63 page_size: page_size 64 ).entries 65 end
Access the local @return [LocalList] @return [LocalContext]
# File lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb 269 def local 270 @local ||= LocalList.new(@version, account_sid: @solution[:account_sid], ) 271 end
Access the mobile @return [MobileList] @return [MobileContext]
# File lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb 277 def mobile 278 @mobile ||= MobileList.new(@version, account_sid: @solution[:account_sid], ) 279 end
Retrieve a single page of IncomingPhoneNumberInstance
records from the API. Request
is executed immediately. @param [Boolean] beta Whether to include phone numbers new to the Twilio
platform. Can be: `true` or `false` and the default is `true`.
@param [String] friendly_name A string that identifies the IncomingPhoneNumber
resources to read.
@param [String] phone_number The phone numbers of the IncomingPhoneNumber
resources to read. You can specify partial numbers and use '*' as a wildcard for any digit.
@param [String] origin Whether to include phone numbers based on their origin.
Can be: `twilio` or `hosted`. By default, phone numbers of all origin are included.
@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 IncomingPhoneNumberInstance
# File lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb 133 def page(beta: :unset, friendly_name: :unset, phone_number: :unset, origin: :unset, page_token: :unset, page_number: :unset, page_size: :unset) 134 params = Twilio::Values.of({ 135 'Beta' => beta, 136 'FriendlyName' => friendly_name, 137 'PhoneNumber' => phone_number, 138 'Origin' => origin, 139 'PageToken' => page_token, 140 'Page' => page_number, 141 'PageSize' => page_size, 142 }) 143 144 response = @version.page('GET', @uri, params: params) 145 146 IncomingPhoneNumberPage.new(@version, response, @solution) 147 end
Streams IncomingPhoneNumberInstance
records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [Boolean] beta Whether to include phone numbers new to the Twilio
platform. Can be: `true` or `false` and the default is `true`.
@param [String] friendly_name A string that identifies the IncomingPhoneNumber
resources to read.
@param [String] phone_number The phone numbers of the IncomingPhoneNumber
resources to read. You can specify partial numbers and use '*' as a wildcard for any digit.
@param [String] origin Whether to include phone numbers based on their origin.
Can be: `twilio` or `hosted`. By default, phone numbers of all origin are included.
@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/incoming_phone_number.rb 88 def stream(beta: :unset, friendly_name: :unset, phone_number: :unset, origin: :unset, limit: nil, page_size: nil) 89 limits = @version.read_limits(limit, page_size) 90 91 page = self.page( 92 beta: beta, 93 friendly_name: friendly_name, 94 phone_number: phone_number, 95 origin: origin, 96 page_size: limits[:page_size], 97 ) 98 99 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 100 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb 291 def to_s 292 '#<Twilio.Api.V2010.IncomingPhoneNumberList>' 293 end
Access the toll_free
@return [TollFreeList] @return [TollFreeContext]
# File lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb 285 def toll_free 286 @toll_free ||= TollFreeList.new(@version, account_sid: @solution[:account_sid], ) 287 end