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.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHORS.md +1 -0
  3. data/CHANGES.md +1 -1
  4. data/README.md +2 -2
  5. data/lib/twilio-ruby/jwt/access_token.rb +23 -1
  6. data/lib/twilio-ruby/rest/api.rb +2 -2
  7. data/lib/twilio-ruby/rest/api/v2010.rb +2 -2
  8. data/lib/twilio-ruby/rest/api/v2010/account.rb +19 -11
  9. data/lib/twilio-ruby/rest/api/v2010/account/conference/participant.rb +29 -5
  10. data/lib/twilio-ruby/rest/api/v2010/account/message.rb +5 -5
  11. data/lib/twilio-ruby/rest/api/v2010/account/recording.rb +25 -0
  12. data/lib/twilio-ruby/rest/api/v2010/account/short_code.rb +406 -0
  13. data/lib/twilio-ruby/rest/api/v2010/account/sip/credential_list/credential.rb +2 -6
  14. data/lib/twilio-ruby/rest/{notifications.rb → chat.rb} +6 -6
  15. data/lib/twilio-ruby/rest/{notifications → chat}/v1.rb +3 -3
  16. data/lib/twilio-ruby/rest/{notifications → chat}/v1/credential.rb +5 -5
  17. data/lib/twilio-ruby/rest/chat/v1/service.rb +501 -0
  18. data/lib/twilio-ruby/rest/chat/v1/service/channel.rb +468 -0
  19. data/lib/twilio-ruby/rest/chat/v1/service/channel/member.rb +351 -0
  20. data/lib/twilio-ruby/rest/{api/v2010/account/sms/sms_message.rb → chat/v1/service/channel/message.rb} +120 -168
  21. data/lib/twilio-ruby/rest/chat/v1/service/role.rb +373 -0
  22. data/lib/twilio-ruby/rest/chat/v1/service/user.rb +378 -0
  23. data/lib/twilio-ruby/rest/client.rb +19 -8
  24. data/lib/twilio-ruby/rest/ip_messaging/v1/service/channel/message.rb +3 -1
  25. data/lib/twilio-ruby/rest/ip_messaging/v1/service/role.rb +2 -6
  26. data/lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb +5 -1
  27. data/lib/twilio-ruby/rest/lookups/v1/phone_number.rb +5 -0
  28. data/lib/twilio-ruby/rest/notify.rb +44 -0
  29. data/lib/twilio-ruby/rest/notify/v1.rb +44 -0
  30. data/lib/twilio-ruby/rest/notify/v1/credential.rb +375 -0
  31. data/lib/twilio-ruby/rest/{notifications → notify}/v1/service.rb +5 -5
  32. data/lib/twilio-ruby/rest/{notifications → notify}/v1/service/binding.rb +5 -5
  33. data/lib/twilio-ruby/rest/{notifications → notify}/v1/service/notification.rb +4 -4
  34. data/lib/twilio-ruby/rest/preview.rb +11 -0
  35. data/lib/twilio-ruby/rest/preview/sync.rb +35 -0
  36. data/lib/twilio-ruby/rest/preview/sync/service.rb +458 -0
  37. data/lib/twilio-ruby/rest/preview/sync/service/document.rb +376 -0
  38. data/lib/twilio-ruby/rest/preview/sync/service/sync_list.rb +375 -0
  39. data/lib/twilio-ruby/rest/preview/sync/service/sync_list/sync_list_item.rb +409 -0
  40. data/lib/twilio-ruby/rest/preview/sync/service/sync_map.rb +375 -0
  41. data/lib/twilio-ruby/rest/preview/sync/service/sync_map/sync_map_item.rb +411 -0
  42. data/lib/twilio-ruby/rest/preview/wireless/device.rb +6 -2
  43. data/lib/twilio-ruby/rest/taskrouter/v1/workspace.rb +55 -3
  44. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb +29 -6
  45. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_channel.rb +294 -0
  46. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb +32 -0
  47. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb +374 -0
  48. data/lib/twilio-ruby/version.rb +1 -1
  49. data/spec/integration/api/v2010/account/conference/participant_spec.rb +6 -6
  50. data/spec/integration/api/v2010/account/recording_spec.rb +10 -1
  51. data/spec/integration/api/v2010/account/{sms/short_code_spec.rb → short_code_spec.rb} +0 -7
  52. data/spec/integration/api/v2010/account/sip/credential_list/credential_spec.rb +3 -7
  53. data/spec/integration/chat/v1/credential_spec.rb +223 -0
  54. data/spec/integration/chat/v1/service/channel/member_spec.rb +213 -0
  55. data/spec/integration/chat/v1/service/channel/message_spec.rb +100 -0
  56. data/spec/integration/chat/v1/service/channel_spec.rb +259 -0
  57. data/spec/integration/chat/v1/service/role_spec.rb +263 -0
  58. data/spec/integration/chat/v1/service/user_spec.rb +242 -0
  59. data/spec/integration/chat/v1/service_spec.rb +263 -0
  60. data/spec/integration/ip_messaging/v1/service/role_spec.rb +2 -3
  61. data/spec/integration/ip_messaging/v1/service/user_spec.rb +2 -3
  62. data/spec/integration/lookups/v1/phone_number_spec.rb +5 -0
  63. data/spec/integration/{notifications → notify}/v1/credential_spec.rb +24 -24
  64. data/spec/integration/{notifications → notify}/v1/service/binding_spec.rb +29 -29
  65. data/spec/integration/{notifications → notify}/v1/service/notification_spec.rb +5 -5
  66. data/spec/integration/{notifications → notify}/v1/service_spec.rb +32 -32
  67. data/spec/integration/preview/sync/service/document_spec.rb +92 -0
  68. data/spec/integration/preview/sync/service/sync_list/sync_list_item_spec.rb +100 -0
  69. data/spec/integration/preview/sync/service/sync_list_spec.rb +73 -0
  70. data/spec/integration/preview/sync/service/sync_map/sync_map_item_spec.rb +101 -0
  71. data/spec/integration/preview/sync/service/sync_map_spec.rb +73 -0
  72. data/spec/integration/preview/sync/service_spec.rb +84 -0
  73. data/spec/integration/taskrouter/v1/workspace/task_channel_spec.rb +127 -0
  74. data/spec/integration/taskrouter/v1/workspace/task_spec.rb +8 -0
  75. data/spec/integration/taskrouter/v1/workspace/worker/worker_channel_spec.rb +201 -0
  76. data/spec/integration/taskrouter/v1/workspace/workflow_spec.rb +2 -3
  77. data/spec/integration/taskrouter/v1/workspace_spec.rb +8 -0
  78. data/spec/jwt/access_token_spec.rb +27 -0
  79. metadata +84 -42
  80. data/lib/twilio-ruby/rest/api/v2010/account/sms.rb +0 -134
  81. data/lib/twilio-ruby/rest/api/v2010/account/sms/short_code.rb +0 -408
  82. data/spec/integration/api/v2010/account/sms/sms_message_spec.rb +0 -275
  83. data/spec/integration/api/v2010/account/sms_spec.rb +0 -10
