twilio-ruby 5.0.0.rc24 → 5.0.0.rc25
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.
- checksums.yaml +4 -4
- data/CHANGES.md +32 -12
- data/LICENSE.md +12 -12
- data/README.md +28 -29
- data/examples/examples.rb +47 -58
- data/examples/print-call-log.rb +6 -6
- data/lib/twilio-ruby/jwt/jwt.rb +2 -2
- data/lib/twilio-ruby/rest/accounts/v1.rb +3 -1
- data/lib/twilio-ruby/rest/accounts/v1/credential.rb +4 -1
- data/lib/twilio-ruby/rest/api/v2010.rb +3 -1
- data/lib/twilio-ruby/rest/api/v2010/account.rb +80 -23
- data/lib/twilio-ruby/rest/api/v2010/account/address.rb +2 -1
- data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number.rb +6 -3
- data/lib/twilio-ruby/rest/api/v2010/account/call.rb +14 -4
- data/lib/twilio-ruby/rest/api/v2010/account/call/recording.rb +10 -0
- data/lib/twilio-ruby/rest/api/v2010/account/conference.rb +4 -1
- data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb +10 -4
- data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on.rb +4 -1
- data/lib/twilio-ruby/rest/api/v2010/account/message.rb +6 -2
- data/lib/twilio-ruby/rest/api/v2010/account/queue.rb +4 -1
- data/lib/twilio-ruby/rest/api/v2010/account/recording.rb +18 -2
- data/lib/twilio-ruby/rest/api/v2010/account/recording/add_on_result.rb +4 -1
- data/lib/twilio-ruby/rest/api/v2010/account/sip.rb +14 -4
- data/lib/twilio-ruby/rest/api/v2010/account/sip/credential_list.rb +4 -1
- data/lib/twilio-ruby/rest/api/v2010/account/sip/domain.rb +8 -2
- data/lib/twilio-ruby/rest/api/v2010/account/sip/ip_access_control_list.rb +4 -1
- data/lib/twilio-ruby/rest/api/v2010/account/usage.rb +6 -2
- data/lib/twilio-ruby/rest/api/v2010/account/usage/record.rb +16 -8
- data/lib/twilio-ruby/rest/chat/v1.rb +6 -2
- data/lib/twilio-ruby/rest/chat/v1/service.rb +12 -3
- data/lib/twilio-ruby/rest/chat/v1/service/channel.rb +12 -3
- data/lib/twilio-ruby/rest/chat/v1/service/user.rb +2 -1
- data/lib/twilio-ruby/rest/chat/v2.rb +6 -2
- data/lib/twilio-ruby/rest/chat/v2/service.rb +12 -3
- data/lib/twilio-ruby/rest/chat/v2/service/channel.rb +12 -3
- data/lib/twilio-ruby/rest/chat/v2/service/user.rb +2 -1
- data/lib/twilio-ruby/rest/fax/v1.rb +3 -1
- data/lib/twilio-ruby/rest/fax/v1/fax.rb +4 -1
- data/lib/twilio-ruby/rest/ip_messaging/v1.rb +6 -2
- data/lib/twilio-ruby/rest/ip_messaging/v1/service.rb +12 -3
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/channel.rb +12 -3
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb +2 -1
- data/lib/twilio-ruby/rest/ip_messaging/v2.rb +6 -2
- data/lib/twilio-ruby/rest/ip_messaging/v2/service.rb +12 -3
- data/lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb +12 -3
- data/lib/twilio-ruby/rest/ip_messaging/v2/service/user.rb +2 -1
- data/lib/twilio-ruby/rest/lookups/v1.rb +3 -1
- data/lib/twilio-ruby/rest/messaging/v1.rb +3 -1
- data/lib/twilio-ruby/rest/messaging/v1/service.rb +26 -6
- data/lib/twilio-ruby/rest/monitor/v1.rb +6 -2
- data/lib/twilio-ruby/rest/notify/v1.rb +6 -2
- data/lib/twilio-ruby/rest/notify/v1/service.rb +12 -4
- data/lib/twilio-ruby/rest/notify/v1/service/notification.rb +3 -1
- data/lib/twilio-ruby/rest/notify/v1/service/user.rb +8 -2
- data/lib/twilio-ruby/rest/preview/bulk_exports.rb +6 -2
- data/lib/twilio-ruby/rest/preview/bulk_exports/export.rb +2 -1
- data/lib/twilio-ruby/rest/preview/hosted_numbers.rb +3 -1
- data/lib/twilio-ruby/rest/preview/hosted_numbers/hosted_number_order.rb +18 -12
- data/lib/twilio-ruby/rest/preview/marketplace.rb +6 -2
- data/lib/twilio-ruby/rest/preview/marketplace/available_add_on.rb +4 -1
- data/lib/twilio-ruby/rest/preview/marketplace/installed_add_on.rb +4 -1
- data/lib/twilio-ruby/rest/preview/proxy.rb +3 -1
- data/lib/twilio-ruby/rest/preview/proxy/service.rb +12 -3
- data/lib/twilio-ruby/rest/preview/proxy/service/session.rb +8 -2
- data/lib/twilio-ruby/rest/preview/proxy/service/session/participant.rb +4 -1
- data/lib/twilio-ruby/rest/preview/sync.rb +3 -1
- data/lib/twilio-ruby/rest/preview/sync/service.rb +12 -3
- data/lib/twilio-ruby/rest/preview/sync/service/document.rb +4 -1
- data/lib/twilio-ruby/rest/preview/sync/service/sync_list.rb +8 -2
- data/lib/twilio-ruby/rest/preview/sync/service/sync_map.rb +8 -2
- data/lib/twilio-ruby/rest/preview/wireless.rb +9 -3
- data/lib/twilio-ruby/rest/preview/wireless/sim.rb +2 -1
- data/lib/twilio-ruby/rest/pricing/v1.rb +9 -3
- data/lib/twilio-ruby/rest/pricing/v1/messaging.rb +4 -1
- data/lib/twilio-ruby/rest/pricing/v1/phone_number.rb +4 -1
- data/lib/twilio-ruby/rest/pricing/v1/voice.rb +8 -2
- data/lib/twilio-ruby/rest/sync/v1.rb +3 -1
- data/lib/twilio-ruby/rest/sync/v1/service.rb +12 -3
- data/lib/twilio-ruby/rest/sync/v1/service/document.rb +4 -1
- data/lib/twilio-ruby/rest/sync/v1/service/sync_list.rb +8 -2
- data/lib/twilio-ruby/rest/sync/v1/service/sync_map.rb +8 -2
- data/lib/twilio-ruby/rest/taskrouter/v1.rb +3 -1
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace.rb +30 -8
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb +4 -1
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue.rb +4 -2
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb +12 -4
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb +2 -1
- data/lib/twilio-ruby/rest/trunking/v1.rb +3 -1
- data/lib/twilio-ruby/rest/trunking/v1/trunk.rb +16 -4
- data/lib/twilio-ruby/rest/video/v1.rb +6 -2
- data/lib/twilio-ruby/rest/video/v1/recording.rb +17 -3
- data/lib/twilio-ruby/rest/video/v1/room.rb +4 -1
- data/lib/twilio-ruby/rest/video/v1/room/recording.rb +31 -3
- data/lib/twilio-ruby/rest/wireless/v1.rb +9 -3
- data/lib/twilio-ruby/rest/wireless/v1/rate_plan.rb +16 -1
- data/lib/twilio-ruby/rest/wireless/v1/sim.rb +2 -1
- data/lib/twilio-ruby/twiml/messaging_response.rb +8 -2
- data/lib/twilio-ruby/twiml/twiml.rb +3 -5
- data/lib/twilio-ruby/twiml/voice_response.rb +60 -42
- data/lib/twilio-ruby/version.rb +1 -1
- data/spec/integration/api/v2010/account/call/recording_spec.rb +14 -2
- data/spec/integration/api/v2010/account/recording_spec.rb +14 -2
- data/spec/integration/messaging/v1/service/phone_number_spec.rb +28 -0
- data/spec/integration/messaging/v1/service_spec.rb +4 -0
- data/spec/integration/notify/v1/service/notification_spec.rb +35 -0
- data/spec/integration/video/v1/recording_spec.rb +45 -0
- data/spec/integration/video/v1/room/recording_spec.rb +4 -3
- data/spec/integration/wireless/v1/rate_plan_spec.rb +8 -0
- data/spec/twiml/messaging_response_spec.rb +28 -0
- data/spec/twiml/voice_response_spec.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 01f12541d8117c7793ef1e5379c69d3e214d80d2
|
|
4
|
+
data.tar.gz: 4e5d252025e627244c09ef9eb42e0a92bb4f1e6e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 076f2cb21d3b85b132d75f8057c87c50520eaa5abfd336f49013e98109196a21ffb709aba5a8454338527beb93b5bdcc125bccbaab84c27eee27ee3ab24ec64e
|
|
7
|
+
data.tar.gz: ed11a19b6ccfe01f1e07f3e3894a25ffbae4a2289a7d5c4cfb1a2529d7a9daa8e0dca1ec89c1f6a2ffa36d74d0e53d05850dda355e8fd60418be18016b4c29c4
|
data/CHANGES.md
CHANGED
|
@@ -1,28 +1,48 @@
|
|
|
1
1
|
twilio-ruby changelog
|
|
2
2
|
=====================
|
|
3
|
-
[2017-06
|
|
3
|
+
[2017-07-06] Version 5.0.0.rc25
|
|
4
|
+
--------------------------------
|
|
5
|
+
**Messaging**
|
|
6
|
+
- Fix incorrectly typed capabilities property for PhoneNumbers.
|
|
7
|
+
|
|
8
|
+
**Notify**
|
|
9
|
+
- Add `ToBinding` optional parameter on Notifications resource creation. Accepted values are json strings.
|
|
10
|
+
|
|
11
|
+
**Preview**
|
|
12
|
+
- [omit] Enabled beta feature flag (api.vault.data-platform) for bulk_exports api
|
|
13
|
+
|
|
14
|
+
**Video**
|
|
15
|
+
- Filter recordings by date using the parameters `DateCreatedAfter` and `DateCreatedBefore`.
|
|
16
|
+
- Override the default time-to-live of a recording's media URL through the `Ttl` parameter (in seconds, default value is 3600).
|
|
17
|
+
- Add query parameters `SourceSid`, `Status`, `DateCreatedAfter` and `DateCreatedBefore` to the convenience method for retrieving Room recordings.
|
|
18
|
+
|
|
19
|
+
**Wireless**
|
|
20
|
+
- Added national and international data limits to the RatePlans resource.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
[2017-06-22] Version 5.0.0.rc24
|
|
4
24
|
-------------------------------
|
|
5
25
|
- Namespaced Policy, Grants, and Scope to their respective Token.
|
|
6
26
|
- Added `announce_url` and `annouce_url_method` to Conference update.
|
|
7
27
|
- Added `store_media` to Fax.
|
|
8
28
|
|
|
9
|
-
[2017-06-19] Version 5.0.0
|
|
29
|
+
[2017-06-19] Version 5.0.0.rc23
|
|
10
30
|
-------------------------------
|
|
11
31
|
- Fixed ClientCapability parameter encoded bug.
|
|
12
32
|
- Optional URL parameter for TwiML Play verb.
|
|
13
33
|
|
|
14
|
-
[2017-06-15] Version 5.0.0
|
|
34
|
+
[2017-06-15] Version 5.0.0.rc22
|
|
15
35
|
-------------------------------
|
|
16
36
|
- Refactor JWT token constructors
|
|
17
37
|
|
|
18
38
|
|
|
19
|
-
[2017-05-24] Version 5.0.0
|
|
39
|
+
[2017-05-24] Version 5.0.0.rc21
|
|
20
40
|
-------------------------------
|
|
21
41
|
- Add HostedNumbers preview support.
|
|
22
42
|
- Add Proxy preview support.
|
|
23
43
|
- Add BulkExports preview support.
|
|
24
44
|
|
|
25
|
-
[2017-05-22] Version 5.0.0
|
|
45
|
+
[2017-05-22] Version 5.0.0.rc20
|
|
26
46
|
-------------------------------
|
|
27
47
|
- Add Wireless Domain
|
|
28
48
|
- Add Fax Domain
|
|
@@ -31,7 +51,7 @@ twilio-ruby changelog
|
|
|
31
51
|
- Add `area_code_geomatch`, `validtiy_period`, `fallback_to_long_code` to Messaging Service
|
|
32
52
|
- Converted `TwilioException` to `TwilioError`
|
|
33
53
|
|
|
34
|
-
[2017-04-27] Version 5.0.0
|
|
54
|
+
[2017-04-27] Version 5.0.0.rc19
|
|
35
55
|
-------------------------------
|
|
36
56
|
|
|
37
57
|
- Add chat v2.
|
|
@@ -39,28 +59,28 @@ twilio-ruby changelog
|
|
|
39
59
|
- Message `ValidityPeriod` parameter.
|
|
40
60
|
- New Usage API categories.
|
|
41
61
|
|
|
42
|
-
Version 5.0.0
|
|
62
|
+
Version 5.0.0.rc18
|
|
43
63
|
-------------------------------
|
|
44
64
|
|
|
45
65
|
Release April 17, 2017
|
|
46
66
|
|
|
47
67
|
- Update VideoGrant access token to accept `room` instead of `configuration_profile_sid`
|
|
48
68
|
|
|
49
|
-
Version 5.0.0
|
|
69
|
+
Version 5.0.0.rc16
|
|
50
70
|
-------------------------------
|
|
51
71
|
|
|
52
72
|
Release September 1, 2016
|
|
53
73
|
|
|
54
74
|
- Add voice grant.
|
|
55
75
|
|
|
56
|
-
Version 5.0.0
|
|
76
|
+
Version 5.0.0.rc8
|
|
57
77
|
-------------
|
|
58
78
|
|
|
59
79
|
Release July 8, 2016
|
|
60
80
|
|
|
61
81
|
- Add SMS and Facebook Messenger for Notify
|
|
62
82
|
|
|
63
|
-
Version 5.0.0
|
|
83
|
+
Version 5.0.0.rc7
|
|
64
84
|
-------------
|
|
65
85
|
|
|
66
86
|
Release June 9, 2016
|
|
@@ -68,14 +88,14 @@ Release June 9, 2016
|
|
|
68
88
|
- Add messaging feedback support
|
|
69
89
|
|
|
70
90
|
|
|
71
|
-
Version 5.0.0
|
|
91
|
+
Version 5.0.0.rc5
|
|
72
92
|
-------------
|
|
73
93
|
|
|
74
94
|
Release May 31, 2016
|
|
75
95
|
|
|
76
96
|
- Add preview.twilio.com/wireless support
|
|
77
97
|
|
|
78
|
-
Version 5.0.0
|
|
98
|
+
Version 5.0.0.rc4
|
|
79
99
|
-------------
|
|
80
100
|
|
|
81
101
|
Release March 28, 2016
|
data/LICENSE.md
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
MIT License
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Copyright (C) 2017, Twilio, Inc. <help@twilio.com>
|
|
4
4
|
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
9
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
10
|
+
so, subject to the following conditions:
|
|
11
11
|
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
14
|
|
|
15
15
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
16
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
17
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
# twilio-ruby
|
|
2
|
+
|
|
2
3
|
[][travis]
|
|
4
|
+
[][gem]
|
|
3
5
|
[][codeclimate]
|
|
4
6
|
|
|
5
|
-
# twilio-ruby
|
|
6
|
-
|
|
7
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]
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
@@ -11,13 +11,13 @@ A module for using the Twilio REST API and generating valid [TwiML](http://www.t
|
|
|
11
11
|
To install using [Bundler][bundler] grab the latest stable version:
|
|
12
12
|
|
|
13
13
|
```ruby
|
|
14
|
-
gem 'twilio-ruby', '~> 5.0.0.
|
|
14
|
+
gem 'twilio-ruby', '~> 5.0.0.rc25'
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
To manually install `twilio-ruby` via [Rubygems][rubygems] simply gem install:
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
gem install twilio-ruby -v 5.0.0.
|
|
20
|
+
gem install twilio-ruby -v 5.0.0.rc25
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
To build and install the development branch yourself from the latest source:
|
|
@@ -41,7 +41,7 @@ During the Release Candidate period of this library, please leave all feedback a
|
|
|
41
41
|
|
|
42
42
|
### Setup Work
|
|
43
43
|
|
|
44
|
-
```
|
|
44
|
+
```ruby
|
|
45
45
|
require 'twilio-ruby'
|
|
46
46
|
|
|
47
47
|
# put your own credentials here
|
|
@@ -63,7 +63,7 @@ end
|
|
|
63
63
|
|
|
64
64
|
### Make a Call
|
|
65
65
|
|
|
66
|
-
```
|
|
66
|
+
```ruby
|
|
67
67
|
@client.api.account.calls.create(
|
|
68
68
|
from: '+14159341234',
|
|
69
69
|
to: '+16105557069',
|
|
@@ -73,7 +73,7 @@ end
|
|
|
73
73
|
|
|
74
74
|
### Send an SMS
|
|
75
75
|
|
|
76
|
-
```
|
|
76
|
+
```ruby
|
|
77
77
|
@client.api.account.messages.create(
|
|
78
78
|
from: '+14159341234',
|
|
79
79
|
to: '+16105557069',
|
|
@@ -82,7 +82,7 @@ end
|
|
|
82
82
|
```
|
|
83
83
|
|
|
84
84
|
### Customizing your HTTP Client
|
|
85
|
-
twilio-ruby uses [Faraday]
|
|
85
|
+
twilio-ruby uses [Faraday][faraday] to make HTTP requests. You can tell Twilio::REST::Client to use any of the Faraday adapters like so:
|
|
86
86
|
|
|
87
87
|
```ruby
|
|
88
88
|
@client.http_client.adapter = :typhoeus
|
|
@@ -94,24 +94,26 @@ If you just need to generate a Capability Token for use with Twilio Client, you
|
|
|
94
94
|
can do this:
|
|
95
95
|
|
|
96
96
|
``` ruby
|
|
97
|
-
require 'rubygems' # not necessary with ruby 1.9 but included for completeness
|
|
98
97
|
require 'twilio-ruby'
|
|
99
98
|
|
|
100
99
|
# put your own account credentials here:
|
|
101
|
-
account_sid = '
|
|
102
|
-
auth_token = '
|
|
100
|
+
account_sid = 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
|
|
101
|
+
auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
|
|
103
102
|
|
|
104
103
|
# set up
|
|
105
|
-
capability = Twilio::
|
|
104
|
+
capability = Twilio::JWT::ClientCapability.new account_sid, auth_token
|
|
105
|
+
|
|
106
106
|
|
|
107
107
|
# allow outgoing calls to an application
|
|
108
|
-
|
|
108
|
+
outgoingScope = Twilio::JWT::ClientCapability::OutgoingClientScope.new 'AP11111111111111111111111111111111'
|
|
109
|
+
capability.add_scope(outgoingScope)
|
|
109
110
|
|
|
110
111
|
# allow incoming calls to 'andrew'
|
|
111
|
-
|
|
112
|
+
incomingScope = Twilio::JWT::ClientCapability::IncomingClientScope.new 'tom'
|
|
113
|
+
capability.add_scope(incomingScope)
|
|
112
114
|
|
|
113
115
|
# generate the token string
|
|
114
|
-
@token = capability.
|
|
116
|
+
@token = capability.to_s
|
|
115
117
|
```
|
|
116
118
|
|
|
117
119
|
There is a slightly more detailed document in the [Capability][capability]
|
|
@@ -123,28 +125,26 @@ TwiML support is based on the [Builder][builder] library. You can construct a
|
|
|
123
125
|
TwiML response like this:
|
|
124
126
|
|
|
125
127
|
``` ruby
|
|
126
|
-
require 'rubygems' # not necessary with ruby 1.9 but included for completeness
|
|
127
128
|
require 'twilio-ruby'
|
|
128
129
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
r.
|
|
132
|
-
|
|
133
|
-
d.Client 'jenny'
|
|
130
|
+
response = Twilio::TwiML::VoiceResponse.new do |r|
|
|
131
|
+
r.say('hello there', voice: 'alice')
|
|
132
|
+
r.dial('', caller_id: '+14159992222') do |d|
|
|
133
|
+
d.client 'jenny'
|
|
134
134
|
end
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
# print the result
|
|
138
|
-
puts response.
|
|
138
|
+
puts response.to_s()
|
|
139
139
|
```
|
|
140
140
|
|
|
141
141
|
This will print the following (except for the whitespace):
|
|
142
142
|
|
|
143
|
-
```
|
|
143
|
+
```xml
|
|
144
144
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
145
145
|
<Response>
|
|
146
146
|
<Say voice="alice">hello there</Say>
|
|
147
|
-
<Dial
|
|
147
|
+
<Dial callerid="+14159992222">
|
|
148
148
|
<Client>jenny</Client>
|
|
149
149
|
</Dial>
|
|
150
150
|
</Response>
|
|
@@ -155,11 +155,11 @@ This will print the following (except for the whitespace):
|
|
|
155
155
|
This library supports and is [tested against][travis] the following Ruby
|
|
156
156
|
implementations:
|
|
157
157
|
|
|
158
|
+
- Ruby 2.4.0
|
|
159
|
+
- Ruby 2.3.0
|
|
158
160
|
- Ruby 2.2.0
|
|
159
161
|
- Ruby 2.1.0
|
|
160
162
|
- Ruby 2.0.0
|
|
161
|
-
- [JRuby][jruby]
|
|
162
|
-
- [Rubinius][rubinius]
|
|
163
163
|
|
|
164
164
|
[capability]: https://github.com/twilio/twilio-ruby/wiki/Capability
|
|
165
165
|
[builder]: http://builder.rubyforge.org/
|
|
@@ -171,7 +171,6 @@ implementations:
|
|
|
171
171
|
[gem]: https://rubygems.org/gems/twilio
|
|
172
172
|
[travis]: http://travis-ci.org/twilio/twilio-ruby
|
|
173
173
|
[codeclimate]: https://codeclimate.com/github/twilio/twilio-ruby
|
|
174
|
-
[jruby]: http://www.jruby.org
|
|
175
|
-
[rubinius]: http://rubini.us
|
|
176
174
|
[upgrade]: https://github.com/twilio/twilio-ruby/wiki/Ruby-Version-5.x-Upgrade-Guide
|
|
177
175
|
[issues]: https://github.com/twilio/twilio-ruby/issues
|
|
176
|
+
[faraday]: https://github.com/lostisland/faraday
|
data/examples/examples.rb
CHANGED
|
@@ -1,83 +1,74 @@
|
|
|
1
|
-
# examples version
|
|
1
|
+
# examples version
|
|
2
2
|
|
|
3
|
-
@account_sid = '
|
|
4
|
-
@auth_token = '
|
|
3
|
+
@account_sid = 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
|
|
4
|
+
@auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
|
|
5
5
|
# set up a client
|
|
6
6
|
@client = Twilio::REST::Client.new(@account_sid, @auth_token)
|
|
7
7
|
|
|
8
8
|
################ ACCOUNTS ################
|
|
9
9
|
|
|
10
10
|
# shortcut to grab your account object (account_sid is inferred from the client's auth credentials)
|
|
11
|
-
@account = @client.account
|
|
11
|
+
@account = @client.api.account
|
|
12
12
|
|
|
13
13
|
# list your (sub)accounts
|
|
14
|
-
@client.accounts.
|
|
14
|
+
@accounts = @client.api.accounts.each do |account|
|
|
15
|
+
puts(account)
|
|
16
|
+
end
|
|
15
17
|
|
|
16
18
|
# grab an account instance resource if you know the sid
|
|
17
|
-
@account = @client.accounts
|
|
18
|
-
|
|
19
|
-
puts @account.friendly_name
|
|
19
|
+
@account = @client.api.accounts(account_sid).fetch
|
|
20
|
+
puts(@account.friendly_name)
|
|
20
21
|
|
|
21
22
|
# update an account's friendly name
|
|
22
|
-
@client.accounts
|
|
23
|
+
@client.api.accounts(account_sid).update(friendly_name: 'A Fabulous Friendly Name')
|
|
23
24
|
|
|
24
25
|
################ CALLS ################
|
|
25
26
|
|
|
26
27
|
# print a list of calls (all parameters optional)
|
|
27
|
-
@
|
|
28
|
-
page: 0,
|
|
29
|
-
page_size: 1000,
|
|
30
|
-
start_time: '2010-09-01'
|
|
31
|
-
).each do |call|
|
|
28
|
+
@client.calls.list(limit: 10, start_time: '2010-09-01').each do |call|
|
|
32
29
|
puts call.sid
|
|
33
30
|
end
|
|
34
31
|
|
|
35
32
|
# get a particular call and list its recording urls
|
|
36
|
-
@
|
|
37
|
-
|
|
33
|
+
@client.calls('CAXXXXXXX').fetch do |call|
|
|
34
|
+
call.recordings().each do |r|
|
|
35
|
+
puts r.wav
|
|
36
|
+
end
|
|
38
37
|
end
|
|
39
38
|
|
|
40
39
|
# make a new outgoing call. returns a call object just like calls.get
|
|
41
|
-
@call = @
|
|
40
|
+
@call = @client.calls.create(
|
|
42
41
|
from: '+14159341234',
|
|
43
42
|
to: '+18004567890',
|
|
44
43
|
url: 'http://example.com/call-handler'
|
|
45
44
|
)
|
|
46
45
|
|
|
47
46
|
# cancel the call if not already in progress
|
|
48
|
-
@
|
|
49
|
-
# or equivalently
|
|
50
|
-
@call.update(status: 'canceled')
|
|
51
|
-
# or simply
|
|
52
|
-
@call.cancel
|
|
47
|
+
@client.calls(@call.sid).update(status: 'canceled')
|
|
53
48
|
|
|
54
49
|
# redirect and then terminate a call
|
|
55
|
-
@call =
|
|
50
|
+
@call = client.calls('CAXXXXXXX')
|
|
56
51
|
@call.update(url: 'http://example.com/call-redirect')
|
|
57
52
|
@call.update(status: 'completed')
|
|
58
|
-
# or, use the aliases...
|
|
59
|
-
@call.redirect_to('http://example.com/call-redirect')
|
|
60
|
-
@call.hangup
|
|
61
53
|
|
|
62
54
|
################ SMS MESSAGES ################
|
|
63
55
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
puts message.body
|
|
56
|
+
@client.messages.list(date_sent: '2010-09-01').each do |message|
|
|
57
|
+
puts message.date_created
|
|
67
58
|
end
|
|
68
59
|
|
|
69
60
|
# print a particular sms message
|
|
70
|
-
puts @
|
|
61
|
+
puts @client.messages('SMXXXXXXXX').fetch.body
|
|
71
62
|
|
|
72
63
|
# send an sms
|
|
73
|
-
@
|
|
64
|
+
@client.messages.create(
|
|
74
65
|
from: '+14159341234',
|
|
75
66
|
to: '+16105557069',
|
|
76
67
|
body: 'Hey there!'
|
|
77
68
|
)
|
|
78
69
|
|
|
79
70
|
# send an mms
|
|
80
|
-
@
|
|
71
|
+
@client.messages.create(
|
|
81
72
|
from: '+14159341234',
|
|
82
73
|
to: '+16105557069',
|
|
83
74
|
media_urls: 'http://example.com/media.png'
|
|
@@ -86,56 +77,54 @@ puts @account.messages.get('SMXXXXXXXX').body
|
|
|
86
77
|
################ PHONE NUMBERS ################
|
|
87
78
|
|
|
88
79
|
# get a list of supported country codes
|
|
89
|
-
@
|
|
80
|
+
@client.available_phone_numbers.list
|
|
90
81
|
|
|
91
82
|
# print some available numbers
|
|
92
|
-
@
|
|
93
|
-
|
|
94
|
-
|
|
83
|
+
@client.available_phone_numbers('US').local.list().each do |num|
|
|
84
|
+
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
@numbers = @client.available_phone_numbers('US').local.list(area_code: '908')
|
|
95
88
|
@numbers.each { |num| puts num.phone_number }
|
|
96
89
|
|
|
97
90
|
# buy the first one
|
|
98
|
-
@
|
|
91
|
+
@client.incoming_phone_numbers.create(phone_number: @numbers[0].phone_number)
|
|
99
92
|
|
|
100
93
|
# update an existing phone number's voice url
|
|
101
|
-
|
|
102
|
-
|
|
94
|
+
@client.incoming_phone_numbers('PNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx').update(
|
|
95
|
+
voice_url: 'http://example.com/voice'
|
|
96
|
+
)
|
|
103
97
|
|
|
104
98
|
# decommission an existing phone number
|
|
105
|
-
numbers = @
|
|
106
|
-
|
|
107
|
-
)
|
|
108
|
-
|
|
99
|
+
numbers = @client.incoming_phone_numbers.list(friendly_name: 'A Fabulous Friendly Name')
|
|
100
|
+
number = numbers[0].sid
|
|
101
|
+
@client.incoming_phone_numbers(number).delete
|
|
102
|
+
|
|
109
103
|
################ CONFERENCES ################
|
|
110
104
|
|
|
111
105
|
# get a particular conference's participants object and stash it
|
|
112
|
-
conference = @
|
|
113
|
-
@participants = conference.participants
|
|
106
|
+
conference = @client.conferences('CFxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx').fetch
|
|
107
|
+
@participants = conference.participants()
|
|
114
108
|
|
|
115
109
|
# list participants
|
|
116
|
-
@participants.
|
|
110
|
+
@participants.each do |p|
|
|
117
111
|
puts p.sid
|
|
118
112
|
end
|
|
119
113
|
|
|
120
114
|
# update a conference participant
|
|
121
|
-
@
|
|
122
|
-
|
|
123
|
-
@participants.get('CA386025c9bf5d6052a1d1ea42b4d16662').mute
|
|
124
|
-
|
|
125
|
-
# and, since we're lazy loading, this would only incur one http request
|
|
126
|
-
@account.conferences.get('CFbbe46ff1274e283f7e3ac1df0072ab39').participants
|
|
127
|
-
.get('CA386025c9bf5d6052a1d1ea42b4d16662').update(muted: 'true')
|
|
115
|
+
@client.conferences('CFxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
|
|
116
|
+
.participants('CAxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx').update(muted: 'true')
|
|
128
117
|
|
|
129
118
|
################ QUEUES ###################
|
|
130
119
|
|
|
131
120
|
# create a new queue
|
|
132
|
-
@queue = @
|
|
121
|
+
@queue = @client.queues.create(friendly_name: 'MyQueue', max_size: 50)
|
|
133
122
|
|
|
134
123
|
# get a list of queues for this account
|
|
135
|
-
@queues = @
|
|
124
|
+
@queues = @client.queues.list()
|
|
136
125
|
|
|
137
126
|
# get a particular queue and its members
|
|
138
|
-
@queue = @
|
|
127
|
+
@queue = @client.queues('QQxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx').fetch
|
|
139
128
|
@members = @queue.members
|
|
140
129
|
|
|
141
130
|
#list members
|
|
@@ -144,5 +133,5 @@ end
|
|
|
144
133
|
end
|
|
145
134
|
|
|
146
135
|
# dequeue a particular user and run twiml at a specific url
|
|
147
|
-
@
|
|
148
|
-
|
|
136
|
+
@client.queues('QQxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
|
|
137
|
+
.members('CAxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx').update(url: 'http://myapp.com/deque', method: 'POST')
|