twilio-ruby 5.0.0.rc16 → 5.0.0.rc17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/AUTHORS.md +1 -0
- data/CHANGES.md +1 -1
- data/README.md +2 -2
- data/lib/twilio-ruby/jwt/access_token.rb +23 -1
- data/lib/twilio-ruby/rest/api.rb +2 -2
- data/lib/twilio-ruby/rest/api/v2010.rb +2 -2
- data/lib/twilio-ruby/rest/api/v2010/account.rb +19 -11
- data/lib/twilio-ruby/rest/api/v2010/account/conference/participant.rb +29 -5
- data/lib/twilio-ruby/rest/api/v2010/account/message.rb +5 -5
- data/lib/twilio-ruby/rest/api/v2010/account/recording.rb +25 -0
- data/lib/twilio-ruby/rest/api/v2010/account/short_code.rb +406 -0
- data/lib/twilio-ruby/rest/api/v2010/account/sip/credential_list/credential.rb +2 -6
- data/lib/twilio-ruby/rest/{notifications.rb → chat.rb} +6 -6
- data/lib/twilio-ruby/rest/{notifications → chat}/v1.rb +3 -3
- data/lib/twilio-ruby/rest/{notifications → chat}/v1/credential.rb +5 -5
- data/lib/twilio-ruby/rest/chat/v1/service.rb +501 -0
- data/lib/twilio-ruby/rest/chat/v1/service/channel.rb +468 -0
- data/lib/twilio-ruby/rest/chat/v1/service/channel/member.rb +351 -0
- data/lib/twilio-ruby/rest/{api/v2010/account/sms/sms_message.rb → chat/v1/service/channel/message.rb} +120 -168
- data/lib/twilio-ruby/rest/chat/v1/service/role.rb +373 -0
- data/lib/twilio-ruby/rest/chat/v1/service/user.rb +378 -0
- data/lib/twilio-ruby/rest/client.rb +19 -8
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/message.rb +3 -1
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/role.rb +2 -6
- data/lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb +5 -1
- data/lib/twilio-ruby/rest/lookups/v1/phone_number.rb +5 -0
- data/lib/twilio-ruby/rest/notify.rb +44 -0
- data/lib/twilio-ruby/rest/notify/v1.rb +44 -0
- data/lib/twilio-ruby/rest/notify/v1/credential.rb +375 -0
- data/lib/twilio-ruby/rest/{notifications → notify}/v1/service.rb +5 -5
- data/lib/twilio-ruby/rest/{notifications → notify}/v1/service/binding.rb +5 -5
- data/lib/twilio-ruby/rest/{notifications → notify}/v1/service/notification.rb +4 -4
- data/lib/twilio-ruby/rest/preview.rb +11 -0
- data/lib/twilio-ruby/rest/preview/sync.rb +35 -0
- data/lib/twilio-ruby/rest/preview/sync/service.rb +458 -0
- data/lib/twilio-ruby/rest/preview/sync/service/document.rb +376 -0
- data/lib/twilio-ruby/rest/preview/sync/service/sync_list.rb +375 -0
- data/lib/twilio-ruby/rest/preview/sync/service/sync_list/sync_list_item.rb +409 -0
- data/lib/twilio-ruby/rest/preview/sync/service/sync_map.rb +375 -0
- data/lib/twilio-ruby/rest/preview/sync/service/sync_map/sync_map_item.rb +411 -0
- data/lib/twilio-ruby/rest/preview/wireless/device.rb +6 -2
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace.rb +55 -3
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb +29 -6
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_channel.rb +294 -0
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb +32 -0
- data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb +374 -0
- data/lib/twilio-ruby/version.rb +1 -1
- data/spec/integration/api/v2010/account/conference/participant_spec.rb +6 -6
- data/spec/integration/api/v2010/account/recording_spec.rb +10 -1
- data/spec/integration/api/v2010/account/{sms/short_code_spec.rb → short_code_spec.rb} +0 -7
- data/spec/integration/api/v2010/account/sip/credential_list/credential_spec.rb +3 -7
- data/spec/integration/chat/v1/credential_spec.rb +223 -0
- data/spec/integration/chat/v1/service/channel/member_spec.rb +213 -0
- data/spec/integration/chat/v1/service/channel/message_spec.rb +100 -0
- data/spec/integration/chat/v1/service/channel_spec.rb +259 -0
- data/spec/integration/chat/v1/service/role_spec.rb +263 -0
- data/spec/integration/chat/v1/service/user_spec.rb +242 -0
- data/spec/integration/chat/v1/service_spec.rb +263 -0
- data/spec/integration/ip_messaging/v1/service/role_spec.rb +2 -3
- data/spec/integration/ip_messaging/v1/service/user_spec.rb +2 -3
- data/spec/integration/lookups/v1/phone_number_spec.rb +5 -0
- data/spec/integration/{notifications → notify}/v1/credential_spec.rb +24 -24
- data/spec/integration/{notifications → notify}/v1/service/binding_spec.rb +29 -29
- data/spec/integration/{notifications → notify}/v1/service/notification_spec.rb +5 -5
- data/spec/integration/{notifications → notify}/v1/service_spec.rb +32 -32
- data/spec/integration/preview/sync/service/document_spec.rb +92 -0
- data/spec/integration/preview/sync/service/sync_list/sync_list_item_spec.rb +100 -0
- data/spec/integration/preview/sync/service/sync_list_spec.rb +73 -0
- data/spec/integration/preview/sync/service/sync_map/sync_map_item_spec.rb +101 -0
- data/spec/integration/preview/sync/service/sync_map_spec.rb +73 -0
- data/spec/integration/preview/sync/service_spec.rb +84 -0
- data/spec/integration/taskrouter/v1/workspace/task_channel_spec.rb +127 -0
- data/spec/integration/taskrouter/v1/workspace/task_spec.rb +8 -0
- data/spec/integration/taskrouter/v1/workspace/worker/worker_channel_spec.rb +201 -0
- data/spec/integration/taskrouter/v1/workspace/workflow_spec.rb +2 -3
- data/spec/integration/taskrouter/v1/workspace_spec.rb +8 -0
- data/spec/jwt/access_token_spec.rb +27 -0
- metadata +84 -42
- data/lib/twilio-ruby/rest/api/v2010/account/sms.rb +0 -134
- data/lib/twilio-ruby/rest/api/v2010/account/sms/short_code.rb +0 -408
- data/spec/integration/api/v2010/account/sms/sms_message_spec.rb +0 -275
- data/spec/integration/api/v2010/account/sms_spec.rb +0 -10
@@ -0,0 +1,373 @@
|
|
1
|
+
##
|
2
|
+
# This code was generated by
|
3
|
+
# \ / _ _ _| _ _
|
4
|
+
# | (_)\/(_)(_|\/| |(/_ v1.0.0
|
5
|
+
# / /
|
6
|
+
|
7
|
+
module Twilio
|
8
|
+
module REST
|
9
|
+
class Chat < Domain
|
10
|
+
class V1 < Version
|
11
|
+
class ServiceContext < InstanceContext
|
12
|
+
class RoleList < ListResource
|
13
|
+
##
|
14
|
+
# Initialize the RoleList
|
15
|
+
# @param [Version] version Version that contains the resource
|
16
|
+
# @param [String] service_sid The service_sid
|
17
|
+
# @return [RoleList] RoleList
|
18
|
+
def initialize(version, service_sid: nil)
|
19
|
+
super(version)
|
20
|
+
|
21
|
+
# Path Solution
|
22
|
+
@solution = {
|
23
|
+
service_sid: service_sid
|
24
|
+
}
|
25
|
+
@uri = "/Services/#{@solution[:service_sid]}/Roles"
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# Retrieve a single page of RoleInstance records from the API.
|
30
|
+
# Request is executed immediately.
|
31
|
+
# @param [String] friendly_name The friendly_name
|
32
|
+
# @param [role.RoleType] type The type
|
33
|
+
# @param [String] permission The permission
|
34
|
+
# @return [RoleInstance] Newly created RoleInstance
|
35
|
+
def create(friendly_name: nil, type: nil, permission: nil)
|
36
|
+
data = {
|
37
|
+
'FriendlyName' => friendly_name,
|
38
|
+
'Type' => type,
|
39
|
+
'Permission' => permission,
|
40
|
+
}
|
41
|
+
|
42
|
+
payload = @version.create(
|
43
|
+
'POST',
|
44
|
+
@uri,
|
45
|
+
data: data
|
46
|
+
)
|
47
|
+
|
48
|
+
return RoleInstance.new(
|
49
|
+
@version,
|
50
|
+
payload,
|
51
|
+
service_sid: @solution[:service_sid],
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
##
|
56
|
+
# Lists RoleInstance records from the API as a list.
|
57
|
+
# Unlike stream(), this operation is eager and will load `limit` records into
|
58
|
+
# memory before returning.
|
59
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
60
|
+
# guarantees to never return more than limit. Default is no limit
|
61
|
+
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
62
|
+
# the default value of 50 records. If no page_size is defined
|
63
|
+
# but a limit is defined, stream() will attempt to read the
|
64
|
+
# limit with the most efficient page size, i.e. min(limit, 1000)
|
65
|
+
# @return [Array] Array of up to limit results
|
66
|
+
def list(limit: nil, page_size: nil)
|
67
|
+
self.stream(
|
68
|
+
limit: limit,
|
69
|
+
page_size: page_size
|
70
|
+
).entries
|
71
|
+
end
|
72
|
+
|
73
|
+
##
|
74
|
+
# Streams RoleInstance records from the API as an Enumerable.
|
75
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
76
|
+
# is reached.
|
77
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
78
|
+
# guarantees to never return more than limit. Default is no limit
|
79
|
+
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
80
|
+
# the default value of 50 records. If no page_size is defined
|
81
|
+
# but a limit is defined, stream() will attempt to read the
|
82
|
+
# limit with the most efficient page size, i.e. min(limit, 1000)
|
83
|
+
# @return [Enumerable] Enumerable that will yield up to limit results
|
84
|
+
def stream(limit: nil, page_size: nil)
|
85
|
+
limits = @version.read_limits(limit, page_size)
|
86
|
+
|
87
|
+
page = self.page(
|
88
|
+
page_size: limits[:page_size],
|
89
|
+
)
|
90
|
+
|
91
|
+
@version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
|
92
|
+
end
|
93
|
+
|
94
|
+
##
|
95
|
+
# When passed a block, yields RoleInstance records from the API.
|
96
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
97
|
+
# is reached.
|
98
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
99
|
+
# guarantees to never return more than limit. Default is no limit
|
100
|
+
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
101
|
+
# the default value of 50 records. If no page_size is defined
|
102
|
+
# but a limit is defined, stream() will attempt to read the
|
103
|
+
# limit with the most efficient page size, i.e. min(limit, 1000)
|
104
|
+
def each
|
105
|
+
limits = @version.read_limits
|
106
|
+
|
107
|
+
page = self.page(
|
108
|
+
page_size: limits[:page_size],
|
109
|
+
)
|
110
|
+
|
111
|
+
@version.stream(page,
|
112
|
+
limit: limits[:limit],
|
113
|
+
page_limit: limits[:page_limit]).each {|x| yield x}
|
114
|
+
end
|
115
|
+
|
116
|
+
##
|
117
|
+
# Retrieve a single page of RoleInstance records from the API.
|
118
|
+
# Request is executed immediately.
|
119
|
+
# @param [String] page_token PageToken provided by the API
|
120
|
+
# @param [Integer] page_number Page Number, this value is simply for client state
|
121
|
+
# @param [Integer] page_size Number of records to return, defaults to 50
|
122
|
+
# @return [Page] Page of RoleInstance
|
123
|
+
def page(page_token: nil, page_number: nil, page_size: nil)
|
124
|
+
params = {
|
125
|
+
'PageToken' => page_token,
|
126
|
+
'Page' => page_number,
|
127
|
+
'PageSize' => page_size,
|
128
|
+
}
|
129
|
+
response = @version.page(
|
130
|
+
'GET',
|
131
|
+
@uri,
|
132
|
+
params
|
133
|
+
)
|
134
|
+
return RolePage.new(@version, response, @solution)
|
135
|
+
end
|
136
|
+
|
137
|
+
##
|
138
|
+
# Provide a user friendly representation
|
139
|
+
def to_s
|
140
|
+
'#<Twilio.Chat.V1.RoleList>'
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
class RolePage < Page
|
145
|
+
##
|
146
|
+
# Initialize the RolePage
|
147
|
+
# @param [Version] version Version that contains the resource
|
148
|
+
# @param [Response] response Response from the API
|
149
|
+
# @param [Hash] solution Path solution for the resource
|
150
|
+
# @param [String] service_sid The service_sid
|
151
|
+
# @return [RolePage] RolePage
|
152
|
+
def initialize(version, response, solution)
|
153
|
+
super(version, response)
|
154
|
+
|
155
|
+
# Path Solution
|
156
|
+
@solution = solution
|
157
|
+
end
|
158
|
+
|
159
|
+
##
|
160
|
+
# Build an instance of RoleInstance
|
161
|
+
# @param [Hash] payload Payload response from the API
|
162
|
+
# @return [RoleInstance] RoleInstance
|
163
|
+
def get_instance(payload)
|
164
|
+
return RoleInstance.new(
|
165
|
+
@version,
|
166
|
+
payload,
|
167
|
+
service_sid: @solution[:service_sid],
|
168
|
+
)
|
169
|
+
end
|
170
|
+
|
171
|
+
##
|
172
|
+
# Provide a user friendly representation
|
173
|
+
def to_s
|
174
|
+
'<Twilio.Chat.V1.RolePage>'
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
class RoleContext < InstanceContext
|
179
|
+
##
|
180
|
+
# Initialize the RoleContext
|
181
|
+
# @param [Version] version Version that contains the resource
|
182
|
+
# @param [String] service_sid The service_sid
|
183
|
+
# @param [String] sid The sid
|
184
|
+
# @return [RoleContext] RoleContext
|
185
|
+
def initialize(version, service_sid, sid)
|
186
|
+
super(version)
|
187
|
+
|
188
|
+
# Path Solution
|
189
|
+
@solution = {
|
190
|
+
service_sid: service_sid,
|
191
|
+
sid: sid,
|
192
|
+
}
|
193
|
+
@uri = "/Services/#{@solution[:service_sid]}/Roles/#{@solution[:sid]}"
|
194
|
+
end
|
195
|
+
|
196
|
+
##
|
197
|
+
# Fetch a RoleInstance
|
198
|
+
# @return [RoleInstance] Fetched RoleInstance
|
199
|
+
def fetch
|
200
|
+
params = {}
|
201
|
+
|
202
|
+
payload = @version.fetch(
|
203
|
+
'GET',
|
204
|
+
@uri,
|
205
|
+
params,
|
206
|
+
)
|
207
|
+
|
208
|
+
return RoleInstance.new(
|
209
|
+
@version,
|
210
|
+
payload,
|
211
|
+
service_sid: @solution[:service_sid],
|
212
|
+
sid: @solution[:sid],
|
213
|
+
)
|
214
|
+
end
|
215
|
+
|
216
|
+
##
|
217
|
+
# Deletes the RoleInstance
|
218
|
+
# @return [Boolean] true if delete succeeds, true otherwise
|
219
|
+
def delete
|
220
|
+
return @version.delete('delete', @uri)
|
221
|
+
end
|
222
|
+
|
223
|
+
##
|
224
|
+
# Update the RoleInstance
|
225
|
+
# @param [String] permission The permission
|
226
|
+
# @return [RoleInstance] Updated RoleInstance
|
227
|
+
def update(permission: nil)
|
228
|
+
data = {
|
229
|
+
'Permission' => permission,
|
230
|
+
}
|
231
|
+
|
232
|
+
payload = @version.update(
|
233
|
+
'POST',
|
234
|
+
@uri,
|
235
|
+
data: data,
|
236
|
+
)
|
237
|
+
|
238
|
+
return RoleInstance.new(
|
239
|
+
@version,
|
240
|
+
payload,
|
241
|
+
service_sid: @solution[:service_sid],
|
242
|
+
sid: @solution[:sid],
|
243
|
+
)
|
244
|
+
end
|
245
|
+
|
246
|
+
##
|
247
|
+
# Provide a user friendly representation
|
248
|
+
def to_s
|
249
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
250
|
+
"#<Twilio.Chat.V1.RoleContext #{context}>"
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
class RoleInstance < InstanceResource
|
255
|
+
##
|
256
|
+
# Initialize the RoleInstance
|
257
|
+
# @param [Version] version Version that contains the resource
|
258
|
+
# @param [Hash] payload payload that contains response from Twilio
|
259
|
+
# @param [String] service_sid The service_sid
|
260
|
+
# @param [String] sid The sid
|
261
|
+
# @return [RoleInstance] RoleInstance
|
262
|
+
def initialize(version, payload, service_sid: nil, sid: nil)
|
263
|
+
super(version)
|
264
|
+
|
265
|
+
# Marshaled Properties
|
266
|
+
@properties = {
|
267
|
+
'sid' => payload['sid'],
|
268
|
+
'account_sid' => payload['account_sid'],
|
269
|
+
'service_sid' => payload['service_sid'],
|
270
|
+
'friendly_name' => payload['friendly_name'],
|
271
|
+
'type' => payload['type'],
|
272
|
+
'permissions' => payload['permissions'],
|
273
|
+
'date_created' => Twilio.deserialize_iso8601(payload['date_created']),
|
274
|
+
'date_updated' => Twilio.deserialize_iso8601(payload['date_updated']),
|
275
|
+
'url' => payload['url'],
|
276
|
+
}
|
277
|
+
|
278
|
+
# Context
|
279
|
+
@instance_context = nil
|
280
|
+
@params = {
|
281
|
+
'service_sid' => service_sid,
|
282
|
+
'sid' => sid || @properties['sid'],
|
283
|
+
}
|
284
|
+
end
|
285
|
+
|
286
|
+
##
|
287
|
+
# Generate an instance context for the instance, the context is capable of
|
288
|
+
# performing various actions. All instance actions are proxied to the context
|
289
|
+
# @param [Version] version Version that contains the resource
|
290
|
+
# @return [RoleContext] RoleContext for this RoleInstance
|
291
|
+
def context
|
292
|
+
unless @instance_context
|
293
|
+
@instance_context = RoleContext.new(
|
294
|
+
@version,
|
295
|
+
@params['service_sid'],
|
296
|
+
@params['sid'],
|
297
|
+
)
|
298
|
+
end
|
299
|
+
@instance_context
|
300
|
+
end
|
301
|
+
|
302
|
+
def sid
|
303
|
+
@properties['sid']
|
304
|
+
end
|
305
|
+
|
306
|
+
def account_sid
|
307
|
+
@properties['account_sid']
|
308
|
+
end
|
309
|
+
|
310
|
+
def service_sid
|
311
|
+
@properties['service_sid']
|
312
|
+
end
|
313
|
+
|
314
|
+
def friendly_name
|
315
|
+
@properties['friendly_name']
|
316
|
+
end
|
317
|
+
|
318
|
+
def type
|
319
|
+
@properties['type']
|
320
|
+
end
|
321
|
+
|
322
|
+
def permissions
|
323
|
+
@properties['permissions']
|
324
|
+
end
|
325
|
+
|
326
|
+
def date_created
|
327
|
+
@properties['date_created']
|
328
|
+
end
|
329
|
+
|
330
|
+
def date_updated
|
331
|
+
@properties['date_updated']
|
332
|
+
end
|
333
|
+
|
334
|
+
def url
|
335
|
+
@properties['url']
|
336
|
+
end
|
337
|
+
|
338
|
+
##
|
339
|
+
# Fetch a RoleInstance
|
340
|
+
# @return [RoleInstance] Fetched RoleInstance
|
341
|
+
def fetch
|
342
|
+
context.fetch
|
343
|
+
end
|
344
|
+
|
345
|
+
##
|
346
|
+
# Deletes the RoleInstance
|
347
|
+
# @return [Boolean] true if delete succeeds, true otherwise
|
348
|
+
def delete
|
349
|
+
context.delete
|
350
|
+
end
|
351
|
+
|
352
|
+
##
|
353
|
+
# Update the RoleInstance
|
354
|
+
# @param [String] permission The permission
|
355
|
+
# @return [RoleInstance] Updated RoleInstance
|
356
|
+
def update(permission: nil)
|
357
|
+
context.update(
|
358
|
+
permission: permission,
|
359
|
+
)
|
360
|
+
end
|
361
|
+
|
362
|
+
##
|
363
|
+
# Provide a user friendly representation
|
364
|
+
def to_s
|
365
|
+
values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
|
366
|
+
"<Twilio.Chat.V1.RoleInstance #{values}>"
|
367
|
+
end
|
368
|
+
end
|
369
|
+
end
|
370
|
+
end
|
371
|
+
end
|
372
|
+
end
|
373
|
+
end
|
@@ -0,0 +1,378 @@
|
|
1
|
+
##
|
2
|
+
# This code was generated by
|
3
|
+
# \ / _ _ _| _ _
|
4
|
+
# | (_)\/(_)(_|\/| |(/_ v1.0.0
|
5
|
+
# / /
|
6
|
+
|
7
|
+
module Twilio
|
8
|
+
module REST
|
9
|
+
class Chat < Domain
|
10
|
+
class V1 < Version
|
11
|
+
class ServiceContext < InstanceContext
|
12
|
+
class UserList < ListResource
|
13
|
+
##
|
14
|
+
# Initialize the UserList
|
15
|
+
# @param [Version] version Version that contains the resource
|
16
|
+
# @param [String] service_sid The service_sid
|
17
|
+
# @return [UserList] UserList
|
18
|
+
def initialize(version, service_sid: nil)
|
19
|
+
super(version)
|
20
|
+
|
21
|
+
# Path Solution
|
22
|
+
@solution = {
|
23
|
+
service_sid: service_sid
|
24
|
+
}
|
25
|
+
@uri = "/Services/#{@solution[:service_sid]}/Users"
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# Retrieve a single page of UserInstance records from the API.
|
30
|
+
# Request is executed immediately.
|
31
|
+
# @param [String] identity The identity
|
32
|
+
# @param [String] role_sid The role_sid
|
33
|
+
# @param [String] attributes The attributes
|
34
|
+
# @param [String] friendly_name The friendly_name
|
35
|
+
# @return [UserInstance] Newly created UserInstance
|
36
|
+
def create(identity: nil, role_sid: nil, attributes: nil, friendly_name: nil)
|
37
|
+
data = {
|
38
|
+
'Identity' => identity,
|
39
|
+
'RoleSid' => role_sid,
|
40
|
+
'Attributes' => attributes,
|
41
|
+
'FriendlyName' => friendly_name,
|
42
|
+
}
|
43
|
+
|
44
|
+
payload = @version.create(
|
45
|
+
'POST',
|
46
|
+
@uri,
|
47
|
+
data: data
|
48
|
+
)
|
49
|
+
|
50
|
+
return UserInstance.new(
|
51
|
+
@version,
|
52
|
+
payload,
|
53
|
+
service_sid: @solution[:service_sid],
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
##
|
58
|
+
# Lists UserInstance records from the API as a list.
|
59
|
+
# Unlike stream(), this operation is eager and will load `limit` records into
|
60
|
+
# memory before returning.
|
61
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
62
|
+
# guarantees to never return more than limit. Default is no limit
|
63
|
+
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
64
|
+
# the default value of 50 records. If no page_size is defined
|
65
|
+
# but a limit is defined, stream() will attempt to read the
|
66
|
+
# limit with the most efficient page size, i.e. min(limit, 1000)
|
67
|
+
# @return [Array] Array of up to limit results
|
68
|
+
def list(limit: nil, page_size: nil)
|
69
|
+
self.stream(
|
70
|
+
limit: limit,
|
71
|
+
page_size: page_size
|
72
|
+
).entries
|
73
|
+
end
|
74
|
+
|
75
|
+
##
|
76
|
+
# Streams UserInstance records from the API as an Enumerable.
|
77
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
78
|
+
# is reached.
|
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
|
+
# @return [Enumerable] Enumerable that will yield up to limit results
|
86
|
+
def stream(limit: nil, page_size: nil)
|
87
|
+
limits = @version.read_limits(limit, page_size)
|
88
|
+
|
89
|
+
page = self.page(
|
90
|
+
page_size: limits[:page_size],
|
91
|
+
)
|
92
|
+
|
93
|
+
@version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
|
94
|
+
end
|
95
|
+
|
96
|
+
##
|
97
|
+
# When passed a block, yields UserInstance records from the API.
|
98
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
99
|
+
# is reached.
|
100
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
101
|
+
# guarantees to never return more than limit. Default is no limit
|
102
|
+
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
103
|
+
# the default value of 50 records. If no page_size is defined
|
104
|
+
# but a limit is defined, stream() will attempt to read the
|
105
|
+
# limit with the most efficient page size, i.e. min(limit, 1000)
|
106
|
+
def each
|
107
|
+
limits = @version.read_limits
|
108
|
+
|
109
|
+
page = self.page(
|
110
|
+
page_size: limits[:page_size],
|
111
|
+
)
|
112
|
+
|
113
|
+
@version.stream(page,
|
114
|
+
limit: limits[:limit],
|
115
|
+
page_limit: limits[:page_limit]).each {|x| yield x}
|
116
|
+
end
|
117
|
+
|
118
|
+
##
|
119
|
+
# Retrieve a single page of UserInstance records from the API.
|
120
|
+
# Request is executed immediately.
|
121
|
+
# @param [String] page_token PageToken provided by the API
|
122
|
+
# @param [Integer] page_number Page Number, this value is simply for client state
|
123
|
+
# @param [Integer] page_size Number of records to return, defaults to 50
|
124
|
+
# @return [Page] Page of UserInstance
|
125
|
+
def page(page_token: nil, page_number: nil, page_size: nil)
|
126
|
+
params = {
|
127
|
+
'PageToken' => page_token,
|
128
|
+
'Page' => page_number,
|
129
|
+
'PageSize' => page_size,
|
130
|
+
}
|
131
|
+
response = @version.page(
|
132
|
+
'GET',
|
133
|
+
@uri,
|
134
|
+
params
|
135
|
+
)
|
136
|
+
return UserPage.new(@version, response, @solution)
|
137
|
+
end
|
138
|
+
|
139
|
+
##
|
140
|
+
# Provide a user friendly representation
|
141
|
+
def to_s
|
142
|
+
'#<Twilio.Chat.V1.UserList>'
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
class UserPage < Page
|
147
|
+
##
|
148
|
+
# Initialize the UserPage
|
149
|
+
# @param [Version] version Version that contains the resource
|
150
|
+
# @param [Response] response Response from the API
|
151
|
+
# @param [Hash] solution Path solution for the resource
|
152
|
+
# @param [String] service_sid The service_sid
|
153
|
+
# @return [UserPage] UserPage
|
154
|
+
def initialize(version, response, solution)
|
155
|
+
super(version, response)
|
156
|
+
|
157
|
+
# Path Solution
|
158
|
+
@solution = solution
|
159
|
+
end
|
160
|
+
|
161
|
+
##
|
162
|
+
# Build an instance of UserInstance
|
163
|
+
# @param [Hash] payload Payload response from the API
|
164
|
+
# @return [UserInstance] UserInstance
|
165
|
+
def get_instance(payload)
|
166
|
+
return UserInstance.new(
|
167
|
+
@version,
|
168
|
+
payload,
|
169
|
+
service_sid: @solution[:service_sid],
|
170
|
+
)
|
171
|
+
end
|
172
|
+
|
173
|
+
##
|
174
|
+
# Provide a user friendly representation
|
175
|
+
def to_s
|
176
|
+
'<Twilio.Chat.V1.UserPage>'
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
class UserContext < InstanceContext
|
181
|
+
##
|
182
|
+
# Initialize the UserContext
|
183
|
+
# @param [Version] version Version that contains the resource
|
184
|
+
# @param [String] service_sid The service_sid
|
185
|
+
# @param [String] sid The sid
|
186
|
+
# @return [UserContext] UserContext
|
187
|
+
def initialize(version, service_sid, sid)
|
188
|
+
super(version)
|
189
|
+
|
190
|
+
# Path Solution
|
191
|
+
@solution = {
|
192
|
+
service_sid: service_sid,
|
193
|
+
sid: sid,
|
194
|
+
}
|
195
|
+
@uri = "/Services/#{@solution[:service_sid]}/Users/#{@solution[:sid]}"
|
196
|
+
end
|
197
|
+
|
198
|
+
##
|
199
|
+
# Fetch a UserInstance
|
200
|
+
# @return [UserInstance] Fetched UserInstance
|
201
|
+
def fetch
|
202
|
+
params = {}
|
203
|
+
|
204
|
+
payload = @version.fetch(
|
205
|
+
'GET',
|
206
|
+
@uri,
|
207
|
+
params,
|
208
|
+
)
|
209
|
+
|
210
|
+
return UserInstance.new(
|
211
|
+
@version,
|
212
|
+
payload,
|
213
|
+
service_sid: @solution[:service_sid],
|
214
|
+
sid: @solution[:sid],
|
215
|
+
)
|
216
|
+
end
|
217
|
+
|
218
|
+
##
|
219
|
+
# Deletes the UserInstance
|
220
|
+
# @return [Boolean] true if delete succeeds, true otherwise
|
221
|
+
def delete
|
222
|
+
return @version.delete('delete', @uri)
|
223
|
+
end
|
224
|
+
|
225
|
+
##
|
226
|
+
# Update the UserInstance
|
227
|
+
# @param [String] role_sid The role_sid
|
228
|
+
# @param [Hash] attributes The attributes
|
229
|
+
# @param [String] friendly_name The friendly_name
|
230
|
+
# @return [UserInstance] Updated UserInstance
|
231
|
+
def update(role_sid: nil, attributes: nil, friendly_name: nil)
|
232
|
+
data = {
|
233
|
+
'RoleSid' => role_sid,
|
234
|
+
'Attributes' => attributes,
|
235
|
+
'FriendlyName' => friendly_name,
|
236
|
+
}
|
237
|
+
|
238
|
+
payload = @version.update(
|
239
|
+
'POST',
|
240
|
+
@uri,
|
241
|
+
data: data,
|
242
|
+
)
|
243
|
+
|
244
|
+
return UserInstance.new(
|
245
|
+
@version,
|
246
|
+
payload,
|
247
|
+
service_sid: @solution[:service_sid],
|
248
|
+
sid: @solution[:sid],
|
249
|
+
)
|
250
|
+
end
|
251
|
+
|
252
|
+
##
|
253
|
+
# Provide a user friendly representation
|
254
|
+
def to_s
|
255
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
256
|
+
"#<Twilio.Chat.V1.UserContext #{context}>"
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
class UserInstance < InstanceResource
|
261
|
+
##
|
262
|
+
# Initialize the UserInstance
|
263
|
+
# @param [Version] version Version that contains the resource
|
264
|
+
# @param [Hash] payload payload that contains response from Twilio
|
265
|
+
# @param [String] service_sid The service_sid
|
266
|
+
# @param [String] sid The sid
|
267
|
+
# @return [UserInstance] UserInstance
|
268
|
+
def initialize(version, payload, service_sid: nil, sid: nil)
|
269
|
+
super(version)
|
270
|
+
|
271
|
+
# Marshaled Properties
|
272
|
+
@properties = {
|
273
|
+
'sid' => payload['sid'],
|
274
|
+
'account_sid' => payload['account_sid'],
|
275
|
+
'service_sid' => payload['service_sid'],
|
276
|
+
'role_sid' => payload['role_sid'],
|
277
|
+
'identity' => payload['identity'],
|
278
|
+
'date_created' => Twilio.deserialize_iso8601(payload['date_created']),
|
279
|
+
'date_updated' => Twilio.deserialize_iso8601(payload['date_updated']),
|
280
|
+
'url' => payload['url'],
|
281
|
+
}
|
282
|
+
|
283
|
+
# Context
|
284
|
+
@instance_context = nil
|
285
|
+
@params = {
|
286
|
+
'service_sid' => service_sid,
|
287
|
+
'sid' => sid || @properties['sid'],
|
288
|
+
}
|
289
|
+
end
|
290
|
+
|
291
|
+
##
|
292
|
+
# Generate an instance context for the instance, the context is capable of
|
293
|
+
# performing various actions. All instance actions are proxied to the context
|
294
|
+
# @param [Version] version Version that contains the resource
|
295
|
+
# @return [UserContext] UserContext for this UserInstance
|
296
|
+
def context
|
297
|
+
unless @instance_context
|
298
|
+
@instance_context = UserContext.new(
|
299
|
+
@version,
|
300
|
+
@params['service_sid'],
|
301
|
+
@params['sid'],
|
302
|
+
)
|
303
|
+
end
|
304
|
+
@instance_context
|
305
|
+
end
|
306
|
+
|
307
|
+
def sid
|
308
|
+
@properties['sid']
|
309
|
+
end
|
310
|
+
|
311
|
+
def account_sid
|
312
|
+
@properties['account_sid']
|
313
|
+
end
|
314
|
+
|
315
|
+
def service_sid
|
316
|
+
@properties['service_sid']
|
317
|
+
end
|
318
|
+
|
319
|
+
def role_sid
|
320
|
+
@properties['role_sid']
|
321
|
+
end
|
322
|
+
|
323
|
+
def identity
|
324
|
+
@properties['identity']
|
325
|
+
end
|
326
|
+
|
327
|
+
def date_created
|
328
|
+
@properties['date_created']
|
329
|
+
end
|
330
|
+
|
331
|
+
def date_updated
|
332
|
+
@properties['date_updated']
|
333
|
+
end
|
334
|
+
|
335
|
+
def url
|
336
|
+
@properties['url']
|
337
|
+
end
|
338
|
+
|
339
|
+
##
|
340
|
+
# Fetch a UserInstance
|
341
|
+
# @return [UserInstance] Fetched UserInstance
|
342
|
+
def fetch
|
343
|
+
context.fetch
|
344
|
+
end
|
345
|
+
|
346
|
+
##
|
347
|
+
# Deletes the UserInstance
|
348
|
+
# @return [Boolean] true if delete succeeds, true otherwise
|
349
|
+
def delete
|
350
|
+
context.delete
|
351
|
+
end
|
352
|
+
|
353
|
+
##
|
354
|
+
# Update the UserInstance
|
355
|
+
# @param [String] role_sid The role_sid
|
356
|
+
# @param [Hash] attributes The attributes
|
357
|
+
# @param [String] friendly_name The friendly_name
|
358
|
+
# @return [UserInstance] Updated UserInstance
|
359
|
+
def update(role_sid: nil, attributes: nil, friendly_name: nil)
|
360
|
+
context.update(
|
361
|
+
role_sid: role_sid,
|
362
|
+
attributes: attributes,
|
363
|
+
friendly_name: friendly_name,
|
364
|
+
)
|
365
|
+
end
|
366
|
+
|
367
|
+
##
|
368
|
+
# Provide a user friendly representation
|
369
|
+
def to_s
|
370
|
+
values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
|
371
|
+
"<Twilio.Chat.V1.UserInstance #{values}>"
|
372
|
+
end
|
373
|
+
end
|
374
|
+
end
|
375
|
+
end
|
376
|
+
end
|
377
|
+
end
|
378
|
+
end
|