twilio-ruby 4.4.0 → 4.13.0

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 (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +85 -0
  3. data/Makefile +3 -0
  4. data/README.md +1 -1
  5. data/issue_template.md +25 -0
  6. data/lib/twilio-ruby/rest/accounts.rb +1 -1
  7. data/lib/twilio-ruby/rest/base_client.rb +3 -2
  8. data/lib/twilio-ruby/rest/ip-messaging/channels.rb +15 -0
  9. data/lib/twilio-ruby/rest/ip-messaging/credentials.rb +19 -0
  10. data/lib/twilio-ruby/rest/ip-messaging/members.rb +8 -0
  11. data/lib/twilio-ruby/rest/ip-messaging/messages.rb +8 -0
  12. data/lib/twilio-ruby/rest/ip-messaging/roles.rb +8 -0
  13. data/lib/twilio-ruby/rest/ip-messaging/services.rb +17 -0
  14. data/lib/twilio-ruby/rest/ip-messaging/users.rb +8 -0
  15. data/lib/twilio-ruby/rest/ip_messaging_client.rb +100 -0
  16. data/lib/twilio-ruby/rest/keys.rb +6 -0
  17. data/lib/twilio-ruby/rest/pricing/messaging.rb +15 -0
  18. data/lib/twilio-ruby/rest/pricing/voice.rb +0 -3
  19. data/lib/twilio-ruby/rest/pricing_client.rb +2 -4
  20. data/lib/twilio-ruby/rest/trunking/credential_lists.rb +8 -0
  21. data/lib/twilio-ruby/rest/trunking/ip_access_control_lists.rb +8 -0
  22. data/lib/twilio-ruby/rest/trunking/origination_urls.rb +8 -0
  23. data/lib/twilio-ruby/rest/trunking/phone_numbers.rb +8 -0
  24. data/lib/twilio-ruby/rest/trunking/trunks.rb +19 -0
  25. data/lib/twilio-ruby/rest/trunking_client.rb +106 -0
  26. data/lib/twilio-ruby/task_router/capability.rb +11 -5
  27. data/lib/twilio-ruby/task_router/workflow_builder.rb +7 -1
  28. data/lib/twilio-ruby/util/access_token.rb +158 -0
  29. data/lib/twilio-ruby/version.rb +1 -1
  30. data/lib/twilio-ruby.rb +22 -0
  31. data/spec/rest/ip-messaging/channel_spec.rb +21 -0
  32. data/spec/rest/ip-messaging/service_spec.rb +30 -0
  33. data/spec/rest/ip_messaging_client_spec.rb +21 -0
  34. data/spec/rest/key_spec.rb +11 -0
  35. data/spec/rest/pricing_client_spec.rb +15 -0
  36. data/spec/rest/trunking/trunk_spec.rb +36 -0
  37. data/spec/task_router/workflow_builder_spec.rb +501 -0
  38. data/spec/task_router_deprecated_spec.rb +15 -6
  39. data/spec/task_router_worker_spec.rb +24 -7
  40. data/spec/util/access_token_spec.rb +161 -0
  41. metadata +35 -3
@@ -0,0 +1,161 @@
1
+ require 'spec_helper'
2
+
3
+ describe Twilio::Util::AccessToken do
4
+
5
+ it 'should generate a token for no grants' do
6
+ scat = Twilio::Util::AccessToken.new 'AC123', 'SK123','secret'
7
+ token = scat.to_s
8
+ expect(token).not_to be_nil
9
+ payload, header = JWT.decode token, 'secret'
10
+
11
+ expect(payload['iss']).to eq('SK123')
12
+ expect(payload['sub']).to eq('AC123')
13
+ expect(payload['exp']).not_to be_nil
14
+ expect(payload['exp']).to be >= Time.now.to_i
15
+ expect(payload['jti']).not_to be_nil
16
+ expect(payload['jti']).to start_with payload['iss']
17
+ expect(payload['nbf']).to be_nil
18
+ expect(payload['grants']).not_to be_nil
19
+ expect(payload['grants'].count).to eq(0)
20
+ end
21
+
22
+ it 'should generate a nbf' do
23
+ now = Time.now.to_i - 1
24
+ scat = Twilio::Util::AccessToken.new 'AC123', 'SK123','secret'
25
+ scat.identity = 'abc'
26
+ scat.nbf = now
27
+
28
+ token = scat.to_s
29
+ expect(token).not_to be_nil
30
+ payload, header = JWT.decode token, 'secret'
31
+
32
+ expect(payload['iss']).to eq('SK123')
33
+ expect(payload['sub']).to eq('AC123')
34
+ expect(payload['nbf']).not_to be_nil
35
+ expect(payload['nbf']).to eq(now)
36
+ expect(payload['exp']).not_to be_nil
37
+ expect(payload['exp']).to be >= Time.now.to_i
38
+ expect(payload['jti']).not_to be_nil
39
+ expect(payload['jti']).to start_with payload['iss']
40
+ expect(payload['grants']).not_to be_nil
41
+ expect(payload['grants'].count).to eq(1)
42
+ expect(payload['grants']['identity']).to eq('abc')
43
+ end
44
+
45
+ it 'should be able to add conversation grant' do
46
+ scat = Twilio::Util::AccessToken.new 'AC123', 'SK123','secret'
47
+ scat.add_grant(Twilio::Util::AccessToken::ConversationsGrant.new)
48
+
49
+ token = scat.to_s
50
+ expect(token).not_to be_nil
51
+ payload, header = JWT.decode token, 'secret'
52
+
53
+ expect(payload['iss']).to eq('SK123')
54
+ expect(payload['sub']).to eq('AC123')
55
+ expect(payload['exp']).not_to be_nil
56
+ expect(payload['exp']).to be >= Time.now.to_i
57
+ expect(payload['jti']).not_to be_nil
58
+ expect(payload['jti']).to start_with payload['iss']
59
+ expect(payload['grants']).not_to be_nil
60
+ expect(payload['grants'].count).to eq(1)
61
+ expect(payload['grants']['rtc']).not_to be_nil
62
+ end
63
+
64
+ it 'should be able to add endpoint grants' do
65
+ scat = Twilio::Util::AccessToken.new 'AC123', 'SK123','secret'
66
+
67
+ grant = Twilio::Util::AccessToken::IpMessagingGrant.new
68
+ grant.push_credential_sid = 'CR123'
69
+ grant.deployment_role_sid = 'DR123'
70
+ grant.service_sid = 'IS123'
71
+ grant.endpoint_id = 'EP123'
72
+ scat.add_grant(grant)
73
+
74
+ token = scat.to_s
75
+ expect(token).not_to be_nil
76
+ payload, header = JWT.decode token, 'secret'
77
+
78
+ expect(payload['iss']).to eq('SK123')
79
+ expect(payload['sub']).to eq('AC123')
80
+ expect(payload['exp']).not_to be_nil
81
+ expect(payload['exp']).to be >= Time.now.to_i
82
+ expect(payload['jti']).not_to be_nil
83
+ expect(payload['jti']).to start_with payload['iss']
84
+ expect(payload['grants']).not_to be_nil
85
+ expect(payload['grants'].count).to eq(1)
86
+ expect(payload['grants']['ip_messaging']).not_to be_nil
87
+ expect(payload['grants']['ip_messaging']['service_sid']).to eq('IS123')
88
+ expect(payload['grants']['ip_messaging']['endpoint_id']).to eq('EP123')
89
+ expect(payload['grants']['ip_messaging']['push_credential_sid']).to eq('CR123')
90
+ expect(payload['grants']['ip_messaging']['deployment_role_sid']).to eq('DR123')
91
+ end
92
+
93
+ it 'should add rest grants' do
94
+ scat = Twilio::Util::AccessToken.new 'AC123', 'SK123','secret'
95
+ scat.add_grant(Twilio::Util::AccessToken::ConversationsGrant.new)
96
+ scat.add_grant(Twilio::Util::AccessToken::IpMessagingGrant.new)
97
+
98
+ token = scat.to_s
99
+ expect(token).not_to be_nil
100
+ payload, header = JWT.decode token, 'secret'
101
+
102
+ expect(payload['iss']).to eq('SK123')
103
+ expect(payload['sub']).to eq('AC123')
104
+ expect(payload['exp']).not_to be_nil
105
+ expect(payload['exp']).to be >= Time.now.to_i
106
+ expect(payload['jti']).not_to be_nil
107
+ expect(payload['jti']).to start_with payload['iss']
108
+ expect(payload['grants']).not_to be_nil
109
+ expect(payload['grants'].count).to eq(2)
110
+ expect(payload['grants']['rtc']).not_to be_nil
111
+ expect(payload['grants']['ip_messaging']).not_to be_nil
112
+ end
113
+
114
+ it 'should add programmable voice grant' do
115
+ scat = Twilio::Util::AccessToken.new 'AC123', 'SK123','secret'
116
+ pvg = Twilio::Util::AccessToken::VoiceGrant.new
117
+ pvg.outgoing_application_sid = 'AP123'
118
+ pvg.outgoing_application_params = { :foo => 'bar' }
119
+
120
+ scat.add_grant(pvg)
121
+
122
+ token = scat.to_s
123
+ expect(token).not_to be_nil
124
+ payload, header = JWT.decode token, 'secret'
125
+
126
+ expect(payload['iss']).to eq('SK123')
127
+ expect(payload['sub']).to eq('AC123')
128
+ expect(payload['exp']).not_to be_nil
129
+ expect(payload['exp']).to be >= Time.now.to_i
130
+ expect(payload['jti']).not_to be_nil
131
+ expect(payload['jti']).to start_with payload['iss']
132
+ expect(payload['grants']).not_to be_nil
133
+ expect(payload['grants'].count).to eq(1)
134
+ expect(payload['grants']['voice']).not_to be_nil
135
+ expect(payload['grants']['voice']['outgoing']['application_sid']).to eq('AP123')
136
+ expect(payload['grants']['voice']['outgoing']['params']['foo']).to eq('bar')
137
+ end
138
+
139
+ it 'should add video grant' do
140
+ scat = Twilio::Util::AccessToken.new 'AC123', 'SK123','secret'
141
+ vg = Twilio::Util::AccessToken::VideoGrant.new
142
+ vg.configuration_profile_sid = 'CP123'
143
+
144
+ scat.add_grant(vg)
145
+
146
+ token = scat.to_s
147
+ expect(token).not_to be_nil
148
+ payload, header = JWT.decode token, 'secret'
149
+
150
+ expect(payload['iss']).to eq('SK123')
151
+ expect(payload['sub']).to eq('AC123')
152
+ expect(payload['exp']).not_to be_nil
153
+ expect(payload['exp']).to be >= Time.now.to_i
154
+ expect(payload['jti']).not_to be_nil
155
+ expect(payload['jti']).to start_with payload['iss']
156
+ expect(payload['grants']).not_to be_nil
157
+ expect(payload['grants'].count).to eq(1)
158
+ expect(payload['grants']['video']).not_to be_nil
159
+ expect(payload['grants']['video']['configuration_profile_sid']).to eq('CP123')
160
+ end
161
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twilio-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.0
4
+ version: 4.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Benton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-23 00:00:00.000000000 Z
11
+ date: 2016-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -130,6 +130,7 @@ files:
130
130
  - examples/examples.rb
131
131
  - examples/print-call-log.rb
132
132
  - examples/taskrouter.examples.rb
133
+ - issue_template.md
133
134
  - lib/rack/twilio_webhook_authentication.rb
134
135
  - lib/twilio-ruby.rb
135
136
  - lib/twilio-ruby/rest/accounts.rb
@@ -156,6 +157,15 @@ files:
156
157
  - lib/twilio-ruby/rest/incoming_phone_numbers/mobile.rb
157
158
  - lib/twilio-ruby/rest/incoming_phone_numbers/toll_free.rb
158
159
  - lib/twilio-ruby/rest/instance_resource.rb
160
+ - lib/twilio-ruby/rest/ip-messaging/channels.rb
161
+ - lib/twilio-ruby/rest/ip-messaging/credentials.rb
162
+ - lib/twilio-ruby/rest/ip-messaging/members.rb
163
+ - lib/twilio-ruby/rest/ip-messaging/messages.rb
164
+ - lib/twilio-ruby/rest/ip-messaging/roles.rb
165
+ - lib/twilio-ruby/rest/ip-messaging/services.rb
166
+ - lib/twilio-ruby/rest/ip-messaging/users.rb
167
+ - lib/twilio-ruby/rest/ip_messaging_client.rb
168
+ - lib/twilio-ruby/rest/keys.rb
159
169
  - lib/twilio-ruby/rest/list_resource.rb
160
170
  - lib/twilio-ruby/rest/lookups/phone_numbers.rb
161
171
  - lib/twilio-ruby/rest/lookups_client.rb
@@ -169,6 +179,7 @@ files:
169
179
  - lib/twilio-ruby/rest/outgoing_caller_ids.rb
170
180
  - lib/twilio-ruby/rest/pricing.rb
171
181
  - lib/twilio-ruby/rest/pricing/countries.rb
182
+ - lib/twilio-ruby/rest/pricing/messaging.rb
172
183
  - lib/twilio-ruby/rest/pricing/phone_numbers.rb
173
184
  - lib/twilio-ruby/rest/pricing/voice.rb
174
185
  - lib/twilio-ruby/rest/pricing/voice/numbers.rb
@@ -204,6 +215,12 @@ files:
204
215
  - lib/twilio-ruby/rest/task_router_client.rb
205
216
  - lib/twilio-ruby/rest/tokens.rb
206
217
  - lib/twilio-ruby/rest/transcriptions.rb
218
+ - lib/twilio-ruby/rest/trunking/credential_lists.rb
219
+ - lib/twilio-ruby/rest/trunking/ip_access_control_lists.rb
220
+ - lib/twilio-ruby/rest/trunking/origination_urls.rb
221
+ - lib/twilio-ruby/rest/trunking/phone_numbers.rb
222
+ - lib/twilio-ruby/rest/trunking/trunks.rb
223
+ - lib/twilio-ruby/rest/trunking_client.rb
207
224
  - lib/twilio-ruby/rest/usage.rb
208
225
  - lib/twilio-ruby/rest/usage/records.rb
209
226
  - lib/twilio-ruby/rest/usage/triggers.rb
@@ -213,6 +230,7 @@ files:
213
230
  - lib/twilio-ruby/task_router/workflow_builder.rb
214
231
  - lib/twilio-ruby/twiml/response.rb
215
232
  - lib/twilio-ruby/util.rb
233
+ - lib/twilio-ruby/util/access_token.rb
216
234
  - lib/twilio-ruby/util/capability.rb
217
235
  - lib/twilio-ruby/util/client_config.rb
218
236
  - lib/twilio-ruby/util/configuration.rb
@@ -227,6 +245,10 @@ files:
227
245
  - spec/rest/client_spec.rb
228
246
  - spec/rest/conference_spec.rb
229
247
  - spec/rest/instance_resource_spec.rb
248
+ - spec/rest/ip-messaging/channel_spec.rb
249
+ - spec/rest/ip-messaging/service_spec.rb
250
+ - spec/rest/ip_messaging_client_spec.rb
251
+ - spec/rest/key_spec.rb
230
252
  - spec/rest/lookups/phone_number_spec.rb
231
253
  - spec/rest/message_spec.rb
232
254
  - spec/rest/monitor_client_spec.rb
@@ -240,15 +262,18 @@ files:
240
262
  - spec/rest/task_router/statistics_spec.rb
241
263
  - spec/rest/task_router/task_queue_spec.rb
242
264
  - spec/rest/token_spec.rb
265
+ - spec/rest/trunking/trunk_spec.rb
243
266
  - spec/rest/utils_spec.rb
244
267
  - spec/spec_helper.rb
245
268
  - spec/support/fakeweb.rb
269
+ - spec/task_router/workflow_builder_spec.rb
246
270
  - spec/task_router_deprecated_spec.rb
247
271
  - spec/task_router_spec.rb
248
272
  - spec/task_router_taskqueue_spec.rb
249
273
  - spec/task_router_worker_spec.rb
250
274
  - spec/task_router_workspace_spec.rb
251
275
  - spec/twilio_spec.rb
276
+ - spec/util/access_token_spec.rb
252
277
  - spec/util/capability_spec.rb
253
278
  - spec/util/client_config_spec.rb
254
279
  - spec/util/configuration_spec.rb
@@ -281,7 +306,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
281
306
  version: '0'
282
307
  requirements: []
283
308
  rubyforge_project:
284
- rubygems_version: 2.0.14
309
+ rubygems_version: 2.0.14.1
285
310
  signing_key:
286
311
  specification_version: 4
287
312
  summary: A simple library for communicating with the Twilio REST API, building TwiML,
@@ -296,6 +321,10 @@ test_files:
296
321
  - spec/rest/client_spec.rb
297
322
  - spec/rest/conference_spec.rb
298
323
  - spec/rest/instance_resource_spec.rb
324
+ - spec/rest/ip-messaging/channel_spec.rb
325
+ - spec/rest/ip-messaging/service_spec.rb
326
+ - spec/rest/ip_messaging_client_spec.rb
327
+ - spec/rest/key_spec.rb
299
328
  - spec/rest/lookups/phone_number_spec.rb
300
329
  - spec/rest/message_spec.rb
301
330
  - spec/rest/monitor_client_spec.rb
@@ -309,15 +338,18 @@ test_files:
309
338
  - spec/rest/task_router/statistics_spec.rb
310
339
  - spec/rest/task_router/task_queue_spec.rb
311
340
  - spec/rest/token_spec.rb
341
+ - spec/rest/trunking/trunk_spec.rb
312
342
  - spec/rest/utils_spec.rb
313
343
  - spec/spec_helper.rb
314
344
  - spec/support/fakeweb.rb
345
+ - spec/task_router/workflow_builder_spec.rb
315
346
  - spec/task_router_deprecated_spec.rb
316
347
  - spec/task_router_spec.rb
317
348
  - spec/task_router_taskqueue_spec.rb
318
349
  - spec/task_router_worker_spec.rb
319
350
  - spec/task_router_workspace_spec.rb
320
351
  - spec/twilio_spec.rb
352
+ - spec/util/access_token_spec.rb
321
353
  - spec/util/capability_spec.rb
322
354
  - spec/util/client_config_spec.rb
323
355
  - spec/util/configuration_spec.rb