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,376 @@
|
|
1
|
+
##
|
2
|
+
# This code was generated by
|
3
|
+
# \ / _ _ _| _ _
|
4
|
+
# | (_)\/(_)(_|\/| |(/_ v1.0.0
|
5
|
+
# / /
|
6
|
+
|
7
|
+
module Twilio
|
8
|
+
module REST
|
9
|
+
class Preview < Domain
|
10
|
+
class Sync < Version
|
11
|
+
class ServiceContext < InstanceContext
|
12
|
+
class DocumentList < ListResource
|
13
|
+
##
|
14
|
+
# Initialize the DocumentList
|
15
|
+
# @param [Version] version Version that contains the resource
|
16
|
+
# @param [String] service_sid The service_sid
|
17
|
+
# @return [DocumentList] DocumentList
|
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]}/Documents"
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# Retrieve a single page of DocumentInstance records from the API.
|
30
|
+
# Request is executed immediately.
|
31
|
+
# @param [String] unique_name The unique_name
|
32
|
+
# @param [Hash] data The data
|
33
|
+
# @return [DocumentInstance] Newly created DocumentInstance
|
34
|
+
def create(unique_name: nil, data: nil)
|
35
|
+
data = {
|
36
|
+
'UniqueName' => unique_name,
|
37
|
+
'Data' => data,
|
38
|
+
}
|
39
|
+
|
40
|
+
payload = @version.create(
|
41
|
+
'POST',
|
42
|
+
@uri,
|
43
|
+
data: data
|
44
|
+
)
|
45
|
+
|
46
|
+
return DocumentInstance.new(
|
47
|
+
@version,
|
48
|
+
payload,
|
49
|
+
service_sid: @solution[:service_sid],
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
##
|
54
|
+
# Lists DocumentInstance records from the API as a list.
|
55
|
+
# Unlike stream(), this operation is eager and will load `limit` records into
|
56
|
+
# memory before returning.
|
57
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
58
|
+
# guarantees to never return more than limit. Default is no limit
|
59
|
+
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
60
|
+
# the default value of 50 records. If no page_size is defined
|
61
|
+
# but a limit is defined, stream() will attempt to read the
|
62
|
+
# limit with the most efficient page size, i.e. min(limit, 1000)
|
63
|
+
# @return [Array] Array of up to limit results
|
64
|
+
def list(limit: nil, page_size: nil)
|
65
|
+
self.stream(
|
66
|
+
limit: limit,
|
67
|
+
page_size: page_size
|
68
|
+
).entries
|
69
|
+
end
|
70
|
+
|
71
|
+
##
|
72
|
+
# Streams DocumentInstance records from the API as an Enumerable.
|
73
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
74
|
+
# is reached.
|
75
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
76
|
+
# guarantees to never return more than limit. Default is no limit
|
77
|
+
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
78
|
+
# the default value of 50 records. If no page_size is defined
|
79
|
+
# but a limit is defined, stream() will attempt to read the
|
80
|
+
# limit with the most efficient page size, i.e. min(limit, 1000)
|
81
|
+
# @return [Enumerable] Enumerable that will yield up to limit results
|
82
|
+
def stream(limit: nil, page_size: nil)
|
83
|
+
limits = @version.read_limits(limit, page_size)
|
84
|
+
|
85
|
+
page = self.page(
|
86
|
+
page_size: limits[:page_size],
|
87
|
+
)
|
88
|
+
|
89
|
+
@version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
|
90
|
+
end
|
91
|
+
|
92
|
+
##
|
93
|
+
# When passed a block, yields DocumentInstance records from the API.
|
94
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
95
|
+
# is reached.
|
96
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
97
|
+
# guarantees to never return more than limit. Default is no limit
|
98
|
+
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
99
|
+
# the default value of 50 records. If no page_size is defined
|
100
|
+
# but a limit is defined, stream() will attempt to read the
|
101
|
+
# limit with the most efficient page size, i.e. min(limit, 1000)
|
102
|
+
def each
|
103
|
+
limits = @version.read_limits
|
104
|
+
|
105
|
+
page = self.page(
|
106
|
+
page_size: limits[:page_size],
|
107
|
+
)
|
108
|
+
|
109
|
+
@version.stream(page,
|
110
|
+
limit: limits[:limit],
|
111
|
+
page_limit: limits[:page_limit]).each {|x| yield x}
|
112
|
+
end
|
113
|
+
|
114
|
+
##
|
115
|
+
# Retrieve a single page of DocumentInstance records from the API.
|
116
|
+
# Request is executed immediately.
|
117
|
+
# @param [String] page_token PageToken provided by the API
|
118
|
+
# @param [Integer] page_number Page Number, this value is simply for client state
|
119
|
+
# @param [Integer] page_size Number of records to return, defaults to 50
|
120
|
+
# @return [Page] Page of DocumentInstance
|
121
|
+
def page(page_token: nil, page_number: nil, page_size: nil)
|
122
|
+
params = {
|
123
|
+
'PageToken' => page_token,
|
124
|
+
'Page' => page_number,
|
125
|
+
'PageSize' => page_size,
|
126
|
+
}
|
127
|
+
response = @version.page(
|
128
|
+
'GET',
|
129
|
+
@uri,
|
130
|
+
params
|
131
|
+
)
|
132
|
+
return DocumentPage.new(@version, response, @solution)
|
133
|
+
end
|
134
|
+
|
135
|
+
##
|
136
|
+
# Provide a user friendly representation
|
137
|
+
def to_s
|
138
|
+
'#<Twilio.Preview.Sync.DocumentList>'
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
class DocumentPage < Page
|
143
|
+
##
|
144
|
+
# Initialize the DocumentPage
|
145
|
+
# @param [Version] version Version that contains the resource
|
146
|
+
# @param [Response] response Response from the API
|
147
|
+
# @param [Hash] solution Path solution for the resource
|
148
|
+
# @param [String] service_sid The service_sid
|
149
|
+
# @return [DocumentPage] DocumentPage
|
150
|
+
def initialize(version, response, solution)
|
151
|
+
super(version, response)
|
152
|
+
|
153
|
+
# Path Solution
|
154
|
+
@solution = solution
|
155
|
+
end
|
156
|
+
|
157
|
+
##
|
158
|
+
# Build an instance of DocumentInstance
|
159
|
+
# @param [Hash] payload Payload response from the API
|
160
|
+
# @return [DocumentInstance] DocumentInstance
|
161
|
+
def get_instance(payload)
|
162
|
+
return DocumentInstance.new(
|
163
|
+
@version,
|
164
|
+
payload,
|
165
|
+
service_sid: @solution[:service_sid],
|
166
|
+
)
|
167
|
+
end
|
168
|
+
|
169
|
+
##
|
170
|
+
# Provide a user friendly representation
|
171
|
+
def to_s
|
172
|
+
'<Twilio.Preview.Sync.DocumentPage>'
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
class DocumentContext < InstanceContext
|
177
|
+
##
|
178
|
+
# Initialize the DocumentContext
|
179
|
+
# @param [Version] version Version that contains the resource
|
180
|
+
# @param [String] service_sid The service_sid
|
181
|
+
# @param [String] sid The sid
|
182
|
+
# @return [DocumentContext] DocumentContext
|
183
|
+
def initialize(version, service_sid, sid)
|
184
|
+
super(version)
|
185
|
+
|
186
|
+
# Path Solution
|
187
|
+
@solution = {
|
188
|
+
service_sid: service_sid,
|
189
|
+
sid: sid,
|
190
|
+
}
|
191
|
+
@uri = "/Services/#{@solution[:service_sid]}/Documents/#{@solution[:sid]}"
|
192
|
+
end
|
193
|
+
|
194
|
+
##
|
195
|
+
# Fetch a DocumentInstance
|
196
|
+
# @return [DocumentInstance] Fetched DocumentInstance
|
197
|
+
def fetch
|
198
|
+
params = {}
|
199
|
+
|
200
|
+
payload = @version.fetch(
|
201
|
+
'GET',
|
202
|
+
@uri,
|
203
|
+
params,
|
204
|
+
)
|
205
|
+
|
206
|
+
return DocumentInstance.new(
|
207
|
+
@version,
|
208
|
+
payload,
|
209
|
+
service_sid: @solution[:service_sid],
|
210
|
+
sid: @solution[:sid],
|
211
|
+
)
|
212
|
+
end
|
213
|
+
|
214
|
+
##
|
215
|
+
# Deletes the DocumentInstance
|
216
|
+
# @return [Boolean] true if delete succeeds, true otherwise
|
217
|
+
def delete
|
218
|
+
return @version.delete('delete', @uri)
|
219
|
+
end
|
220
|
+
|
221
|
+
##
|
222
|
+
# Update the DocumentInstance
|
223
|
+
# @param [Hash] data The data
|
224
|
+
# @return [DocumentInstance] Updated DocumentInstance
|
225
|
+
def update(data: nil)
|
226
|
+
data = {
|
227
|
+
'Data' => data,
|
228
|
+
}
|
229
|
+
|
230
|
+
payload = @version.update(
|
231
|
+
'POST',
|
232
|
+
@uri,
|
233
|
+
data: data,
|
234
|
+
)
|
235
|
+
|
236
|
+
return DocumentInstance.new(
|
237
|
+
@version,
|
238
|
+
payload,
|
239
|
+
service_sid: @solution[:service_sid],
|
240
|
+
sid: @solution[:sid],
|
241
|
+
)
|
242
|
+
end
|
243
|
+
|
244
|
+
##
|
245
|
+
# Provide a user friendly representation
|
246
|
+
def to_s
|
247
|
+
context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
|
248
|
+
"#<Twilio.Preview.Sync.DocumentContext #{context}>"
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
class DocumentInstance < InstanceResource
|
253
|
+
##
|
254
|
+
# Initialize the DocumentInstance
|
255
|
+
# @param [Version] version Version that contains the resource
|
256
|
+
# @param [Hash] payload payload that contains response from Twilio
|
257
|
+
# @param [String] service_sid The service_sid
|
258
|
+
# @param [String] sid The sid
|
259
|
+
# @return [DocumentInstance] DocumentInstance
|
260
|
+
def initialize(version, payload, service_sid: nil, sid: nil)
|
261
|
+
super(version)
|
262
|
+
|
263
|
+
# Marshaled Properties
|
264
|
+
@properties = {
|
265
|
+
'sid' => payload['sid'],
|
266
|
+
'unique_name' => payload['unique_name'],
|
267
|
+
'account_sid' => payload['account_sid'],
|
268
|
+
'service_sid' => payload['service_sid'],
|
269
|
+
'url' => payload['url'],
|
270
|
+
'revision' => payload['revision'],
|
271
|
+
'data' => payload['data'],
|
272
|
+
'date_created' => Twilio.deserialize_iso8601(payload['date_created']),
|
273
|
+
'date_updated' => Twilio.deserialize_iso8601(payload['date_updated']),
|
274
|
+
'created_by' => payload['created_by'],
|
275
|
+
}
|
276
|
+
|
277
|
+
# Context
|
278
|
+
@instance_context = nil
|
279
|
+
@params = {
|
280
|
+
'service_sid' => service_sid,
|
281
|
+
'sid' => sid || @properties['sid'],
|
282
|
+
}
|
283
|
+
end
|
284
|
+
|
285
|
+
##
|
286
|
+
# Generate an instance context for the instance, the context is capable of
|
287
|
+
# performing various actions. All instance actions are proxied to the context
|
288
|
+
# @param [Version] version Version that contains the resource
|
289
|
+
# @return [DocumentContext] DocumentContext for this DocumentInstance
|
290
|
+
def context
|
291
|
+
unless @instance_context
|
292
|
+
@instance_context = DocumentContext.new(
|
293
|
+
@version,
|
294
|
+
@params['service_sid'],
|
295
|
+
@params['sid'],
|
296
|
+
)
|
297
|
+
end
|
298
|
+
@instance_context
|
299
|
+
end
|
300
|
+
|
301
|
+
def sid
|
302
|
+
@properties['sid']
|
303
|
+
end
|
304
|
+
|
305
|
+
def unique_name
|
306
|
+
@properties['unique_name']
|
307
|
+
end
|
308
|
+
|
309
|
+
def account_sid
|
310
|
+
@properties['account_sid']
|
311
|
+
end
|
312
|
+
|
313
|
+
def service_sid
|
314
|
+
@properties['service_sid']
|
315
|
+
end
|
316
|
+
|
317
|
+
def url
|
318
|
+
@properties['url']
|
319
|
+
end
|
320
|
+
|
321
|
+
def revision
|
322
|
+
@properties['revision']
|
323
|
+
end
|
324
|
+
|
325
|
+
def data
|
326
|
+
@properties['data']
|
327
|
+
end
|
328
|
+
|
329
|
+
def date_created
|
330
|
+
@properties['date_created']
|
331
|
+
end
|
332
|
+
|
333
|
+
def date_updated
|
334
|
+
@properties['date_updated']
|
335
|
+
end
|
336
|
+
|
337
|
+
def created_by
|
338
|
+
@properties['created_by']
|
339
|
+
end
|
340
|
+
|
341
|
+
##
|
342
|
+
# Fetch a DocumentInstance
|
343
|
+
# @return [DocumentInstance] Fetched DocumentInstance
|
344
|
+
def fetch
|
345
|
+
context.fetch
|
346
|
+
end
|
347
|
+
|
348
|
+
##
|
349
|
+
# Deletes the DocumentInstance
|
350
|
+
# @return [Boolean] true if delete succeeds, true otherwise
|
351
|
+
def delete
|
352
|
+
context.delete
|
353
|
+
end
|
354
|
+
|
355
|
+
##
|
356
|
+
# Update the DocumentInstance
|
357
|
+
# @param [Hash] data The data
|
358
|
+
# @return [DocumentInstance] Updated DocumentInstance
|
359
|
+
def update(data: nil)
|
360
|
+
context.update(
|
361
|
+
data: data,
|
362
|
+
)
|
363
|
+
end
|
364
|
+
|
365
|
+
##
|
366
|
+
# Provide a user friendly representation
|
367
|
+
def to_s
|
368
|
+
values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
|
369
|
+
"<Twilio.Preview.Sync.DocumentInstance #{values}>"
|
370
|
+
end
|
371
|
+
end
|
372
|
+
end
|
373
|
+
end
|
374
|
+
end
|
375
|
+
end
|
376
|
+
end
|
@@ -0,0 +1,375 @@
|
|
1
|
+
##
|
2
|
+
# This code was generated by
|
3
|
+
# \ / _ _ _| _ _
|
4
|
+
# | (_)\/(_)(_|\/| |(/_ v1.0.0
|
5
|
+
# / /
|
6
|
+
|
7
|
+
module Twilio
|
8
|
+
module REST
|
9
|
+
class Preview < Domain
|
10
|
+
class Sync < Version
|
11
|
+
class ServiceContext < InstanceContext
|
12
|
+
class SyncListList < ListResource
|
13
|
+
##
|
14
|
+
# Initialize the SyncListList
|
15
|
+
# @param [Version] version Version that contains the resource
|
16
|
+
# @param [String] service_sid The service_sid
|
17
|
+
# @return [SyncListList] SyncListList
|
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]}/Lists"
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# Retrieve a single page of SyncListInstance records from the API.
|
30
|
+
# Request is executed immediately.
|
31
|
+
# @param [String] unique_name The unique_name
|
32
|
+
# @return [SyncListInstance] Newly created SyncListInstance
|
33
|
+
def create(unique_name: nil)
|
34
|
+
data = {
|
35
|
+
'UniqueName' => unique_name,
|
36
|
+
}
|
37
|
+
|
38
|
+
payload = @version.create(
|
39
|
+
'POST',
|
40
|
+
@uri,
|
41
|
+
data: data
|
42
|
+
)
|
43
|
+
|
44
|
+
return SyncListInstance.new(
|
45
|
+
@version,
|
46
|
+
payload,
|
47
|
+
service_sid: @solution[:service_sid],
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
##
|
52
|
+
# Lists SyncListInstance records from the API as a list.
|
53
|
+
# Unlike stream(), this operation is eager and will load `limit` records into
|
54
|
+
# memory before returning.
|
55
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
56
|
+
# guarantees to never return more than limit. Default is no limit
|
57
|
+
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
58
|
+
# the default value of 50 records. If no page_size is defined
|
59
|
+
# but a limit is defined, stream() will attempt to read the
|
60
|
+
# limit with the most efficient page size, i.e. min(limit, 1000)
|
61
|
+
# @return [Array] Array of up to limit results
|
62
|
+
def list(limit: nil, page_size: nil)
|
63
|
+
self.stream(
|
64
|
+
limit: limit,
|
65
|
+
page_size: page_size
|
66
|
+
).entries
|
67
|
+
end
|
68
|
+
|
69
|
+
##
|
70
|
+
# Streams SyncListInstance records from the API as an Enumerable.
|
71
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
72
|
+
# is reached.
|
73
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
74
|
+
# guarantees to never return more than limit. Default is no limit
|
75
|
+
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
76
|
+
# the default value of 50 records. If no page_size is defined
|
77
|
+
# but a limit is defined, stream() will attempt to read the
|
78
|
+
# limit with the most efficient page size, i.e. min(limit, 1000)
|
79
|
+
# @return [Enumerable] Enumerable that will yield up to limit results
|
80
|
+
def stream(limit: nil, page_size: nil)
|
81
|
+
limits = @version.read_limits(limit, page_size)
|
82
|
+
|
83
|
+
page = self.page(
|
84
|
+
page_size: limits[:page_size],
|
85
|
+
)
|
86
|
+
|
87
|
+
@version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
|
88
|
+
end
|
89
|
+
|
90
|
+
##
|
91
|
+
# When passed a block, yields SyncListInstance records from the API.
|
92
|
+
# This operation lazily loads records as efficiently as possible until the limit
|
93
|
+
# is reached.
|
94
|
+
# @param [Integer] limit Upper limit for the number of records to return. stream()
|
95
|
+
# guarantees to never return more than limit. Default is no limit
|
96
|
+
# @param [Integer] page_size Number of records to fetch per request, when not set will use
|
97
|
+
# the default value of 50 records. If no page_size is defined
|
98
|
+
# but a limit is defined, stream() will attempt to read the
|
99
|
+
# limit with the most efficient page size, i.e. min(limit, 1000)
|
100
|
+
def each
|
101
|
+
limits = @version.read_limits
|
102
|
+
|
103
|
+
page = self.page(
|
104
|
+
page_size: limits[:page_size],
|
105
|
+
)
|
106
|
+
|
107
|
+
@version.stream(page,
|
108
|
+
limit: limits[:limit],
|
109
|
+
page_limit: limits[:page_limit]).each {|x| yield x}
|
110
|
+
end
|
111
|
+
|
112
|
+
##
|
113
|
+
# Retrieve a single page of SyncListInstance records from the API.
|
114
|
+
# Request is executed immediately.
|
115
|
+
# @param [String] page_token PageToken provided by the API
|
116
|
+
# @param [Integer] page_number Page Number, this value is simply for client state
|
117
|
+
# @param [Integer] page_size Number of records to return, defaults to 50
|
118
|
+
# @return [Page] Page of SyncListInstance
|
119
|
+
def page(page_token: nil, page_number: nil, page_size: nil)
|
120
|
+
params = {
|
121
|
+
'PageToken' => page_token,
|
122
|
+
'Page' => page_number,
|
123
|
+
'PageSize' => page_size,
|
124
|
+
}
|
125
|
+
response = @version.page(
|
126
|
+
'GET',
|
127
|
+
@uri,
|
128
|
+
params
|
129
|
+
)
|
130
|
+
return SyncListPage.new(@version, response, @solution)
|
131
|
+
end
|
132
|
+
|
133
|
+
##
|
134
|
+
# Provide a user friendly representation
|
135
|
+
def to_s
|
136
|
+
'#<Twilio.Preview.Sync.SyncListList>'
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
class SyncListPage < Page
|
141
|
+
##
|
142
|
+
# Initialize the SyncListPage
|
143
|
+
# @param [Version] version Version that contains the resource
|
144
|
+
# @param [Response] response Response from the API
|
145
|
+
# @param [Hash] solution Path solution for the resource
|
146
|
+
# @param [String] service_sid The service_sid
|
147
|
+
# @return [SyncListPage] SyncListPage
|
148
|
+
def initialize(version, response, solution)
|
149
|
+
super(version, response)
|
150
|
+
|
151
|
+
# Path Solution
|
152
|
+
@solution = solution
|
153
|
+
end
|
154
|
+
|
155
|
+
##
|
156
|
+
# Build an instance of SyncListInstance
|
157
|
+
# @param [Hash] payload Payload response from the API
|
158
|
+
# @return [SyncListInstance] SyncListInstance
|
159
|
+
def get_instance(payload)
|
160
|
+
return SyncListInstance.new(
|
161
|
+
@version,
|
162
|
+
payload,
|
163
|
+
service_sid: @solution[:service_sid],
|
164
|
+
)
|
165
|
+
end
|
166
|
+
|
167
|
+
##
|
168
|
+
# Provide a user friendly representation
|
169
|
+
def to_s
|
170
|
+
'<Twilio.Preview.Sync.SyncListPage>'
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
class SyncListContext < InstanceContext
|
175
|
+
##
|
176
|
+
# Initialize the SyncListContext
|
177
|
+
# @param [Version] version Version that contains the resource
|
178
|
+
# @param [String] service_sid The service_sid
|
179
|
+
# @param [String] sid The sid
|
180
|
+
# @return [SyncListContext] SyncListContext
|
181
|
+
def initialize(version, service_sid, sid)
|
182
|
+
super(version)
|
183
|
+
|
184
|
+
# Path Solution
|
185
|
+
@solution = {
|
186
|
+
service_sid: service_sid,
|
187
|
+
sid: sid,
|
188
|
+
}
|
189
|
+
@uri = "/Services/#{@solution[:service_sid]}/Lists/#{@solution[:sid]}"
|
190
|
+
|
191
|
+
# Dependents
|
192
|
+
@sync_list_items = nil
|
193
|
+
end
|
194
|
+
|
195
|
+
##
|
196
|
+
# Fetch a SyncListInstance
|
197
|
+
# @return [SyncListInstance] Fetched SyncListInstance
|
198
|
+
def fetch
|
199
|
+
params = {}
|
200
|
+
|
201
|
+
payload = @version.fetch(
|
202
|
+
'GET',
|
203
|
+
@uri,
|
204
|
+
params,
|
205
|
+
)
|
206
|
+
|
207
|
+
return SyncListInstance.new(
|
208
|
+
@version,
|
209
|
+
payload,
|
210
|
+
service_sid: @solution[:service_sid],
|
211
|
+
sid: @solution[:sid],
|
212
|
+
)
|
213
|
+
end
|
214
|
+
|
215
|
+
##
|
216
|
+
# Deletes the SyncListInstance
|
217
|
+
# @return [Boolean] true if delete succeeds, true otherwise
|
218
|
+
def delete
|
219
|
+
return @version.delete('delete', @uri)
|
220
|
+
end
|
221
|
+
|
222
|
+
##
|
223
|
+
# Access the sync_list_items
|
224
|
+
# @return [SyncListItemList] SyncListItemList
|
225
|
+
def sync_list_items(index=:unset)
|
226
|
+
if index != :unset
|
227
|
+
return SyncListItemContext.new(
|
228
|
+
@version,
|
229
|
+
@solution[:service_sid],
|
230
|
+
@solution[:sid],
|
231
|
+
index,
|
232
|
+
)
|
233
|
+
end
|
234
|
+
|
235
|
+
unless @sync_list_items
|
236
|
+
@sync_list_items = SyncListItemList.new(
|
237
|
+
@version,
|
238
|
+
service_sid: @solution[:service_sid],
|
239
|
+
list_sid: @solution[:sid],
|
240
|
+
)
|
241
|
+
end
|
242
|
+
|
243
|
+
@sync_list_items
|
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.Preview.Sync.SyncListContext #{context}>"
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
class SyncListInstance < InstanceResource
|
255
|
+
##
|
256
|
+
# Initialize the SyncListInstance
|
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 [SyncListInstance] SyncListInstance
|
262
|
+
def initialize(version, payload, service_sid: nil, sid: nil)
|
263
|
+
super(version)
|
264
|
+
|
265
|
+
# Marshaled Properties
|
266
|
+
@properties = {
|
267
|
+
'sid' => payload['sid'],
|
268
|
+
'unique_name' => payload['unique_name'],
|
269
|
+
'account_sid' => payload['account_sid'],
|
270
|
+
'service_sid' => payload['service_sid'],
|
271
|
+
'url' => payload['url'],
|
272
|
+
'links' => payload['links'],
|
273
|
+
'revision' => payload['revision'],
|
274
|
+
'date_created' => Twilio.deserialize_iso8601(payload['date_created']),
|
275
|
+
'date_updated' => Twilio.deserialize_iso8601(payload['date_updated']),
|
276
|
+
'created_by' => payload['created_by'],
|
277
|
+
}
|
278
|
+
|
279
|
+
# Context
|
280
|
+
@instance_context = nil
|
281
|
+
@params = {
|
282
|
+
'service_sid' => service_sid,
|
283
|
+
'sid' => sid || @properties['sid'],
|
284
|
+
}
|
285
|
+
end
|
286
|
+
|
287
|
+
##
|
288
|
+
# Generate an instance context for the instance, the context is capable of
|
289
|
+
# performing various actions. All instance actions are proxied to the context
|
290
|
+
# @param [Version] version Version that contains the resource
|
291
|
+
# @return [SyncListContext] SyncListContext for this SyncListInstance
|
292
|
+
def context
|
293
|
+
unless @instance_context
|
294
|
+
@instance_context = SyncListContext.new(
|
295
|
+
@version,
|
296
|
+
@params['service_sid'],
|
297
|
+
@params['sid'],
|
298
|
+
)
|
299
|
+
end
|
300
|
+
@instance_context
|
301
|
+
end
|
302
|
+
|
303
|
+
def sid
|
304
|
+
@properties['sid']
|
305
|
+
end
|
306
|
+
|
307
|
+
def unique_name
|
308
|
+
@properties['unique_name']
|
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 url
|
320
|
+
@properties['url']
|
321
|
+
end
|
322
|
+
|
323
|
+
def links
|
324
|
+
@properties['links']
|
325
|
+
end
|
326
|
+
|
327
|
+
def revision
|
328
|
+
@properties['revision']
|
329
|
+
end
|
330
|
+
|
331
|
+
def date_created
|
332
|
+
@properties['date_created']
|
333
|
+
end
|
334
|
+
|
335
|
+
def date_updated
|
336
|
+
@properties['date_updated']
|
337
|
+
end
|
338
|
+
|
339
|
+
def created_by
|
340
|
+
@properties['created_by']
|
341
|
+
end
|
342
|
+
|
343
|
+
##
|
344
|
+
# Fetch a SyncListInstance
|
345
|
+
# @return [SyncListInstance] Fetched SyncListInstance
|
346
|
+
def fetch
|
347
|
+
context.fetch
|
348
|
+
end
|
349
|
+
|
350
|
+
##
|
351
|
+
# Deletes the SyncListInstance
|
352
|
+
# @return [Boolean] true if delete succeeds, true otherwise
|
353
|
+
def delete
|
354
|
+
context.delete
|
355
|
+
end
|
356
|
+
|
357
|
+
##
|
358
|
+
# Access the sync_list_items
|
359
|
+
# @return [sync_list_items] sync_list_items
|
360
|
+
def sync_list_items
|
361
|
+
context.sync_list_items
|
362
|
+
end
|
363
|
+
|
364
|
+
##
|
365
|
+
# Provide a user friendly representation
|
366
|
+
def to_s
|
367
|
+
values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
|
368
|
+
"<Twilio.Preview.Sync.SyncListInstance #{values}>"
|
369
|
+
end
|
370
|
+
end
|
371
|
+
end
|
372
|
+
end
|
373
|
+
end
|
374
|
+
end
|
375
|
+
end
|