twilio-ruby 3.10.1 → 3.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS.md +24 -0
- data/CHANGES +11 -0
- data/Makefile +13 -0
- data/README.md +28 -13
- data/docs/Makefile +130 -0
- data/docs/_themes/LICENSE +45 -0
- data/docs/_themes/README.rst +25 -0
- data/docs/_themes/flask_theme_support.py +86 -0
- data/docs/_themes/kr/layout.html +32 -0
- data/docs/_themes/kr/relations.html +19 -0
- data/docs/_themes/kr/static/flasky.css_t +469 -0
- data/docs/_themes/kr/static/small_flask.css +70 -0
- data/docs/_themes/kr/theme.conf +7 -0
- data/docs/_themes/kr_small/layout.html +22 -0
- data/docs/_themes/kr_small/static/flasky.css_t +287 -0
- data/docs/_themes/kr_small/theme.conf +10 -0
- data/docs/changelog.rst +1 -0
- data/docs/conf.py +266 -0
- data/docs/faq.rst +42 -0
- data/docs/getting-started.rst +91 -0
- data/docs/index.rst +108 -0
- data/docs/make.bat +170 -0
- data/docs/src/pip-delete-this-directory.txt +5 -0
- data/docs/usage/accounts.rst +89 -0
- data/docs/usage/applications.rst +108 -0
- data/docs/usage/basics.rst +81 -0
- data/docs/usage/caller-ids.rst +45 -0
- data/docs/usage/conferences.rst +108 -0
- data/docs/usage/messages.rst +110 -0
- data/docs/usage/notifications.rst +70 -0
- data/docs/usage/phone-calls.rst +168 -0
- data/docs/usage/phone-numbers.rst +159 -0
- data/docs/usage/queues.rst +112 -0
- data/docs/usage/recordings.rst +96 -0
- data/docs/usage/sip.rst +103 -0
- data/docs/usage/token-generation.rst +81 -0
- data/docs/usage/transcriptions.rst +31 -0
- data/docs/usage/twiml.rst +70 -0
- data/docs/usage/validation.rst +71 -0
- data/examples/examples.rb +8 -5
- data/lib/twilio-ruby.rb +10 -0
- data/lib/twilio-ruby/rest/accounts.rb +1 -1
- data/lib/twilio-ruby/rest/instance_resource.rb +2 -1
- data/lib/twilio-ruby/rest/list_resource.rb +4 -1
- data/lib/twilio-ruby/rest/media.rb +14 -0
- data/lib/twilio-ruby/rest/messages.rb +12 -0
- data/lib/twilio-ruby/rest/sip.rb +12 -0
- data/lib/twilio-ruby/rest/sip/credential_lists.rb +11 -0
- data/lib/twilio-ruby/rest/sip/credential_lists/credentials.rb +6 -0
- data/lib/twilio-ruby/rest/sip/domains.rb +12 -0
- data/lib/twilio-ruby/rest/sip/domains/credential_list_mappings.rb +6 -0
- data/lib/twilio-ruby/rest/sip/domains/ip_access_control_list_mappings.rb +6 -0
- data/lib/twilio-ruby/rest/sip/ip_access_control_lists.rb +11 -0
- data/lib/twilio-ruby/rest/sip/ip_access_control_lists/ip_addresses.rb +6 -0
- data/lib/twilio-ruby/rest/sms.rb +1 -1
- data/lib/twilio-ruby/rest/usage/records.rb +1 -1
- data/lib/twilio-ruby/rest/utils.rb +1 -1
- data/lib/twilio-ruby/version.rb +1 -1
- data/spec/rest/message_spec.rb +12 -0
- metadata +52 -2
data/docs/faq.rst
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
==========================
|
2
|
+
Frequently Asked Questions
|
3
|
+
==========================
|
4
|
+
|
5
|
+
Hopefully you can find an answer here to one of your questions. If not, please
|
6
|
+
contact `help@twilio.com <mailto:help@twilio.com>`_.
|
7
|
+
|
8
|
+
|
9
|
+
Formatting phone numbers
|
10
|
+
------------------------
|
11
|
+
|
12
|
+
Twilio always returns phone numbers that are formatted in the `E.164 format
|
13
|
+
<http://en.wikipedia.org/wiki/E.164>`_, like this: ``+12125551234``. However
|
14
|
+
your users may enter them like this: ``(212) 555-1234``. This can lead to
|
15
|
+
problems when, for example, Twilio makes a POST request to your server with the
|
16
|
+
``From`` phone number as ``+12125551234``, but you stored the phone number in
|
17
|
+
your database as ``(212) 555-1234``, causing a database lookup to fail.
|
18
|
+
|
19
|
+
We suggest that you convert the number to E.164 format
|
20
|
+
before you store it in the database. The `phony
|
21
|
+
<https://github.com/floere/phony>`_ gem is excellent
|
22
|
+
for this purpose. Install it like this:
|
23
|
+
|
24
|
+
.. code-block:: bash
|
25
|
+
|
26
|
+
$ gem install phony
|
27
|
+
|
28
|
+
Then you can convert user input to phone numbers like this:
|
29
|
+
|
30
|
+
.. code-block:: ruby
|
31
|
+
|
32
|
+
require 'phony'
|
33
|
+
|
34
|
+
def convert_to_e164(raw_phone)
|
35
|
+
Phony.format(
|
36
|
+
raw_phone,
|
37
|
+
:format => :international,
|
38
|
+
:spaces => ''
|
39
|
+
).gsub(/\s+/, "") # Phony won't remove all spaces
|
40
|
+
end
|
41
|
+
|
42
|
+
puts convert_to_e164('212 555 1234') # prints +12125551234
|
@@ -0,0 +1,91 @@
|
|
1
|
+
===========
|
2
|
+
Quickstart
|
3
|
+
===========
|
4
|
+
|
5
|
+
Getting started with the Twilio API couldn't be easier. Create a Twilio REST
|
6
|
+
client to get started. For example, the following code makes a call using the
|
7
|
+
Twilio REST API.
|
8
|
+
|
9
|
+
|
10
|
+
Make a Call
|
11
|
+
===============
|
12
|
+
|
13
|
+
.. code-block:: ruby
|
14
|
+
|
15
|
+
require 'twilio-ruby'
|
16
|
+
|
17
|
+
# To find these visit https://www.twilio.com/user/account
|
18
|
+
account_sid = "ACXXXXXXXXXXXXXXXXX"
|
19
|
+
auth_token = "YYYYYYYYYYYYYYYYYY"
|
20
|
+
|
21
|
+
@client = Twilio::REST::Client.new account_sid, auth_token
|
22
|
+
@call = @client.calls.create({:to => "9991231234", :from => "9991231234",
|
23
|
+
:url => "http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient"})
|
24
|
+
puts @call.length
|
25
|
+
puts @call.sid
|
26
|
+
|
27
|
+
|
28
|
+
Send an SMS
|
29
|
+
===========
|
30
|
+
|
31
|
+
.. code-block:: ruby
|
32
|
+
|
33
|
+
require 'twilio-ruby'
|
34
|
+
|
35
|
+
# To find these visit https://www.twilio.com/user/account
|
36
|
+
account_sid = "ACXXXXXXXXXXXXXXXXX"
|
37
|
+
auth_token = "YYYYYYYYYYYYYYYYYY"
|
38
|
+
|
39
|
+
@client = Twilio::REST::Client.new account_sid, auth_token
|
40
|
+
|
41
|
+
@message = client.messages.create({:to => "+12316851234",
|
42
|
+
:from => "+15555555555",
|
43
|
+
:body => "Hello there!"})
|
44
|
+
|
45
|
+
|
46
|
+
Send an MMS
|
47
|
+
===========
|
48
|
+
|
49
|
+
.. code-block:: ruby
|
50
|
+
|
51
|
+
require 'twilio-ruby'
|
52
|
+
|
53
|
+
# To find these visit https://www.twilio.com/user/account
|
54
|
+
account_sid = "ACXXXXXXXXXXXXXXXXX"
|
55
|
+
auth_token = "YYYYYYYYYYYYYYYYYY"
|
56
|
+
|
57
|
+
@client = Twilio::REST::Client.new account_sid, auth_token
|
58
|
+
|
59
|
+
@message = client.messages.create({:to => "+15558676309",
|
60
|
+
:from => "+15555555555",
|
61
|
+
:body => "Jenny I need you!",
|
62
|
+
:media_url => "http://twilio.com/heart.jpg"})
|
63
|
+
|
64
|
+
|
65
|
+
Generating TwiML
|
66
|
+
=================
|
67
|
+
|
68
|
+
To control phone calls, your application needs to output `TwiML
|
69
|
+
<http://www.twilio.com/docs/api/twiml/>`_. Use :class:`twilio.twiml.Response`
|
70
|
+
to easily create such responses.
|
71
|
+
|
72
|
+
.. code-block:: ruby
|
73
|
+
|
74
|
+
Twilio::TwiML::Response do |r|
|
75
|
+
r.Play "https://api.twilio.com/cowbell.mp3", :loop => 5
|
76
|
+
end.text
|
77
|
+
|
78
|
+
.. code-block:: xml
|
79
|
+
|
80
|
+
<?xml version="1.0" encoding="utf-8"?>
|
81
|
+
<Response>
|
82
|
+
<Play loop="5">https://api.twilio.com/cowbell.mp3</Play>
|
83
|
+
<Response>
|
84
|
+
|
85
|
+
|
86
|
+
Digging Deeper
|
87
|
+
========================
|
88
|
+
|
89
|
+
The full power of the Twilio API is at your fingertips. The :ref:`user-guide`
|
90
|
+
explains all the awesome features available to use.
|
91
|
+
|
data/docs/index.rst
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
=============================
|
2
|
+
Twilio Ruby Helper Library
|
3
|
+
=============================
|
4
|
+
|
5
|
+
.. _installation:
|
6
|
+
|
7
|
+
Installation
|
8
|
+
================
|
9
|
+
|
10
|
+
Just install the gem!
|
11
|
+
|
12
|
+
.. code-block:: bash
|
13
|
+
|
14
|
+
$ gem install twilio-ruby
|
15
|
+
|
16
|
+
Getting Started
|
17
|
+
================
|
18
|
+
|
19
|
+
The :doc:`/getting-started` will get you up and running in a few quick minutes.
|
20
|
+
This guide assumes you understand the core concepts of Twilio.
|
21
|
+
If you've never used Twilio before, don't fret! Just read
|
22
|
+
`about how Twilio works <http://www.twilio.com/api/>`_ and then jump in!
|
23
|
+
|
24
|
+
|
25
|
+
.. _user-guide:
|
26
|
+
|
27
|
+
User Guide
|
28
|
+
==================
|
29
|
+
|
30
|
+
Functionality is split over three different sub-packages within
|
31
|
+
**twilio-ruby**. Below are in-depth guides to specific portions of the
|
32
|
+
library.
|
33
|
+
|
34
|
+
|
35
|
+
REST API
|
36
|
+
----------
|
37
|
+
|
38
|
+
Query the Twilio REST API to create phone calls, send SMS/MMS messages and more!
|
39
|
+
|
40
|
+
.. toctree::
|
41
|
+
:maxdepth: 1
|
42
|
+
|
43
|
+
usage/basics
|
44
|
+
usage/messages
|
45
|
+
usage/phone-calls
|
46
|
+
usage/phone-numbers
|
47
|
+
usage/accounts
|
48
|
+
usage/conferences
|
49
|
+
usage/applications
|
50
|
+
usage/notifications
|
51
|
+
usage/recordings
|
52
|
+
usage/transcriptions
|
53
|
+
usage/caller-ids
|
54
|
+
usage/queues
|
55
|
+
usage/sip
|
56
|
+
|
57
|
+
TwiML
|
58
|
+
---------
|
59
|
+
|
60
|
+
Generates valid TwiML for controlling and manipulating phone calls.
|
61
|
+
|
62
|
+
.. toctree::
|
63
|
+
:maxdepth: 2
|
64
|
+
|
65
|
+
usage/twiml
|
66
|
+
|
67
|
+
Utilities
|
68
|
+
----------
|
69
|
+
|
70
|
+
Small functions useful for validating requests are coming from Twilio
|
71
|
+
|
72
|
+
.. toctree::
|
73
|
+
:maxdepth: 1
|
74
|
+
|
75
|
+
usage/validation
|
76
|
+
usage/token-generation
|
77
|
+
|
78
|
+
Frequently Asked Questions
|
79
|
+
==========================
|
80
|
+
|
81
|
+
What to do if you get an ``ImportError``, and some advice about how to format
|
82
|
+
phone numbers.
|
83
|
+
|
84
|
+
.. toctree::
|
85
|
+
:maxdepth: 2
|
86
|
+
|
87
|
+
faq
|
88
|
+
|
89
|
+
Changelog
|
90
|
+
=========
|
91
|
+
|
92
|
+
See the :doc:`/changelog` for version history.
|
93
|
+
|
94
|
+
Support and Development
|
95
|
+
==========================
|
96
|
+
All development occurs over on
|
97
|
+
`Github <https://github.com/twilio/twilio-ruby>`_. To checkout the source,
|
98
|
+
|
99
|
+
.. code-block:: bash
|
100
|
+
|
101
|
+
$ git clone git@github.com:twilio/twilio-ruby.git
|
102
|
+
|
103
|
+
|
104
|
+
Report bugs using the Github
|
105
|
+
`issue tracker <https://github.com/twilio/twilio-ruby/issues>`_.
|
106
|
+
|
107
|
+
If you have questions that aren't answered by this documentation,
|
108
|
+
ask the `#twilio IRC channel <irc://irc.freenode.net/#twilio>`_
|
data/docs/make.bat
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
@ECHO OFF
|
2
|
+
|
3
|
+
REM Command file for Sphinx documentation
|
4
|
+
|
5
|
+
if "%SPHINXBUILD%" == "" (
|
6
|
+
set SPHINXBUILD=sphinx-build
|
7
|
+
)
|
8
|
+
set BUILDDIR=_build
|
9
|
+
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
|
10
|
+
if NOT "%PAPER%" == "" (
|
11
|
+
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
|
12
|
+
)
|
13
|
+
|
14
|
+
if "%1" == "" goto help
|
15
|
+
|
16
|
+
if "%1" == "help" (
|
17
|
+
:help
|
18
|
+
echo.Please use `make ^<target^>` where ^<target^> is one of
|
19
|
+
echo. html to make standalone HTML files
|
20
|
+
echo. dirhtml to make HTML files named index.html in directories
|
21
|
+
echo. singlehtml to make a single large HTML file
|
22
|
+
echo. pickle to make pickle files
|
23
|
+
echo. json to make JSON files
|
24
|
+
echo. htmlhelp to make HTML files and a HTML help project
|
25
|
+
echo. qthelp to make HTML files and a qthelp project
|
26
|
+
echo. devhelp to make HTML files and a Devhelp project
|
27
|
+
echo. epub to make an epub
|
28
|
+
echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
|
29
|
+
echo. text to make text files
|
30
|
+
echo. man to make manual pages
|
31
|
+
echo. changes to make an overview over all changed/added/deprecated items
|
32
|
+
echo. linkcheck to check all external links for integrity
|
33
|
+
echo. doctest to run all doctests embedded in the documentation if enabled
|
34
|
+
goto end
|
35
|
+
)
|
36
|
+
|
37
|
+
if "%1" == "clean" (
|
38
|
+
for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
|
39
|
+
del /q /s %BUILDDIR%\*
|
40
|
+
goto end
|
41
|
+
)
|
42
|
+
|
43
|
+
if "%1" == "html" (
|
44
|
+
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
|
45
|
+
if errorlevel 1 exit /b 1
|
46
|
+
echo.
|
47
|
+
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
|
48
|
+
goto end
|
49
|
+
)
|
50
|
+
|
51
|
+
if "%1" == "dirhtml" (
|
52
|
+
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
|
53
|
+
if errorlevel 1 exit /b 1
|
54
|
+
echo.
|
55
|
+
echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
|
56
|
+
goto end
|
57
|
+
)
|
58
|
+
|
59
|
+
if "%1" == "singlehtml" (
|
60
|
+
%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
|
61
|
+
if errorlevel 1 exit /b 1
|
62
|
+
echo.
|
63
|
+
echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
|
64
|
+
goto end
|
65
|
+
)
|
66
|
+
|
67
|
+
if "%1" == "pickle" (
|
68
|
+
%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
|
69
|
+
if errorlevel 1 exit /b 1
|
70
|
+
echo.
|
71
|
+
echo.Build finished; now you can process the pickle files.
|
72
|
+
goto end
|
73
|
+
)
|
74
|
+
|
75
|
+
if "%1" == "json" (
|
76
|
+
%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
|
77
|
+
if errorlevel 1 exit /b 1
|
78
|
+
echo.
|
79
|
+
echo.Build finished; now you can process the JSON files.
|
80
|
+
goto end
|
81
|
+
)
|
82
|
+
|
83
|
+
if "%1" == "htmlhelp" (
|
84
|
+
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
|
85
|
+
if errorlevel 1 exit /b 1
|
86
|
+
echo.
|
87
|
+
echo.Build finished; now you can run HTML Help Workshop with the ^
|
88
|
+
.hhp project file in %BUILDDIR%/htmlhelp.
|
89
|
+
goto end
|
90
|
+
)
|
91
|
+
|
92
|
+
if "%1" == "qthelp" (
|
93
|
+
%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
|
94
|
+
if errorlevel 1 exit /b 1
|
95
|
+
echo.
|
96
|
+
echo.Build finished; now you can run "qcollectiongenerator" with the ^
|
97
|
+
.qhcp project file in %BUILDDIR%/qthelp, like this:
|
98
|
+
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\twilio-python2.qhcp
|
99
|
+
echo.To view the help file:
|
100
|
+
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\twilio-python2.ghc
|
101
|
+
goto end
|
102
|
+
)
|
103
|
+
|
104
|
+
if "%1" == "devhelp" (
|
105
|
+
%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
|
106
|
+
if errorlevel 1 exit /b 1
|
107
|
+
echo.
|
108
|
+
echo.Build finished.
|
109
|
+
goto end
|
110
|
+
)
|
111
|
+
|
112
|
+
if "%1" == "epub" (
|
113
|
+
%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
|
114
|
+
if errorlevel 1 exit /b 1
|
115
|
+
echo.
|
116
|
+
echo.Build finished. The epub file is in %BUILDDIR%/epub.
|
117
|
+
goto end
|
118
|
+
)
|
119
|
+
|
120
|
+
if "%1" == "latex" (
|
121
|
+
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
|
122
|
+
if errorlevel 1 exit /b 1
|
123
|
+
echo.
|
124
|
+
echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
|
125
|
+
goto end
|
126
|
+
)
|
127
|
+
|
128
|
+
if "%1" == "text" (
|
129
|
+
%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
|
130
|
+
if errorlevel 1 exit /b 1
|
131
|
+
echo.
|
132
|
+
echo.Build finished. The text files are in %BUILDDIR%/text.
|
133
|
+
goto end
|
134
|
+
)
|
135
|
+
|
136
|
+
if "%1" == "man" (
|
137
|
+
%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
|
138
|
+
if errorlevel 1 exit /b 1
|
139
|
+
echo.
|
140
|
+
echo.Build finished. The manual pages are in %BUILDDIR%/man.
|
141
|
+
goto end
|
142
|
+
)
|
143
|
+
|
144
|
+
if "%1" == "changes" (
|
145
|
+
%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
|
146
|
+
if errorlevel 1 exit /b 1
|
147
|
+
echo.
|
148
|
+
echo.The overview file is in %BUILDDIR%/changes.
|
149
|
+
goto end
|
150
|
+
)
|
151
|
+
|
152
|
+
if "%1" == "linkcheck" (
|
153
|
+
%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
|
154
|
+
if errorlevel 1 exit /b 1
|
155
|
+
echo.
|
156
|
+
echo.Link check complete; look for any errors in the above output ^
|
157
|
+
or in %BUILDDIR%/linkcheck/output.txt.
|
158
|
+
goto end
|
159
|
+
)
|
160
|
+
|
161
|
+
if "%1" == "doctest" (
|
162
|
+
%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
|
163
|
+
if errorlevel 1 exit /b 1
|
164
|
+
echo.
|
165
|
+
echo.Testing of doctests in the sources finished, look at the ^
|
166
|
+
results in %BUILDDIR%/doctest/output.txt.
|
167
|
+
goto end
|
168
|
+
)
|
169
|
+
|
170
|
+
:end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
.. module:: twilio.rest
|
2
|
+
|
3
|
+
===========
|
4
|
+
Accounts
|
5
|
+
===========
|
6
|
+
|
7
|
+
Managing Twilio accounts is straightforward.
|
8
|
+
Update your own account information or create and manage multiple subaccounts.
|
9
|
+
|
10
|
+
For more information, see the
|
11
|
+
`Account REST Resource <http://www.twilio.com/docs/api/rest/account>`_
|
12
|
+
documentation.
|
13
|
+
|
14
|
+
|
15
|
+
Updating Account Information
|
16
|
+
----------------------------
|
17
|
+
|
18
|
+
Use the :meth:`Account.update` to modify one of your accounts.
|
19
|
+
Right now the only valid attribute is :attr:`friendly_name`.
|
20
|
+
|
21
|
+
.. code-block:: ruby
|
22
|
+
|
23
|
+
require 'twilio-ruby'
|
24
|
+
|
25
|
+
# To find these visit https://www.twilio.com/user/account
|
26
|
+
account_sid = "ACXXXXXXXXXXXXXXXXX"
|
27
|
+
auth_token = "YYYYYYYYYYYYYYYYYY"
|
28
|
+
|
29
|
+
@client = Twilio::REST::Client.new account_sid, auth_token
|
30
|
+
@account = @client.accounts.get(account_sid)
|
31
|
+
@account.update({:friendly_name => "My Awesome Account"})
|
32
|
+
|
33
|
+
|
34
|
+
Creating Subaccounts
|
35
|
+
----------------------
|
36
|
+
|
37
|
+
Subaccounts are easy to make.
|
38
|
+
|
39
|
+
.. code-block:: ruby
|
40
|
+
|
41
|
+
require 'twilio-ruby'
|
42
|
+
|
43
|
+
# To find these visit https://www.twilio.com/user/account
|
44
|
+
account_sid = "ACXXXXXXXXXXXXXXXXX"
|
45
|
+
auth_token = "YYYYYYYYYYYYYYYYYY"
|
46
|
+
|
47
|
+
@client = Twilio::Rest::Client.new account_sid, auth_token
|
48
|
+
@subaccount = @client.accounts.create({:name => "My Awesome SubAccount"})
|
49
|
+
|
50
|
+
|
51
|
+
Managing Subaccounts
|
52
|
+
-------------------------
|
53
|
+
|
54
|
+
Say you have a subaccount for Client X with an account sid `AC123`
|
55
|
+
|
56
|
+
.. code-block:: ruby
|
57
|
+
|
58
|
+
require 'twilio-ruby'
|
59
|
+
|
60
|
+
# To find these visit https://www.twilio.com/user/account
|
61
|
+
account_sid = "ACXXXXXXXXXXXXXXXXX"
|
62
|
+
auth_token = "YYYYYYYYYYYYYYYYYY"
|
63
|
+
|
64
|
+
@client = Twilio::Rest::Client.new account_sid, auth_token
|
65
|
+
|
66
|
+
# Client X's subaccount
|
67
|
+
@subaccount = @client.accounts.get('AC123')
|
68
|
+
|
69
|
+
Client X hasn't paid you recently, so let's suspend their account.
|
70
|
+
|
71
|
+
.. code-block:: ruby
|
72
|
+
|
73
|
+
@subaccount.update({:status => 'suspended'}
|
74
|
+
|
75
|
+
If it was just a misunderstanding, reenable their account.
|
76
|
+
|
77
|
+
.. code-block:: ruby
|
78
|
+
|
79
|
+
@subaccount.update({:status => 'active'}
|
80
|
+
|
81
|
+
Otherwise, close their account permanently.
|
82
|
+
|
83
|
+
.. code-block:: ruby
|
84
|
+
|
85
|
+
@subaccount.update({:status => 'closed'}
|
86
|
+
|
87
|
+
.. warning::
|
88
|
+
This action can't be undone.
|
89
|
+
|