Class: VoiceML::IncomingPhoneNumbersResource
- Inherits:
-
BaseResource
- Object
- BaseResource
- VoiceML::IncomingPhoneNumbersResource
- Defined in:
- lib/voiceml/resources/incoming_phone_numbers.rb
Overview
Operations on ‘/IncomingPhoneNumbers` — tenant-scoped DID lookup and routing.
Twilio-compatible: ‘sid` is the canonical `PN`-prefixed identifier, `phone_number` is the E.164 form. The standard lookup-by-number pattern (`list(phone_number: ’+1…‘)` returning a 0-or-1-row envelope, then `get(sid)`) is supported.
Constant Summary collapse
- LIST_FIELDS =
{ 'PhoneNumber' => :phone_number, 'Page' => :page, 'PageSize' => :page_size, 'PageToken' => :page_token }.freeze
- CREATE_FIELDS =
{ 'PhoneNumber' => :phone_number, 'VoiceUrl' => :voice_url, 'VoiceMethod' => :voice_method, 'VoiceFallbackUrl' => :voice_fallback_url, 'VoiceFallbackMethod' => :voice_fallback_method, 'FriendlyName' => :friendly_name }.freeze
- UPDATE_FIELDS =
{ 'VoiceUrl' => :voice_url, 'VoiceMethod' => :voice_method, 'VoiceFallbackUrl' => :voice_fallback_url, 'VoiceFallbackMethod' => :voice_fallback_method, 'FriendlyName' => :friendly_name }.freeze
- LIST_TYPED_FIELDS =
{ 'PhoneNumber' => :phone_number, 'FriendlyName' => :friendly_name, 'Beta' => :beta, 'Origin' => :origin, 'Page' => :page, 'PageSize' => :page_size, 'PageToken' => :page_token }.freeze
Instance Method Summary collapse
-
#create(phone_number:, voice_url: nil, voice_method: nil, voice_fallback_url: nil, voice_fallback_method: nil, friendly_name: nil) ⇒ VoiceML::IncomingPhoneNumber
Assign a DID to the authenticated tenant.
- #create_local(**kwargs) ⇒ VoiceML::IncomingPhoneNumber
- #create_mobile(**kwargs) ⇒ VoiceML::IncomingPhoneNumber
- #create_toll_free(**kwargs) ⇒ VoiceML::IncomingPhoneNumber
-
#delete(sid) ⇒ nil
Release a DID from the authenticated tenant.
-
#get(sid) ⇒ VoiceML::IncomingPhoneNumber
Fetch a single DID by its ‘PN`-prefixed sid.
-
#list(phone_number: nil, page: nil, page_size: nil) ⇒ VoiceML::IncomingPhoneNumberList
List DIDs assigned to the authenticated tenant.
- #list_local(**kwargs) ⇒ VoiceML::IncomingPhoneNumberList
- #list_mobile(**kwargs) ⇒ VoiceML::IncomingPhoneNumberList
- #list_toll_free(**kwargs) ⇒ VoiceML::IncomingPhoneNumberList
-
#update(sid, **opts) ⇒ VoiceML::IncomingPhoneNumber
Update voice routing on an assigned DID.
Methods inherited from BaseResource
Constructor Details
This class inherits a constructor from VoiceML::BaseResource
Instance Method Details
#create(phone_number:, voice_url: nil, voice_method: nil, voice_fallback_url: nil, voice_fallback_method: nil, friendly_name: nil) ⇒ VoiceML::IncomingPhoneNumber
Assign a DID to the authenticated tenant. Idempotent re-POSTing the same ‘phone_number:` rebinds the voice routing (matches Twilio update semantics).
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/voiceml/resources/incoming_phone_numbers.rb', line 72 def create(phone_number:, voice_url: nil, voice_method: nil, voice_fallback_url: nil, voice_fallback_method: nil, friendly_name: nil) kwargs = { phone_number: phone_number, voice_url: voice_url, voice_method: voice_method, voice_fallback_url: voice_fallback_url, voice_fallback_method: voice_fallback_method, friendly_name: friendly_name } IncomingPhoneNumber.from_hash( @transport.request(:post, path('IncomingPhoneNumbers'), form: form_params(CREATE_FIELDS, kwargs)) ) end |
#create_local(**kwargs) ⇒ VoiceML::IncomingPhoneNumber
122 123 124 |
# File 'lib/voiceml/resources/incoming_phone_numbers.rb', line 122 def create_local(**kwargs) create_typed('Local', kwargs) end |
#create_mobile(**kwargs) ⇒ VoiceML::IncomingPhoneNumber
132 133 134 |
# File 'lib/voiceml/resources/incoming_phone_numbers.rb', line 132 def create_mobile(**kwargs) create_typed('Mobile', kwargs) end |
#create_toll_free(**kwargs) ⇒ VoiceML::IncomingPhoneNumber
142 143 144 |
# File 'lib/voiceml/resources/incoming_phone_numbers.rb', line 142 def create_toll_free(**kwargs) create_typed('TollFree', kwargs) end |
#delete(sid) ⇒ nil
Release a DID from the authenticated tenant. Idempotent — 204 even if already gone.
111 112 113 114 |
# File 'lib/voiceml/resources/incoming_phone_numbers.rb', line 111 def delete(sid) @transport.request(:delete, path('IncomingPhoneNumbers', sid)) nil end |
#get(sid) ⇒ VoiceML::IncomingPhoneNumber
Fetch a single DID by its ‘PN`-prefixed sid.
90 91 92 93 94 |
# File 'lib/voiceml/resources/incoming_phone_numbers.rb', line 90 def get(sid) IncomingPhoneNumber.from_hash( @transport.request(:get, path('IncomingPhoneNumbers', sid)) ) end |
#list(phone_number: nil, page: nil, page_size: nil) ⇒ VoiceML::IncomingPhoneNumberList
List DIDs assigned to the authenticated tenant.
54 55 56 57 58 59 60 |
# File 'lib/voiceml/resources/incoming_phone_numbers.rb', line 54 def list(phone_number: nil, page: nil, page_size: nil) kwargs = { phone_number: phone_number, page: page, page_size: page_size } IncomingPhoneNumberList.from_hash( @transport.request(:get, path('IncomingPhoneNumbers'), params: form_params(LIST_FIELDS, kwargs)) ) end |
#list_local(**kwargs) ⇒ VoiceML::IncomingPhoneNumberList
117 118 119 |
# File 'lib/voiceml/resources/incoming_phone_numbers.rb', line 117 def list_local(**kwargs) list_typed('Local', kwargs) end |
#list_mobile(**kwargs) ⇒ VoiceML::IncomingPhoneNumberList
127 128 129 |
# File 'lib/voiceml/resources/incoming_phone_numbers.rb', line 127 def list_mobile(**kwargs) list_typed('Mobile', kwargs) end |
#list_toll_free(**kwargs) ⇒ VoiceML::IncomingPhoneNumberList
137 138 139 |
# File 'lib/voiceml/resources/incoming_phone_numbers.rb', line 137 def list_toll_free(**kwargs) list_typed('TollFree', kwargs) end |
#update(sid, **opts) ⇒ VoiceML::IncomingPhoneNumber
Update voice routing on an assigned DID. Only set fields are touched.
102 103 104 105 106 107 |
# File 'lib/voiceml/resources/incoming_phone_numbers.rb', line 102 def update(sid, **opts) IncomingPhoneNumber.from_hash( @transport.request(:post, path('IncomingPhoneNumbers', sid), form: form_params(UPDATE_FIELDS, opts)) ) end |