class Twilio::REST::Api::V2010::AccountContext::IncomingPhoneNumberList::MobileList
Public Class Methods
Initialize the MobileList
@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 [MobileList] MobileList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/mobile.rb 23 def initialize(version, account_sid: nil) 24 super(version) 25 26 # Path Solution 27 @solution = {account_sid: account_sid} 28 @uri = "/Accounts/#{@solution[:account_sid]}/IncomingPhoneNumbers/Mobile.json" 29 end
Public Instance Methods
Create the MobileInstance
@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] 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, the is a formatted version of the 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 of 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 [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 [mobile.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 [mobile.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.
@return [MobileInstance] Created MobileInstance
# File lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/mobile.rb 220 def create(phone_number: nil, 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, identity_sid: :unset, address_sid: :unset, emergency_status: :unset, emergency_address_sid: :unset, trunk_sid: :unset, voice_receive_mode: :unset, bundle_sid: :unset) 221 data = Twilio::Values.of({ 222 'PhoneNumber' => phone_number, 223 'ApiVersion' => api_version, 224 'FriendlyName' => friendly_name, 225 'SmsApplicationSid' => sms_application_sid, 226 'SmsFallbackMethod' => sms_fallback_method, 227 'SmsFallbackUrl' => sms_fallback_url, 228 'SmsMethod' => sms_method, 229 'SmsUrl' => sms_url, 230 'StatusCallback' => status_callback, 231 'StatusCallbackMethod' => status_callback_method, 232 'VoiceApplicationSid' => voice_application_sid, 233 'VoiceCallerIdLookup' => voice_caller_id_lookup, 234 'VoiceFallbackMethod' => voice_fallback_method, 235 'VoiceFallbackUrl' => voice_fallback_url, 236 'VoiceMethod' => voice_method, 237 'VoiceUrl' => voice_url, 238 'IdentitySid' => identity_sid, 239 'AddressSid' => address_sid, 240 'EmergencyStatus' => emergency_status, 241 'EmergencyAddressSid' => emergency_address_sid, 242 'TrunkSid' => trunk_sid, 243 'VoiceReceiveMode' => voice_receive_mode, 244 'BundleSid' => bundle_sid, 245 }) 246 247 payload = @version.create('POST', @uri, data: data) 248 249 MobileInstance.new(@version, payload, account_sid: @solution[:account_sid], ) 250 end
When passed a block, yields MobileInstance
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/mobile.rb 100 def each 101 limits = @version.read_limits 102 103 page = self.page(page_size: limits[:page_size], ) 104 105 @version.stream(page, 106 limit: limits[:limit], 107 page_limit: limits[:page_limit]).each {|x| yield x} 108 end
Retrieve a single page of MobileInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of MobileInstance
# File lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/mobile.rb 147 def get_page(target_url) 148 response = @version.domain.request( 149 'GET', 150 target_url 151 ) 152 MobilePage.new(@version, response, @solution) 153 end
Lists MobileInstance
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 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/mobile.rb 51 def list(beta: :unset, friendly_name: :unset, phone_number: :unset, origin: :unset, limit: nil, page_size: nil) 52 self.stream( 53 beta: beta, 54 friendly_name: friendly_name, 55 phone_number: phone_number, 56 origin: origin, 57 limit: limit, 58 page_size: page_size 59 ).entries 60 end
Retrieve a single page of MobileInstance
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 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 MobileInstance
# File lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/mobile.rb 126 def page(beta: :unset, friendly_name: :unset, phone_number: :unset, origin: :unset, page_token: :unset, page_number: :unset, page_size: :unset) 127 params = Twilio::Values.of({ 128 'Beta' => beta, 129 'FriendlyName' => friendly_name, 130 'PhoneNumber' => phone_number, 131 'Origin' => origin, 132 'PageToken' => page_token, 133 'Page' => page_number, 134 'PageSize' => page_size, 135 }) 136 137 response = @version.page('GET', @uri, params: params) 138 139 MobilePage.new(@version, response, @solution) 140 end
Streams MobileInstance
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 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/mobile.rb 82 def stream(beta: :unset, friendly_name: :unset, phone_number: :unset, origin: :unset, limit: nil, page_size: nil) 83 limits = @version.read_limits(limit, page_size) 84 85 page = self.page( 86 beta: beta, 87 friendly_name: friendly_name, 88 phone_number: phone_number, 89 origin: origin, 90 page_size: limits[:page_size], 91 ) 92 93 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 94 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/mobile.rb 254 def to_s 255 '#<Twilio.Api.V2010.MobileList>' 256 end