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, AssignedAddOnInstanceMetadata, AssignedAddOnList, AssignedAddOnListResponse, AssignedAddOnPage, AssignedAddOnPageMetadata

Instance Method Summary collapse

Constructor Details

#initialize(version, account_sid, sid) ⇒ IncomingPhoneNumberContext

Initialize the IncomingPhoneNumberContext

Parameters:



414
415
416
417
418
419
420
421
422
423
424
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 414

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)


699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 699

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



428
429
430
431
432
433
434
435
436
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 428

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    

    @version.delete('DELETE', @uri, headers: headers)
end

#delete_with_metadataBoolean

Delete the IncomingPhoneNumberInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 441

def 

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

#fetchIncomingPhoneNumberInstance

Fetch the IncomingPhoneNumberInstance

Returns:



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

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

#fetch_with_metadataIncomingPhoneNumberInstance

Fetch the IncomingPhoneNumberInstanceMetadata

Returns:



480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 480

def 

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

#inspectObject

Provide a detailed, user friendly representation



724
725
726
727
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 724

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

#to_sObject

Provide a user friendly representation



717
718
719
720
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 717

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:



529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 529

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

#update_with_metadata(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 IncomingPhoneNumberInstanceMetadata

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:



622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
# File 'lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb', line 622

def (
  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', })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    incoming_phone_number_instance = IncomingPhoneNumberInstance.new(
        @version,
        response.body,
        account_sid: @solution[:account_sid],
        sid: @solution[:sid],
    )
    .new(
        @version,
        incoming_phone_number_instance,
        response.headers,
        response.status_code
    )
end