twilio-ruby 5.0.0.rc13 → 5.0.0.rc14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/twilio-ruby/framework/exception.rb +19 -3
- data/lib/twilio-ruby/framework/version.rb +20 -5
- data/lib/twilio-ruby/rest/api/v2010/account/call.rb +10 -1
- data/lib/twilio-ruby/rest/client.rb +7 -5
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task/reservation.rb +9 -23
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb +1 -1
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/reservation.rb +426 -0
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb +32 -0
- data/lib/twilio-ruby/version.rb +1 -1
- data/spec/integration/taskrouter/v1/workspace/worker/reservation_spec.rb +192 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9211a021f399ed356530eff15db5a4bf4f413767
|
4
|
+
data.tar.gz: 875e85e3705723ac5639ed8b171f2bee92b1432b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85baeb0d8ec8d4fe6ce0e828055615a4772998145a0fde5608d9f412f2e7330223315aeedad491f8247be15100bc9c67f6976aaad1f18932b31db81324d1302e
|
7
|
+
data.tar.gz: e7857cd7165efd56bdf6b436292d8ed94f4fdf84c885f59df9ea312ff2febd08fbdf470a0d2306169d5090780b5f605ad6f25c3e7b00472e48a540923c352683
|
data/README.md
CHANGED
@@ -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.rc14'
|
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.rc14
|
21
21
|
```
|
22
22
|
|
23
23
|
To build and install the development branch yourself from the latest source:
|
@@ -1,13 +1,29 @@
|
|
1
1
|
module Twilio
|
2
2
|
module REST
|
3
3
|
class TwilioException < Exception
|
4
|
-
|
5
|
-
|
4
|
+
attr_reader :message, :body
|
5
|
+
|
6
|
+
def initialize(message, body = nil)
|
7
|
+
@message = message
|
6
8
|
@body = body
|
7
9
|
end
|
8
10
|
|
9
11
|
def to_s
|
10
|
-
"#{@
|
12
|
+
"#{@message}: #{@body || 'no body'}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class RestException < TwilioException
|
17
|
+
attr_reader :message, :code, :status_code
|
18
|
+
|
19
|
+
def initialize(message, code, status_code)
|
20
|
+
@message = message
|
21
|
+
@code = code
|
22
|
+
@status_code = status_code
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_s
|
26
|
+
"[HTTP #{status_code}] #{code} : #{msg}"
|
11
27
|
end
|
12
28
|
end
|
13
29
|
end
|
@@ -62,6 +62,21 @@ module Twilio
|
|
62
62
|
)
|
63
63
|
end
|
64
64
|
|
65
|
+
def exception(response, header)
|
66
|
+
message = header
|
67
|
+
code = response.status_code
|
68
|
+
|
69
|
+
if response.body.has_key?('message')
|
70
|
+
message += ": #{response.body['message']}"
|
71
|
+
end
|
72
|
+
|
73
|
+
if response.body.has_key?('code')
|
74
|
+
code = response.body['code']
|
75
|
+
end
|
76
|
+
|
77
|
+
return Twilio::REST::RestException.new(message, code, response.status_code)
|
78
|
+
end
|
79
|
+
|
65
80
|
def fetch(method, uri, params={}, data={}, headers={}, auth=nil, timeout=nil)
|
66
81
|
response = self.request(
|
67
82
|
method,
|
@@ -74,7 +89,7 @@ module Twilio
|
|
74
89
|
)
|
75
90
|
|
76
91
|
if response.status_code < 200 || response.status_code >= 300
|
77
|
-
raise
|
92
|
+
raise exception(response, 'Unable to fetch record')
|
78
93
|
end
|
79
94
|
|
80
95
|
response.body
|
@@ -92,7 +107,7 @@ module Twilio
|
|
92
107
|
)
|
93
108
|
|
94
109
|
if response.status_code < 200 || response.status_code >= 300
|
95
|
-
raise
|
110
|
+
raise exception(response, 'Unable to update record')
|
96
111
|
end
|
97
112
|
|
98
113
|
response.body
|
@@ -110,7 +125,7 @@ module Twilio
|
|
110
125
|
)
|
111
126
|
|
112
127
|
if response.status_code < 200 || response.status_code >= 300
|
113
|
-
raise
|
128
|
+
raise exception(response, 'Unable to delete record')
|
114
129
|
end
|
115
130
|
|
116
131
|
response.status_code == 204
|
@@ -159,10 +174,10 @@ module Twilio
|
|
159
174
|
timeout)
|
160
175
|
|
161
176
|
if response.status_code < 200 || response.status_code >= 300
|
162
|
-
raise
|
177
|
+
raise exception(response, 'Unable to create record')
|
163
178
|
end
|
164
179
|
|
165
|
-
|
180
|
+
response.body
|
166
181
|
end
|
167
182
|
end
|
168
183
|
end
|
@@ -48,6 +48,7 @@ module Twilio
|
|
48
48
|
# @param [String] status_callback A URL that Twilio will request when the call
|
49
49
|
# ends to notify your app. If an `ApplicationSid` was provided, this parameter is
|
50
50
|
# ignored.
|
51
|
+
# @param [String] status_callback_event The status_callback_event
|
51
52
|
# @param [String] status_callback_method The HTTP method that Twilio should use to
|
52
53
|
# request the `StatusCallback`. Defaults to `POST`. If an `ApplicationSid` was
|
53
54
|
# provided, this parameter is ignored.
|
@@ -66,6 +67,10 @@ module Twilio
|
|
66
67
|
# @param [Boolean] record Set this parameter to true to record the entirety of a
|
67
68
|
# phone call. The RecordingUrl will be sent to the StatusCallback URL. Defaults to
|
68
69
|
# false.
|
70
|
+
# @param [String] recording_channels The recording_channels
|
71
|
+
# @param [String] recording_status_callback The recording_status_callback
|
72
|
+
# @param [String] recording_status_callback_method The
|
73
|
+
# recording_status_callback_method
|
69
74
|
# @param [String] sip_auth_username The sip_auth_username
|
70
75
|
# @param [String] sip_auth_password The sip_auth_password
|
71
76
|
# @param [String] url The fully qualified URL that should be consulted when the
|
@@ -75,7 +80,7 @@ module Twilio
|
|
75
80
|
# should use to handle this phone call. If this parameter is present, Twilio will
|
76
81
|
# ignore all of the voice URLs passed and use the URLs set on the application.
|
77
82
|
# @return [CallInstance] Newly created CallInstance
|
78
|
-
def create(to: nil, from: nil, method: nil, fallback_url: nil, fallback_method: nil, status_callback: nil, status_callback_method: nil, send_digits: nil, if_machine: nil, timeout: nil, record: nil, sip_auth_username: nil, sip_auth_password: nil, url: nil, application_sid: nil)
|
83
|
+
def create(to: nil, from: nil, method: nil, fallback_url: nil, fallback_method: nil, status_callback: nil, status_callback_event: nil, status_callback_method: nil, send_digits: nil, if_machine: nil, timeout: nil, record: nil, recording_channels: nil, recording_status_callback: nil, recording_status_callback_method: nil, sip_auth_username: nil, sip_auth_password: nil, url: nil, application_sid: nil)
|
79
84
|
data = {
|
80
85
|
'To' => to,
|
81
86
|
'From' => from,
|
@@ -85,11 +90,15 @@ module Twilio
|
|
85
90
|
'FallbackUrl' => fallback_url,
|
86
91
|
'FallbackMethod' => fallback_method,
|
87
92
|
'StatusCallback' => status_callback,
|
93
|
+
'StatusCallbackEvent' => status_callback_event,
|
88
94
|
'StatusCallbackMethod' => status_callback_method,
|
89
95
|
'SendDigits' => send_digits,
|
90
96
|
'IfMachine' => if_machine,
|
91
97
|
'Timeout' => timeout,
|
92
98
|
'Record' => record,
|
99
|
+
'RecordingChannels' => recording_channels,
|
100
|
+
'RecordingStatusCallback' => recording_status_callback,
|
101
|
+
'RecordingStatusCallbackMethod' => recording_status_callback_method,
|
93
102
|
'SipAuthUsername' => sip_auth_username,
|
94
103
|
'SipAuthPassword' => sip_auth_password,
|
95
104
|
}
|
@@ -9,14 +9,16 @@ module Twilio
|
|
9
9
|
##
|
10
10
|
# A client for accessing the Twilio API.
|
11
11
|
class Client
|
12
|
-
attr_accessor :http_client, :account_sid, :auth_token
|
12
|
+
attr_accessor :http_client, :username, :password, :account_sid, :auth_token
|
13
13
|
|
14
14
|
##
|
15
15
|
# Initializes the Twilio Client
|
16
|
-
def initialize(
|
17
|
-
@
|
18
|
-
@
|
19
|
-
@
|
16
|
+
def initialize(username=nil, password=nil, account_sid=nil, http_client=Twilio::HTTP::Client.new)
|
17
|
+
@username = username || Twilio.configuration.account_sid
|
18
|
+
@password = password || Twilio.configuration.auth_token
|
19
|
+
@account_sid = account_sid || @username
|
20
|
+
@auth_token = @password
|
21
|
+
@auth = [@username, @password]
|
20
22
|
@http_client = http_client
|
21
23
|
|
22
24
|
# Domains
|
@@ -32,9 +32,7 @@ module Twilio
|
|
32
32
|
# Lists ReservationInstance records from the API as a list.
|
33
33
|
# Unlike stream(), this operation is eager and will load `limit` records into
|
34
34
|
# memory before returning.
|
35
|
-
# @param [
|
36
|
-
# @param [String] assignment_status The assignment_status
|
37
|
-
# @param [String] reservation_status The reservation_status
|
35
|
+
# @param [reservation.Status] reservation_status The reservation_status
|
38
36
|
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
39
37
|
# guarantees to never return more than limit. Default is no limit
|
40
38
|
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
@@ -42,10 +40,8 @@ module Twilio
|
|
42
40
|
# but a limit is defined, stream() will attempt to read the
|
43
41
|
# limit with the most efficient page size, i.e. min(limit, 1000)
|
44
42
|
# @return [Array] Array of up to limit results
|
45
|
-
def list(
|
43
|
+
def list(reservation_status: nil, limit: nil, page_size: nil)
|
46
44
|
self.stream(
|
47
|
-
status: status,
|
48
|
-
assignment_status: assignment_status,
|
49
45
|
reservation_status: reservation_status,
|
50
46
|
limit: limit,
|
51
47
|
page_size: page_size
|
@@ -56,9 +52,7 @@ module Twilio
|
|
56
52
|
# Streams ReservationInstance records from the API as an Enumerable.
|
57
53
|
# This operation lazily loads records as efficiently as possible until the limit
|
58
54
|
# is reached.
|
59
|
-
# @param [
|
60
|
-
# @param [String] assignment_status The assignment_status
|
61
|
-
# @param [String] reservation_status The reservation_status
|
55
|
+
# @param [reservation.Status] reservation_status The reservation_status
|
62
56
|
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
63
57
|
# guarantees to never return more than limit. Default is no limit
|
64
58
|
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
@@ -66,12 +60,10 @@ module Twilio
|
|
66
60
|
# but a limit is defined, stream() will attempt to read the
|
67
61
|
# limit with the most efficient page size, i.e. min(limit, 1000)
|
68
62
|
# @return [Enumerable] Enumerable that will yield up to limit results
|
69
|
-
def stream(
|
63
|
+
def stream(reservation_status: nil, limit: nil, page_size: nil)
|
70
64
|
limits = @version.read_limits(limit, page_size)
|
71
65
|
|
72
66
|
page = self.page(
|
73
|
-
status: status,
|
74
|
-
assignment_status: assignment_status,
|
75
67
|
reservation_status: reservation_status,
|
76
68
|
page_size: limits[:page_size],
|
77
69
|
)
|
@@ -83,9 +75,7 @@ module Twilio
|
|
83
75
|
# When passed a block, yields ReservationInstance records from the API.
|
84
76
|
# This operation lazily loads records as efficiently as possible until the limit
|
85
77
|
# is reached.
|
86
|
-
# @param [
|
87
|
-
# @param [String] assignment_status The assignment_status
|
88
|
-
# @param [String] reservation_status The reservation_status
|
78
|
+
# @param [reservation.Status] reservation_status The reservation_status
|
89
79
|
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
90
80
|
# guarantees to never return more than limit. Default is no limit
|
91
81
|
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
@@ -107,17 +97,13 @@ module Twilio
|
|
107
97
|
##
|
108
98
|
# Retrieve a single page of ReservationInstance records from the API.
|
109
99
|
# Request is executed immediately.
|
110
|
-
# @param [
|
111
|
-
# @param [String] assignment_status The assignment_status
|
112
|
-
# @param [String] reservation_status The reservation_status
|
100
|
+
# @param [reservation.Status] reservation_status The reservation_status
|
113
101
|
# @param [String] page_token PageToken provided by the API
|
114
102
|
# @param [Integer] page_number Page Number, this value is simply for client state
|
115
103
|
# @param [Integer] page_size Number of records to return, defaults to 50
|
116
104
|
# @return [Page] Page of ReservationInstance
|
117
|
-
def page(
|
105
|
+
def page(reservation_status: nil, page_token: nil, page_number: nil, page_size: nil)
|
118
106
|
params = {
|
119
|
-
'Status' => status,
|
120
|
-
'AssignmentStatus' => assignment_status,
|
121
107
|
'ReservationStatus' => reservation_status,
|
122
108
|
'PageToken' => page_token,
|
123
109
|
'Page' => page_number,
|
@@ -217,7 +203,7 @@ module Twilio
|
|
217
203
|
|
218
204
|
##
|
219
205
|
# Update the ReservationInstance
|
220
|
-
# @param [
|
206
|
+
# @param [reservation.Status] reservation_status The reservation_status
|
221
207
|
# @param [String] worker_activity_sid The worker_activity_sid
|
222
208
|
# @param [String] instruction The instruction
|
223
209
|
# @param [String] dequeue_post_work_activity_sid The
|
@@ -380,7 +366,7 @@ module Twilio
|
|
380
366
|
|
381
367
|
##
|
382
368
|
# Update the ReservationInstance
|
383
|
-
# @param [
|
369
|
+
# @param [reservation.Status] reservation_status The reservation_status
|
384
370
|
# @param [String] worker_activity_sid The worker_activity_sid
|
385
371
|
# @param [String] instruction The instruction
|
386
372
|
# @param [String] dequeue_post_work_activity_sid The
|
@@ -442,7 +442,7 @@ module Twilio
|
|
442
442
|
##
|
443
443
|
# Update the TaskInstance
|
444
444
|
# @param [String] attributes The attributes
|
445
|
-
# @param [
|
445
|
+
# @param [reservation.Status] assignment_status The assignment_status
|
446
446
|
# @param [String] reason The reason
|
447
447
|
# @param [String] priority The priority
|
448
448
|
# @return [TaskInstance] Updated TaskInstance
|
@@ -0,0 +1,426 @@
|
|
1
|
+
##
|
2
|
+
# This code was generated by
|
3
|
+
# \ / _ _ _| _ _
|
4
|
+
# | (_)\/(_)(_|\/| |(/_ v1.0.0
|
5
|
+
# / /
|
6
|
+
|
7
|
+
module Twilio
|
8
|
+
module REST
|
9
|
+
class Taskrouter < Domain
|
10
|
+
class V1 < Version
|
11
|
+
class WorkspaceContext < InstanceContext
|
12
|
+
class WorkerContext < InstanceContext
|
13
|
+
class ReservationList < ListResource
|
14
|
+
##
|
15
|
+
# Initialize the ReservationList
|
16
|
+
# @param [Version] version Version that contains the resource
|
17
|
+
# @param [String] workspace_sid The workspace_sid
|
18
|
+
# @param [String] worker_sid The worker_sid
|
19
|
+
# @return [ReservationList] ReservationList
|
20
|
+
def initialize(version, workspace_sid: nil, worker_sid: nil)
|
21
|
+
super(version)
|
22
|
+
|
23
|
+
# Path Solution
|
24
|
+
@solution = {
|
25
|
+
workspace_sid: workspace_sid,
|
26
|
+
worker_sid: worker_sid
|
27
|
+
}
|
28
|
+
@uri = "/Workspaces/#{@solution[:workspace_sid]}/Workers/#{@solution[:worker_sid]}/Reservations"
|
29
|
+
end
|
30
|
+
|
31
|
+
##
|
32
|
+
# Lists ReservationInstance records from the API as a list.
|
33
|
+
# Unlike stream(), this operation is eager and will load `limit` records into
|
34
|
+
# memory before returning.
|
35
|
+
# @param [reservation.Status] reservation_status The reservation_status
|
36
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
37
|
+
# guarantees to never return more than limit. Default is no limit
|
38
|
+
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
39
|
+
# the default value of 50 records. If no page_size is defined
|
40
|
+
# but a limit is defined, stream() will attempt to read the
|
41
|
+
# limit with the most efficient page size, i.e. min(limit, 1000)
|
42
|
+
# @return [Array] Array of up to limit results
|
43
|
+
def list(reservation_status: nil, limit: nil, page_size: nil)
|
44
|
+
self.stream(
|
45
|
+
reservation_status: reservation_status,
|
46
|
+
limit: limit,
|
47
|
+
page_size: page_size
|
48
|
+
).entries
|
49
|
+
end
|
50
|
+
|
51
|
+
##
|
52
|
+
# Streams ReservationInstance records from the API as an Enumerable.
|
53
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
54
|
+
# is reached.
|
55
|
+
# @param [reservation.Status] reservation_status The reservation_status
|
56
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
57
|
+
# guarantees to never return more than limit. Default is no limit
|
58
|
+
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
59
|
+
# the default value of 50 records. If no page_size is defined
|
60
|
+
# but a limit is defined, stream() will attempt to read the
|
61
|
+
# limit with the most efficient page size, i.e. min(limit, 1000)
|
62
|
+
# @return [Enumerable] Enumerable that will yield up to limit results
|
63
|
+
def stream(reservation_status: nil, limit: nil, page_size: nil)
|
64
|
+
limits = @version.read_limits(limit, page_size)
|
65
|
+
|
66
|
+
page = self.page(
|
67
|
+
reservation_status: reservation_status,
|
68
|
+
page_size: limits[:page_size],
|
69
|
+
)
|
70
|
+
|
71
|
+
@version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
|
72
|
+
end
|
73
|
+
|
74
|
+
##
|
75
|
+
# When passed a block, yields ReservationInstance records from the API.
|
76
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
77
|
+
# is reached.
|
78
|
+
# @param [reservation.Status] reservation_status The reservation_status
|
79
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
80
|
+
# guarantees to never return more than limit. Default is no limit
|
81
|
+
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
82
|
+
# the default value of 50 records. If no page_size is defined
|
83
|
+
# but a limit is defined, stream() will attempt to read the
|
84
|
+
# limit with the most efficient page size, i.e. min(limit, 1000)
|
85
|
+
def each
|
86
|
+
limits = @version.read_limits
|
87
|
+
|
88
|
+
page = self.page(
|
89
|
+
page_size: limits[:page_size],
|
90
|
+
)
|
91
|
+
|
92
|
+
@version.stream(page,
|
93
|
+
limit: limits[:limit],
|
94
|
+
page_limit: limits[:page_limit]).each {|x| yield x}
|
95
|
+
end
|
96
|
+
|
97
|
+
##
|
98
|
+
# Retrieve a single page of ReservationInstance records from the API.
|
99
|
+
# Request is executed immediately.
|
100
|
+
# @param [reservation.Status] reservation_status The reservation_status
|
101
|
+
# @param [String] page_token PageToken provided by the API
|
102
|
+
# @param [Integer] page_number Page Number, this value is simply for client state
|
103
|
+
# @param [Integer] page_size Number of records to return, defaults to 50
|
104
|
+
# @return [Page] Page of ReservationInstance
|
105
|
+
def page(reservation_status: nil, page_token: nil, page_number: nil, page_size: nil)
|
106
|
+
params = {
|
107
|
+
'ReservationStatus' => reservation_status,
|
108
|
+
'PageToken' => page_token,
|
109
|
+
'Page' => page_number,
|
110
|
+
'PageSize' => page_size,
|
111
|
+
}
|
112
|
+
response = @version.page(
|
113
|
+
'GET',
|
114
|
+
@uri,
|
115
|
+
params
|
116
|
+
)
|
117
|
+
return ReservationPage.new(@version, response, @solution)
|
118
|
+
end
|
119
|
+
|
120
|
+
##
|
121
|
+
# Provide a user friendly representation
|
122
|
+
def to_s
|
123
|
+
'#<Twilio.Taskrouter.V1.ReservationList>'
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
class ReservationPage < Page
|
128
|
+
##
|
129
|
+
# Initialize the ReservationPage
|
130
|
+
# @param [Version] version Version that contains the resource
|
131
|
+
# @param [Response] response Response from the API
|
132
|
+
# @param [Hash] solution Path solution for the resource
|
133
|
+
# @param [String] workspace_sid The workspace_sid
|
134
|
+
# @param [String] worker_sid The worker_sid
|
135
|
+
# @return [ReservationPage] ReservationPage
|
136
|
+
def initialize(version, response, solution)
|
137
|
+
super(version, response)
|
138
|
+
|
139
|
+
# Path Solution
|
140
|
+
@solution = solution
|
141
|
+
end
|
142
|
+
|
143
|
+
##
|
144
|
+
# Build an instance of ReservationInstance
|
145
|
+
# @param [Hash] payload Payload response from the API
|
146
|
+
# @return [ReservationInstance] ReservationInstance
|
147
|
+
def get_instance(payload)
|
148
|
+
return ReservationInstance.new(
|
149
|
+
@version,
|
150
|
+
payload,
|
151
|
+
workspace_sid: @solution[:workspace_sid],
|
152
|
+
worker_sid: @solution[:worker_sid],
|
153
|
+
)
|
154
|
+
end
|
155
|
+
|
156
|
+
##
|
157
|
+
# Provide a user friendly representation
|
158
|
+
def to_s
|
159
|
+
'<Twilio.Taskrouter.V1.ReservationPage>'
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
class ReservationContext < InstanceContext
|
164
|
+
##
|
165
|
+
# Initialize the ReservationContext
|
166
|
+
# @param [Version] version Version that contains the resource
|
167
|
+
# @param [String] workspace_sid The workspace_sid
|
168
|
+
# @param [String] worker_sid The worker_sid
|
169
|
+
# @param [String] sid The sid
|
170
|
+
# @return [ReservationContext] ReservationContext
|
171
|
+
def initialize(version, workspace_sid, worker_sid, sid)
|
172
|
+
super(version)
|
173
|
+
|
174
|
+
# Path Solution
|
175
|
+
@solution = {
|
176
|
+
workspace_sid: workspace_sid,
|
177
|
+
worker_sid: worker_sid,
|
178
|
+
sid: sid,
|
179
|
+
}
|
180
|
+
@uri = "/Workspaces/#{@solution[:workspace_sid]}/Workers/#{@solution[:worker_sid]}/Reservations/#{@solution[:sid]}"
|
181
|
+
end
|
182
|
+
|
183
|
+
##
|
184
|
+
# Fetch a ReservationInstance
|
185
|
+
# @return [ReservationInstance] Fetched ReservationInstance
|
186
|
+
def fetch
|
187
|
+
params = {}
|
188
|
+
|
189
|
+
payload = @version.fetch(
|
190
|
+
'GET',
|
191
|
+
@uri,
|
192
|
+
params,
|
193
|
+
)
|
194
|
+
|
195
|
+
return ReservationInstance.new(
|
196
|
+
@version,
|
197
|
+
payload,
|
198
|
+
workspace_sid: @solution[:workspace_sid],
|
199
|
+
worker_sid: @solution[:worker_sid],
|
200
|
+
sid: @solution[:sid],
|
201
|
+
)
|
202
|
+
end
|
203
|
+
|
204
|
+
##
|
205
|
+
# Update the ReservationInstance
|
206
|
+
# @param [reservation.Status] reservation_status The reservation_status
|
207
|
+
# @param [String] worker_activity_sid The worker_activity_sid
|
208
|
+
# @param [String] instruction The instruction
|
209
|
+
# @param [String] dequeue_post_work_activity_sid The
|
210
|
+
# dequeue_post_work_activity_sid
|
211
|
+
# @param [String] dequeue_from The dequeue_from
|
212
|
+
# @param [String] dequeue_record The dequeue_record
|
213
|
+
# @param [String] dequeue_timeout The dequeue_timeout
|
214
|
+
# @param [String] dequeue_to The dequeue_to
|
215
|
+
# @param [String] dequeue_status_callback_url The dequeue_status_callback_url
|
216
|
+
# @param [String] call_from The call_from
|
217
|
+
# @param [String] call_record The call_record
|
218
|
+
# @param [String] call_timeout The call_timeout
|
219
|
+
# @param [String] call_to The call_to
|
220
|
+
# @param [String] call_url The call_url
|
221
|
+
# @param [String] call_status_callback_url The call_status_callback_url
|
222
|
+
# @param [Boolean] call_accept The call_accept
|
223
|
+
# @param [String] redirect_call_sid The redirect_call_sid
|
224
|
+
# @param [Boolean] redirect_accept The redirect_accept
|
225
|
+
# @param [String] redirect_url The redirect_url
|
226
|
+
# @return [ReservationInstance] Updated ReservationInstance
|
227
|
+
def update(reservation_status: nil, worker_activity_sid: nil, instruction: nil, dequeue_post_work_activity_sid: nil, dequeue_from: nil, dequeue_record: nil, dequeue_timeout: nil, dequeue_to: nil, dequeue_status_callback_url: nil, call_from: nil, call_record: nil, call_timeout: nil, call_to: nil, call_url: nil, call_status_callback_url: nil, call_accept: nil, redirect_call_sid: nil, redirect_accept: nil, redirect_url: nil)
|
228
|
+
data = {
|
229
|
+
'ReservationStatus' => reservation_status,
|
230
|
+
'WorkerActivitySid' => worker_activity_sid,
|
231
|
+
'Instruction' => instruction,
|
232
|
+
'DequeuePostWorkActivitySid' => dequeue_post_work_activity_sid,
|
233
|
+
'DequeueFrom' => dequeue_from,
|
234
|
+
'DequeueRecord' => dequeue_record,
|
235
|
+
'DequeueTimeout' => dequeue_timeout,
|
236
|
+
'DequeueTo' => dequeue_to,
|
237
|
+
'DequeueStatusCallbackUrl' => dequeue_status_callback_url,
|
238
|
+
'CallFrom' => call_from,
|
239
|
+
'CallRecord' => call_record,
|
240
|
+
'CallTimeout' => call_timeout,
|
241
|
+
'CallTo' => call_to,
|
242
|
+
'CallUrl' => call_url,
|
243
|
+
'CallStatusCallbackUrl' => call_status_callback_url,
|
244
|
+
'CallAccept' => call_accept,
|
245
|
+
'RedirectCallSid' => redirect_call_sid,
|
246
|
+
'RedirectAccept' => redirect_accept,
|
247
|
+
'RedirectUrl' => redirect_url,
|
248
|
+
}
|
249
|
+
|
250
|
+
payload = @version.update(
|
251
|
+
'POST',
|
252
|
+
@uri,
|
253
|
+
data: data,
|
254
|
+
)
|
255
|
+
|
256
|
+
return ReservationInstance.new(
|
257
|
+
@version,
|
258
|
+
payload,
|
259
|
+
workspace_sid: @solution[:workspace_sid],
|
260
|
+
worker_sid: @solution[:worker_sid],
|
261
|
+
sid: @solution[:sid],
|
262
|
+
)
|
263
|
+
end
|
264
|
+
|
265
|
+
##
|
266
|
+
# Provide a user friendly representation
|
267
|
+
def to_s
|
268
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
269
|
+
"#<Twilio.Taskrouter.V1.ReservationContext #{context}>"
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
class ReservationInstance < InstanceResource
|
274
|
+
##
|
275
|
+
# Initialize the ReservationInstance
|
276
|
+
# @param [Version] version Version that contains the resource
|
277
|
+
# @param [Hash] payload payload that contains response from Twilio
|
278
|
+
# @param [String] workspace_sid The workspace_sid
|
279
|
+
# @param [String] worker_sid The worker_sid
|
280
|
+
# @param [String] sid The sid
|
281
|
+
# @return [ReservationInstance] ReservationInstance
|
282
|
+
def initialize(version, payload, workspace_sid: nil, worker_sid: nil, sid: nil)
|
283
|
+
super(version)
|
284
|
+
|
285
|
+
# Marshaled Properties
|
286
|
+
@properties = {
|
287
|
+
'account_sid' => payload['account_sid'],
|
288
|
+
'date_created' => Twilio.deserialize_iso8601(payload['date_created']),
|
289
|
+
'date_updated' => Twilio.deserialize_iso8601(payload['date_updated']),
|
290
|
+
'reservation_status' => payload['reservation_status'],
|
291
|
+
'sid' => payload['sid'],
|
292
|
+
'task_sid' => payload['task_sid'],
|
293
|
+
'worker_name' => payload['worker_name'],
|
294
|
+
'worker_sid' => payload['worker_sid'],
|
295
|
+
'workspace_sid' => payload['workspace_sid'],
|
296
|
+
}
|
297
|
+
|
298
|
+
# Context
|
299
|
+
@instance_context = nil
|
300
|
+
@params = {
|
301
|
+
'workspace_sid' => workspace_sid,
|
302
|
+
'worker_sid' => worker_sid,
|
303
|
+
'sid' => sid || @properties['sid'],
|
304
|
+
}
|
305
|
+
end
|
306
|
+
|
307
|
+
##
|
308
|
+
# Generate an instance context for the instance, the context is capable of
|
309
|
+
# performing various actions. All instance actions are proxied to the context
|
310
|
+
# @param [Version] version Version that contains the resource
|
311
|
+
# @return [ReservationContext] ReservationContext for this ReservationInstance
|
312
|
+
def context
|
313
|
+
unless @instance_context
|
314
|
+
@instance_context = ReservationContext.new(
|
315
|
+
@version,
|
316
|
+
@params['workspace_sid'],
|
317
|
+
@params['worker_sid'],
|
318
|
+
@params['sid'],
|
319
|
+
)
|
320
|
+
end
|
321
|
+
@instance_context
|
322
|
+
end
|
323
|
+
|
324
|
+
def account_sid
|
325
|
+
@properties['account_sid']
|
326
|
+
end
|
327
|
+
|
328
|
+
def date_created
|
329
|
+
@properties['date_created']
|
330
|
+
end
|
331
|
+
|
332
|
+
def date_updated
|
333
|
+
@properties['date_updated']
|
334
|
+
end
|
335
|
+
|
336
|
+
def reservation_status
|
337
|
+
@properties['reservation_status']
|
338
|
+
end
|
339
|
+
|
340
|
+
def sid
|
341
|
+
@properties['sid']
|
342
|
+
end
|
343
|
+
|
344
|
+
def task_sid
|
345
|
+
@properties['task_sid']
|
346
|
+
end
|
347
|
+
|
348
|
+
def worker_name
|
349
|
+
@properties['worker_name']
|
350
|
+
end
|
351
|
+
|
352
|
+
def worker_sid
|
353
|
+
@properties['worker_sid']
|
354
|
+
end
|
355
|
+
|
356
|
+
def workspace_sid
|
357
|
+
@properties['workspace_sid']
|
358
|
+
end
|
359
|
+
|
360
|
+
##
|
361
|
+
# Fetch a ReservationInstance
|
362
|
+
# @return [ReservationInstance] Fetched ReservationInstance
|
363
|
+
def fetch
|
364
|
+
context.fetch
|
365
|
+
end
|
366
|
+
|
367
|
+
##
|
368
|
+
# Update the ReservationInstance
|
369
|
+
# @param [reservation.Status] reservation_status The reservation_status
|
370
|
+
# @param [String] worker_activity_sid The worker_activity_sid
|
371
|
+
# @param [String] instruction The instruction
|
372
|
+
# @param [String] dequeue_post_work_activity_sid The
|
373
|
+
# dequeue_post_work_activity_sid
|
374
|
+
# @param [String] dequeue_from The dequeue_from
|
375
|
+
# @param [String] dequeue_record The dequeue_record
|
376
|
+
# @param [String] dequeue_timeout The dequeue_timeout
|
377
|
+
# @param [String] dequeue_to The dequeue_to
|
378
|
+
# @param [String] dequeue_status_callback_url The dequeue_status_callback_url
|
379
|
+
# @param [String] call_from The call_from
|
380
|
+
# @param [String] call_record The call_record
|
381
|
+
# @param [String] call_timeout The call_timeout
|
382
|
+
# @param [String] call_to The call_to
|
383
|
+
# @param [String] call_url The call_url
|
384
|
+
# @param [String] call_status_callback_url The call_status_callback_url
|
385
|
+
# @param [Boolean] call_accept The call_accept
|
386
|
+
# @param [String] redirect_call_sid The redirect_call_sid
|
387
|
+
# @param [Boolean] redirect_accept The redirect_accept
|
388
|
+
# @param [String] redirect_url The redirect_url
|
389
|
+
# @return [ReservationInstance] Updated ReservationInstance
|
390
|
+
def update(reservation_status: nil, worker_activity_sid: nil, instruction: nil, dequeue_post_work_activity_sid: nil, dequeue_from: nil, dequeue_record: nil, dequeue_timeout: nil, dequeue_to: nil, dequeue_status_callback_url: nil, call_from: nil, call_record: nil, call_timeout: nil, call_to: nil, call_url: nil, call_status_callback_url: nil, call_accept: nil, redirect_call_sid: nil, redirect_accept: nil, redirect_url: nil)
|
391
|
+
context.update(
|
392
|
+
reservation_status: reservation_status,
|
393
|
+
worker_activity_sid: worker_activity_sid,
|
394
|
+
instruction: instruction,
|
395
|
+
dequeue_post_work_activity_sid: dequeue_post_work_activity_sid,
|
396
|
+
dequeue_from: dequeue_from,
|
397
|
+
dequeue_record: dequeue_record,
|
398
|
+
dequeue_timeout: dequeue_timeout,
|
399
|
+
dequeue_to: dequeue_to,
|
400
|
+
dequeue_status_callback_url: dequeue_status_callback_url,
|
401
|
+
call_from: call_from,
|
402
|
+
call_record: call_record,
|
403
|
+
call_timeout: call_timeout,
|
404
|
+
call_to: call_to,
|
405
|
+
call_url: call_url,
|
406
|
+
call_status_callback_url: call_status_callback_url,
|
407
|
+
call_accept: call_accept,
|
408
|
+
redirect_call_sid: redirect_call_sid,
|
409
|
+
redirect_accept: redirect_accept,
|
410
|
+
redirect_url: redirect_url,
|
411
|
+
)
|
412
|
+
end
|
413
|
+
|
414
|
+
##
|
415
|
+
# Provide a user friendly representation
|
416
|
+
def to_s
|
417
|
+
values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
|
418
|
+
"<Twilio.Taskrouter.V1.ReservationInstance #{values}>"
|
419
|
+
end
|
420
|
+
end
|
421
|
+
end
|
422
|
+
end
|
423
|
+
end
|
424
|
+
end
|
425
|
+
end
|
426
|
+
end
|
@@ -261,6 +261,7 @@ module Twilio
|
|
261
261
|
|
262
262
|
# Dependents
|
263
263
|
@statistics = nil
|
264
|
+
@reservations = nil
|
264
265
|
end
|
265
266
|
|
266
267
|
##
|
@@ -328,6 +329,30 @@ module Twilio
|
|
328
329
|
)
|
329
330
|
end
|
330
331
|
|
332
|
+
##
|
333
|
+
# Access the reservations
|
334
|
+
# @return [ReservationList] ReservationList
|
335
|
+
def reservations(sid=:unset)
|
336
|
+
if sid != :unset
|
337
|
+
return ReservationContext.new(
|
338
|
+
@version,
|
339
|
+
@solution[:workspace_sid],
|
340
|
+
@solution[:sid],
|
341
|
+
sid,
|
342
|
+
)
|
343
|
+
end
|
344
|
+
|
345
|
+
unless @reservations
|
346
|
+
@reservations = ReservationList.new(
|
347
|
+
@version,
|
348
|
+
workspace_sid: @solution[:workspace_sid],
|
349
|
+
worker_sid: @solution[:sid],
|
350
|
+
)
|
351
|
+
end
|
352
|
+
|
353
|
+
@reservations
|
354
|
+
end
|
355
|
+
|
331
356
|
##
|
332
357
|
# Provide a user friendly representation
|
333
358
|
def to_s
|
@@ -465,6 +490,13 @@ module Twilio
|
|
465
490
|
context.statistics
|
466
491
|
end
|
467
492
|
|
493
|
+
##
|
494
|
+
# Access the reservations
|
495
|
+
# @return [reservations] reservations
|
496
|
+
def reservations
|
497
|
+
context.reservations
|
498
|
+
end
|
499
|
+
|
468
500
|
##
|
469
501
|
# Provide a user friendly representation
|
470
502
|
def to_s
|
data/lib/twilio-ruby/version.rb
CHANGED
@@ -0,0 +1,192 @@
|
|
1
|
+
##
|
2
|
+
# This code was generated by
|
3
|
+
# \ / _ _ _| _ _
|
4
|
+
# | (_)\/(_)(_|\/| |(/_ v1.0.0
|
5
|
+
# / /
|
6
|
+
|
7
|
+
require 'spec_helper.rb'
|
8
|
+
|
9
|
+
describe 'Reservation' do
|
10
|
+
it "can read" do
|
11
|
+
@holodeck.mock(Twilio::TwilioResponse.new(500, ''))
|
12
|
+
|
13
|
+
expect {
|
14
|
+
@client.taskrouter.v1.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \
|
15
|
+
.workers("WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \
|
16
|
+
.reservations.list()
|
17
|
+
}.to raise_exception(Twilio::REST::TwilioException)
|
18
|
+
|
19
|
+
values = {}
|
20
|
+
expect(
|
21
|
+
@holodeck.has_request?(Holodeck::Request.new(
|
22
|
+
method: 'get',
|
23
|
+
url: 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations',
|
24
|
+
))).to eq(true)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "receives read_full responses" do
|
28
|
+
@holodeck.mock(Twilio::TwilioResponse.new(
|
29
|
+
200,
|
30
|
+
%q[
|
31
|
+
{
|
32
|
+
"meta": {
|
33
|
+
"first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations?PageSize=50&Page=0",
|
34
|
+
"key": "reservations",
|
35
|
+
"next_page_url": null,
|
36
|
+
"page": 0,
|
37
|
+
"page_size": 50,
|
38
|
+
"previous_page_url": null,
|
39
|
+
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations"
|
40
|
+
},
|
41
|
+
"reservations": [
|
42
|
+
{
|
43
|
+
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
44
|
+
"date_created": "2014-05-14T10:50:02Z",
|
45
|
+
"date_updated": "2014-05-15T16:03:42Z",
|
46
|
+
"links": {
|
47
|
+
"task": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
48
|
+
"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
49
|
+
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
50
|
+
},
|
51
|
+
"reservation_status": "reserved",
|
52
|
+
"sid": "WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
53
|
+
"task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
54
|
+
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
55
|
+
"worker_name": "Doug",
|
56
|
+
"worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
57
|
+
"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
58
|
+
}
|
59
|
+
]
|
60
|
+
}
|
61
|
+
]
|
62
|
+
))
|
63
|
+
|
64
|
+
actual = @client.taskrouter.v1.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \
|
65
|
+
.workers("WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \
|
66
|
+
.reservations.list()
|
67
|
+
|
68
|
+
expect(actual).to_not eq(nil)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "receives read_empty responses" do
|
72
|
+
@holodeck.mock(Twilio::TwilioResponse.new(
|
73
|
+
200,
|
74
|
+
%q[
|
75
|
+
{
|
76
|
+
"meta": {
|
77
|
+
"first_page_url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations?PageSize=50&Page=0",
|
78
|
+
"key": "reservations",
|
79
|
+
"next_page_url": null,
|
80
|
+
"page": 0,
|
81
|
+
"page_size": 50,
|
82
|
+
"previous_page_url": null,
|
83
|
+
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations"
|
84
|
+
},
|
85
|
+
"reservations": []
|
86
|
+
}
|
87
|
+
]
|
88
|
+
))
|
89
|
+
|
90
|
+
actual = @client.taskrouter.v1.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \
|
91
|
+
.workers("WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \
|
92
|
+
.reservations.list()
|
93
|
+
|
94
|
+
expect(actual).to_not eq(nil)
|
95
|
+
end
|
96
|
+
|
97
|
+
it "can fetch" do
|
98
|
+
@holodeck.mock(Twilio::TwilioResponse.new(500, ''))
|
99
|
+
|
100
|
+
expect {
|
101
|
+
@client.taskrouter.v1.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \
|
102
|
+
.workers("WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \
|
103
|
+
.reservations("WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch()
|
104
|
+
}.to raise_exception(Twilio::REST::TwilioException)
|
105
|
+
|
106
|
+
values = {}
|
107
|
+
expect(
|
108
|
+
@holodeck.has_request?(Holodeck::Request.new(
|
109
|
+
method: 'get',
|
110
|
+
url: 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
|
111
|
+
))).to eq(true)
|
112
|
+
end
|
113
|
+
|
114
|
+
it "receives fetch responses" do
|
115
|
+
@holodeck.mock(Twilio::TwilioResponse.new(
|
116
|
+
200,
|
117
|
+
%q[
|
118
|
+
{
|
119
|
+
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
120
|
+
"date_created": "2014-05-14T10:50:02Z",
|
121
|
+
"date_updated": "2014-05-15T16:03:42Z",
|
122
|
+
"links": {
|
123
|
+
"task": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
124
|
+
"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
125
|
+
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
126
|
+
},
|
127
|
+
"reservation_status": "reserved",
|
128
|
+
"sid": "WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
129
|
+
"task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
130
|
+
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
131
|
+
"worker_name": "Doug",
|
132
|
+
"worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
133
|
+
"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
134
|
+
}
|
135
|
+
]
|
136
|
+
))
|
137
|
+
|
138
|
+
actual = @client.taskrouter.v1.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \
|
139
|
+
.workers("WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \
|
140
|
+
.reservations("WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch()
|
141
|
+
|
142
|
+
expect(actual).to_not eq(nil)
|
143
|
+
end
|
144
|
+
|
145
|
+
it "can update" do
|
146
|
+
@holodeck.mock(Twilio::TwilioResponse.new(500, ''))
|
147
|
+
|
148
|
+
expect {
|
149
|
+
@client.taskrouter.v1.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \
|
150
|
+
.workers("WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \
|
151
|
+
.reservations("WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update()
|
152
|
+
}.to raise_exception(Twilio::REST::TwilioException)
|
153
|
+
|
154
|
+
values = {}
|
155
|
+
expect(
|
156
|
+
@holodeck.has_request?(Holodeck::Request.new(
|
157
|
+
method: 'post',
|
158
|
+
url: 'https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
|
159
|
+
))).to eq(true)
|
160
|
+
end
|
161
|
+
|
162
|
+
it "receives update responses" do
|
163
|
+
@holodeck.mock(Twilio::TwilioResponse.new(
|
164
|
+
200,
|
165
|
+
%q[
|
166
|
+
{
|
167
|
+
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
168
|
+
"date_created": "2014-05-14T10:50:02Z",
|
169
|
+
"date_updated": "2014-05-15T16:03:42Z",
|
170
|
+
"links": {
|
171
|
+
"task": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Tasks/WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
172
|
+
"worker": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
173
|
+
"workspace": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
174
|
+
},
|
175
|
+
"reservation_status": "reserved",
|
176
|
+
"sid": "WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
177
|
+
"task_sid": "WTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
178
|
+
"url": "https://taskrouter.twilio.com/v1/Workspaces/WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Workers/WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Reservations/WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
179
|
+
"worker_name": "Doug",
|
180
|
+
"worker_sid": "WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
181
|
+
"workspace_sid": "WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
182
|
+
}
|
183
|
+
]
|
184
|
+
))
|
185
|
+
|
186
|
+
actual = @client.taskrouter.v1.workspaces("WSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \
|
187
|
+
.workers("WKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") \
|
188
|
+
.reservations("WRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").update()
|
189
|
+
|
190
|
+
expect(actual).to_not eq(nil)
|
191
|
+
end
|
192
|
+
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.0.0.
|
4
|
+
version: 5.0.0.rc14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Benton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: builder
|
@@ -215,6 +215,7 @@ files:
|
|
215
215
|
- lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_statistics.rb
|
216
216
|
- lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queues_statistics.rb
|
217
217
|
- lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb
|
218
|
+
- lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/reservation.rb
|
218
219
|
- lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_statistics.rb
|
219
220
|
- lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_statistics.rb
|
220
221
|
- lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb
|
@@ -327,6 +328,7 @@ files:
|
|
327
328
|
- spec/integration/taskrouter/v1/workspace/task_queue/task_queues_statistics_spec.rb
|
328
329
|
- spec/integration/taskrouter/v1/workspace/task_queue_spec.rb
|
329
330
|
- spec/integration/taskrouter/v1/workspace/task_spec.rb
|
331
|
+
- spec/integration/taskrouter/v1/workspace/worker/reservation_spec.rb
|
330
332
|
- spec/integration/taskrouter/v1/workspace/worker/worker_statistics_spec.rb
|
331
333
|
- spec/integration/taskrouter/v1/workspace/worker/workers_statistics_spec.rb
|
332
334
|
- spec/integration/taskrouter/v1/workspace/worker_spec.rb
|
@@ -481,6 +483,7 @@ test_files:
|
|
481
483
|
- spec/integration/taskrouter/v1/workspace/task_queue/task_queues_statistics_spec.rb
|
482
484
|
- spec/integration/taskrouter/v1/workspace/task_queue_spec.rb
|
483
485
|
- spec/integration/taskrouter/v1/workspace/task_spec.rb
|
486
|
+
- spec/integration/taskrouter/v1/workspace/worker/reservation_spec.rb
|
484
487
|
- spec/integration/taskrouter/v1/workspace/worker/worker_statistics_spec.rb
|
485
488
|
- spec/integration/taskrouter/v1/workspace/worker/workers_statistics_spec.rb
|
486
489
|
- spec/integration/taskrouter/v1/workspace/worker_spec.rb
|