Class: Twilio::REST::Api::V2010::AccountContext::IncomingPhoneNumberContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb,
lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on.rb,
lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on/assigned_add_on_extension.rb

Defined Under Namespace

Classes: AssignedAddOnContext, AssignedAddOnInstance, AssignedAddOnList, AssignedAddOnPage

Instance Method Summary collapse

Constructor Details

#initialize(version, account_sid, sid) ⇒ IncomingPhoneNumberContext

Initialize the IncomingPhoneNumberContext

Parameters:



282
283
284
285
286
287
288
289
290
291
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 282

def initialize(version, , sid)
    super(version)

    # Path Solution
    @solution = { account_sid: , sid: sid,  }
    @uri = "/Accounts/#{@solution[:account_sid]}/IncomingPhoneNumbers/#{@solution[:sid]}.json"

    # Dependents
    @assigned_add_ons = nil
end

Instance Method Details

#assigned_add_ons(sid = :unset) ⇒ AssignedAddOnList, AssignedAddOnContext

Access the assigned_add_ons

Returns:

Raises:

  • (ArgumentError)


421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 421

def assigned_add_ons(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return AssignedAddOnContext.new(@version, @solution[:account_sid], @solution[:sid],sid )
    end

    unless @assigned_add_ons
        @assigned_add_ons = AssignedAddOnList.new(
            @version, account_sid: @solution[:account_sid], resource_sid: @solution[:sid], )
    end

 @assigned_add_ons
end

#deleteBoolean

Delete the IncomingPhoneNumberInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



295
296
297
298
299
300
301
302
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 295

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    @version.delete('DELETE', @uri, headers: headers)
end

#fetchIncomingPhoneNumberInstance

Fetch the IncomingPhoneNumberInstance

Returns:



307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 307

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    IncomingPhoneNumberInstance.new(
        @version,
        payload,
        account_sid: @solution[:account_sid],
        sid: @solution[:sid],
    )
end

#inspectObject

Provide a detailed, user friendly representation



446
447
448
449
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 446

def inspect
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Api.V2010.IncomingPhoneNumberContext #{context}>"
end

#to_sObject

Provide a user friendly representation



439
440
441
442
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 439

def to_s
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Api.V2010.IncomingPhoneNumberContext #{context}>"
end

#update(account_sid: :unset, 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, voice_receive_mode: :unset, identity_sid: :unset, address_sid: :unset, bundle_sid: :unset) ⇒ IncomingPhoneNumberInstance

Update the IncomingPhoneNumberInstance

Parameters:

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

    The SID of the [Account](www.twilio.com/docs/iam/api/account) that created the IncomingPhoneNumber resource to update. For more information, see [Exchanging Numbers Between Subaccounts](www.twilio.com/docs/iam/api/subaccounts#exchanging-numbers).

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

    The API version to use for incoming calls made to the phone number. The default is ‘2010-04-01`.

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

    A descriptive string that you created to describe this phone number. It can be up to 64 characters long. By default, this is a formatted version of the phone number.

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

    The SID of the application that should handle SMS messages sent to the number. If an ‘sms_application_sid` is present, we ignore all of the `sms_*_url` urls and use those set on the application.

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

    The HTTP method that we should use to call ‘sms_fallback_url`. Can be: `GET` or `POST` and defaults to `POST`.

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

    The URL that we should call when an error occurs while requesting or executing the TwiML defined by ‘sms_url`.

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

    The HTTP method that we should use to call ‘sms_url`. Can be: `GET` or `POST` and defaults to `POST`.

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

    The URL we should call when the phone number receives an incoming SMS message.

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

    The URL we should call using the ‘status_callback_method` to send status information to your application.

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

    The HTTP method we should use to call ‘status_callback`. Can be: `GET` or `POST` and defaults to `POST`.

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

    The SID of the application we should use to handle phone calls to the 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.

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

    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`.

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

    The HTTP method that we should use to call ‘voice_fallback_url`. Can be: `GET` or `POST` and defaults to `POST`.

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

    The URL that we should call when an error occurs retrieving or executing the TwiML requested by ‘url`.

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

    The HTTP method that we should use to call ‘voice_url`. Can be: `GET` or `POST` and defaults to `POST`.

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

    The URL that we should call to answer a call to the phone number. The ‘voice_url` will not be called if a `voice_application_sid` or a `trunk_sid` is set.

  • emergency_status (EmergencyStatus) (defaults to: :unset)
  • emergency_address_sid (String) (defaults to: :unset)

    The SID of the emergency address configuration to use for emergency calling from this phone number.

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

    The SID of the Trunk we should use to handle phone calls to the 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.

  • voice_receive_mode (VoiceReceiveMode) (defaults to: :unset)
  • identity_sid (String) (defaults to: :unset)

    The SID of the Identity resource that we should associate with the phone number. Some regions require an identity to meet local regulations.

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

    The SID of the Address resource we should associate with the phone number. Some regions require addresses to meet local regulations.

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

    The SID of the Bundle resource that you associate with the phone number. Some regions require a Bundle to meet local Regulations.

Returns:



350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 350

def update(
    account_sid: :unset, 
    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, 
    voice_receive_mode: :unset, 
    identity_sid: :unset, 
    address_sid: :unset, 
    bundle_sid: :unset
)

    data = Twilio::Values.of({
        'AccountSid' => ,
        'ApiVersion' => api_version,
        'FriendlyName' => friendly_name,
        'SmsApplicationSid' => sms_application_sid,
        'SmsFallbackMethod' => sms_fallback_method,
        'SmsFallbackUrl' => sms_fallback_url,
        'SmsMethod' => sms_method,
        'SmsUrl' => sms_url,
        'StatusCallback' => status_callback,
        'StatusCallbackMethod' => status_callback_method,
        'VoiceApplicationSid' => voice_application_sid,
        'VoiceCallerIdLookup' => voice_caller_id_lookup,
        'VoiceFallbackMethod' => voice_fallback_method,
        'VoiceFallbackUrl' => voice_fallback_url,
        'VoiceMethod' => voice_method,
        'VoiceUrl' => voice_url,
        'EmergencyStatus' => emergency_status,
        'EmergencyAddressSid' => emergency_address_sid,
        'TrunkSid' => trunk_sid,
        'VoiceReceiveMode' => voice_receive_mode,
        'IdentitySid' => identity_sid,
        'AddressSid' => address_sid,
        'BundleSid' => bundle_sid,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    IncomingPhoneNumberInstance.new(
        @version,
        payload,
        account_sid: @solution[:account_sid],
        sid: @solution[:sid],
    )
end