twilio-ruby 5.2.3 → 5.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +26 -0
  3. data/README.md +3 -3
  4. data/UPGRADE.md +30 -0
  5. data/lib/twilio-ruby.rb +0 -18
  6. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb +2 -2
  7. data/lib/twilio-ruby/rest/chat/v2/service.rb +24 -2
  8. data/lib/twilio-ruby/rest/chat/v2/service/channel/message.rb +5 -3
  9. data/lib/twilio-ruby/rest/client.rb +3 -3
  10. data/lib/twilio-ruby/rest/ip_messaging/v2/service.rb +24 -2
  11. data/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/message.rb +5 -3
  12. data/lib/twilio-ruby/rest/notify/v1/service/notification.rb +12 -12
  13. data/lib/twilio-ruby/rest/taskrouter/v1/workspace.rb +38 -0
  14. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue.rb +40 -0
  15. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_cumulative_statistics.rb +350 -0
  16. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_real_time_statistics.rb +264 -0
  17. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_statistics.rb +10 -2
  18. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queues_statistics.rb +15 -3
  19. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb +38 -0
  20. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_statistics.rb +6 -2
  21. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_cumulative_statistics.rb +274 -0
  22. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_real_time_statistics.rb +213 -0
  23. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_statistics.rb +14 -10
  24. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb +40 -0
  25. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_cumulative_statistics.rb +357 -0
  26. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_real_time_statistics.rb +243 -0
  27. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_statistics.rb +10 -2
  28. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_cumulative_statistics.rb +339 -0
  29. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_real_time_statistics.rb +239 -0
  30. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_statistics.rb +10 -2
  31. data/lib/twilio-ruby/rest/video/v1/room.rb +7 -0
  32. data/lib/twilio-ruby/security/request_validator.rb +1 -1
  33. data/lib/twilio-ruby/version.rb +1 -1
  34. data/spec/integration/chat/v2/service/channel/message_spec.rb +41 -7
  35. data/spec/integration/chat/v2/service_spec.rb +8 -0
  36. data/spec/integration/ip_messaging/v2/service/channel/message_spec.rb +41 -7
  37. data/spec/integration/ip_messaging/v2/service_spec.rb +8 -0
  38. data/spec/integration/taskrouter/v1/workspace/task_queue/task_queue_cumulative_statistics_spec.rb +94 -0
  39. data/spec/integration/taskrouter/v1/workspace/task_queue/task_queue_real_time_statistics_spec.rb +79 -0
  40. data/spec/integration/taskrouter/v1/workspace/task_queue_spec.rb +8 -0
  41. data/spec/integration/taskrouter/v1/workspace/worker/worker_statistics_spec.rb +21 -38
  42. data/spec/integration/taskrouter/v1/workspace/worker/workers_cumulative_statistics_spec.rb +87 -0
  43. data/spec/integration/taskrouter/v1/workspace/worker/workers_real_time_statistics_spec.rb +68 -0
  44. data/spec/integration/taskrouter/v1/workspace/worker/workers_statistics_spec.rb +34 -61
  45. data/spec/integration/taskrouter/v1/workspace/worker_spec.rb +8 -0
  46. data/spec/integration/taskrouter/v1/workspace/workflow/workflow_cumulative_statistics_spec.rb +95 -0
  47. data/spec/integration/taskrouter/v1/workspace/workflow/workflow_real_time_statistics_spec.rb +55 -0
  48. data/spec/integration/taskrouter/v1/workspace/workflow_spec.rb +12 -4
  49. data/spec/integration/taskrouter/v1/workspace/workspace_cumulative_statistics_spec.rb +92 -0
  50. data/spec/integration/taskrouter/v1/workspace/workspace_real_time_statistics_spec.rb +70 -0
  51. data/spec/integration/taskrouter/v1/workspace_spec.rb +8 -0
  52. data/spec/integration/video/v1/room_spec.rb +12 -0
  53. data/spec/security/request_validator_spec.rb +0 -28
  54. data/spec/twilio_spec.rb +0 -15
  55. metadata +28 -9
  56. data/lib/rack/twilio_webhook_authentication.rb +0 -46
  57. data/lib/twilio-ruby/util/configuration.rb +0 -7
  58. data/spec/rack/twilio_webhook_authentication_spec.rb +0 -106
  59. data/spec/util/configuration_spec.rb +0 -15
