twilio-ruby 5.0.0.rc24 → 5.0.0.rc25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +32 -12
  3. data/LICENSE.md +12 -12
  4. data/README.md +28 -29
  5. data/examples/examples.rb +47 -58
  6. data/examples/print-call-log.rb +6 -6
  7. data/lib/twilio-ruby/jwt/jwt.rb +2 -2
  8. data/lib/twilio-ruby/rest/accounts/v1.rb +3 -1
  9. data/lib/twilio-ruby/rest/accounts/v1/credential.rb +4 -1
  10. data/lib/twilio-ruby/rest/api/v2010.rb +3 -1
  11. data/lib/twilio-ruby/rest/api/v2010/account.rb +80 -23
  12. data/lib/twilio-ruby/rest/api/v2010/account/address.rb +2 -1
  13. data/lib/twilio-ruby/rest/api/v2010/account/available_phone_number.rb +6 -3
  14. data/lib/twilio-ruby/rest/api/v2010/account/call.rb +14 -4
  15. data/lib/twilio-ruby/rest/api/v2010/account/call/recording.rb +10 -0
  16. data/lib/twilio-ruby/rest/api/v2010/account/conference.rb +4 -1
  17. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb +10 -4
  18. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number/assigned_add_on.rb +4 -1
  19. data/lib/twilio-ruby/rest/api/v2010/account/message.rb +6 -2
  20. data/lib/twilio-ruby/rest/api/v2010/account/queue.rb +4 -1
  21. data/lib/twilio-ruby/rest/api/v2010/account/recording.rb +18 -2
  22. data/lib/twilio-ruby/rest/api/v2010/account/recording/add_on_result.rb +4 -1
  23. data/lib/twilio-ruby/rest/api/v2010/account/sip.rb +14 -4
  24. data/lib/twilio-ruby/rest/api/v2010/account/sip/credential_list.rb +4 -1
  25. data/lib/twilio-ruby/rest/api/v2010/account/sip/domain.rb +8 -2
  26. data/lib/twilio-ruby/rest/api/v2010/account/sip/ip_access_control_list.rb +4 -1
  27. data/lib/twilio-ruby/rest/api/v2010/account/usage.rb +6 -2
  28. data/lib/twilio-ruby/rest/api/v2010/account/usage/record.rb +16 -8
  29. data/lib/twilio-ruby/rest/chat/v1.rb +6 -2
  30. data/lib/twilio-ruby/rest/chat/v1/service.rb +12 -3
  31. data/lib/twilio-ruby/rest/chat/v1/service/channel.rb +12 -3
  32. data/lib/twilio-ruby/rest/chat/v1/service/user.rb +2 -1
  33. data/lib/twilio-ruby/rest/chat/v2.rb +6 -2
  34. data/lib/twilio-ruby/rest/chat/v2/service.rb +12 -3
  35. data/lib/twilio-ruby/rest/chat/v2/service/channel.rb +12 -3
  36. data/lib/twilio-ruby/rest/chat/v2/service/user.rb +2 -1
  37. data/lib/twilio-ruby/rest/fax/v1.rb +3 -1
  38. data/lib/twilio-ruby/rest/fax/v1/fax.rb +4 -1
  39. data/lib/twilio-ruby/rest/ip_messaging/v1.rb +6 -2
  40. data/lib/twilio-ruby/rest/ip_messaging/v1/service.rb +12 -3
  41. data/lib/twilio-ruby/rest/ip_messaging/v1/service/channel.rb +12 -3
  42. data/lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb +2 -1
  43. data/lib/twilio-ruby/rest/ip_messaging/v2.rb +6 -2
  44. data/lib/twilio-ruby/rest/ip_messaging/v2/service.rb +12 -3
  45. data/lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb +12 -3
  46. data/lib/twilio-ruby/rest/ip_messaging/v2/service/user.rb +2 -1
  47. data/lib/twilio-ruby/rest/lookups/v1.rb +3 -1
  48. data/lib/twilio-ruby/rest/messaging/v1.rb +3 -1
  49. data/lib/twilio-ruby/rest/messaging/v1/service.rb +26 -6
  50. data/lib/twilio-ruby/rest/monitor/v1.rb +6 -2
  51. data/lib/twilio-ruby/rest/notify/v1.rb +6 -2
  52. data/lib/twilio-ruby/rest/notify/v1/service.rb +12 -4
  53. data/lib/twilio-ruby/rest/notify/v1/service/notification.rb +3 -1
  54. data/lib/twilio-ruby/rest/notify/v1/service/user.rb +8 -2
  55. data/lib/twilio-ruby/rest/preview/bulk_exports.rb +6 -2
  56. data/lib/twilio-ruby/rest/preview/bulk_exports/export.rb +2 -1
  57. data/lib/twilio-ruby/rest/preview/hosted_numbers.rb +3 -1
  58. data/lib/twilio-ruby/rest/preview/hosted_numbers/hosted_number_order.rb +18 -12
  59. data/lib/twilio-ruby/rest/preview/marketplace.rb +6 -2
  60. data/lib/twilio-ruby/rest/preview/marketplace/available_add_on.rb +4 -1
  61. data/lib/twilio-ruby/rest/preview/marketplace/installed_add_on.rb +4 -1
  62. data/lib/twilio-ruby/rest/preview/proxy.rb +3 -1
  63. data/lib/twilio-ruby/rest/preview/proxy/service.rb +12 -3
  64. data/lib/twilio-ruby/rest/preview/proxy/service/session.rb +8 -2
  65. data/lib/twilio-ruby/rest/preview/proxy/service/session/participant.rb +4 -1
  66. data/lib/twilio-ruby/rest/preview/sync.rb +3 -1
  67. data/lib/twilio-ruby/rest/preview/sync/service.rb +12 -3
  68. data/lib/twilio-ruby/rest/preview/sync/service/document.rb +4 -1
  69. data/lib/twilio-ruby/rest/preview/sync/service/sync_list.rb +8 -2
  70. data/lib/twilio-ruby/rest/preview/sync/service/sync_map.rb +8 -2
  71. data/lib/twilio-ruby/rest/preview/wireless.rb +9 -3
  72. data/lib/twilio-ruby/rest/preview/wireless/sim.rb +2 -1
  73. data/lib/twilio-ruby/rest/pricing/v1.rb +9 -3
  74. data/lib/twilio-ruby/rest/pricing/v1/messaging.rb +4 -1
  75. data/lib/twilio-ruby/rest/pricing/v1/phone_number.rb +4 -1
  76. data/lib/twilio-ruby/rest/pricing/v1/voice.rb +8 -2
  77. data/lib/twilio-ruby/rest/sync/v1.rb +3 -1
  78. data/lib/twilio-ruby/rest/sync/v1/service.rb +12 -3
  79. data/lib/twilio-ruby/rest/sync/v1/service/document.rb +4 -1
  80. data/lib/twilio-ruby/rest/sync/v1/service/sync_list.rb +8 -2
  81. data/lib/twilio-ruby/rest/sync/v1/service/sync_map.rb +8 -2
  82. data/lib/twilio-ruby/rest/taskrouter/v1.rb +3 -1
  83. data/lib/twilio-ruby/rest/taskrouter/v1/workspace.rb +30 -8
  84. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb +4 -1
  85. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue.rb +4 -2
  86. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb +12 -4
  87. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb +2 -1
  88. data/lib/twilio-ruby/rest/trunking/v1.rb +3 -1
  89. data/lib/twilio-ruby/rest/trunking/v1/trunk.rb +16 -4
  90. data/lib/twilio-ruby/rest/video/v1.rb +6 -2
  91. data/lib/twilio-ruby/rest/video/v1/recording.rb +17 -3
  92. data/lib/twilio-ruby/rest/video/v1/room.rb +4 -1
  93. data/lib/twilio-ruby/rest/video/v1/room/recording.rb +31 -3
  94. data/lib/twilio-ruby/rest/wireless/v1.rb +9 -3
  95. data/lib/twilio-ruby/rest/wireless/v1/rate_plan.rb +16 -1
  96. data/lib/twilio-ruby/rest/wireless/v1/sim.rb +2 -1
  97. data/lib/twilio-ruby/twiml/messaging_response.rb +8 -2
  98. data/lib/twilio-ruby/twiml/twiml.rb +3 -5
  99. data/lib/twilio-ruby/twiml/voice_response.rb +60 -42
  100. data/lib/twilio-ruby/version.rb +1 -1
  101. data/spec/integration/api/v2010/account/call/recording_spec.rb +14 -2
  102. data/spec/integration/api/v2010/account/recording_spec.rb +14 -2
  103. data/spec/integration/messaging/v1/service/phone_number_spec.rb +28 -0
  104. data/spec/integration/messaging/v1/service_spec.rb +4 -0
  105. data/spec/integration/notify/v1/service/notification_spec.rb +35 -0
  106. data/spec/integration/video/v1/recording_spec.rb +45 -0
  107. data/spec/integration/video/v1/room/recording_spec.rb +4 -3
  108. data/spec/integration/wireless/v1/rate_plan_spec.rb +8 -0
  109. data/spec/twiml/messaging_response_spec.rb +28 -0
  110. data/spec/twiml/voice_response_spec.rb +9 -0
  111. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f981811e9dfbdbb8ccebb024fc19d02f8572343e
