forked from TwilioDevEd/api-snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add exchanging-numbers ruby 5.x snippet
- Loading branch information
Showing
2 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
rest/subaccounts/exchanging-numbers-example-1/exchanging-numbers-example-1.5.x.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Get twilio-ruby from twilio.com/docs/ruby/install | ||
require 'rubygems' # This line not needed for ruby > 1.8 | ||
require 'twilio-ruby' | ||
|
||
# Get your Account Sid and Auth Token from twilio.com/user/account | ||
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' | ||
auth_token = 'your_auth_token' | ||
client = Twilio::REST::Client.new account_sid, auth_token | ||
|
||
# In the case you want to transfer numbers between subaccounts, you need to | ||
# know three things - the account SID of the phone number's current owner, | ||
# the account SID of the account you'd like to transfer the number to, and | ||
# the SID of the phone number you'd like to transfer | ||
current_owner_sid = 'ACyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy' | ||
new_owner_sid = 'ACzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz' | ||
phone_number_sid = 'PNyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy' | ||
|
||
# Update the number | ||
number = client.api.v2010.accounts(current_owner_sid) | ||
.incoming_phone_numbers(phone_number_sid) | ||
.fetch | ||
number.update(account_sid: new_owner_sid) | ||
puts number.phone_number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters