twilio-ruby 3.11.0 → 3.11.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c4463ad95b5c4cdd215f8c1ba739c94356598855
4
+ data.tar.gz: f7b531fa9490928e9ee8631e660c74068be58366
5
+ SHA512:
6
+ metadata.gz: 414d7a39fe93d2159a6890f057aa54ea741d75e4d6ac5f9b167ea7c17c787ae0d5cd34b8cf029c497816dc8141d1af134c0487322a0fd0edd75e8d813ce8de5f
7
+ data.tar.gz: e914fd9c3a2c539c4360544338bb4f2808055f56c94dd4845ad0deed1a90ba5dcac850d6a7bcbeb221d864a677179f0f105b4b7637e3b555bb2df04a0545651b
data/README.md CHANGED
@@ -1,6 +1,12 @@
1
1
  [![Build Status](https://travis-ci.org/twilio/twilio-ruby.png?branch=master)](https://travis-ci.org/twilio/twilio-ruby)
2
2
  [![Gem Version](https://badge.fury.io/rb/twilio-ruby.png)](http://badge.fury.io/rb/twilio-ruby)
3
3
 
4
+ # twilio-ruby
5
+
6
+ A module for using the Twilio REST API and generating valid
7
+ [TwiML](http://www.twilio.com/docs/api/twiml/ "TwiML - Twilio Markup Language").
8
+ [Click here to read the full documentation.][documentation]
9
+
4
10
  ## Install
5
11
 
6
12
  Via rubygems.org:
@@ -165,13 +171,11 @@ This will print the following (except for the whitespace):
165
171
  There are more detailed examples in the included [examples][examples]
166
172
  directory.
167
173
 
168
- Full [API documentation][documentation], as well as an [upgrade guide][upgrade]
169
- for users of the old twiliolib gem, is available in the
170
- [twilio-ruby github wiki][wiki].
174
+ The [upgrade guide][upgrade] is available in the [twilio-ruby github wiki][wiki].
171
175
 
172
176
  [capability]:https://github.com/twilio/twilio-ruby/wiki/Capability
173
177
  [builder]:http://builder.rubyforge.org/
174
178
  [examples]:https://github.com/twilio/twilio-ruby/blob/master/examples
175
- [documentation]:https://github.com/twilio/twilio-ruby/wiki/Documentation
179
+ [documentation]:http://twilio-ruby.readthedocs.org/en/latest
176
180
  [upgrade]:https://github.com/twilio/twilio-ruby/wiki/UpgradeGuide
177
181
  [wiki]:https://github.com/twilio/twilio-ruby/wiki
@@ -12,7 +12,7 @@
12
12
  <div class="footer">
13
13
  &copy; Copyright {{ copyright }}.
14
14
  </div>
15
- <a href="https://github.com/twilio/twilio-python">
15
+ <a href="https://github.com/twilio/twilio-ruby">
16
16
  <img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" />
17
17
  </a>
18
18
  <script type="text/javascript">
data/docs/conf.py CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # twilio-python2 documentation build configuration file, created by
3
+ # twilio-ruby documentation build configuration file, created by
4
4
  # sphinx-quickstart on Mon Dec 13 16:47:32 2010.
5
5
  #
6
6
  # This file is execfile()d with the current directory set to its containing dir.
@@ -47,7 +47,7 @@ source_suffix = '.rst'
47
47
  master_doc = 'index'
48
48
 
49
49
  # General information about the project.
50
- project = u'twilio-python'
50
+ project = u'twilio-ruby'
51
51
  copyright = unicode(datetime.utcnow().year) + u', Twilio Inc'
52
52
 
53
53
  # The version info for the project you're documenting, acts as replacement for
@@ -174,7 +174,7 @@ html_static_path = ['_static']
174
174
  #html_file_suffix = None
175
175
 
176
176
  # Output file base name for HTML help builder.
177
- htmlhelp_basename = 'twilio-pythondoc'
177
+ htmlhelp_basename = 'twilio-rubydoc'
178
178
 
179
179
 
180
180
  # -- Options for LaTeX output --------------------------------------------------
@@ -188,7 +188,7 @@ htmlhelp_basename = 'twilio-pythondoc'
188
188
  # Grouping the document tree into LaTeX files. List of tuples
189
189
  # (source start file, target name, title, author, documentclass [howto/manual]).
190
190
  latex_documents = [
191
- ('index', 'twilio-python.tex', u'twilio-python Documentation',
191
+ ('index', 'twilio-ruby.tex', u'twilio-ruby Documentation',
192
192
  u'Twilio Inc.', 'manual'),
193
193
  ]
194
194
 
@@ -221,7 +221,7 @@ latex_documents = [
221
221
  # One entry per manual page. List of tuples
222
222
  # (source start file, name, description, authors, manual section).
223
223
  man_pages = [
224
- ('index', 'twilio-python', u'twilio-python Documentation',
224
+ ('index', 'twilio-ruby', u'twilio-ruby Documentation',
225
225
  [u'Twilio Inc.'], 1)
226
226
  ]
227
227
 
@@ -229,7 +229,7 @@ man_pages = [
229
229
  # -- Options for Epub output ---------------------------------------------------
230
230
 
231
231
  # Bibliographic Dublin Core info.
232
- epub_title = u'twilio-python'
232
+ epub_title = u'twilio-ruby'
233
233
  epub_author = u'kyle@twilio.com'
234
234
  epub_publisher = u'Twilio Inc.'
235
235
  epub_copyright = u'2010, Twilio Inc.'
@@ -19,7 +19,7 @@ Make a Call
19
19
  auth_token = "YYYYYYYYYYYYYYYYYY"
20
20
 
21
21
  @client = Twilio::REST::Client.new account_sid, auth_token
22
- @call = @client.calls.create({:to => "9991231234", :from => "9991231234",
22
+ @call = @client.account.calls.create({:to => "9991231234", :from => "9991231234",
23
23
  :url => "http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient"})
24
24
  puts @call.length
25
25
  puts @call.sid
@@ -38,7 +38,7 @@ Send an SMS
38
38
 
39
39
  @client = Twilio::REST::Client.new account_sid, auth_token
40
40
 
41
- @message = client.messages.create({:to => "+12316851234",
41
+ @message = @client.account.messages.create({:to => "+12316851234",
42
42
  :from => "+15555555555",
43
43
  :body => "Hello there!"})
44
44
 
@@ -56,7 +56,7 @@ Send an MMS
56
56
 
57
57
  @client = Twilio::REST::Client.new account_sid, auth_token
58
58
 
59
- @message = client.messages.create({:to => "+15558676309",
59
+ @message = @client.account.messages.create({:to => "+15558676309",
60
60
  :from => "+15555555555",
61
61
  :body => "Jenny I need you!",
62
62
  :media_url => "http://twilio.com/heart.jpg"})
@@ -26,7 +26,7 @@ The following code will print out the :attr:`friendly_name` for each :class:`App
26
26
  auth_token = "YYYYYYYYYYYYYYYYYY"
27
27
 
28
28
  @client = Twilio::REST::Client.new account_sid, auth_token
29
- @client.applications.each do |app|
29
+ @client.account.applications.each do |app|
30
30
  puts app.friendly_name
31
31
  end
32
32
 
@@ -45,7 +45,7 @@ You can filter applications by FriendlyName
45
45
  auth_token = "YYYYYYYYYYYYYYYYYY"
46
46
 
47
47
  @client = Twilio::REST::Client.new account_sid, auth_token
48
- @client.applications.list({:friendly_name => 'FOO'})}.each do |app|
48
+ @client.account.applications.list({:friendly_name => 'FOO'})}.each do |app|
49
49
  puts app.sid
50
50
  end
51
51
 
@@ -66,7 +66,7 @@ accepts many other arguments for url configuration.
66
66
  auth_token = "YYYYYYYYYYYYYYYYYY"
67
67
 
68
68
  @client = Twilio::REST::Client.new account_sid, auth_token
69
- @application = @client.applications.create({:friendly_name => "My New App"})
69
+ @application = @client.account.applications.create({:friendly_name => "My New App"})
70
70
 
71
71
 
72
72
  Updating an Application
@@ -85,7 +85,7 @@ Updating an Application
85
85
  url = "http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient"
86
86
  app_sid = 'AP123' # the app you'd like to update
87
87
 
88
- @application = @client.applications.get(app_sid)
88
+ @application = @client.account.applications.get(app_sid)
89
89
  @application.update({:voice_url => url})
90
90
 
91
91
 
@@ -103,6 +103,6 @@ Deleting an Application
103
103
  @client = Twilio::REST::Client.new account_sid, auth_token
104
104
 
105
105
  app_sid = 'AP123' # the app you'd like to delete
106
- @client.applications.get(app_sid)
106
+ @client.account.applications.get(app_sid)
107
107
  @application.delete()
108
108
 
@@ -5,12 +5,12 @@ Accessing REST Resources
5
5
  =========================
6
6
 
7
7
  To access Twilio REST resources, you'll first need to instantiate a
8
- :class:`TwilioRestClient`.
8
+ :class:`Twilio::REST::Client`.
9
9
 
10
10
  Authentication
11
11
  --------------------------
12
12
 
13
- The :class:`TwilioRestClient` needs your Twilio credentials. To get
13
+ The :class:`Twilio::REST::Client` needs your Twilio credentials. To get
14
14
  your credentials, visit `your Twilio account portal
15
15
  <https://www.twilio.com/user/account>`_. If you don't have a Twilio account
16
16
  yet, go `here <https://www.twilio.com/try-twilio>`_ to get started.
@@ -43,12 +43,12 @@ The :class:`Client` gives you access to various list resources.
43
43
  auth_token = "YYYYYYYYYYYYYYYYYY"
44
44
 
45
45
  @client = Twilio::REST::Client.new account_sid, auth_token
46
- @calls = client.calls.list()
46
+ @calls = @client.account.calls.list()
47
47
 
48
48
  :meth:`ListResource.list` accepts paging arguments.
49
49
  The following will return page 3 with page size of 25.
50
50
 
51
- .. code-block:: python
51
+ .. code-block:: ruby
52
52
 
53
53
  require 'twilio-ruby'
54
54
 
@@ -57,7 +57,7 @@ The following will return page 3 with page size of 25.
57
57
  auth_token = "YYYYYYYYYYYYYYYYYY"
58
58
 
59
59
  @client = Twilio::REST::Client.new account_sid, auth_token
60
- @calls = client.calls.list(page=3, page_size=25)
60
+ @calls = @client.account.calls.list(:page=>3, :page_size=>25)
61
61
 
62
62
 
63
63
  Get an Individual Resource
@@ -76,6 +76,6 @@ Provide the :attr:`sid` of the resource you'd like to get.
76
76
 
77
77
  @client = Twilio::REST::Client.new account_sid, auth_token
78
78
 
79
- @call = @client.calls.get("CA123")
79
+ @call = @client.account.calls.get("CA123")
80
80
  puts @call.to
81
81
 
@@ -19,7 +19,7 @@ Validating a phone number is quick and easy.
19
19
  auth_token = "YYYYYYYYYYYYYYYYYY"
20
20
 
21
21
  @client = Twilio::REST::Client.new account_sid, auth_token
22
- @response = @client.caller_ids.create("+44 9876543212")
22
+ @response = @client.account.outgoing_caller_ids.create(:phone_number => "+44 9876543212")
23
23
  puts @response.validation_code
24
24
 
25
25
  Twilio will call the provided number and wait for the validation code to be
@@ -40,6 +40,6 @@ Deleting a phone number is quick and easy.
40
40
 
41
41
  @client = Twilio::REST::Client.new account_sid, auth_token
42
42
 
43
- @response = @client.caller_ids.list(phone_number="+15555555555")
43
+ @response = @client.account.outgoing_caller_ids.list(:phone_number => "+15555555555")
44
44
  @callerid = response[0]
45
45
  @callerid.delete()
@@ -20,7 +20,7 @@ Listing Conferences
20
20
  auth_token = "YYYYYYYYYYYYYYYYYY"
21
21
 
22
22
  @client = Twilio::REST::Client.new account_sid, auth_token
23
- @conferences = @client.conferences.list()
23
+ @conferences = @client.account.conferences.list()
24
24
 
25
25
  @conferences.each do |conference|
26
26
  puts conference.sid
@@ -43,7 +43,7 @@ will return a list of all in-progress conferences and print their friendly name.
43
43
  auth_token = "YYYYYYYYYYYYYYYYYY"
44
44
 
45
45
  @client = Twilio::REST::Client.new account_sid, auth_token
46
- @conferences = @client.conferences.list({:status => "in-progress"})
46
+ @conferences = @client.account.conferences.list({:status => "in-progress"})
47
47
 
48
48
  @conference.each do |conference|
49
49
  puts conference.friendly_name
@@ -64,7 +64,7 @@ Each :class:`Conference` has a :attr:`participants` instance which represents al
64
64
  auth_token = "YYYYYYYYYYYYYYYYYY"
65
65
 
66
66
  @client = Twilio::REST::Client.new account_sid, auth_token
67
- @conference = @client.conferences.get("CF123")
67
+ @conference = @client.account.conferences.get("CF123")
68
68
 
69
69
  @conference.participants.list.each.do |paricipant|
70
70
  puts participant.sid
@@ -94,7 +94,7 @@ code kicks out the first participant and mutes the rest.
94
94
  auth_token = "YYYYYYYYYYYYYYYYYY"
95
95
 
96
96
  @client = Twilio::REST::Client.new account_sid, auth_token
97
- @participants = @client.conferences.get("CF123").participants.list()
97
+ @participants = @client.account.conferences.get("CF123").participants.list()
98
98
 
99
99
  if @participants.empty?
100
100
  return
@@ -24,7 +24,7 @@ Send a text message in only a few lines of code.
24
24
 
25
25
  @client = Twilio::REST::Client.new account_sid, auth_token
26
26
 
27
- @message = client.messages.create({:to => "+13216851234",
27
+ @message = @client.account.messages.create({:to => "+13216851234",
28
28
  :from => "+15555555555",
29
29
  :body => "Hello!"})
30
30
 
@@ -48,7 +48,7 @@ To send a picture, set :attr:`media_url` to the url of the picture you wish to s
48
48
 
49
49
  @client = Twilio::REST::Client.new account_sid, auth_token
50
50
 
51
- @message = client.messages.create({:to => "+15558676309",
51
+ @message = @client.account.messages.create({:to => "+15558676309",
52
52
  :from => "+15555555555",
53
53
  :body => "Jenny I need you!",
54
54
  :media_url => "http://twilio.com/heart.jpg"})
@@ -58,7 +58,7 @@ an array of urls.
58
58
 
59
59
  .. code-block:: ruby
60
60
 
61
- @message = client.messages.create({:to => "+15558676309",
61
+ @message = @client.account.messages.create({:to => "+15558676309",
62
62
  :from => "+15555555555",
63
63
  :body => "Jenny I need you!",
64
64
  :media_url => [
@@ -80,7 +80,7 @@ Retrieving Sent Messages
80
80
 
81
81
  @client = Twilio::REST::Client.new account_sid, auth_token
82
82
 
83
- @client.messages.each do |message|
83
+ @client.account.messages.each do |message|
84
84
  puts message.body
85
85
 
86
86
 
@@ -101,8 +101,7 @@ The following will only show messages to "+5466758723" on January 1st, 2011.
101
101
 
102
102
  @client = Twilio::REST::Client.new account_sid, auth_token
103
103
 
104
- @messages = client.messages.list({:to => "+5466758723",
105
- :date_sent => date(2011,1,1)})
104
+ @messages = @client.account.messages.list({:to => "+5466758723", :date_sent => "2011-01-01"})
106
105
 
107
106
  @messages.each do |message|
108
107
  puts message.body
@@ -24,7 +24,7 @@ current :class:`Notification` resources.
24
24
 
25
25
  @client = Twilio::REST::Client.new account_sid, auth_token
26
26
 
27
- @client.notifications.list().each do |notification|:
27
+ @client.account.notifications.list().each do |notification|:
28
28
  puts notification.more_info
29
29
 
30
30
  You can filter transcriptions by :attr:`log` and :attr:`message_date`.
@@ -42,7 +42,7 @@ The :attr:`log` value is 0 for `ERROR` and 1 for `WARNING`.
42
42
 
43
43
  ERROR = 0
44
44
 
45
- @client.notifications.list(log=ERROR).each do |notification|:
45
+ @client.account.notifications.list(log=ERROR).each do |notification|:
46
46
  puts notification.error_code
47
47
 
48
48
  .. note:: Due to the potentially voluminous amount of data in a notification,
@@ -25,7 +25,7 @@ outputs valid `TwiML <http://www.twilio.com/docs/api/twiml/>`_.
25
25
  auth_token = "YYYYYYYYYYYYYYYYYY"
26
26
 
27
27
  @client = Twilio::REST::Client.new account_sid, auth_token
28
- @call = @client.calls.create({:to => "9991231234",
28
+ @call = @client.account.calls.create({:to => "9991231234",
29
29
  :from => "9991231234",
30
30
  :url => "http://foo.com/call.xml"})
31
31
  puts @call.length
@@ -48,7 +48,7 @@ you can use the client to retrieve that record.
48
48
 
49
49
  @client = Twilio::REST::Client.new account_sid, auth_token
50
50
  sid = "CA12341234"
51
- @call = @client.calls.get(sid)
51
+ @call = @client.account.calls.get(sid)
52
52
 
53
53
 
54
54
  Accessing Specific Call Resources
@@ -69,7 +69,7 @@ just like the :class:`Calls` resource itself.
69
69
 
70
70
  @client = Twilio::REST::Client.new account_sid, auth_token
71
71
  sid = "CA12341234"
72
- @call = @client.calls.get(sid)
72
+ @call = @client.account.calls.get(sid)
73
73
 
74
74
  puts @call.notifications.list()
75
75
  puts @call.recordings.list()
@@ -100,8 +100,6 @@ Modifying Live Calls
100
100
  The :class:`Call` resource makes it easy to find current live calls and
101
101
  redirect them as necessary
102
102
 
103
- .. code-block:: python
104
-
105
103
  .. code-block:: ruby
106
104
 
107
105
  require 'twilio-ruby'
@@ -111,7 +109,7 @@ redirect them as necessary
111
109
  auth_token = "YYYYYYYYYYYYYYYYYY"
112
110
 
113
111
  @client = Twilio::REST::Client.new account_sid, auth_token
114
- @calls = @client.calls.list({:status => "in-progress")
112
+ @calls = @client.account.calls.list({:status => "in-progress"})
115
113
 
116
114
  @calls.each do |call|
117
115
  call.redirect_to("http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient")
@@ -129,7 +127,7 @@ Ending all live calls is also possible
129
127
  auth_token = "YYYYYYYYYYYYYYYYYY"
130
128
 
131
129
  @client = Twilio::REST::Client.new account_sid, auth_token
132
- @calls = @client.calls.list({:status => "in-progress")
130
+ @calls = @client.account.calls.list({:status => "in-progress"})
133
131
 
134
132
  @calls.each do |call|
135
133
  call.hangup()
@@ -150,7 +148,7 @@ resource to update the record without having to use :meth:`get` first.
150
148
 
151
149
  @client = Twilio::REST::Client.new account_sid, auth_token
152
150
  sid = "CA12341234"
153
- @client.calls.get(sid).redirect_to("http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient")
151
+ @client.account.calls.get(sid).redirect_to("http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient")
154
152
 
155
153
  Hanging up the call also works.
156
154
 
@@ -164,5 +162,5 @@ Hanging up the call also works.
164
162
 
165
163
  @client = Twilio::REST::Client.new account_sid, auth_token
166
164
  sid = "CA12341234"
167
- @client.calls.get(sid).hangup()
165
+ @client.account.calls.get(sid).hangup()
168
166
 
@@ -18,16 +18,16 @@ Finding numbers to buy couldn't be easier.
18
18
  We first search for a number in area code 530.
19
19
  Once we find one, we'll purchase it for our account.
20
20
 
21
- .. code-block:: python
21
+ .. code-block:: ruby
22
22
 
23
- from twilio.rest import TwilioRestClient
23
+ require 'twilio-ruby'
24
24
 
25
25
  # To find these visit https://www.twilio.com/user/account
26
- ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXX"
27
- AUTH_TOKEN = "YYYYYYYYYYYYYYYYYY"
26
+ account_sid = "ACXXXXXXXXXXXXXXXXX"
27
+ auth_token = "YYYYYYYYYYYYYYYYYY"
28
28
 
29
- client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
30
- numbers = client.phone_numbers.search(area_code=530)
29
+ @client = Twilio::REST::Client.new account_sid, auth_token
30
+ numbers = @client.account.available_phone_numbers.list(:area_code=>"530")
31
31
 
32
32
  if numbers:
33
33
  numbers[0].purchase()
@@ -41,9 +41,9 @@ Toll Free Numbers
41
41
  By default, :meth:`PhoneNumbers.search` looks for local phone numbers. Add a
42
42
  :data:`type` : ``tollfree`` parameter to search toll-free numbers instead.
43
43
 
44
- .. code-block:: python
44
+ .. code-block:: ruby
45
45
 
46
- numbers = client.phone_numbers.search(type="tollfree")
46
+ numbers = @client.account.available_phone_numbers.list(:type=>"tollfree")
47
47
 
48
48
 
49
49
  Numbers Containing Words
@@ -52,15 +52,15 @@ Numbers Containing Words
52
52
  Phone number search also supports looking for words inside phone numbers.
53
53
  The following example will find any phone number with "FOO" in it.
54
54
 
55
- .. code-block:: python
55
+ .. code-block:: ruby
56
56
 
57
- numbers = client.phone_numbers.search(contains="FOO")
57
+ numbers = @client.account.available_phone_numbers.list(:contains=>"FOO")
58
58
 
59
59
  You can use the ''*'' wildcard to match any character. The following example finds any phone number that matches the pattern ''D*D''.
60
60
 
61
- .. code-block:: python
61
+ .. code-block:: ruby
62
62
 
63
- numbers = client.phone_numbers.search(contains="D*D")
63
+ numbers = @client.account.available_phone_numbers.list(:contains=>"D*D")
64
64
 
65
65
 
66
66
  International Numbers
@@ -70,9 +70,9 @@ By default, the client library will look for US numbers. Set the
70
70
  :data:`country` keyword to a country code of your choice to search for
71
71
  international numbers.
72
72
 
73
- .. code-block:: python
73
+ .. code-block:: ruby
74
74
 
75
- numbers = client.phone_numbers.search(country="FR")
75
+ numbers = @client.account.available_phone_numbers.list(:country=>"FR")
76
76
 
77
77
 
78
78
  :meth:`PhoneNumbers.search` method has plenty of other options to augment your search :
@@ -93,16 +93,16 @@ Buying a Number
93
93
 
94
94
  If you've found a phone number you want, you can purchase the number.
95
95
 
96
- .. code-block:: python
96
+ .. code-block:: ruby
97
97
 
98
- from twilio.rest import TwilioRestClient
98
+ require 'twilio-ruby'
99
99
 
100
100
  # To find these visit https://www.twilio.com/user/account
101
- ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXX"
102
- AUTH_TOKEN = "YYYYYYYYYYYYYYYYYY"
101
+ account_sid = "ACXXXXXXXXXXXXXXXXX"
102
+ auth_token = "YYYYYYYYYYYYYYYYYY"
103
103
 
104
- client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
105
- number = client.phone_numbers.purchase(phone_number="+15305431234")
104
+ @client = Twilio::REST::Client.new account_sid, auth_token
105
+ @number = @client.account.phone_numbers.purchase({:phone_number => "+15305431234"})
106
106
 
107
107
  However, it's easier to purchase numbers after finding them using search (as
108
108
  shown in the first example).
@@ -116,19 +116,19 @@ on the phone number object, with any of the parameters
116
116
  listed in the `IncomingPhoneNumbers Resource documentation
117
117
  <http://www.twilio.com/docs/api/rest/incoming-phone-numbers>`_
118
118
 
119
- .. code-block:: python
119
+ .. code-block:: ruby
120
120
 
121
- from twilio.rest import TwilioRestClient
121
+ require 'twilio-ruby'
122
122
 
123
123
  # To find these visit https://www.twilio.com/user/account
124
- ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXX"
125
- AUTH_TOKEN = "YYYYYYYYYYYYYYYYYY"
124
+ account_sid = "ACXXXXXXXXXXXXXXXXX"
125
+ auth_token = "YYYYYYYYYYYYYYYYYY"
126
126
 
127
- client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
128
- for number in client.phone_numbers.list(api_version="2010-04-01"):
129
- number.update(voice_url="http://twimlets.com/holdmusic?" +
127
+ @client = Twilio::REST::Client.new account_sid, auth_token
128
+ @client.account.phone_numbers.list(api_version="2010-04-01").each do |number|
129
+ number.update({:voice_url => "http://twimlets.com/holdmusic?" +
130
130
  "Bucket=com.twilio.music.ambient",
131
- status_callback="http://example.com/callback")
131
+ :status_callback => "http://example.com/callback"})
132
132
 
133
133
 
134
134
  Changing Applications
@@ -136,18 +136,20 @@ Changing Applications
136
136
 
137
137
  An :class:`Application` encapsulates all necessary URLs for use with phone numbers. Update an application on a phone number using :meth:`update`.
138
138
 
139
- .. code-block:: python
139
+ .. code-block:: ruby
140
140
 
141
- from twilio.rest import TwilioRestClient
142
-
143
- phone_sid = "PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
141
+ require 'twilio-ruby'
144
142
 
145
143
  # To find these visit https://www.twilio.com/user/account
146
- ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXX"
147
- AUTH_TOKEN = "YYYYYYYYYYYYYYYYYY"
144
+ account_sid = "ACXXXXXXXXXXXXXXXXX"
145
+ auth_token = "YYYYYYYYYYYYYYYYYY"
146
+
147
+ @client = Twilio::REST::Client.new account_sid, auth_token
148
+
149
+ phone_sid = "PNXXXXXXXXXXXXXXXXX"
148
150
 
149
- client = TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
150
- number = client.phone_numbers.update(phone_sid, sms_application_sid="AP123")
151
+ @number = @client.account.phone_numbers.get(phone_sid)
152
+ @number.update(:sms_application_sid => "APXXXXXXXXXXXXXXXXXX")
151
153
 
152
154
  See :doc:`/usage/applications` for instructions on updating and maintaining Applications.
153
155
 
@@ -22,7 +22,7 @@ Listing Queues
22
22
  auth_token = "YYYYYYYYYYYYYYYYYY"
23
23
 
24
24
  @client = Twilio::REST::Client.new account_sid, auth_token
25
- @queues = client.queues.list()
25
+ @queues = @client.account.queues.list()
26
26
 
27
27
  @queues.each do |queue|
28
28
  puts queue.sid
@@ -44,7 +44,7 @@ represents all current calls in the queue.
44
44
  auth_token = "YYYYYYYYYYYYYYYYYY"
45
45
 
46
46
  @client = Twilio::REST::Client.new account_sid, auth_token
47
- @queue = @client.queues.get("QU123")
47
+ @queue = @client.account.queues.get("QU123")
48
48
 
49
49
  @queue.members.list().each do |member|
50
50
  print member.call_sid
@@ -75,7 +75,7 @@ first call in the queue.
75
75
  queue_sid = "QUAAAAAAAAAAAAA"
76
76
  call_sid = "CAXXXXXXXXXXXXXX"
77
77
 
78
- @members = @client.queues.get(queue_sid).members
78
+ @members = @client.account.queues.get(queue_sid).members
79
79
 
80
80
  # Get the first call in the queue
81
81
  puts members.front.date_enqueued
@@ -106,7 +106,7 @@ default values are 'Front' and 'GET'
106
106
 
107
107
  queue_sid = "QUAAAAAAAAAAAAA"
108
108
 
109
- @members = @client.queues.get(queue_sid).members
109
+ @members = @client.account.queues.get(queue_sid).members
110
110
 
111
111
  # Dequeue the first call in the queue
112
112
  puts @members.dequeue('http://www.twilio.com/welcome/call')
@@ -35,7 +35,7 @@ for each :class:`Recording`.
35
35
 
36
36
  @client = Twilio::REST::Client.new account_sid, auth_token
37
37
 
38
- @client.recordings.list().each do |recording|
38
+ @client.account.recordings.list().each do |recording|
39
39
  puts recording.duration
40
40
 
41
41
  You can filter recordings by CallSid by passing the Sid as :attr:`call`.
@@ -52,7 +52,7 @@ The following will only show recordings made before January 1, 2011.
52
52
  auth_token = "YYYYYYYYYYYYYYYYYY"
53
53
 
54
54
  @client = Twilio::REST::Client.new account_sid, auth_token
55
- @client.recordings.list(before=date(2011,1,1)).each do |recording|:
55
+ @client.account.recordings.list(before=date(2011,1,1)).each do |recording|:
56
56
  puts recording.duration
57
57
 
58
58
 
@@ -70,7 +70,7 @@ The :class:`Recordings` resource allows you to delete unnecessary recordings.
70
70
  auth_token = "YYYYYYYYYYYYYYYYYY"
71
71
 
72
72
  @client = Twilio::REST::Client.new account_sid, auth_token
73
- @client.recordings.get("RC123").delete()
73
+ @client.account.recordings.get("RC123").delete()
74
74
 
75
75
 
76
76
  Accessing Related Transcptions
@@ -89,7 +89,7 @@ with this recording.
89
89
  auth_token = "YYYYYYYYYYYYYYYYYY"
90
90
 
91
91
  @client = Twilio::REST::Client.new account_sid, auth_token
92
- @recording = @client.recordings.get("RC123")
92
+ @recording = @client.account.recordings.get("RC123")
93
93
 
94
94
  @recording.transcriptions.list().each do |transcription|
95
95
  puts transcription.transcription_text
data/docs/usage/sip.rst CHANGED
@@ -26,7 +26,7 @@ under sip.twilio.com.
26
26
 
27
27
  @client = Twilio::REST::Client.new account_sid, auth_token
28
28
 
29
- @domain = @client.sip.domains.create(
29
+ @domain = @client.account.sip.domains.create(
30
30
  {:friendly_name => "The Office Domain",
31
31
  :voice_url => "http://example.com/voice",
32
32
  :domain_name => "dunder-mifflin-scranton.sip.twilio.com",}
@@ -50,7 +50,7 @@ to individual ip addresses. To do this, you'll first need to create an
50
50
 
51
51
  @client = Twilio::REST::Client.new account_sid, auth_token
52
52
 
53
- @ip_acl = @client.sip.ip_access_control_lists.create(
53
+ @ip_acl = @client.account.sip.ip_access_control_lists.create(
54
54
  {:friendly_name => "The Office IpAccessControlList",}
55
55
  )
56
56
  puts @ip_acl.sid
@@ -70,7 +70,7 @@ Now it's time to add an :class:`IpAddress` to your new :class:`IpAccessControlLi
70
70
 
71
71
  @client = Twilio::REST::Client.new account_sid, auth_token
72
72
 
73
- @ip_address = @client.sip.ip_access_control_lists.get(
73
+ @ip_address = @client.account.sip.ip_access_control_lists.get(
74
74
  "AL456", # IpAccessControlList sid
75
75
  ).ip_addresses.create(
76
76
  {:friendly_name => "Dwights's Computer",
@@ -94,7 +94,7 @@ associate them. To do this, create an :class:`IpAccessControlListMapping`.
94
94
 
95
95
  @client = Twilio::REST::Client.new account_sid, auth_token
96
96
 
97
- @ip_acl_mapping = @client.sip.domains.get(
97
+ @ip_acl_mapping = @client.account.sip.domains.get(
98
98
  "SD456", # SIP Domain sid
99
99
  ).ip_access_control_list_mappings.create(
100
100
  {:ip_access_control_list_sid => "AL789"})
@@ -26,6 +26,6 @@ The following code will print out the length of each :class:`Transcription`.
26
26
  auth_token = "YYYYYYYYYYYYYYYYYY"
27
27
 
28
28
  @client = Twilio::REST::Client.new account_sid, auth_token
29
- @client.transcriptions.list().each do |transcription|
29
+ @client.account.transcriptions.list().each do |transcription|
30
30
  puts transcription.duration
31
31
 
data/docs/usage/twiml.rst CHANGED
@@ -13,7 +13,7 @@ These methods return the verbs they create to ease creation of nested TwiML.
13
13
  To finish, call the :meth:`toxml` method on the :class:`Response`,
14
14
  which returns raw TwiML.
15
15
 
16
- .. code-block:: python
16
+ .. code-block:: ruby
17
17
 
18
18
  require 'twilio-ruby'
19
19
 
@@ -30,7 +30,7 @@ The verb methods (outlined in the :doc:`complete reference </api/twiml>`)
30
30
  take the body (only text) of the verb as the first argument.
31
31
  All attributes are keyword arguments.
32
32
 
33
- .. code-block:: python
33
+ .. code-block:: ruby
34
34
 
35
35
  require 'twilio-ruby'
36
36
 
@@ -45,10 +45,9 @@ All attributes are keyword arguments.
45
45
  <Play loop="3">https://api.twilio.com/cowbell.mp3</Play>
46
46
  <Response>
47
47
 
48
- Python 2.6+ added the :const:`with` statement for context management.
49
- Using :const:`with`, the module can *almost* emulate Ruby blocks.
48
+ Any example of nesting nouns in verbs
50
49
 
51
- .. code-block:: python
50
+ .. code-block:: ruby
52
51
 
53
52
  require 'twilio-ruby'
54
53
 
@@ -30,7 +30,7 @@ data as a dictionary and the url and X-Twilio-Signature as strings.
30
30
  The below example will print out a confirmation message if the request is
31
31
  actually from Twilio.
32
32
 
33
- .. code-block:: python
33
+ .. code-block:: ruby
34
34
 
35
35
  require 'twilio-ruby'
36
36
 
@@ -1,6 +1,11 @@
1
1
  module Twilio
2
2
  module REST
3
- class Messages < ListResource; end
3
+ class Messages < ListResource
4
+ def initialize(path, client)
5
+ path.gsub! '/SMS', ''
6
+ super
7
+ end
8
+ end
4
9
 
5
10
  class Message < InstanceResource
6
11
  def initialize(path, client, params={})
@@ -1,3 +1,3 @@
1
1
  module Twilio
2
- VERSION = '3.11.0'
2
+ VERSION = '3.11.1'
3
3
  end
data/lib/twilio-ruby.rb CHANGED
@@ -20,7 +20,6 @@ require 'twilio-ruby/rest/sandbox'
20
20
  require 'twilio-ruby/rest/accounts'
21
21
  require 'twilio-ruby/rest/calls'
22
22
  require 'twilio-ruby/rest/sms'
23
- require 'twilio-ruby/rest/sms/messages'
24
23
  require 'twilio-ruby/rest/sms/short_codes'
25
24
  require 'twilio-ruby/rest/sip'
26
25
  require 'twilio-ruby/rest/sip/domains'
@@ -9,4 +9,9 @@ describe Twilio::REST::Message do
9
9
  @message.should respond_to(:media)
10
10
  @message.media.instance_variable_get('@path').should == 'someUri/Media'
11
11
  end
12
+
13
+ it 'does not use the old endpoint' do
14
+ client = Twilio::REST::Client.new('someId', 'sometoken')
15
+ client.account.sms.messages.instance_variable_get('@path').include?('/SMS').should be_false
16
+ end
12
17
  end
metadata CHANGED
@@ -1,68 +1,60 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twilio-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.11.0
5
- prerelease:
4
+ version: 3.11.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Andrew Benton
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-09-18 00:00:00.000000000 Z
11
+ date: 2013-09-25 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: multi_json
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 1.3.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 1.3.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: builder
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: 2.1.2
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: 2.1.2
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: jwt
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: 0.1.2
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: 0.1.2
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rake
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rspec
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ~>
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ~>
92
81
  - !ruby/object:Gem::Version
@@ -94,7 +83,6 @@ dependencies:
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: fakeweb
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - ~>
100
88
  - !ruby/object:Gem::Version
@@ -102,7 +90,6 @@ dependencies:
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - ~>
108
95
  - !ruby/object:Gem::Version
@@ -110,7 +97,6 @@ dependencies:
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: rack
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
101
  - - ~>
116
102
  - !ruby/object:Gem::Version
@@ -118,7 +104,6 @@ dependencies:
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
108
  - - ~>
124
109
  - !ruby/object:Gem::Version
@@ -213,7 +198,6 @@ files:
213
198
  - lib/twilio-ruby/rest/sip/ip_access_control_lists.rb
214
199
  - lib/twilio-ruby/rest/sip/ip_access_control_lists/ip_addresses.rb
215
200
  - lib/twilio-ruby/rest/sms.rb
216
- - lib/twilio-ruby/rest/sms/messages.rb
217
201
  - lib/twilio-ruby/rest/sms/short_codes.rb
218
202
  - lib/twilio-ruby/rest/transcriptions.rb
219
203
  - lib/twilio-ruby/rest/usage.rb
@@ -240,6 +224,7 @@ files:
240
224
  homepage: http://github.com/twilio/twilio-ruby
241
225
  licenses:
242
226
  - MIT
227
+ metadata: {}
243
228
  post_install_message:
244
229
  rdoc_options:
245
230
  - --line-numbers
@@ -251,33 +236,31 @@ rdoc_options:
251
236
  require_paths:
252
237
  - lib
253
238
  required_ruby_version: !ruby/object:Gem::Requirement
254
- none: false
255
239
  requirements:
256
- - - ! '>='
240
+ - - '>='
257
241
  - !ruby/object:Gem::Version
258
242
  version: '0'
259
243
  required_rubygems_version: !ruby/object:Gem::Requirement
260
- none: false
261
244
  requirements:
262
- - - ! '>='
245
+ - - '>='
263
246
  - !ruby/object:Gem::Version
264
247
  version: '0'
265
248
  requirements: []
266
249
  rubyforge_project:
267
- rubygems_version: 1.8.23
250
+ rubygems_version: 2.1.4
268
251
  signing_key:
269
- specification_version: 3
252
+ specification_version: 4
270
253
  summary: A simple library for communicating with the Twilio REST API, building TwiML,
271
254
  and generating Twilio Client Capability Tokens
272
255
  test_files:
273
- - spec/spec_helper.rb
274
- - spec/rest/conference_spec.rb
256
+ - spec/rest/account_spec.rb
275
257
  - spec/rest/call_spec.rb
258
+ - spec/rest/client_spec.rb
259
+ - spec/rest/conference_spec.rb
276
260
  - spec/rest/instance_resource_spec.rb
277
- - spec/rest/recording_spec.rb
278
- - spec/rest/account_spec.rb
279
261
  - spec/rest/message_spec.rb
280
- - spec/rest/client_spec.rb
281
262
  - spec/rest/queue_spec.rb
263
+ - spec/rest/recording_spec.rb
264
+ - spec/spec_helper.rb
282
265
  - spec/util/capability_spec.rb
283
266
  - spec/util/request_validator_spec.rb
@@ -1,13 +0,0 @@
1
- module Twilio
2
- module REST
3
- class Messages < ListResource
4
- def initialize(path, client)
5
- super
6
- # hard-code the json key since 'messages' doesn't exist in the response
7
- @list_key = 'sms_messages'
8
- end
9
- end
10
-
11
- class Message < InstanceResource; end
12
- end
13
- end