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 account_sid

  • sid (String)

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



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

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)


451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 451

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



443
444
445
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 443

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

#fetchIncomingPhoneNumberInstance

Fetch a IncomingPhoneNumberInstance

Returns:



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

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



471
472
473
474
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 471

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 id of the Account to which you wish to transfer this phone number

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

    Calls to this phone number will start a new TwiML session with this API version.

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

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

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

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

    The URL that Twilio will request if an error occurs retrieving or executing the TwiML from ‘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 Twilio will request when receiving an incoming SMS message to this 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. 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)

    The URL that Twilio will request if an error occurs retrieving or executing the TwiML requested by ‘Url`.

  • 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 Twilio will request when this phone number receives a call. 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 emergency_status

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

    The emergency_address_sid

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

  • 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 use to associate with the number. Addresses are required in some regions to meet local regulations

Returns:



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
416
417
418
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 380

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