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 unique id of the [Account](www.twilio.com/docs/iam/api/account) responsible for this phone number.

  • sid (String)

    The incoming-phone-number Sid that uniquely identifies this resource



344
345
346
347
348
349
350
351
352
353
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 344

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)


489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 489

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

Deletes the IncomingPhoneNumberInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



481
482
483
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 481

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

#fetchIncomingPhoneNumberInstance

Fetch a IncomingPhoneNumberInstance

Returns:



461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 461

def fetch
  params = Twilio::Values.of({})

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

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

#to_sObject

Provide a user friendly representation



509
510
511
512
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 509

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) ⇒ IncomingPhoneNumberInstance

Update the IncomingPhoneNumberInstance

Parameters:

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

    The unique 34 character id of the account to which you wish to transfer this phone number. See [Exchanging Numbers Between Subaccounts](www.twilio.com/docs/iam/api/subaccounts#exchanging-numbers).

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

    Calls to this phone number will start a new TwiML session with this API version. Either ‘2010-04-01` or `2008-08-01`.

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

    A human readable descriptive text for this resource, up to 64 characters long. By default, the ‘FriendlyName` is a nicely formatted version of the phone number.

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

    The 34 character sid of the application Twilio should use to handle SMSs sent to this number. If a ‘SmsApplicationSid` is present, Twilio will ignore all of the SMS urls above and use those set on the application instead.

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

    The HTTP method that should be used to request the ‘SmsFallbackUrl`. Either `GET` or `POST`.

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

    A URL that Twilio will request if an error occurs requesting or executing the TwiML defined by ‘SmsUrl`.

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

    The HTTP method Twilio will use when making requests to the ‘SmsUrl`. Either `GET` or `POST`.

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

    The URL that Twilio should request when somebody sends an SMS to the new phone number.

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

    The URL that Twilio will request to pass status parameters (such as call ended) to your application.

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

    The HTTP method Twilio will use to make requests to the ‘StatusCallback` URL. Either `GET` or `POST`.

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

    The 34 character sid of the application Twilio should use to handle phone calls to this number. If a ‘VoiceApplicationSid` is present, Twilio will ignore all of the voice urls above and use those set on the application instead. Setting a `VoiceApplicationSid` will automatically delete your `TrunkSid` and vice versa.

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

    Look up the caller’s caller-ID name from the CNAM database ($0.01 per look up). Either ‘true` or `false`.

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

    The HTTP method Twilio will use when requesting the ‘VoiceFallbackUrl`. Either `GET` or `POST`.

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

    A URL that Twilio will request if an error occurs requesting or executing the TwiML defined by ‘VoiceUrl`.

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

    The HTTP method Twilio will use when requesting the above ‘Url`. Either `GET` or `POST`.

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

    The URL that Twilio should request when somebody dials the phone number. The VoiceURL will no longer be used if a ‘VoiceApplicationSid` or a `TrunkSid` is set.

  • emergency_status (incoming_phone_number.EmergencyStatus) (defaults to: :unset)

    The configuration status parameter determining whether this phone number is enabled for emergency calling

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

    The 34 character sid of the EmergencyAddress configuration to leverage emergency calling for this phone number

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

    The 34 character sid of the Trunk Twilio should use to handle phone calls to this number. If a ‘TrunkSid` is present, Twilio will ignore all of the voice urls and voice applications above and use those set on the Trunk. Setting a `TrunkSid` will automatically delete your `VoiceApplicationSid` and vice versa.

  • voice_receive_mode (incoming_phone_number.VoiceReceiveMode) (defaults to: :unset)

    The configuration parameter for this phone number to receive incoming voice calls or faxes. Must be either ‘fax` or `voice`. Defaults to `voice`

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

    The 34 character sid of the identity Twilio should use to associate with the number. Identities are required in some regions to meet local regulations

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

    The 34 character sid of the address Twilio should associate with the number. If the number has address restrictions, only another address that satisfies the requirement can replace the existing one.

Returns:



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
447
448
449
450
451
452
453
454
455
456
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 418

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

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

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