twilio-ruby 3.11.5 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.gitignore +1 -1
- data/.travis.yml +20 -9
- data/AUTHORS.md +32 -25
- data/CHANGES.md +203 -0
- data/Gemfile +8 -1
- data/{LICENSE → LICENSE.md} +4 -2
- data/Makefile +1 -2
- data/README.md +70 -39
- data/Rakefile +8 -10
- data/docs/faq.rst +3 -3
- data/docs/getting-started.rst +17 -12
- data/docs/index.rst +15 -0
- data/docs/usage/accounts.rst +6 -6
- data/docs/usage/addresses.rst +101 -0
- data/docs/usage/applications.rst +10 -10
- data/docs/usage/basics.rst +17 -4
- data/docs/usage/caller-ids.rst +4 -2
- data/docs/usage/conferences.rst +11 -11
- data/docs/usage/errors.rst +7 -7
- data/docs/usage/messages.rst +48 -20
- data/docs/usage/notifications.rst +6 -4
- data/docs/usage/phone-calls.rst +33 -14
- data/docs/usage/phone-numbers.rst +45 -31
- data/docs/usage/queues.rst +8 -8
- data/docs/usage/recordings.rst +12 -10
- data/docs/usage/sip.rst +15 -14
- data/docs/usage/taskrouter-tokens.rst +98 -0
- data/docs/usage/taskrouter.rst +226 -0
- data/docs/usage/token-generation.rst +19 -4
- data/docs/usage/transcriptions.rst +3 -2
- data/docs/usage/twiml.rst +7 -7
- data/docs/usage/validation.rst +39 -3
- data/examples/examples.rb +44 -20
- data/examples/print-call-log.rb +1 -1
- data/lib/rack/twilio_webhook_authentication.rb +47 -0
- data/lib/twilio-ruby/rest/accounts.rb +2 -1
- data/lib/twilio-ruby/rest/addresses/dependent_phone_numbers.rb +6 -0
- data/lib/twilio-ruby/rest/addresses.rb +12 -0
- data/lib/twilio-ruby/rest/base_client.rb +127 -0
- data/lib/twilio-ruby/rest/call_feedback.rb +28 -0
- data/lib/twilio-ruby/rest/call_feedback_summary.rb +13 -0
- data/lib/twilio-ruby/rest/calls.rb +10 -5
- data/lib/twilio-ruby/rest/client.rb +44 -109
- data/lib/twilio-ruby/rest/conferences/participants.rb +2 -2
- data/lib/twilio-ruby/rest/incoming_phone_numbers.rb +1 -1
- data/lib/twilio-ruby/rest/instance_resource.rb +2 -16
- data/lib/twilio-ruby/rest/list_resource.rb +20 -30
- data/lib/twilio-ruby/rest/lookups/phone_numbers.rb +17 -0
- data/lib/twilio-ruby/rest/lookups_client.rb +99 -0
- data/lib/twilio-ruby/rest/messages.rb +5 -0
- data/lib/twilio-ruby/rest/next_gen_list_resource.rb +36 -0
- data/lib/twilio-ruby/rest/outgoing_caller_ids.rb +1 -1
- data/lib/twilio-ruby/rest/queues/members.rb +1 -1
- data/lib/twilio-ruby/rest/sip.rb +1 -3
- data/lib/twilio-ruby/rest/sms/messages.rb +23 -0
- data/lib/twilio-ruby/rest/task_router/activities.rb +8 -0
- data/lib/twilio-ruby/rest/task_router/events.rb +8 -0
- data/lib/twilio-ruby/rest/task_router/reservations.rb +8 -0
- data/lib/twilio-ruby/rest/task_router/statistics.rb +26 -0
- data/lib/twilio-ruby/rest/task_router/task_queues.rb +17 -0
- data/lib/twilio-ruby/rest/task_router/task_queues_statistics.rb +15 -0
- data/lib/twilio-ruby/rest/task_router/tasks.rb +15 -0
- data/lib/twilio-ruby/rest/task_router/workers.rb +13 -0
- data/lib/twilio-ruby/rest/task_router/workers_statistics.rb +8 -0
- data/lib/twilio-ruby/rest/task_router/workflow_statistics.rb +7 -0
- data/lib/twilio-ruby/rest/task_router/workflows.rb +11 -0
- data/lib/twilio-ruby/rest/task_router/workspace_statistics.rb +7 -0
- data/lib/twilio-ruby/rest/task_router/workspaces.rb +17 -0
- data/lib/twilio-ruby/rest/task_router_client.rb +176 -0
- data/lib/twilio-ruby/rest/tokens.rb +7 -0
- data/lib/twilio-ruby/rest/usage/records.rb +2 -2
- data/lib/twilio-ruby/rest/utils.rb +35 -11
- data/lib/twilio-ruby/task_router/capability.rb +87 -0
- data/lib/twilio-ruby/task_router.rb +0 -0
- data/lib/twilio-ruby/twiml/response.rb +1 -0
- data/lib/twilio-ruby/util/capability.rb +10 -7
- data/lib/twilio-ruby/util/client_config.rb +29 -0
- data/lib/twilio-ruby/util/configuration.rb +7 -0
- data/lib/twilio-ruby/util/request_validator.rb +18 -3
- data/lib/twilio-ruby/version.rb +1 -1
- data/lib/twilio-ruby.rb +48 -0
- data/spec/rack/twilio_webhook_authentication_spec.rb +110 -0
- data/spec/rest/account_spec.rb +51 -20
- data/spec/rest/address_spec.rb +11 -0
- data/spec/rest/call_feedback_spec.rb +12 -0
- data/spec/rest/call_feedback_summary_spec.rb +9 -0
- data/spec/rest/call_spec.rb +8 -4
- data/spec/rest/client_spec.rb +209 -51
- data/spec/rest/conference_spec.rb +4 -2
- data/spec/rest/instance_resource_spec.rb +4 -4
- data/spec/rest/lookups/phone_number_spec.rb +8 -0
- data/spec/rest/message_spec.rb +2 -2
- data/spec/rest/numbers_spec.rb +25 -13
- data/spec/rest/queue_spec.rb +4 -2
- data/spec/rest/recording_spec.rb +4 -2
- data/spec/rest/sms/message_spec.rb +37 -0
- data/spec/rest/sms/messages_spec.rb +31 -0
- data/spec/rest/task_router/reservation_spec.rb +9 -0
- data/spec/rest/task_router/task_queue_spec.rb +9 -0
- data/spec/rest/token_spec.rb +7 -0
- data/spec/rest/utils_spec.rb +45 -0
- data/spec/spec_helper.rb +12 -3
- data/spec/support/fakeweb.rb +2 -0
- data/spec/task_router_spec.rb +114 -0
- data/spec/twilio_spec.rb +15 -0
- data/spec/util/capability_spec.rb +167 -118
- data/spec/util/client_config_spec.rb +21 -0
- data/spec/util/configuration_spec.rb +15 -0
- data/spec/util/request_validator_spec.rb +31 -3
- data/spec/util/url_encode_spec.rb +2 -2
- data/twilio-ruby.gemspec +28 -27
- metadata +93 -71
- data/CHANGES +0 -47
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OTVlYzExOGM0MDgwMzg3NmE4MTM0M2M1MjAyNTY1MmU5Yjk3NjY1Mw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MTBlYzkxM2NjYjViMzY2OGU5NzUyMjBhMjNjOGQ5ZWVmN2I5YTdjYw==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
Mjk0ZDNjYjIwYTc2NjZiYjAzNmM4NGQ4NWQ4NWJlNGM0NzA2NTI5NmI1OTI4
|
10
|
+
Y2E5ZDEzYzQ0MjNiNTEzM2Y0MWQ5MzBiMTFiM2MwNThmODNjMjY4NmE2MTdi
|
11
|
+
MDM4NWY3OWU0ZGY1NWI4YjU2MTM4NzRiZTRjNmQ4MzNjZDEyOWU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ODBhZjRmYWQ4ZTU3MTA3ZjE5MjEyNjYyODI2ZDk0Njk3Mjg3YjRjYTgyYTA4
|
14
|
+
NGEyMjExNzUzYjhjMGE3ZWM1YmI2MzM4YThmOGEwNGRkZTZmNzc5ZmMwMjli
|
15
|
+
OTNkMmE3YjY2NmIxZjRkZGRmMTc3OWE3NmM2ZjE5MGJmOTViN2E=
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,13 +1,24 @@
|
|
1
|
+
sudo: false
|
1
2
|
language: ruby
|
2
|
-
|
3
|
+
cache: bundler
|
4
|
+
bundler_args: --without development
|
3
5
|
rvm:
|
4
|
-
-
|
5
|
-
-
|
6
|
-
-
|
7
|
-
- 2.0.0
|
6
|
+
- ruby-head
|
7
|
+
- ruby
|
8
|
+
- 2.2.0
|
8
9
|
- 2.1.0
|
9
|
-
-
|
10
|
+
- 2.0.0
|
11
|
+
- 1.9.3
|
12
|
+
- jruby-head
|
13
|
+
- jruby
|
10
14
|
- jruby-19mode
|
11
|
-
- rbx-
|
12
|
-
- rbx-2
|
13
|
-
|
15
|
+
- rbx-head
|
16
|
+
- rbx-2
|
17
|
+
matrix:
|
18
|
+
fast_finish: true
|
19
|
+
allow_failures:
|
20
|
+
- rvm: ruby-head
|
21
|
+
- rvm: ruby
|
22
|
+
- rvm: jruby-head
|
23
|
+
- rvm: jruby
|
24
|
+
- rvm: rbx-head
|
data/AUTHORS.md
CHANGED
@@ -4,28 +4,35 @@ Authors
|
|
4
4
|
A huge thanks to all of our contributors:
|
5
5
|
|
6
6
|
|
7
|
-
- Adam Ballai
|
8
|
-
- Alexander Murmann & Ryan Spore
|
9
|
-
-
|
10
|
-
-
|
11
|
-
-
|
12
|
-
-
|
13
|
-
-
|
14
|
-
-
|
15
|
-
-
|
16
|
-
-
|
17
|
-
-
|
18
|
-
-
|
19
|
-
-
|
20
|
-
-
|
21
|
-
-
|
22
|
-
-
|
23
|
-
-
|
24
|
-
-
|
25
|
-
-
|
26
|
-
-
|
27
|
-
-
|
28
|
-
-
|
29
|
-
-
|
30
|
-
-
|
31
|
-
-
|
7
|
+
- Adam Ballai
|
8
|
+
- Alexander Murmann & Ryan Spore
|
9
|
+
- Alexandre Payment
|
10
|
+
- Andrew Benton
|
11
|
+
- Brian Levine
|
12
|
+
- Caley Woods
|
13
|
+
- Carlos Diaz-Padron
|
14
|
+
- Connor Montgomery
|
15
|
+
- Doug Black
|
16
|
+
- Elaine Tsai
|
17
|
+
- Fiona Tay & Will Read
|
18
|
+
- Geoff Petrie
|
19
|
+
- Guille Carlos
|
20
|
+
- Jeremy Franz
|
21
|
+
- Josh Hull
|
22
|
+
- Joël Franusic
|
23
|
+
- K Gautam Pai
|
24
|
+
- Karl Freeman
|
25
|
+
- Kevin Burke
|
26
|
+
- Kyle Conroy
|
27
|
+
- Leo Adamek
|
28
|
+
- Oscar
|
29
|
+
- Oscar Sanchez
|
30
|
+
- Phil Nash
|
31
|
+
- Rafael Chacon
|
32
|
+
- Ryan Cavicchioni
|
33
|
+
- Ryan Spore
|
34
|
+
- Sam Kimbrel
|
35
|
+
- Tom Moor
|
36
|
+
- Torey Heinz
|
37
|
+
- Vipul A M
|
38
|
+
- vfrride
|
data/CHANGES.md
ADDED
@@ -0,0 +1,203 @@
|
|
1
|
+
twilio-ruby changelog
|
2
|
+
=====================
|
3
|
+
|
4
|
+
Version 4.0.0
|
5
|
+
-------------
|
6
|
+
|
7
|
+
Released April 16, 2015
|
8
|
+
|
9
|
+
- Remove support for total
|
10
|
+
- Use configuration object instead of defaults hash for REST clients
|
11
|
+
- Moves statistics from task router client to individual classes
|
12
|
+
- Deprecates statistics methods on task router client
|
13
|
+
|
14
|
+
Version 3.16.1
|
15
|
+
--------------
|
16
|
+
|
17
|
+
Released March 31, 2015
|
18
|
+
|
19
|
+
- Fix bug in PhoneNumbers resource
|
20
|
+
|
21
|
+
Version 3.16.0
|
22
|
+
--------------
|
23
|
+
|
24
|
+
Released March 31, 2015
|
25
|
+
|
26
|
+
- Add support for new Twilio Lookups API
|
27
|
+
- Update LICENSE wording
|
28
|
+
|
29
|
+
Version 3.15.2
|
30
|
+
--------------
|
31
|
+
|
32
|
+
Released March 10, 2015
|
33
|
+
|
34
|
+
- Add missing documentation on TaskRouter client
|
35
|
+
|
36
|
+
Version 3.15.1
|
37
|
+
--------------
|
38
|
+
|
39
|
+
Released February 18, 2015
|
40
|
+
|
41
|
+
- For real this time, add TaskRouterClient object and resources for new TaskRouter API
|
42
|
+
|
43
|
+
Version 3.15.0
|
44
|
+
--------------
|
45
|
+
|
46
|
+
Released February 18, 2015
|
47
|
+
|
48
|
+
- Adds TaskRouterClient object and resources for new TaskRouter API
|
49
|
+
|
50
|
+
Version 3.14.5
|
51
|
+
--------------
|
52
|
+
|
53
|
+
Released February 9, 2015
|
54
|
+
|
55
|
+
- Relaxes JWT gem version requirement
|
56
|
+
- Adds Ruby 2.2.0 testing to TravisCI
|
57
|
+
|
58
|
+
Version 3.14.4
|
59
|
+
--------------
|
60
|
+
|
61
|
+
Released January 8, 2015
|
62
|
+
|
63
|
+
- Feature: dynamically choose the auth token to validate requests with when using the TwilioWebhookAuthentication middleware.
|
64
|
+
- Deprecation: The Twilio::REST::SMS::Message resource is deprecated.
|
65
|
+
- More fixing of docs
|
66
|
+
|
67
|
+
Version 3.14.3
|
68
|
+
--------------
|
69
|
+
|
70
|
+
Released January 8, 2015
|
71
|
+
|
72
|
+
- Fix nil error in RequestValidator middleware
|
73
|
+
- Fix up docs
|
74
|
+
|
75
|
+
Version 3.14.2
|
76
|
+
--------------
|
77
|
+
|
78
|
+
Released November 24, 2014
|
79
|
+
|
80
|
+
- Fixed incomplete token support
|
81
|
+
|
82
|
+
Version 3.14.1
|
83
|
+
--------------
|
84
|
+
|
85
|
+
Released November 21, 2014
|
86
|
+
|
87
|
+
- Add support for the new Tokens endpoint
|
88
|
+
|
89
|
+
Version 3.14.0
|
90
|
+
--------------
|
91
|
+
|
92
|
+
Released November 13, 2014
|
93
|
+
|
94
|
+
- Switch to a constant-time string comparison for TwiML request signature validation
|
95
|
+
- Add support for Call and Message deletion/redaction
|
96
|
+
|
97
|
+
Version 3.13.1
|
98
|
+
--------------
|
99
|
+
|
100
|
+
Released October 1, 2014
|
101
|
+
|
102
|
+
- Bump required version to 1.9.3
|
103
|
+
|
104
|
+
Version 3.13.0
|
105
|
+
--------------
|
106
|
+
|
107
|
+
Released September 23, 2014
|
108
|
+
|
109
|
+
- Deprecates 1.8.7 support
|
110
|
+
- Internal code style changes including:
|
111
|
+
- change symbol hash syntax to Ruby 1.9 style
|
112
|
+
- remove curly braces from hash arguments to methods
|
113
|
+
- add spaces around curly braces in blocks
|
114
|
+
- reduces all lines to less than 80 characters
|
115
|
+
|
116
|
+
Version 3.12.3
|
117
|
+
--------------
|
118
|
+
|
119
|
+
Released September 23, 2014
|
120
|
+
|
121
|
+
- Added block configure syntax
|
122
|
+
|
123
|
+
Version 3.12.2
|
124
|
+
--------------
|
125
|
+
|
126
|
+
Released August 29, 2014
|
127
|
+
|
128
|
+
- `client.account.{resource}` can now be accessed with `client.{resource}`
|
129
|
+
- Many doc updates
|
130
|
+
|
131
|
+
Version 3.12.1
|
132
|
+
--------------
|
133
|
+
|
134
|
+
Released August 26, 2014
|
135
|
+
|
136
|
+
- Add support for new call feedback endpoints
|
137
|
+
|
138
|
+
Version 3.12.0
|
139
|
+
--------------
|
140
|
+
|
141
|
+
Released August 18, 2014
|
142
|
+
|
143
|
+
- Add Rack middleware for Twilio request-signature validation
|
144
|
+
- Upgrade dependencies and clean up project files
|
145
|
+
- Documentation fixes
|
146
|
+
- Add `text` alias for `to_xml` method on TwiML generator objects
|
147
|
+
|
148
|
+
Version 3.11.6
|
149
|
+
--------------
|
150
|
+
|
151
|
+
Released July 25, 2014
|
152
|
+
|
153
|
+
- Add #to_xml to TwiML Responses.
|
154
|
+
- Updated test / development dependencies.
|
155
|
+
- Updated to RSpec 3 syntax.
|
156
|
+
|
157
|
+
Version 3.11.5
|
158
|
+
--------------
|
159
|
+
|
160
|
+
Released February 4, 2014
|
161
|
+
|
162
|
+
- Add bangs for twilify to indicate it's a dangerous operation.
|
163
|
+
- Remove reference to deprecated OpenSSL Digest parameter.
|
164
|
+
- Encode dates properly before passing them to the Twilio API.
|
165
|
+
|
166
|
+
Version 3.11.4
|
167
|
+
--------------
|
168
|
+
|
169
|
+
Released October 21, 2013
|
170
|
+
|
171
|
+
- Add support for listing IncomingPhoneNumbers by type.
|
172
|
+
- Add support for searching for mobile enabled numbers for
|
173
|
+
both IncomingPhoneNumbers and AvailablePhoneNumbers.
|
174
|
+
|
175
|
+
Version 3.11.3
|
176
|
+
--------------
|
177
|
+
|
178
|
+
Released October 15, 2013
|
179
|
+
|
180
|
+
- Restore support for versions of Ruby other than 2.0.0, which the
|
181
|
+
previous release removed.
|
182
|
+
|
183
|
+
Version 3.11.2
|
184
|
+
|
185
|
+
Released October 15, 2013
|
186
|
+
|
187
|
+
- Restore ability of `sms.messages` to make requests to /SMS/Messages.
|
188
|
+
|
189
|
+
Version 3.11.1
|
190
|
+
--------------
|
191
|
+
|
192
|
+
Released September 24, 2013
|
193
|
+
|
194
|
+
- Fix a bug causing request the new messages class to fail.
|
195
|
+
|
196
|
+
Version 3.11.0
|
197
|
+
-------------
|
198
|
+
|
199
|
+
Released September 18, 2013
|
200
|
+
|
201
|
+
- Add MMS support.
|
202
|
+
- Add SIP-In support.
|
203
|
+
- Add docs.
|
data/Gemfile
CHANGED
data/{LICENSE → LICENSE.md}
RENAMED
@@ -1,4 +1,6 @@
|
|
1
|
-
Copyright (c) 2010-
|
1
|
+
Copyright (c) 2010-2014 Andrew Benton.
|
2
|
+
|
3
|
+
The MIT License (MIT)
|
2
4
|
|
3
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
6
|
of this software and associated documentation files (the "Software"), to deal
|
@@ -16,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
THE SOFTWARE.
|
21
|
+
THE SOFTWARE.
|
data/Makefile
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,20 @@
|
|
1
|
-
[![
|
2
|
-
[![
|
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
|
-
##
|
9
|
+
## Installation
|
11
10
|
|
12
|
-
|
11
|
+
To install using [Bundler][bundler] grab the latest stable version:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'twilio-ruby', '~> 4.0.0'
|
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,26 +42,35 @@ 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.
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
59
|
+
@client.messages.create(
|
60
|
+
from: '+14159341234',
|
61
|
+
to: '+16105557069',
|
62
|
+
body: 'Hey there!'
|
49
63
|
)
|
50
64
|
```
|
51
65
|
|
52
66
|
### Send an MMS
|
53
67
|
|
54
68
|
``` ruby
|
55
|
-
@client.
|
56
|
-
:
|
57
|
-
:
|
58
|
-
:
|
59
|
-
:
|
69
|
+
@client.messages.create(
|
70
|
+
from: '+14159341234',
|
71
|
+
to: '+16105557069',
|
72
|
+
body: 'Hey there!',
|
73
|
+
media_url: 'http://example.com/smileyface.jpg'
|
60
74
|
)
|
61
75
|
```
|
62
76
|
|
@@ -64,17 +78,17 @@ auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
|
|
64
78
|
|
65
79
|
``` ruby
|
66
80
|
# make a new outgoing call
|
67
|
-
@call = @client.
|
68
|
-
:
|
69
|
-
:
|
70
|
-
:
|
81
|
+
@call = @client.calls.create(
|
82
|
+
from: '+14159341234',
|
83
|
+
to: '+18004567890',
|
84
|
+
url: 'http://example.com/call-handler'
|
71
85
|
)
|
72
86
|
|
73
87
|
# hangup a ringing call, but don't touch it if it's connected
|
74
88
|
@call.cancel
|
75
89
|
|
76
90
|
# if you have the call sid, you can fetch a call object via:
|
77
|
-
@call = @client.
|
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.
|
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.
|
98
|
-
:
|
111
|
+
@numbers = @client.available_phone_numbers.get('US').local.list(
|
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.
|
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 [
|
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
|
@@ -144,8 +158,8 @@ require 'twilio-ruby'
|
|
144
158
|
|
145
159
|
# build up a response
|
146
160
|
response = Twilio::TwiML::Response.new do |r|
|
147
|
-
r.Say 'hello there', :
|
148
|
-
r.Dial :
|
161
|
+
r.Say 'hello there', voice: 'alice'
|
162
|
+
r.Dial callerId: '+14159992222' do |d|
|
149
163
|
d.Client 'jenny'
|
150
164
|
end
|
151
165
|
end
|
@@ -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
|
-
##
|
183
|
+
## Supported Ruby Versions
|
170
184
|
|
171
|
-
|
172
|
-
|
185
|
+
This library supports and is [tested against][travis] the following Ruby
|
186
|
+
implementations:
|
173
187
|
|
174
|
-
|
188
|
+
- Ruby 2.2.0
|
189
|
+
- Ruby 2.1.0
|
190
|
+
- Ruby 2.0.0
|
191
|
+
- Ruby 1.9.3
|
192
|
+
- [JRuby][jruby]
|
193
|
+
- [Rubinius][rubinius]
|
175
194
|
|
176
|
-
|
177
|
-
|
178
|
-
[examples]
|
179
|
-
[
|
180
|
-
|
181
|
-
[
|
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 '
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
spec = eval(File.read('twilio-ruby.gemspec'))
|
1
|
+
require 'bundler'
|
2
|
+
Bundler.setup
|
3
|
+
Bundler::GemHelper.install_tasks
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
desc 'Run all specs'
|
7
|
+
RSpec::Core::RakeTask.new(:spec)
|
10
8
|
|
11
|
-
|
12
|
-
task :
|
9
|
+
task default: :spec
|
10
|
+
task test: :spec
|
data/docs/faq.rst
CHANGED
@@ -34,9 +34,9 @@ Then you can convert user input to phone numbers like this:
|
|
34
34
|
def convert_to_e164(raw_phone)
|
35
35
|
Phony.format(
|
36
36
|
raw_phone,
|
37
|
-
:
|
38
|
-
:
|
37
|
+
format: :international,
|
38
|
+
spaces: ''
|
39
39
|
).gsub(/\s+/, "") # Phony won't remove all spaces
|
40
|
-
end
|
40
|
+
end
|
41
41
|
|
42
42
|
puts convert_to_e164('212 555 1234') # prints +12125551234
|
data/docs/getting-started.rst
CHANGED
@@ -19,8 +19,11 @@ Make a Call
|
|
19
19
|
auth_token = "YYYYYYYYYYYYYYYYYY"
|
20
20
|
|
21
21
|
@client = Twilio::REST::Client.new account_sid, auth_token
|
22
|
-
@call = @client.
|
23
|
-
|
22
|
+
@call = @client.calls.create(
|
23
|
+
to: "9991231234",
|
24
|
+
from: "9991231234",
|
25
|
+
url: "http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient"
|
26
|
+
)
|
24
27
|
puts @call.length
|
25
28
|
puts @call.sid
|
26
29
|
|
@@ -38,10 +41,11 @@ Send an SMS
|
|
38
41
|
|
39
42
|
@client = Twilio::REST::Client.new account_sid, auth_token
|
40
43
|
|
41
|
-
@message = @client.
|
42
|
-
|
43
|
-
|
44
|
-
|
44
|
+
@message = @client.messages.create(
|
45
|
+
to: "+12316851234",
|
46
|
+
from: "+15555555555",
|
47
|
+
body: "Hello there!"
|
48
|
+
)
|
45
49
|
|
46
50
|
Send an MMS
|
47
51
|
===========
|
@@ -56,11 +60,12 @@ Send an MMS
|
|
56
60
|
|
57
61
|
@client = Twilio::REST::Client.new account_sid, auth_token
|
58
62
|
|
59
|
-
@message = @client.
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
63
|
+
@message = @client.messages.create(
|
64
|
+
to: "+15558676309",
|
65
|
+
from: "+15555555555",
|
66
|
+
body: "Jenny I need you!",
|
67
|
+
media_url: "http://twilio.com/heart.jpg"
|
68
|
+
)
|
64
69
|
|
65
70
|
Generating TwiML
|
66
71
|
=================
|
@@ -72,7 +77,7 @@ to easily create such responses.
|
|
72
77
|
.. code-block:: ruby
|
73
78
|
|
74
79
|
Twilio::TwiML::Response do |r|
|
75
|
-
r.Play "https://api.twilio.com/cowbell.mp3", :
|
80
|
+
r.Play "https://api.twilio.com/cowbell.mp3", loop: 5
|
76
81
|
end.text
|
77
82
|
|
78
83
|
.. code-block:: xml
|
data/docs/index.rst
CHANGED
@@ -55,6 +55,21 @@ Query the Twilio REST API to create phone calls, send SMS/MMS messages and more!
|
|
55
55
|
usage/queues
|
56
56
|
usage/sip
|
57
57
|
|
58
|
+
|
59
|
+
TaskRouter
|
60
|
+
---------
|
61
|
+
|
62
|
+
Query the Twilio TaskRouter API to set up workspaces and task routing, and
|
63
|
+
create capability tokens to authorize your client-side code to safely update
|
64
|
+
state.
|
65
|
+
|
66
|
+
.. toctree::
|
67
|
+
:maxdepth: 1
|
68
|
+
|
69
|
+
usage/taskrouter
|
70
|
+
usage/taskrouter-tokens
|
71
|
+
|
72
|
+
|
58
73
|
TwiML
|
59
74
|
---------
|
60
75
|
|