@@ -0,0 +1,468 @@
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 ChannelList < ListResource
13
+ ##
14
+ # Initialize the ChannelList
15
+ # @param [Version] version Version that contains the resource
16
+ # @param [String] service_sid The service_sid
17
+ # @return [ChannelList] ChannelList
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]}/Channels"
26
+ end
27
+
28
+ ##
29
+ # Retrieve a single page of ChannelInstance records from the API.
30
+ # Request is executed immediately.
31
+ # @param [String] friendly_name The friendly_name
32
+ # @param [String] unique_name The unique_name
33
+ # @param [Hash] attributes The attributes
34
+ # @param [channel.ChannelType] type The type
35
+ # @return [ChannelInstance] Newly created ChannelInstance
36
+ def create(friendly_name: nil, unique_name: nil, attributes: nil, type: nil)
37
+ data = {
38
+ 'FriendlyName' => friendly_name,
39
+ 'UniqueName' => unique_name,
40
+ 'Attributes' => attributes,
41
+ 'Type' => type,
42
+ }
43
+
44
+ payload = @version.create(
45
+ 'POST',
46
+ @uri,
47
+ data: data
48
+ )
49
+
50
+ return ChannelInstance.new(
51
+ @version,
52
+ payload,
53
+ service_sid: @solution[:service_sid],
54
+ )
55
+ end
56
+
57
+ ##
58
+ # Lists ChannelInstance 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 ChannelInstance 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 ChannelInstance 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 ChannelInstance 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 ChannelInstance
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 ChannelPage.new(@version, response, @solution)
137
+ end
138
+
139
+ ##
140
+ # Provide a user friendly representation
141
+ def to_s
142
+ '#<Twilio.Chat.V1.ChannelList>'
143
+ end
144
+ end
145
+
146
+ class ChannelPage < Page
147
+ ##
148
+ # Initialize the ChannelPage
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 [ChannelPage] ChannelPage
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 ChannelInstance
163
+ # @param [Hash] payload Payload response from the API
164
+ # @return [ChannelInstance] ChannelInstance
165
+ def get_instance(payload)
166
+ return ChannelInstance.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.ChannelPage>'
177
+ end
178
+ end
179
+
180
+ class ChannelContext < InstanceContext
181
+ ##
182
+ # Initialize the ChannelContext
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 [ChannelContext] ChannelContext
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]}/Channels/#{@solution[:sid]}"
196
+
197
+ # Dependents
198
+ @members = nil
199
+ @messages = nil
200
+ end
201
+
202
+ ##
203
+ # Fetch a ChannelInstance
204
+ # @return [ChannelInstance] Fetched ChannelInstance
205
+ def fetch
206
+ params = {}
207
+
208
+ payload = @version.fetch(
209
+ 'GET',
210
+ @uri,
211
+ params,
212
+ )
213
+
214
+ return ChannelInstance.new(
215
+ @version,
216
+ payload,
217
+ service_sid: @solution[:service_sid],
218
+ sid: @solution[:sid],
219
+ )
220
+ end
221
+
222
+ ##
223
+ # Deletes the ChannelInstance
224
+ # @return [Boolean] true if delete succeeds, true otherwise
225
+ def delete
226
+ return @version.delete('delete', @uri)
227
+ end
228
+
229
+ ##
230
+ # Update the ChannelInstance
231
+ # @param [String] friendly_name The friendly_name
232
+ # @param [String] unique_name The unique_name
233
+ # @param [Hash] attributes The attributes
234
+ # @param [channel.ChannelType] type The type
235
+ # @return [ChannelInstance] Updated ChannelInstance
236
+ def update(friendly_name: nil, unique_name: nil, attributes: nil, type: nil)
237
+ data = {
238
+ 'FriendlyName' => friendly_name,
239
+ 'UniqueName' => unique_name,
240
+ 'Attributes' => attributes,
241
+ 'Type' => type,
242
+ }
243
+
244
+ payload = @version.update(
245
+ 'POST',
246
+ @uri,
247
+ data: data,
248
+ )
249
+
250
+ return ChannelInstance.new(
251
+ @version,
252
+ payload,
253
+ service_sid: @solution[:service_sid],
254
+ sid: @solution[:sid],
255
+ )
256
+ end
257
+
258
+ ##
259
+ # Access the members
260
+ # @return [MemberList] MemberList
261
+ def members(sid=:unset)
262
+ if sid != :unset
263
+ return MemberContext.new(
264
+ @version,
265
+ @solution[:service_sid],
266
+ @solution[:sid],
267
+ sid,
268
+ )
269
+ end
270
+
271
+ unless @members
272
+ @members = MemberList.new(
273
+ @version,
274
+ service_sid: @solution[:service_sid],
275
+ channel_sid: @solution[:sid],
276
+ )
277
+ end
278
+
279
+ @members
280
+ end
281
+
282
+ ##
283
+ # Access the messages
284
+ # @return [MessageList] MessageList
285
+ def messages(sid=:unset)
286
+ if sid != :unset
287
+ return MessageContext.new(
288
+ @version,
289
+ @solution[:service_sid],
290
+ @solution[:sid],
291
+ sid,
292
+ )
293
+ end
294
+
295
+ unless @messages
296
+ @messages = MessageList.new(
297
+ @version,
298
+ service_sid: @solution[:service_sid],
299
+ channel_sid: @solution[:sid],
300
+ )
301
+ end
302
+
303
+ @messages
304
+ end
305
+
306
+ ##
307
+ # Provide a user friendly representation
308
+ def to_s
309
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
310
+ "#<Twilio.Chat.V1.ChannelContext #{context}>"
311
+ end
312
+ end
313
+
314
+ class ChannelInstance < InstanceResource
315
+ ##
316
+ # Initialize the ChannelInstance
317
+ # @param [Version] version Version that contains the resource
318
+ # @param [Hash] payload payload that contains response from Twilio
319
+ # @param [String] service_sid The service_sid
320
+ # @param [String] sid The sid
321
+ # @return [ChannelInstance] ChannelInstance
322
+ def initialize(version, payload, service_sid: nil, sid: nil)
323
+ super(version)
324
+
325
+ # Marshaled Properties
326
+ @properties = {
327
+ 'sid' => payload['sid'],
328
+ 'account_sid' => payload['account_sid'],
329
+ 'service_sid' => payload['service_sid'],
330
+ 'friendly_name' => payload['friendly_name'],
331
+ 'unique_name' => payload['unique_name'],
332
+ 'attributes' => payload['attributes'],
333
+ 'type' => payload['type'],
334
+ 'date_created' => Twilio.deserialize_iso8601(payload['date_created']),
335
+ 'date_updated' => Twilio.deserialize_iso8601(payload['date_updated']),
336
+ 'created_by' => payload['created_by'],
337
+ 'url' => payload['url'],
338
+ 'links' => payload['links'],
339
+ }
340
+
341
+ # Context
342
+ @instance_context = nil
343
+ @params = {
344
+ 'service_sid' => service_sid,
345
+ 'sid' => sid || @properties['sid'],
346
+ }
347
+ end
348
+
349
+ ##
350
+ # Generate an instance context for the instance, the context is capable of
351
+ # performing various actions. All instance actions are proxied to the context
352
+ # @param [Version] version Version that contains the resource
353
+ # @return [ChannelContext] ChannelContext for this ChannelInstance
354
+ def context
355
+ unless @instance_context
356
+ @instance_context = ChannelContext.new(
357
+ @version,
358
+ @params['service_sid'],
359
+ @params['sid'],
360
+ )
361
+ end
362
+ @instance_context
363
+ end
364
+
365
+ def sid
366
+ @properties['sid']
367
+ end
368
+
369
+ def account_sid
370
+ @properties['account_sid']
371
+ end
372
+
373
+ def service_sid
374
+ @properties['service_sid']
375
+ end
376
+
377
+ def friendly_name
378
+ @properties['friendly_name']
379
+ end
380
+
381
+ def unique_name
382
+ @properties['unique_name']
383
+ end
384
+
385
+ def attributes
386
+ @properties['attributes']
387
+ end
388
+
389
+ def type
390
+ @properties['type']
391
+ end
392
+
393
+ def date_created
394
+ @properties['date_created']
395
+ end
396
+
397
+ def date_updated
398
+ @properties['date_updated']
399
+ end
400
+
401
+ def created_by
402
+ @properties['created_by']
403
+ end
404
+
405
+ def url
406
+ @properties['url']
407
+ end
408
+
409
+ def links
410
+ @properties['links']
411
+ end
412
+
413
+ ##
414
+ # Fetch a ChannelInstance
415
+ # @return [ChannelInstance] Fetched ChannelInstance
416
+ def fetch
417
+ context.fetch
418
+ end
419
+
420
+ ##
421
+ # Deletes the ChannelInstance
422
+ # @return [Boolean] true if delete succeeds, true otherwise
423
+ def delete
424
+ context.delete
425
+ end
426
+
427
+ ##
428
+ # Update the ChannelInstance
429
+ # @param [String] friendly_name The friendly_name
430
+ # @param [String] unique_name The unique_name
431
+ # @param [Hash] attributes The attributes
432
+ # @param [channel.ChannelType] type The type
433
+ # @return [ChannelInstance] Updated ChannelInstance
434
+ def update(friendly_name: nil, unique_name: nil, attributes: nil, type: nil)
435
+ context.update(
436
+ friendly_name: friendly_name,
437
+ unique_name: unique_name,
438
+ attributes: attributes,
439
+ type: type,
440
+ )
441
+ end
442
+
443
+ ##
444
+ # Access the members
445
+ # @return [members] members
446
+ def members
447
+ context.members
448
+ end
449
+
450
+ ##
451
+ # Access the messages
452
+ # @return [messages] messages
453
+ def messages
454
+ context.messages
455
+ end
456
+
457
+ ##
458
+ # Provide a user friendly representation
459
+ def to_s
460
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
461
+ "<Twilio.Chat.V1.ChannelInstance #{values}>"
462
+ end
463
+ end
464
+ end
465
+ end
466
+ end
467
+ end
468
+ end