I use twilio gem and I do not know how to release the phone number. I try:
@client.account.incoming_phone_numbers.delete(:phone_number => phone_number)
but rails say:
undefined method `delete' for #<Twilio::REST::IncomingPhoneNumbers:0x7f35c99e93e0>
How to correct release number?
Login to the Twilio Console and select a subaccount by clicking the "View Subaccount" button next to the subaccount listed on your Subaccount Page. Then navigate to the Numbers tab and click the phone number(s) you wish to delete.
Phone verification APIs are, as their name suggests, used to verify phone numbers. Verification APIs and services review phone numbers and make sure they're valid (i.e., they exist) and still in use. They can also be used to standardize phone numbers and identify geographic information for compliance purposes.
The twilio-ruby helper library lets you write Ruby code to make HTTP requests to the Twilio API. This library is open source, so if you find a feature missing or a bug, we encourage you to contribute back to the twilio-ruby project hosted on GitHub.
I found solution:
@client.account.incoming_phone_numbers.list({:phone_number => phone_number}).each do |n|
num = @client.account.incoming_phone_numbers.get(n.sid)
num.delete
end
Using the 5.x gem version and the new Twilio API's you have two options:
If you know the Number SID
client = Twilio::REST::Client.new(TWILIO_SID, TWILIO_TOKEN)
number = client.api.account.incoming_phone_numbers(PHONE_SID).fetch
number.delete
If you only know the phone number
client = Twilio::REST::Client.new(TWILIO_SID, TWILIO_TOKEN)
client.incoming_phone_numbers.list(phone_number: PHONE_NUMBER).each do |number|
number.delete
end
Hope this helps new readers using the latest gem versions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With