twilio-ruby 3.11.5 → 3.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. checksums.yaml +13 -5
  2. data/.gitignore +1 -1
  3. data/.travis.yml +20 -8
  4. data/AUTHORS.md +29 -25
  5. data/{CHANGES → CHANGES.md} +45 -1
  6. data/Gemfile +8 -1
  7. data/{LICENSE → LICENSE.md} +1 -1
  8. data/Makefile +1 -2
  9. data/README.md +57 -26
  10. data/Rakefile +8 -10
  11. data/docs/getting-started.rst +3 -3
  12. data/docs/usage/applications.rst +5 -5
  13. data/docs/usage/basics.rst +17 -4
  14. data/docs/usage/caller-ids.rst +2 -2
  15. data/docs/usage/conferences.rst +5 -5
  16. data/docs/usage/errors.rst +1 -1
  17. data/docs/usage/messages.rst +6 -6
  18. data/docs/usage/notifications.rst +2 -2
  19. data/docs/usage/phone-calls.rst +7 -7
  20. data/docs/usage/phone-numbers.rst +12 -12
  21. data/docs/usage/queues.rst +6 -6
  22. data/docs/usage/recordings.rst +5 -5
  23. data/docs/usage/sip.rst +5 -5
  24. data/docs/usage/token-generation.rst +18 -3
  25. data/docs/usage/transcriptions.rst +1 -1
  26. data/docs/usage/twiml.rst +1 -1
  27. data/docs/usage/validation.rst +27 -1
  28. data/examples/print-call-log.rb +1 -1
  29. data/lib/rack/twilio_webhook_authentication.rb +40 -0
  30. data/lib/twilio-ruby/rest/call_feedback.rb +28 -0
  31. data/lib/twilio-ruby/rest/call_feedback_summary.rb +13 -0
  32. data/lib/twilio-ruby/rest/calls.rb +6 -1
  33. data/lib/twilio-ruby/rest/client.rb +43 -5
  34. data/lib/twilio-ruby/rest/list_resource.rb +10 -4
  35. data/lib/twilio-ruby/rest/usage/records.rb +2 -2
  36. data/lib/twilio-ruby/twiml/response.rb +1 -0
  37. data/lib/twilio-ruby/util/capability.rb +6 -3
  38. data/lib/twilio-ruby/util/configuration.rb +7 -0
  39. data/lib/twilio-ruby/util/request_validator.rb +3 -2
  40. data/lib/twilio-ruby/version.rb +1 -1
  41. data/lib/twilio-ruby.rb +25 -0
  42. data/spec/rack/twilio_webhook_authentication_spec.rb +76 -0
  43. data/spec/rest/account_spec.rb +20 -20
  44. data/spec/rest/call_feedback_spec.rb +12 -0
  45. data/spec/rest/call_feedback_summary_spec.rb +9 -0
  46. data/spec/rest/call_spec.rb +4 -4
  47. data/spec/rest/client_spec.rb +114 -38
  48. data/spec/rest/conference_spec.rb +2 -2
  49. data/spec/rest/instance_resource_spec.rb +3 -3
  50. data/spec/rest/message_spec.rb +2 -2
  51. data/spec/rest/numbers_spec.rb +12 -12
  52. data/spec/rest/queue_spec.rb +2 -2
  53. data/spec/rest/recording_spec.rb +2 -2
  54. data/spec/spec_helper.rb +12 -3
  55. data/spec/support/fakeweb.rb +2 -0
  56. data/spec/twilio_spec.rb +15 -0
  57. data/spec/util/capability_spec.rb +167 -118
  58. data/spec/util/configuration_spec.rb +13 -0
  59. data/spec/util/request_validator_spec.rb +31 -3
  60. data/spec/util/url_encode_spec.rb +1 -1
  61. data/twilio-ruby.gemspec +28 -27
  62. metadata +46 -71
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7ab94258630ce056a2ec9062bcead79026e6ace5
4
- data.tar.gz: dee171b3ef56e709b2a83e9266ec0afd4ea49ba2
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YTAxY2JmOWY5NjY3MTMyNTA1ZTVhMWE1NmMyZmIxYzI3NjNhYWVlYw==
5
+ data.tar.gz: !binary |-
6
+ NTQwYTVkMDFhMGUzNzAyMzE0NGQyN2U2YmJiMWQ5ZmE2NzZkZjVmNg==
5
7
  SHA512:
6
- metadata.gz: 51e94cefd327185a93ae3fadf1151a13affae35f4d7af2bd0fbc418d25a82ac800ca79974b719edf6e572f3649db87364c5794f56597db3fdcc2452823173372
7
- data.tar.gz: 921bede6c840a2dcb37495e1778982c322c6d04406466b56964f003f0ffcb0263a9cccf71b4b5564e1a64033f8f9e8cd62219e4cc8616dff5f09c29140f37793
8
+ metadata.gz: !binary |-
9
+ ZjY4MTY2ZmRlY2M0YzJhMzA3OTMxMTBlZmEwZjlkNzgxNWJmMTRiODQ4NDRh
10
+ OWUxYjEwOWQ5MDczNGI3MTEwZGM3ZmZkNWM5YzU1ZjNiY2NjZGI0ZTIwZTBl
11
+ N2JiOGQ1YTE5YTE0MDNkYWVjMjI3ZDRhMmQ3YzJhMmFiZGZlZDg=
12
+ data.tar.gz: !binary |-
13
+ YTA2ZWZhZDdiZDRiOWYwY2MxOThjM2RlNDkyMzZjOWUyNWI0ZjI5ZTQ3Mjc3
14
+ NjAxOWNjMjFlNmVhMWE3OGM5YzExNTJjNWNmNGUzMDFlMGZlYTRjMTk3MGZk
15
+ MDNlYTUxYzkwNDRiMWVjNDY1YjY3OGVlZjU5NDAwMWMxN2YwNTU=
data/.gitignore CHANGED
@@ -4,5 +4,5 @@ pkg/*
4
4
  doc/*
5
5
  Gemfile.lock
6
6
  *.gem
7
-
7
+ bin
8
8
  docs/_build
data/.travis.yml CHANGED
@@ -1,13 +1,25 @@
1
1
  language: ruby
2
- script: "rake spec"
2
+ cache: bundler
3
+ bundler_args: --without development
3
4
  rvm:
4
- - 1.8.7
5
- - 1.9.2
6
- - 1.9.3
7
- - 2.0.0
5
+ - ruby-head
6
+ - ruby
8
7
  - 2.1.0
9
- - jruby-18mode
8
+ - 2.0.0
9
+ - 1.9.3
10
+ - 1.8.7
11
+ - jruby-head
12
+ - jruby
10
13
  - jruby-19mode
11
- - rbx-2.1.1
12
- - rbx-2.2.1
14
+ - jruby-18mode
15
+ - rbx-head
16
+ - rbx-2
13
17
  - ree
18
+ matrix:
19
+ fast_finish: true
20
+ allow_failures:
21
+ - rvm: ruby-head
22
+ - rvm: ruby
23
+ - rvm: jruby-head
24
+ - rvm: jruby
25
+ - rvm: rbx-head
data/AUTHORS.md CHANGED
@@ -4,28 +4,32 @@ Authors
4
4
  A huge thanks to all of our contributors:
5
5
 
6
6
 
7
- - Adam Ballai
8
- - Alexander Murmann & Ryan Spore
9
- - Andrew Benton
10
- - Brian Levine
11
- - Caley Woods
12
- - Carlos Diaz-Padron
13
- - Connor Montgomery
14
- - Doug Black
15
- - Elaine Tsai
16
- - Fiona Tay & Will Read
17
- - Geoff Petrie
18
- - Guille Carlos
19
- - Josh Hull
20
- - Joël Franusic
21
- - K Gautam Pai
22
- - Kevin Burke
23
- - Kyle Conroy
24
- - Oscar
25
- - Oscar Sanchez
26
- - Rafael Chacon
27
- - Ryan Spore
28
- - Sam Kimbrel
29
- - Torey Heinz
30
- - Vipul A M
31
- - vfrride
7
+ - Adam Ballai
8
+ - Alexander Murmann & Ryan Spore
9
+ - Andrew Benton
10
+ - Brian Levine
11
+ - Caley Woods
12
+ - Carlos Diaz-Padron
13
+ - Connor Montgomery
14
+ - Doug Black
15
+ - Elaine Tsai
16
+ - Fiona Tay & Will Read
17
+ - Geoff Petrie
18
+ - Guille Carlos
19
+ - Jeremy Franz
20
+ - Josh Hull
21
+ - Joël Franusic
22
+ - K Gautam Pai
23
+ - Karl Freeman
24
+ - Kevin Burke
25
+ - Kyle Conroy
26
+ - Leo Adamek
27
+ - Oscar
28
+ - Oscar Sanchez
29
+ - Phil Nash
30
+ - Rafael Chacon
31
+ - Ryan Spore
32
+ - Sam Kimbrel
33
+ - Torey Heinz
34
+ - Vipul A M
35
+ - vfrride
@@ -1,15 +1,58 @@
1
1
  twilio-ruby changelog
2
2
  =====================
3
3
 
4
+ Version 3.12.3
5
+ --------------
6
+
7
+ Released September 23, 2014
8
+
9
+ - Added block configure syntax
10
+
11
+ Version 3.12.2
12
+ --------------
13
+
14
+ Released August 29, 2014
15
+
16
+ - `client.account.{resource}` can now be accessed with `client.{resource}`
17
+ - Many doc updates
18
+
19
+ Version 3.12.1
20
+ --------------
21
+
22
+ Released August 26, 2014
23
+
24
+ - Add support for new call feedback endpoints
25
+
26
+ Version 3.12.0
27
+ --------------
28
+
29
+ Released August 18, 2014
30
+
31
+ - Add Rack middleware for Twilio request-signature validation
32
+ - Upgrade dependencies and clean up project files
33
+ - Documentation fixes
34
+ - Add `text` alias for `to_xml` method on TwiML generator objects
35
+
36
+ Version 3.11.6
37
+ --------------
38
+
39
+ Released July 25, 2014
40
+
41
+ - Add #to_xml to TwiML Responses.
42
+ - Updated test / development dependencies.
43
+ - Updated to RSpec 3 syntax.
44
+
4
45
  Version 3.11.5
46
+ --------------
5
47
 
6
- Released February 4
48
+ Released February 4, 2014
7
49
 
8
50
  - Add bangs for twilify to indicate it's a dangerous operation.
9
51
  - Remove reference to deprecated OpenSSL Digest parameter.
10
52
  - Encode dates properly before passing them to the Twilio API.
11
53
 
12
54
  Version 3.11.4
55
+ --------------
13
56
 
14
57
  Released October 21, 2013
15
58
 
@@ -18,6 +61,7 @@ Released October 21, 2013
18
61
  both IncomingPhoneNumbers and AvailablePhoneNumbers.
19
62
 
20
63
  Version 3.11.3
64
+ --------------
21
65
 
22
66
  Released October 15, 2013
23
67
 
data/Gemfile CHANGED
@@ -1,3 +1,10 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ group :test do
6
+ gem 'rake', '~> 10.1'
7
+ gem 'rspec', '~> 3.0'
8
+ gem 'fakeweb', '~> 1.3'
9
+ gem 'rack', '~> 1.3'
10
+ end
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2012 Andrew Benton.
1
+ Copyright (c) 2010-2014 Andrew Benton.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/Makefile CHANGED
@@ -1,6 +1,5 @@
1
1
  install:
2
- gem build twilio-ruby.gemspec
3
- gem install twilio-ruby-*.gem
2
+ bundle exec rake install
4
3
 
5
4
  test-install:
6
5
  bundle install
data/README.md CHANGED
@@ -1,15 +1,20 @@
1
- [![Build Status](https://travis-ci.org/twilio/twilio-ruby.png?branch=master)](https://travis-ci.org/twilio/twilio-ruby)
2
- [![Gem Version](https://badge.fury.io/rb/twilio-ruby.png)](http://badge.fury.io/rb/twilio-ruby)
1
+ [![Gem Version](http://img.shields.io/gem/v/twilio-ruby.svg)][gem]
2
+ [![Build Status](http://img.shields.io/travis/twilio/twilio-ruby.svg)][travis]
3
+ [![Code Quality](http://img.shields.io/codeclimate/github/twilio/twilio-ruby.svg)][codeclimate]
3
4
 
4
5
  # twilio-ruby
5
6
 
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]
7
+ A module for using the Twilio REST API and generating valid [TwiML](http://www.twilio.com/docs/api/twiml/ "TwiML - Twilio Markup Language"). [Click here to read the full documentation.][documentation]
9
8
 
10
- ## Install
9
+ ## Installation
11
10
 
12
- Via rubygems.org:
11
+ To install using [Bundler][bundler] grab the latest stable version:
12
+
13
+ ```ruby
14
+ gem 'twilio-ruby', '~> 3.12'
15
+ ```
16
+
17
+ To manually install `twilio-ruby` via [Rubygems][rubygems] simply gem install:
13
18
 
14
19
  ```bash
15
20
  gem install twilio-ruby
@@ -37,12 +42,21 @@ auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
37
42
 
38
43
  # set up a client to talk to the Twilio REST API
39
44
  @client = Twilio::REST::Client.new account_sid, auth_token
45
+
46
+ # alternatively, you can preconfigure the client like so
47
+ Twilio.configure do |config|
48
+ config.account_sid = account_sid
49
+ config.auth_token = auth_token
50
+ end
51
+
52
+ # and then you can create a new client without parameters
53
+ @client = Twilio::REST::Client.new
40
54
  ```
41
55
 
42
56
  ### Send an SMS
43
57
 
44
58
  ``` ruby
45
- @client.account.messages.create(
59
+ @client.messages.create(
46
60
  :from => '+14159341234',
47
61
  :to => '+16105557069',
48
62
  :body => 'Hey there!'
@@ -52,7 +66,7 @@ auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
52
66
  ### Send an MMS
53
67
 
54
68
  ``` ruby
55
- @client.account.messages.create(
69
+ @client.messages.create(
56
70
  :from => '+14159341234',
57
71
  :to => '+16105557069',
58
72
  :body => 'Hey there!',
@@ -64,7 +78,7 @@ auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
64
78
 
65
79
  ``` ruby
66
80
  # make a new outgoing call
67
- @call = @client.account.calls.create(
81
+ @call = @client.calls.create(
68
82
  :from => '+14159341234',
69
83
  :to => '+18004567890',
70
84
  :url => 'http://example.com/call-handler',
@@ -74,7 +88,7 @@ auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
74
88
  @call.cancel
75
89
 
76
90
  # if you have the call sid, you can fetch a call object via:
77
- @call = @client.account.calls.get('CA386025c9bf5d6052a1d1ea42b4d16662')
91
+ @call = @client.calls.get('CA386025c9bf5d6052a1d1ea42b4d16662')
78
92
 
79
93
  # redirect an in-progress call
80
94
  @call.redirect_to('http://example.com/call-redirect')
@@ -87,21 +101,21 @@ auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
87
101
 
88
102
  ``` ruby
89
103
  # list calls made or received on or after May 13, 2013
90
- @client.account.calls.list("start_time>" => "2013-05-13") # Notice we omit the "=" in the "start_time>=" parameter because it is automatically added
104
+ @client.calls.list("start_time>" => "2013-05-13") # Notice we omit the "=" in the "start_time>=" parameter because it is automatically added
91
105
  ```
92
106
 
93
107
  ### Buy a Phone Number
94
108
 
95
109
  ``` ruby
96
110
  # print some available numbers
97
- @numbers = @client.account.available_phone_numbers.get('US').local.list(
111
+ @numbers = @client.available_phone_numbers.get('US').local.list(
98
112
  :contains => 'AWESOME'
99
113
  )
100
114
  @numbers.each {|num| puts num.phone_number}
101
115
 
102
116
  # buy the first one
103
117
  @number = @numbers[0].phone_number
104
- @client.account.incoming_phone_numbers.create(:phone_number => @number)
118
+ @client.incoming_phone_numbers.create(:phone_number => @number)
105
119
  ```
106
120
 
107
121
  ## Getting Started With Client Capability Tokens
@@ -135,7 +149,7 @@ section of the wiki.
135
149
 
136
150
  ## Getting Started With TwiML
137
151
 
138
- TwiML support is based on the [builder][builder] library. You can construct a
152
+ TwiML support is based on the [Builder][builder] library. You can construct a
139
153
  TwiML response like this:
140
154
 
141
155
  ``` ruby
@@ -156,7 +170,7 @@ puts response.text
156
170
 
157
171
  This will print the following (except for the whitespace):
158
172
 
159
- ```
173
+ ``` xml
160
174
  <?xml version="1.0" encoding="UTF-8"?>
161
175
  <Response>
162
176
  <Say voice="alice">hello there</Say>
@@ -166,16 +180,33 @@ This will print the following (except for the whitespace):
166
180
  </Response>
167
181
  ```
168
182
 
169
- ## More Information
183
+ ## Supported Ruby Versions
170
184
 
171
- There are more detailed examples in the included [examples][examples]
172
- directory.
185
+ This library supports and is [tested against][travis] the following Ruby
186
+ implementations:
173
187
 
174
- The [upgrade guide][upgrade] is available in the [twilio-ruby github wiki][wiki].
188
+ - Ruby 2.1.0
189
+ - Ruby 2.0.0
190
+ - Ruby 1.9.3
191
+ - Ruby 1.8.7
192
+ - [JRuby][jruby]
193
+ - [Rubinius][rubinius]
175
194
 
176
- [capability]:https://github.com/twilio/twilio-ruby/wiki/Capability
177
- [builder]:http://builder.rubyforge.org/
178
- [examples]:https://github.com/twilio/twilio-ruby/blob/master/examples
179
- [documentation]:http://twilio-ruby.readthedocs.org/en/latest
180
- [upgrade]:https://github.com/twilio/twilio-ruby/wiki/UpgradeGuide
181
- [wiki]:https://github.com/twilio/twilio-ruby/wiki
195
+ ## More Information
196
+
197
+ There are more detailed examples in the included [examples][examples]
198
+ directory. Also for thoose upgrading, the [upgrade guide][upgrade] is available in the [twilio-ruby github wiki][wiki].
199
+
200
+ [capability]: https://github.com/twilio/twilio-ruby/wiki/Capability
201
+ [builder]: http://builder.rubyforge.org/
202
+ [examples]: https://github.com/twilio/twilio-ruby/blob/master/examples
203
+ [documentation]: http://twilio-ruby.readthedocs.org/en/latest
204
+ [upgrade]: https://github.com/twilio/twilio-ruby/wiki/UpgradeGuide
205
+ [wiki]: https://github.com/twilio/twilio-ruby/wiki
206
+ [bundler]: http://bundler.io
207
+ [rubygems]: http://rubygems.org
208
+ [gem]: https://rubygems.org/gems/twilio
209
+ [travis]: http://travis-ci.org/twilio/twilio-ruby
210
+ [codeclimate]: https://codeclimate.com/github/twilio/twilio-ruby
211
+ [jruby]: http://www.jruby.org
212
+ [rubinius]: http://rubini.us
data/Rakefile CHANGED
@@ -1,12 +1,10 @@
1
- require 'rubygems'
2
- require 'rubygems/package_task'
3
- require 'rspec/core/rake_task'
4
-
5
- spec = eval(File.read('twilio-ruby.gemspec'))
1
+ require 'bundler'
2
+ Bundler.setup
3
+ Bundler::GemHelper.install_tasks
6
4
 
7
- Gem::PackageTask.new(spec) do |p|
8
- p.gem_spec = spec
9
- end
5
+ require 'rspec/core/rake_task'
6
+ desc 'Run all specs'
7
+ RSpec::Core::RakeTask.new(:spec)
10
8
 
11
- RSpec::Core::RakeTask.new
12
- task :default => :spec
9
+ task :default => :spec
10
+ task :test => :spec
@@ -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.account.calls.create({:to => "9991231234", :from => "9991231234",
22
+ @call = @client.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.account.messages.create({:to => "+12316851234",
41
+ @message = @client.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.account.messages.create({:to => "+15558676309",
59
+ @message = @client.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.account.applications.each do |app|
29
+ @client.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.account.applications.list({:friendly_name => 'FOO'})}.each do |app|
48
+ @client.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.account.applications.create({:friendly_name => "My New App"})
69
+ @application = @client.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.account.applications.get(app_sid)
88
+ @application = @client.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.account.applications.get(app_sid)
106
+ @client.applications.get(app_sid)
107
107
  @application.delete()
108
108
 
@@ -27,6 +27,19 @@ Once you have your credentials, you can create create a new :class:`Client` and
27
27
 
28
28
  @client = Twilio::REST::Client.new account_sid, auth_token
29
29
 
30
+ You can also configure the client using the top level configure method, like so:
31
+
32
+ .. code-block:: ruby
33
+
34
+ require 'twilio-ruby'
35
+
36
+ Twilio.configure do |config|
37
+ config.account_sid = "ACXXXXXXXXXXXXXXXXX"
38
+ config.auth_token = "YYYYYYYYYYYYYYYYYY"
39
+ end
40
+
41
+ @client = Twilio::REST::Client.new
42
+
30
43
 
31
44
  Listing Resources
32
45
  -------------------
@@ -43,7 +56,7 @@ The :class:`Client` gives you access to various list resources.
43
56
  auth_token = "YYYYYYYYYYYYYYYYYY"
44
57
 
45
58
  @client = Twilio::REST::Client.new account_sid, auth_token
46
- @calls = @client.account.calls.list()
59
+ @calls = @client.calls.list()
47
60
 
48
61
  :meth:`ListResource.list` accepts paging arguments.
49
62
  The following will return page 3 with page size of 25.
@@ -57,7 +70,7 @@ The following will return page 3 with page size of 25.
57
70
  auth_token = "YYYYYYYYYYYYYYYYYY"
58
71
 
59
72
  @client = Twilio::REST::Client.new account_sid, auth_token
60
- @calls = @client.account.calls.list(:page=>3, :page_size=>25)
73
+ @calls = @client.calls.list(:page=>3, :page_size=>25)
61
74
 
62
75
 
63
76
  Get an Individual Resource
@@ -76,7 +89,7 @@ Provide the :attr:`sid` of the resource you'd like to get.
76
89
 
77
90
  @client = Twilio::REST::Client.new account_sid, auth_token
78
91
 
79
- @call = @client.account.calls.get("CA123")
92
+ @call = @client.calls.get("CA123")
80
93
  puts @call.to
81
94
 
82
95
 
@@ -97,6 +110,6 @@ and then call :meth:`delete` on it.
97
110
 
98
111
  @client = Twilio::REST::Client.new account_sid, auth_token
99
112
 
100
- @recording = @client.account.recordings.get("RC123")
113
+ @recording = @client.recordings.get("RC123")
101
114
  @recording.delete()
102
115
 
@@ -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.account.outgoing_caller_ids.create(:phone_number => "+44 9876543212")
22
+ @response = @client.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.account.outgoing_caller_ids.list(:phone_number => "+15555555555")
43
+ @response = @client.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.account.conferences.list()
23
+ @conferences = @client.conferences.list()
24
24
 
25
25
  @conferences.each do |conference|
26
26
  puts conference.sid
@@ -43,8 +43,8 @@ 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.account.conferences.list({:status => "in-progress"})
47
-
46
+ @conferences = @client.conferences.list({:status => "in-progress"})
47
+
48
48
  @conference.each do |conference|
49
49
  puts conference.friendly_name
50
50
  end
@@ -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.account.conferences.get("CF123")
67
+ @conference = @client.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.account.conferences.get("CF123").participants.list()
97
+ @participants = @client.conferences.get("CF123").participants.list()
98
98
 
99
99
  if @participants.empty?
100
100
  return
@@ -19,7 +19,7 @@ handled appropriately.
19
19
 
20
20
  begin
21
21
  @client = Twilio::REST::Client.new account_sid, auth_token
22
- client.account.messages.create({
22
+ client.messages.create({
23
23
  :from => '+1234567890',
24
24
  :to => '+1234567890',
25
25
  :body => 'Hello world'
@@ -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.account.messages.create({:to => "+13216851234",
27
+ @message = @client.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.account.messages.create({:to => "+15558676309",
51
+ @message = @client.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.account.messages.create({:to => "+15558676309",
61
+ @message = @client.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.account.messages.list.each do |message|
83
+ @client.messages.list.each do |message|
84
84
  puts message.body
85
85
 
86
86
 
@@ -101,9 +101,9 @@ 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.account.messages.list({:to => "+5466758723", :date_sent => "2011-01-01"})
104
+ @messages = @client.messages.list({:to => "+5466758723", :date_sent => "2011-01-01"})
105
105
 
106
106
  @messages.each do |message|
107
107
  puts message.body
108
-
108
+
109
109
 
@@ -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.account.notifications.list().each do |notification|:
27
+ @client.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.account.notifications.list(log=ERROR).each do |notification|:
45
+ @client.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,