4
- data.tar.gz: 3816114ec774607280c563ceba304d71a7e1586c
3
+ metadata.gz: 01f12541d8117c7793ef1e5379c69d3e214d80d2
4
+ data.tar.gz: 4e5d252025e627244c09ef9eb42e0a92bb4f1e6e
5
5
  SHA512:
6
- metadata.gz: 15f5dec31b1c60f3c48ecba58a092e0bfba5b3421dddf07cf88f4fd59187b8d1b42aa1c7b763f9cd38f7422a2d8dabe9609624e915a4b9116affe157843c6a4d
7
- data.tar.gz: adc945fc725af82de455d4ef556509bf1a15424c8eaa98206d7a27e07d9fdb583ed73d7968373d2b3cb1bfb06778a77d78efa55f2b368dbb0e5a34e309f54ebe
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-22] Version 5.0.0-rc24
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-rc23
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-rc22
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-rc21
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-rc20
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-rc19
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-rc18
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-rc16
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-rc8
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-rc7
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-rc5
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-rc4
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
- Copyright (c) 2010-2014 Andrew Benton.
1
+ MIT License
2
2
 
3
- The MIT License (MIT)
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
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
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
- all copies or substantial portions of the Software.
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
- THE SOFTWARE.
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
- [![Gem Version](http://img.shields.io/gem/v/twilio-ruby.svg)][gem]
1
+ # twilio-ruby
2
+
2
3
  [![Build Status](http://img.shields.io/travis/twilio/twilio-ruby.svg)][travis]
4
+ [![Gem Version](http://img.shields.io/gem/v/twilio-ruby.svg)][gem]
3
5
  [![Code Quality](http://img.shields.io/codeclimate/github/twilio/twilio-ruby.svg)][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.rc21'
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.rc21
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
- ``` ruby
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
- ``` ruby
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
- ``` ruby
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](https://github.com/lostisland/faraday) to make HTTP requests. You can tell Twilio::REST::Client to use any of the Faraday adapters like so:
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 = 'AC043dcf9844e13758bc3a36a84c29761'
102
- auth_token = '62ea81de3a5b413254eb263595357c69'
100
+ account_sid = 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
101
+ auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
103
102
 
104
103
  # set up
105
- capability = Twilio::Util::Capability.new account_sid, auth_token
104
+ capability = Twilio::JWT::ClientCapability.new account_sid, auth_token
105
+
106
106
 
107
107
  # allow outgoing calls to an application
108
- capability.allow_client_outgoing 'AP89a0180a1a4ddf1da954efca349b7a20'
108
+ outgoingScope = Twilio::JWT::ClientCapability::OutgoingClientScope.new 'AP11111111111111111111111111111111'
109
+ capability.add_scope(outgoingScope)
109
110
 
110
111
  # allow incoming calls to 'andrew'
111
- capability.allow_client_incoming 'andrew'
112
+ incomingScope = Twilio::JWT::ClientCapability::IncomingClientScope.new 'tom'
113
+ capability.add_scope(incomingScope)
112
114
 
113
115
  # generate the token string
114
- @token = capability.generate
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
- # build up a response
130
- response = Twilio::TwiML::Response.new do |r|
131
- r.Say 'hello there', voice: 'alice'
132
- r.Dial callerId: '+14159992222' do |d|
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.text
138
+ puts response.to_s()
139
139
  ```
140
140
 
141
141
  This will print the following (except for the whitespace):
142
142
 
143
- ``` xml
143
+ ```xml
144
144
  <?xml version="1.0" encoding="UTF-8"?>
145
145
  <Response>
146
146
  <Say voice="alice">hello there</Say>
147
- <Dial callerId="+14159992222">
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 3
1
+ # examples version
2
2
 
3
- @account_sid = 'AC043dcf9844e04758bc3a36a84c29761'
4
- @auth_token = '62ea81de3a5b414154eb263595357c69'
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.list
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.get(@account_sid)
18
- # http round trip happens here
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.get(@account_sid).update(friendly_name: 'A Fabulous Friendly Name')
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
- @account.calls.list(
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
- @account.calls.get('CAXXXXXXX').recordings.list.each do |r|
37
- puts r.wav
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 = @account.calls.create(
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
- @account.calls.get(@call.sid).update(status: 'canceled')
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 = @account.calls.get('CA386025c9bf5d6052a1d1ea42b4d16662')
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
- # print a list of messages
65
- @account.messages.list(date_sent: '2010-09-01').each do |message|
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 @account.messages.get('SMXXXXXXXX').body
61
+ puts @client.messages('SMXXXXXXXX').fetch.body
71
62
 
72
63
  # send an sms
73
- @account.messages.create(
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
- @account.messages.create(
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
- @account.available_phone_numbers.list
80
+ @client.available_phone_numbers.list
90
81
 
91
82
  # print some available numbers
92
- @numbers = @account.available_phone_numbers.get('US').local.list(
93
- contains: 'AWESOME'
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
- @account.incoming_phone_numbers.create(phone_number: @numbers[0].phone_number)
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
- number = @account.incoming_phone_numbers.get('PNdba508c5616a7f5e141789f44f022cc3')
102
- number.update(voice_url: 'http://example.com/voice')
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 = @account.incoming_phone_numbers.list(
106
- friendly_name: 'A Fabulous Friendly Name'
107
- )
108
- numbers[0].delete
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 = @account.conferences.get('CFbbe46ff1274e283f7e3ac1df0072ab39')
113
- @participants = conference.participants
106
+ conference = @client.conferences('CFxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx').fetch
107
+ @participants = conference.participants()
114
108
 
115
109
  # list participants
116
- @participants.list.each do |p|
110
+ @participants.each do |p|
117
111
  puts p.sid
118
112
  end
119
113
 
120
114
  # update a conference participant
121
- @participants.get('CA386025c9bf5d6052a1d1ea42b4d16662').update(muted: 'true')
122
- # or an easier way
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 = @account.queues.create(friendly_name: 'MyQueue', max_size: 50)
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 = @account.queues.list
124
+ @queues = @client.queues.list()
136
125
 
137
126
  # get a particular queue and its members
138
- @queue = @account.queues.get("QQb6765b0458714964970a73dcaf55efd1")
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
- @member = @members.get('CA386025c9bf5d6052a1d1ea42b4d16662')
148
- @member.dequeue('http://myapp.com/deque')
136
+ @client.queues('QQxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
137
+ .members('CAxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx').update(url: 'http://myapp.com/deque', method: 'POST')