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:

  • version (Version)

    Version that contains the resource

  • account_sid (String)

    The SID of the Account that created the IncomingPhoneNumber resource to fetch.

  • sid (String)

    The Twilio-provided string that uniquely identifies the IncomingPhoneNumber resource to fetch.


335
336
337
338
339
340
341
342
343
344
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 335

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)

473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 473

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


465
466
467
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 465

def delete
   @version.delete('DELETE', @uri)
end

#fetchIncomingPhoneNumberInstance

Fetch the IncomingPhoneNumberInstance

Returns:


451
452
453
454
455
456
457
458
459
460
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 451

def fetch
  payload = @version.fetch('GET', @uri)

  IncomingPhoneNumberInstance.new(
      @version,
      payload,
      account_sid: @solution[:account_sid],
      sid: @solution[:sid],
  )
end

#inspectObject

Provide a detailed, user friendly representation


500
501
502
503
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 500

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

#to_sObject

Provide a user friendly representation


493
494
495
496
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 493

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 that created the IncomingPhoneNumber resource to update. For more information, see Exchanging Numbers Between Subaccounts.

  • 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 (incoming_phone_number.EmergencyStatus) (defaults to: :unset)

    The configuration status parameter that determines whether the phone number is enabled for emergency calling.

  • 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 (incoming_phone_number.VoiceReceiveMode) (defaults to: :unset)

    The configuration parameter for the phone number to receive incoming voice calls or faxes. Can be: `fax` or `voice` and defaults to `voice`.

  • 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:


411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 411

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

  payload = @version.update('POST', @uri, data: data)

  IncomingPhoneNumberInstance.new(
      @version,
      payload,
      account_sid: @solution[:account_sid],
      sid: @solution[:sid],
  )
end