@@ -0,0 +1,70 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+
7
+ require 'spec_helper.rb'
8
+
9
+ describe 'WorkspaceRealTimeStatistics' do
10
+ it "can fetch" do
11
+ @holodeck.mock(Twilio::Response.new(500, ''))
12
+
13
+ expect {
14
+ @client.taskrouter.v1.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \
15
+ .workspace_real_time_statistics().fetch()
16
+ }.to raise_exception(Twilio::REST::TwilioError)
17
+
18
+ values = {}
19
+ expect(
20
+ @holodeck.has_request?(Holodeck::Request.new(
21
+ method: 'get',
22
+ url: 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics',
23
+ ))).to eq(true)
24
+ end
25
+
26
+ it "receives fetch responses" do
27
+ @holodeck.mock(Twilio::Response.new(
28
+ 200,
29
+ %q[
30
+ {
31
+ "url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics",
32
+ "tasks_by_priority": {},
33
+ "activity_statistics": [
34
+ {
35
+ "friendly_name": "Idle",
36
+ "workers": 0,
37
+ "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
38
+ },
39
+ {
40
+ "friendly_name": "Busy",
41
+ "workers": 9,
42
+ "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
43
+ },
44
+ {
45
+ "friendly_name": "Offline",
46
+ "workers": 6,
47
+ "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
48
+ },
49
+ {
50
+ "friendly_name": "Reserved",
51
+ "workers": 0,
52
+ "sid": "WAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
53
+ }
54
+ ],
55
+ "workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
56
+ "longest_task_waiting_age": 100,
57
+ "total_workers": 100,
58
+ "total_tasks": 100,
59
+ "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
60
+ "tasks_by_status": {}
61
+ }
62
+ ]
63
+ ))
64
+
65
+ actual = @client.taskrouter.v1.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \
66
+ .workspace_real_time_statistics().fetch()
67
+
68
+ expect(actual).to_not eq(nil)
69
+ end
70
+ end
@@ -38,6 +38,8 @@ describe 'Workspace' do
38
38
  "links": {
39
39
  "activities": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities",
40
40
  "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics",
41
+ "workspace_real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics",
42
+ "workspace_cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics",
41
43
  "task_queues": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues",
42
44
  "tasks": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks",
43
45
  "workers": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers",
@@ -91,6 +93,8 @@ describe 'Workspace' do
91
93
  "links": {
92
94
  "activities": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities",
93
95
  "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics",
96
+ "workspace_real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics",
97
+ "workspace_cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics",
94
98
  "task_queues": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues",
95
99
  "tasks": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks",
96
100
  "workers": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers",
@@ -155,6 +159,8 @@ describe 'Workspace' do
155
159
  "links": {
156
160
  "activities": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities",
157
161
  "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics",
162
+ "workspace_real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics",
163
+ "workspace_cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics",
158
164
  "task_queues": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues",
159
165
  "tasks": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks",
160
166
  "workers": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers",
@@ -237,6 +243,8 @@ describe 'Workspace' do
237
243
  "links": {
238
244
  "activities": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Activities",
239
245
  "statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Statistics",
246
+ "workspace_real_time_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/RealTimeStatistics",
247
+ "workspace_cumulative_statistics": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CumulativeStatistics",
240
248
  "task_queues": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/TaskQueues",
241
249
  "tasks": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks",
242
250
  "workers": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers",
@@ -40,6 +40,9 @@ describe 'Room' do
40
40
  "status_callback_method": "POST",
41
41
  "status_callback": "",
42
42
  "record_participants_on_connect": false,
43
+ "video_codecs": [
44
+ "VP8"
45
+ ],
43
46
  "end_time": "2015-07-30T20:00:00Z",
44
47
  "url": "https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
45
48
  "links": {
@@ -87,6 +90,9 @@ describe 'Room' do
87
90
  "status_callback_method": "POST",
88
91
  "status_callback": "",
89
92
  "record_participants_on_connect": false,
93
+ "video_codecs": [
94
+ "VP8"
95
+ ],
90
96
  "end_time": "2015-07-30T20:00:00Z",
91
97
  "url": "https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
92
98
  "links": {
@@ -161,6 +167,9 @@ describe 'Room' do
161
167
  "duration": 2,
162
168
  "max_participants": 10,
163
169
  "record_participants_on_connect": false,
170
+ "video_codecs": [
171
+ "VP8"
172
+ ],
164
173
  "url": "https://video.twilio.com/v1/Rooms/RM4070b618362c1682b2385b1f9982833c",
165
174
  "links": {
166
175
  "recordings": "https://video.twilio.com/v1/Rooms/RM4070b618362c1682b2385b1f9982833c/Recordings"
@@ -220,6 +229,9 @@ describe 'Room' do
220
229
  "status_callback_method": "POST",
221
230
  "status_callback": "",
222
231
  "record_participants_on_connect": false,
232
+ "video_codecs": [
233
+ "VP8"
234
+ ],
223
235
  "end_time": "2015-07-30T20:00:00Z",
224
236
  "duration": 10,
225
237
  "url": "https://video.twilio.com/v1/Rooms/RMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
@@ -1,34 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Twilio::Security::RequestValidator do
4
- describe 'configuration' do
5
- after(:each) do
6
- Twilio.instance_variable_set('@configuration', nil)
7
- end
8
-
9
- it 'should set the auth token from a configuration block' do
10
- Twilio.configure do |config|
11
- config.auth_token = 'someToken'
12
- end
13
-
14
- validator = Twilio::Security::RequestValidator.new
15
- expect(validator.instance_variable_get('@auth_token')).to eq('someToken')
16
- end
17
-
18
- it 'should overwrite the auth token if passed to initializer' do
19
- Twilio.configure do |config|
20
- config.auth_token = 'someToken'
21
- end
22
-
23
- validator = Twilio::Security::RequestValidator.new 'otherToken'
24
- expect(validator.instance_variable_get('@auth_token')).to eq('otherToken')
25
- end
26
-
27
- it 'should throw an argument error if the auth token isn\'t set' do
28
- expect { Twilio::Security::RequestValidator.new }.to raise_error(ArgumentError)
29
- end
30
- end
31
-
32
4
  describe 'validations' do
33
5
  let(:token) { '2bd9e9638872de601313dc77410d3b23' }
34
6
 
data/spec/twilio_spec.rb CHANGED
@@ -1,15 +0,0 @@
1
- describe Twilio do
2
- after(:each) do
3
- Twilio.instance_variable_set('@configuration', nil)
4
- end
5
-
6
- it 'should set the account sid and auth token with a config block' do
7
- Twilio.configure do |config|
8
- config.account_sid = 'someSid'
9
- config.auth_token = 'someToken'
10
- end
11
-
12
- expect(Twilio.account_sid).to eq('someSid')
13
- expect(Twilio.auth_token).to eq('someToken')
14
- end
15
- 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: 5.2.3
4
+ version: 5.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Twilio API Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-15 00:00:00.000000000 Z
11
+ date: 2017-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: libxml-ruby
@@ -122,12 +122,12 @@ files:
122
122
  - Makefile
123
123
  - README.md
124
124
  - Rakefile
125
+ - UPGRADE.md
125
126
  - VERSIONS.md
126
127
  - conf/cacert.pem
127
128
  - examples/examples.rb
128
129
  - examples/print_call_log.rb
129
130
  - githooks/pre-commit
130
- - lib/rack/twilio_webhook_authentication.rb
131
131
  - lib/twilio-ruby.rb
132
132
  - lib/twilio-ruby/framework/domain.rb
133
133
  - lib/twilio-ruby/framework/error.rb
@@ -355,15 +355,23 @@ files:
355
355
  - lib/twilio-ruby/rest/taskrouter/v1/workspace/task/reservation.rb
356
356
  - lib/twilio-ruby/rest/taskrouter/v1/workspace/task_channel.rb
357
357
  - lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue.rb
358
+ - lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_cumulative_statistics.rb
359
+ - lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_real_time_statistics.rb
358
360
  - lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_statistics.rb
359
361
  - lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queues_statistics.rb
360
362
  - lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb
361
363
  - lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/reservation.rb
362
364
  - lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb
363
365
  - lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_statistics.rb
366
+ - lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_cumulative_statistics.rb
367
+ - lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_real_time_statistics.rb
364
368
  - lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_statistics.rb
365
369
  - lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb
370
+ - lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_cumulative_statistics.rb
371
+ - lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_real_time_statistics.rb
366
372
  - lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_statistics.rb
373
+ - lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_cumulative_statistics.rb
374
+ - lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_real_time_statistics.rb
367
375
  - lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_statistics.rb
368
376
  - lib/twilio-ruby/rest/trunking.rb
369
377
  - lib/twilio-ruby/rest/trunking/v1.rb
@@ -390,7 +398,6 @@ files:
390
398
  - lib/twilio-ruby/twiml/twiml.rb
391
399
  - lib/twilio-ruby/twiml/voice_response.rb
392
400
  - lib/twilio-ruby/util.rb
393
- - lib/twilio-ruby/util/configuration.rb
394
401
  - lib/twilio-ruby/version.rb
395
402
  - spec/framework/request_spec.rb
396
403
  - spec/framework/serialize_spec.rb
@@ -568,6 +575,8 @@ files:
568
575
  - spec/integration/taskrouter/v1/workspace/event_spec.rb
569
576
  - spec/integration/taskrouter/v1/workspace/task/reservation_spec.rb
570
577
  - spec/integration/taskrouter/v1/workspace/task_channel_spec.rb
578
+ - spec/integration/taskrouter/v1/workspace/task_queue/task_queue_cumulative_statistics_spec.rb
579
+ - spec/integration/taskrouter/v1/workspace/task_queue/task_queue_real_time_statistics_spec.rb
571
580
  - spec/integration/taskrouter/v1/workspace/task_queue/task_queue_statistics_spec.rb
572
581
  - spec/integration/taskrouter/v1/workspace/task_queue/task_queues_statistics_spec.rb
573
582
  - spec/integration/taskrouter/v1/workspace/task_queue_spec.rb
@@ -575,10 +584,16 @@ files:
575
584
  - spec/integration/taskrouter/v1/workspace/worker/reservation_spec.rb
576
585
  - spec/integration/taskrouter/v1/workspace/worker/worker_channel_spec.rb
577
586
  - spec/integration/taskrouter/v1/workspace/worker/worker_statistics_spec.rb
587
+ - spec/integration/taskrouter/v1/workspace/worker/workers_cumulative_statistics_spec.rb
588
+ - spec/integration/taskrouter/v1/workspace/worker/workers_real_time_statistics_spec.rb
578
589
  - spec/integration/taskrouter/v1/workspace/worker/workers_statistics_spec.rb
579
590
  - spec/integration/taskrouter/v1/workspace/worker_spec.rb
591
+ - spec/integration/taskrouter/v1/workspace/workflow/workflow_cumulative_statistics_spec.rb
592
+ - spec/integration/taskrouter/v1/workspace/workflow/workflow_real_time_statistics_spec.rb
580
593
  - spec/integration/taskrouter/v1/workspace/workflow/workflow_statistics_spec.rb
581
594
  - spec/integration/taskrouter/v1/workspace/workflow_spec.rb
595
+ - spec/integration/taskrouter/v1/workspace/workspace_cumulative_statistics_spec.rb
596
+ - spec/integration/taskrouter/v1/workspace/workspace_real_time_statistics_spec.rb
582
597
  - spec/integration/taskrouter/v1/workspace/workspace_statistics_spec.rb
583
598
  - spec/integration/taskrouter/v1/workspace_spec.rb
584
599
  - spec/integration/trunking/v1/trunk/credential_list_spec.rb
@@ -597,7 +612,6 @@ files:
597
612
  - spec/jwt/access_token_spec.rb
598
613
  - spec/jwt/client_capability_spec.rb
599
614
  - spec/jwt/task_router_spec.rb
600
- - spec/rack/twilio_webhook_authentication_spec.rb
601
615
  - spec/rest/client_spec.rb
602
616
  - spec/security/request_validator_spec.rb
603
617
  - spec/spec_helper.rb
@@ -605,7 +619,6 @@ files:
605
619
  - spec/twilio_spec.rb
606
620
  - spec/twiml/messaging_response_spec.rb
607
621
  - spec/twiml/voice_response_spec.rb
608
- - spec/util/configuration_spec.rb
609
622
  - spec/util/url_encode_spec.rb
610
623
  - twilio-ruby.gemspec
611
624
  homepage: http://github.com/twilio/twilio-ruby
@@ -635,7 +648,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
635
648
  version: '0'
636
649
  requirements: []
637
650
  rubyforge_project:
638
- rubygems_version: 2.6.11
651
+ rubygems_version: 2.2.0
639
652
  signing_key:
640
653
  specification_version: 4
641
654
  summary: A simple library for communicating with the Twilio REST API, building TwiML,
@@ -817,6 +830,8 @@ test_files:
817
830
  - spec/integration/taskrouter/v1/workspace/event_spec.rb
818
831
  - spec/integration/taskrouter/v1/workspace/task/reservation_spec.rb
819
832
  - spec/integration/taskrouter/v1/workspace/task_channel_spec.rb
833
+ - spec/integration/taskrouter/v1/workspace/task_queue/task_queue_cumulative_statistics_spec.rb
834
+ - spec/integration/taskrouter/v1/workspace/task_queue/task_queue_real_time_statistics_spec.rb
820
835
  - spec/integration/taskrouter/v1/workspace/task_queue/task_queue_statistics_spec.rb
821
836
  - spec/integration/taskrouter/v1/workspace/task_queue/task_queues_statistics_spec.rb
822
837
  - spec/integration/taskrouter/v1/workspace/task_queue_spec.rb
@@ -824,10 +839,16 @@ test_files:
824
839
  - spec/integration/taskrouter/v1/workspace/worker/reservation_spec.rb
825
840
  - spec/integration/taskrouter/v1/workspace/worker/worker_channel_spec.rb
826
841
  - spec/integration/taskrouter/v1/workspace/worker/worker_statistics_spec.rb
842
+ - spec/integration/taskrouter/v1/workspace/worker/workers_cumulative_statistics_spec.rb
843
+ - spec/integration/taskrouter/v1/workspace/worker/workers_real_time_statistics_spec.rb
827
844
  - spec/integration/taskrouter/v1/workspace/worker/workers_statistics_spec.rb
828
845
  - spec/integration/taskrouter/v1/workspace/worker_spec.rb
846
+ - spec/integration/taskrouter/v1/workspace/workflow/workflow_cumulative_statistics_spec.rb
847
+ - spec/integration/taskrouter/v1/workspace/workflow/workflow_real_time_statistics_spec.rb
829
848
  - spec/integration/taskrouter/v1/workspace/workflow/workflow_statistics_spec.rb
830
849
  - spec/integration/taskrouter/v1/workspace/workflow_spec.rb
850
+ - spec/integration/taskrouter/v1/workspace/workspace_cumulative_statistics_spec.rb
851
+ - spec/integration/taskrouter/v1/workspace/workspace_real_time_statistics_spec.rb
831
852
  - spec/integration/taskrouter/v1/workspace/workspace_statistics_spec.rb
832
853
  - spec/integration/taskrouter/v1/workspace_spec.rb
833
854
  - spec/integration/trunking/v1/trunk/credential_list_spec.rb
@@ -846,7 +867,6 @@ test_files:
846
867
  - spec/jwt/access_token_spec.rb
847
868
  - spec/jwt/client_capability_spec.rb
848
869
  - spec/jwt/task_router_spec.rb
849
- - spec/rack/twilio_webhook_authentication_spec.rb
850
870
  - spec/rest/client_spec.rb
851
871
  - spec/security/request_validator_spec.rb
852
872
  - spec/spec_helper.rb
@@ -854,5 +874,4 @@ test_files:
854
874
  - spec/twilio_spec.rb
855
875
  - spec/twiml/messaging_response_spec.rb
856
876
  - spec/twiml/voice_response_spec.rb
857
- - spec/util/configuration_spec.rb
858
877
  - spec/util/url_encode_spec.rb
@@ -1,46 +0,0 @@
1
- module Rack
2
- # Middleware that authenticates webhooks from Twilio using the request
3
- # validator.
4
- #
5
- # The middleware takes an auth token with which to set up the request
6
- # validator and any number of paths. When a path matches the incoming request
7
- # path, the request will be checked for authentication.
8
- #
9
- # Example:
10
- #
11
- # require 'rack'
12
- # use Rack::TwilioWebhookAuthentication, ENV['AUTH_TOKEN'], /\/messages/
13
- #
14
- # The above appends this middleware to the stack, using an auth token saved in
15
- # the ENV and only against paths that match /\/messages/. If the request
16
- # validates then it gets passed on to the action as normal. If the request
17
- # doesn't validate then the middleware responds immediately with a 403 status.
18
-
19
- class TwilioWebhookAuthentication
20
- def initialize(app, auth_token, *paths, &auth_token_lookup)
21
- @app = app
22
- @auth_token = auth_token
23
- define_singleton_method(:get_auth_token, auth_token_lookup) if block_given?
24
- @path_regex = Regexp.union(paths)
25
- end
26
-
27
- def call(env)
28
- return @app.call(env) unless env['PATH_INFO'].match(@path_regex)
29
- request = Rack::Request.new(env)
30
- original_url = request.url
31
- params = request.post? ? request.POST : {}
32
- auth_token = @auth_token || get_auth_token(params['AccountSid'])
33
- validator = Twilio::Security::RequestValidator.new(auth_token)
34
- signature = env['HTTP_X_TWILIO_SIGNATURE'] || ''
35
- if validator.validate(original_url, params, signature)
36
- @app.call(env)
37
- else
38
- [
39
- 403,
40
- { 'Content-Type' => 'text/plain' },
41
- ['Twilio Request Validation Failed.']
42
- ]
43
- end
44
- end
45
- end
46
- end
@@ -1,7 +0,0 @@
1
- module Twilio
2
- module Util
3
- class Configuration
4
- attr_accessor :account_sid, :auth_token
5
- end
6
- end
7
- end
@@ -1,106 +0,0 @@
1
- require 'spec_helper'
2
- require 'rack/mock'
3
-
4
- describe Rack::TwilioWebhookAuthentication do
5
- before do
6
- @app = ->(_env) { [200, { 'Content-Type' => 'text/plain' }, ['Hello']] }
7
- end
8
-
9
- describe 'new' do
10
- it 'should initialize with an app, auth token and a path' do
11
- expect do
12
- Rack::TwilioWebhookAuthentication.new(@app, 'ABC', /\/voice/)
13
- end.not_to raise_error
14
- end
15
-
16
- it 'should initialize with an app, auth token and paths' do
17
- expect do
18
- Rack::TwilioWebhookAuthentication.new(@app, 'ABC', /\/voice/, /\/sms/)
19
- end.not_to raise_error
20
- end
21
-
22
- it 'should initialize with an app, dynamic token and paths' do
23
- expect do
24
- Rack::TwilioWebhookAuthentication.new(@app, nil, /\/voice/, /\/sms/)
25
- end.not_to raise_error
26
- end
27
- end
28
-
29
- describe 'calling against one path with dynamic auth token' do
30
- it 'should allow a request through if it validates' do
31
- auth_token = 'qwerty'
32
- account_sid = 12_345
33
- expect_any_instance_of(Rack::Request).to receive(:post?).and_return(true)
34
- expect_any_instance_of(Rack::Request).to receive(:POST).and_return({ 'AccountSid' => account_sid })
35
- @middleware = Rack::TwilioWebhookAuthentication.new(@app, nil, /\/voice/) { |asid| auth_token }
36
- request_validator = double('RequestValidator')
37
- expect(Twilio::Security::RequestValidator).to receive(:new).with(auth_token).and_return(request_validator)
38
- expect(request_validator).to receive(:validate).and_return(true)
39
- request = Rack::MockRequest.env_for('/voice')
40
- status, headers, body = @middleware.call(request)
41
- expect(status).to be(200)
42
- end
43
- end
44
-
45
- describe 'calling against one path' do
46
- before do
47
- @middleware = Rack::TwilioWebhookAuthentication.new(@app, 'ABC', /\/voice/)
48
- end
49
-
50
- it 'should not intercept when the path doesn\'t match' do
51
- expect(Twilio::Security::RequestValidator).to_not receive(:validate)
52
- request = Rack::MockRequest.env_for('/sms')
53
- status, headers, body = @middleware.call(request)
54
- expect(status).to be(200)
55
- end
56
-
57
- it 'should allow a request through if it validates' do
58
- expect_any_instance_of(Twilio::Security::RequestValidator).to(
59
- receive(:validate).and_return(true)
60
- )
61
- request = Rack::MockRequest.env_for('/voice')
62
- status, headers, body = @middleware.call(request)
63
- expect(status).to be(200)
64
- end
65
-
66
- it 'should short circuit a request to 403 if it does not validate' do
67
- expect_any_instance_of(Twilio::Security::RequestValidator).to(
68
- receive(:validate).and_return(false)
69
- )
70
- request = Rack::MockRequest.env_for('/voice')
71
- status, headers, body = @middleware.call(request)
72
- expect(status).to be(403)
73
- end
74
- end
75
-
76
- describe 'calling against many paths' do
77
- before do
78
- @middleware = Rack::TwilioWebhookAuthentication.new(@app, 'ABC', /\/voice/, /\/sms/)
79
- end
80
-
81
- it 'should not intercept when the path doesn\'t match' do
82
- expect(Twilio::Security::RequestValidator).to_not receive(:validate)
83
- request = Rack::MockRequest.env_for('icesms')
84
- status, headers, body = @middleware.call(request)
85
- expect(status).to be(200)
86
- end
87
-
88
- it 'shold allow a request through if it validates' do
89
- expect_any_instance_of(Twilio::Security::RequestValidator).to(
90
- receive(:validate).and_return(true)
91
- )
92
- request = Rack::MockRequest.env_for('/sms')
93
- status, headers, body = @middleware.call(request)
94
- expect(status).to be(200)
95
- end
96
-
97
- it 'should short circuit a request to 403 if it does not validate' do
98
- expect_any_instance_of(Twilio::Security::RequestValidator).to(
99
- receive(:validate).and_return(false)
100
- )
101
- request = Rack::MockRequest.env_for('/sms')
102
- status, headers, body = @middleware.call(request)
103
- expect(status).to be(403)
104
- end
105
- end
106
- end