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
@@ -115,12 +115,16 @@ module Twilio
115
115
  # Request is executed immediately.
116
116
  # @param [String] friendly_name The friendly_name
117
117
  # @param [String] event_callback_url The event_callback_url
118
+ # @param [String] events_filter The events_filter
119
+ # @param [Boolean] multi_task_enabled The multi_task_enabled
118
120
  # @param [String] template The template
119
121
  # @return [WorkspaceInstance] Newly created WorkspaceInstance
120
- def create(friendly_name: nil, event_callback_url: nil, template: nil)
122
+ def create(friendly_name: nil, event_callback_url: nil, events_filter: nil, multi_task_enabled: nil, template: nil)
121
123
  data = {
122
124
  'FriendlyName' => friendly_name,
123
125
  'EventCallbackUrl' => event_callback_url,
126
+ 'EventsFilter' => events_filter,
127
+ 'MultiTaskEnabled' => multi_task_enabled,
124
128
  'Template' => template,
125
129
  }
126
130
 
@@ -198,6 +202,7 @@ module Twilio
198
202
  @workers = nil
199
203
  @workflows = nil
200
204
  @statistics = nil
205
+ @task_channels = nil
201
206
  end
202
207
 
203
208
  ##
@@ -223,14 +228,18 @@ module Twilio
223
228
  # Update the WorkspaceInstance
224
229
  # @param [String] default_activity_sid The default_activity_sid
225
230
  # @param [String] event_callback_url The event_callback_url
231
+ # @param [String] events_filter The events_filter
226
232
  # @param [String] friendly_name The friendly_name
233
+ # @param [Boolean] multi_task_enabled The multi_task_enabled
227
234
  # @param [String] timeout_activity_sid The timeout_activity_sid
228
235
  # @return [WorkspaceInstance] Updated WorkspaceInstance
229
- def update(default_activity_sid: nil, event_callback_url: nil, friendly_name: nil, timeout_activity_sid: nil)
236
+ def update(default_activity_sid: nil, event_callback_url: nil, events_filter: nil, friendly_name: nil, multi_task_enabled: nil, timeout_activity_sid: nil)
230
237
  data = {
231
238
  'DefaultActivitySid' => default_activity_sid,
232
239
  'EventCallbackUrl' => event_callback_url,
240
+ 'EventsFilter' => events_filter,
233
241
  'FriendlyName' => friendly_name,
242
+ 'MultiTaskEnabled' => multi_task_enabled,
234
243
  'TimeoutActivitySid' => timeout_activity_sid,
235
244
  }
236
245
 
@@ -396,6 +405,28 @@ module Twilio
396
405
  )
397
406
  end
398
407
 
408
+ ##
409
+ # Access the task_channels
410
+ # @return [TaskChannelList] TaskChannelList
411
+ def task_channels(sid=:unset)
412
+ if sid != :unset
413
+ return TaskChannelContext.new(
414
+ @version,
415
+ @solution[:sid],
416
+ sid,
417
+ )
418
+ end
419
+
420
+ unless @task_channels
421
+ @task_channels = TaskChannelList.new(
422
+ @version,
423
+ workspace_sid: @solution[:sid],
424
+ )
425
+ end
426
+
427
+ @task_channels
428
+ end
429
+
399
430
  ##
400
431
  # Provide a user friendly representation
401
432
  def to_s
@@ -422,7 +453,9 @@ module Twilio
422
453
  'default_activity_name' => payload['default_activity_name'],
423
454
  'default_activity_sid' => payload['default_activity_sid'],
424
455
  'event_callback_url' => payload['event_callback_url'],
456
+ 'events_filter' => payload['events_filter'],
425
457
  'friendly_name' => payload['friendly_name'],
458
+ 'multi_task_enabled' => payload['multi_task_enabled'],
426
459
  'sid' => payload['sid'],
427
460
  'timeout_activity_name' => payload['timeout_activity_name'],
428
461
  'timeout_activity_sid' => payload['timeout_activity_sid'],
@@ -474,10 +507,18 @@ module Twilio
474
507
  @properties['event_callback_url']
475
508
  end
476
509
 
510
+ def events_filter
511
+ @properties['events_filter']
512
+ end
513
+
477
514
  def friendly_name
478
515
  @properties['friendly_name']
479
516
  end
480
517
 
518
+ def multi_task_enabled
519
+ @properties['multi_task_enabled']
520
+ end
521
+
481
522
  def sid
482
523
  @properties['sid']
483
524
  end
@@ -501,14 +542,18 @@ module Twilio
501
542
  # Update the WorkspaceInstance
502
543
  # @param [String] default_activity_sid The default_activity_sid
503
544
  # @param [String] event_callback_url The event_callback_url
545
+ # @param [String] events_filter The events_filter
504
546
  # @param [String] friendly_name The friendly_name
547
+ # @param [Boolean] multi_task_enabled The multi_task_enabled
505
548
  # @param [String] timeout_activity_sid The timeout_activity_sid
506
549
  # @return [WorkspaceInstance] Updated WorkspaceInstance
507
- def update(default_activity_sid: nil, event_callback_url: nil, friendly_name: nil, timeout_activity_sid: nil)
550
+ def update(default_activity_sid: nil, event_callback_url: nil, events_filter: nil, friendly_name: nil, multi_task_enabled: nil, timeout_activity_sid: nil)
508
551
  context.update(
509
552
  default_activity_sid: default_activity_sid,
510
553
  event_callback_url: event_callback_url,
554
+ events_filter: events_filter,
511
555
  friendly_name: friendly_name,
556
+ multi_task_enabled: multi_task_enabled,
512
557
  timeout_activity_sid: timeout_activity_sid,
513
558
  )
514
559
  end
@@ -569,6 +614,13 @@ module Twilio
569
614
  context.statistics
570
615
  end
571
616
 
617
+ ##
618
+ # Access the task_channels
619
+ # @return [task_channels] task_channels
620
+ def task_channels
621
+ context.task_channels
622
+ end
623
+
572
624
  ##
573
625
  # Provide a user friendly representation
574
626
  def to_s
@@ -35,6 +35,7 @@ module Twilio
35
35
  # @param [String] workflow_name The workflow_name
36
36
  # @param [String] task_queue_sid The task_queue_sid
37
37
  # @param [String] task_queue_name The task_queue_name
38
+ # @param [String] task_channel The task_channel
38
39
  # @param [Integer] limit Upper limit for the number of records to return. stream()
39
40
  # guarantees to never return more than limit. Default is no limit
40
41
  # @param [Integer] page_size Number of records to fetch per request, when not set will use
@@ -42,7 +43,7 @@ module Twilio
42
43
  # but a limit is defined, stream() will attempt to read the
43
44
  # limit with the most efficient page size, i.e. min(limit, 1000)
44
45
  # @return [Array] Array of up to limit results
45
- def list(priority: nil, assignment_status: nil, workflow_sid: nil, workflow_name: nil, task_queue_sid: nil, task_queue_name: nil, limit: nil, page_size: nil)
46
+ def list(priority: nil, assignment_status: nil, workflow_sid: nil, workflow_name: nil, task_queue_sid: nil, task_queue_name: nil, task_channel: nil, limit: nil, page_size: nil)
46
47
  self.stream(
47
48
  priority: priority,
48
49
  assignment_status: assignment_status,
@@ -50,6 +51,7 @@ module Twilio
50
51
  workflow_name: workflow_name,
51
52
  task_queue_sid: task_queue_sid,
52
53
  task_queue_name: task_queue_name,
54
+ task_channel: task_channel,
53
55
  limit: limit,
54
56
  page_size: page_size
55
57
  ).entries
@@ -65,6 +67,7 @@ module Twilio
65
67
  # @param [String] workflow_name The workflow_name
66
68
  # @param [String] task_queue_sid The task_queue_sid
67
69
  # @param [String] task_queue_name The task_queue_name
70
+ # @param [String] task_channel The task_channel
68
71
  # @param [Integer] limit Upper limit for the number of records to return. stream()
69
72
  # guarantees to never return more than limit. Default is no limit
70
73
  # @param [Integer] page_size Number of records to fetch per request, when not set will use
@@ -72,7 +75,7 @@ module Twilio
72
75
  # but a limit is defined, stream() will attempt to read the
73
76
  # limit with the most efficient page size, i.e. min(limit, 1000)
74
77
  # @return [Enumerable] Enumerable that will yield up to limit results
75
- def stream(priority: nil, assignment_status: nil, workflow_sid: nil, workflow_name: nil, task_queue_sid: nil, task_queue_name: nil, limit: nil, page_size: nil)
78
+ def stream(priority: nil, assignment_status: nil, workflow_sid: nil, workflow_name: nil, task_queue_sid: nil, task_queue_name: nil, task_channel: nil, limit: nil, page_size: nil)
76
79
  limits = @version.read_limits(limit, page_size)
77
80
 
78
81
  page = self.page(
@@ -82,6 +85,7 @@ module Twilio
82
85
  workflow_name: workflow_name,
83
86
  task_queue_sid: task_queue_sid,
84
87
  task_queue_name: task_queue_name,
88
+ task_channel: task_channel,
85
89
  page_size: limits[:page_size],
86
90
  )
87
91
 
@@ -98,6 +102,7 @@ module Twilio
98
102
  # @param [String] workflow_name The workflow_name
99
103
  # @param [String] task_queue_sid The task_queue_sid
100
104
  # @param [String] task_queue_name The task_queue_name
105
+ # @param [String] task_channel The task_channel
101
106
  # @param [Integer] limit Upper limit for the number of records to return. stream()
102
107
  # guarantees to never return more than limit. Default is no limit
103
108
  # @param [Integer] page_size Number of records to fetch per request, when not set will use
@@ -125,11 +130,12 @@ module Twilio
125
130
  # @param [String] workflow_name The workflow_name
126
131
  # @param [String] task_queue_sid The task_queue_sid
127
132
  # @param [String] task_queue_name The task_queue_name
133
+ # @param [String] task_channel The task_channel
128
134
  # @param [String] page_token PageToken provided by the API
129
135
  # @param [Integer] page_number Page Number, this value is simply for client state
130
136
  # @param [Integer] page_size Number of records to return, defaults to 50
131
137
  # @return [Page] Page of TaskInstance
132
- def page(priority: nil, assignment_status: nil, workflow_sid: nil, workflow_name: nil, task_queue_sid: nil, task_queue_name: nil, page_token: nil, page_number: nil, page_size: nil)
138
+ def page(priority: nil, assignment_status: nil, workflow_sid: nil, workflow_name: nil, task_queue_sid: nil, task_queue_name: nil, task_channel: nil, page_token: nil, page_number: nil, page_size: nil)
133
139
  params = {
134
140
  'Priority' => priority,
135
141
  'AssignmentStatus' => assignment_status,
@@ -137,6 +143,7 @@ module Twilio
137
143
  'WorkflowName' => workflow_name,
138
144
  'TaskQueueSid' => task_queue_sid,
139
145
  'TaskQueueName' => task_queue_name,
146
+ 'TaskChannel' => task_channel,
140
147
  'PageToken' => page_token,
141
148
  'Page' => page_number,
142
149
  'PageSize' => page_size,
@@ -156,13 +163,15 @@ module Twilio
156
163
  # @param [String] workflow_sid The workflow_sid
157
164
  # @param [String] timeout The timeout
158
165
  # @param [String] priority The priority
166
+ # @param [String] task_channel The task_channel
159
167
  # @return [TaskInstance] Newly created TaskInstance
160
- def create(attributes: nil, workflow_sid: nil, timeout: nil, priority: nil)
168
+ def create(attributes: nil, workflow_sid: nil, timeout: nil, priority: nil, task_channel: nil)
161
169
  data = {
162
170
  'Attributes' => attributes,
163
171
  'WorkflowSid' => workflow_sid,
164
172
  'Timeout' => timeout,
165
173
  'Priority' => priority,
174
+ 'TaskChannel' => task_channel,
166
175
  }
167
176
 
168
177
  payload = @version.create(
@@ -266,13 +275,15 @@ module Twilio
266
275
  # @param [task.Status] assignment_status The assignment_status
267
276
  # @param [String] reason The reason
268
277
  # @param [String] priority The priority
278
+ # @param [String] task_channel The task_channel
269
279
  # @return [TaskInstance] Updated TaskInstance
270
- def update(attributes: nil, assignment_status: nil, reason: nil, priority: nil)
280
+ def update(attributes: nil, assignment_status: nil, reason: nil, priority: nil, task_channel: nil)
271
281
  data = {
272
282
  'Attributes' => attributes,
273
283
  'AssignmentStatus' => assignment_status,
274
284
  'Reason' => reason,
275
285
  'Priority' => priority,
286
+ 'TaskChannel' => task_channel,
276
287
  }
277
288
 
278
289
  payload = @version.update(
@@ -351,6 +362,8 @@ module Twilio
351
362
  'reason' => payload['reason'],
352
363
  'sid' => payload['sid'],
353
364
  'task_queue_sid' => payload['task_queue_sid'],
365
+ 'task_channel_sid' => payload['task_channel_sid'],
366
+ 'task_channel_unique_name' => payload['task_channel_unique_name'],
354
367
  'timeout' => payload['timeout'].to_i,
355
368
  'workflow_sid' => payload['workflow_sid'],
356
369
  'workspace_sid' => payload['workspace_sid'],
@@ -420,6 +433,14 @@ module Twilio
420
433
  @properties['task_queue_sid']
421
434
  end
422
435
 
436
+ def task_channel_sid
437
+ @properties['task_channel_sid']
438
+ end
439
+
440
+ def task_channel_unique_name
441
+ @properties['task_channel_unique_name']
442
+ end
443
+
423
444
  def timeout
424
445
  @properties['timeout']
425
446
  end
@@ -445,13 +466,15 @@ module Twilio
445
466
  # @param [reservation.Status] assignment_status The assignment_status
446
467
  # @param [String] reason The reason
447
468
  # @param [String] priority The priority
469
+ # @param [String] task_channel The task_channel
448
470
  # @return [TaskInstance] Updated TaskInstance
449
- def update(attributes: nil, assignment_status: nil, reason: nil, priority: nil)
471
+ def update(attributes: nil, assignment_status: nil, reason: nil, priority: nil, task_channel: nil)
450
472
  context.update(
451
473
  attributes: attributes,
452
474
  assignment_status: assignment_status,
453
475
  reason: reason,
454
476
  priority: priority,
477
+ task_channel: task_channel,
455
478
  )
456
479
  end
457
480
 
@@ -0,0 +1,294 @@
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 TaskChannelList < ListResource
13
+ ##
14
+ # Initialize the TaskChannelList
15
+ # @param [Version] version Version that contains the resource
16
+ # @param [String] workspace_sid The workspace_sid
17
+ # @return [TaskChannelList] TaskChannelList
18
+ def initialize(version, workspace_sid: nil)
19
+ super(version)
20
+
21
+ # Path Solution
22
+ @solution = {
23
+ workspace_sid: workspace_sid
24
+ }
25
+ @uri = "/Workspaces/#{@solution[:workspace_sid]}/TaskChannels"
26
+ end
27
+
28
+ ##
29
+ # Lists TaskChannelInstance records from the API as a list.
30
+ # Unlike stream(), this operation is eager and will load `limit` records into
31
+ # memory before returning.
32
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
33
+ # guarantees to never return more than limit. Default is no limit
34
+ # @param [Integer] page_size Number of records to fetch per request, when not set will use
35
+ # the default value of 50 records. If no page_size is defined
36
+ # but a limit is defined, stream() will attempt to read the
37
+ # limit with the most efficient page size, i.e. min(limit, 1000)
38
+ # @return [Array] Array of up to limit results
39
+ def list(limit: nil, page_size: nil)
40
+ self.stream(
41
+ limit: limit,
42
+ page_size: page_size
43
+ ).entries
44
+ end
45
+
46
+ ##
47
+ # Streams TaskChannelInstance records from the API as an Enumerable.
48
+ # This operation lazily loads records as efficiently as possible until the limit
49
+ # is reached.
50
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
51
+ # guarantees to never return more than limit. Default is no limit
52
+ # @param [Integer] page_size Number of records to fetch per request, when not set will use
53
+ # the default value of 50 records. If no page_size is defined
54
+ # but a limit is defined, stream() will attempt to read the
55
+ # limit with the most efficient page size, i.e. min(limit, 1000)
56
+ # @return [Enumerable] Enumerable that will yield up to limit results
57
+ def stream(limit: nil, page_size: nil)
58
+ limits = @version.read_limits(limit, page_size)
59
+
60
+ page = self.page(
61
+ page_size: limits[:page_size],
62
+ )
63
+
64
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
65
+ end
66
+
67
+ ##
68
+ # When passed a block, yields TaskChannelInstance records from the API.
69
+ # This operation lazily loads records as efficiently as possible until the limit
70
+ # is reached.
71
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
72
+ # guarantees to never return more than limit. Default is no limit
73
+ # @param [Integer] page_size Number of records to fetch per request, when not set will use
74
+ # the default value of 50 records. If no page_size is defined
75
+ # but a limit is defined, stream() will attempt to read the
76
+ # limit with the most efficient page size, i.e. min(limit, 1000)
77
+ def each
78
+ limits = @version.read_limits
79
+
80
+ page = self.page(
81
+ page_size: limits[:page_size],
82
+ )
83
+
84
+ @version.stream(page,
85
+ limit: limits[:limit],
86
+ page_limit: limits[:page_limit]).each {|x| yield x}
87
+ end
88
+
89
+ ##
90
+ # Retrieve a single page of TaskChannelInstance records from the API.
91
+ # Request is executed immediately.
92
+ # @param [String] page_token PageToken provided by the API
93
+ # @param [Integer] page_number Page Number, this value is simply for client state
94
+ # @param [Integer] page_size Number of records to return, defaults to 50
95
+ # @return [Page] Page of TaskChannelInstance
96
+ def page(page_token: nil, page_number: nil, page_size: nil)
97
+ params = {
98
+ 'PageToken' => page_token,
99
+ 'Page' => page_number,
100
+ 'PageSize' => page_size,
101
+ }
102
+ response = @version.page(
103
+ 'GET',
104
+ @uri,
105
+ params
106
+ )
107
+ return TaskChannelPage.new(@version, response, @solution)
108
+ end
109
+
110
+ ##
111
+ # Provide a user friendly representation
112
+ def to_s
113
+ '#<Twilio.Taskrouter.V1.TaskChannelList>'
114
+ end
115
+ end
116
+
117
+ class TaskChannelPage < Page
118
+ ##
119
+ # Initialize the TaskChannelPage
120
+ # @param [Version] version Version that contains the resource
121
+ # @param [Response] response Response from the API
122
+ # @param [Hash] solution Path solution for the resource
123
+ # @param [String] workspace_sid The workspace_sid
124
+ # @return [TaskChannelPage] TaskChannelPage
125
+ def initialize(version, response, solution)
126
+ super(version, response)
127
+
128
+ # Path Solution
129
+ @solution = solution
130
+ end
131
+
132
+ ##
133
+ # Build an instance of TaskChannelInstance
134
+ # @param [Hash] payload Payload response from the API
135
+ # @return [TaskChannelInstance] TaskChannelInstance
136
+ def get_instance(payload)
137
+ return TaskChannelInstance.new(
138
+ @version,
139
+ payload,
140
+ workspace_sid: @solution[:workspace_sid],
141
+ )
142
+ end
143
+
144
+ ##
145
+ # Provide a user friendly representation
146
+ def to_s
147
+ '<Twilio.Taskrouter.V1.TaskChannelPage>'
148
+ end
149
+ end
150
+
151
+ class TaskChannelContext < InstanceContext
152
+ ##
153
+ # Initialize the TaskChannelContext
154
+ # @param [Version] version Version that contains the resource
155
+ # @param [String] workspace_sid The workspace_sid
156
+ # @param [String] sid The sid
157
+ # @return [TaskChannelContext] TaskChannelContext
158
+ def initialize(version, workspace_sid, sid)
159
+ super(version)
160
+
161
+ # Path Solution
162
+ @solution = {
163
+ workspace_sid: workspace_sid,
164
+ sid: sid,
165
+ }
166
+ @uri = "/Workspaces/#{@solution[:workspace_sid]}/TaskChannels/#{@solution[:sid]}"
167
+ end
168
+
169
+ ##
170
+ # Fetch a TaskChannelInstance
171
+ # @return [TaskChannelInstance] Fetched TaskChannelInstance
172
+ def fetch
173
+ params = {}
174
+
175
+ payload = @version.fetch(
176
+ 'GET',
177
+ @uri,
178
+ params,
179
+ )
180
+
181
+ return TaskChannelInstance.new(
182
+ @version,
183
+ payload,
184
+ workspace_sid: @solution[:workspace_sid],
185
+ sid: @solution[:sid],
186
+ )
187
+ end
188
+
189
+ ##
190
+ # Provide a user friendly representation
191
+ def to_s
192
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
193
+ "#<Twilio.Taskrouter.V1.TaskChannelContext #{context}>"
194
+ end
195
+ end
196
+
197
+ class TaskChannelInstance < InstanceResource
198
+ ##
199
+ # Initialize the TaskChannelInstance
200
+ # @param [Version] version Version that contains the resource
201
+ # @param [Hash] payload payload that contains response from Twilio
202
+ # @param [String] workspace_sid The workspace_sid
203
+ # @param [String] sid The sid
204
+ # @return [TaskChannelInstance] TaskChannelInstance
205
+ def initialize(version, payload, workspace_sid: nil, sid: nil)
206
+ super(version)
207
+
208
+ # Marshaled Properties
209
+ @properties = {
210
+ 'account_sid' => payload['account_sid'],
211
+ 'date_created' => Twilio.deserialize_iso8601(payload['date_created']),
212
+ 'date_updated' => Twilio.deserialize_iso8601(payload['date_updated']),
213
+ 'friendly_name' => payload['friendly_name'],
214
+ 'sid' => payload['sid'],
215
+ 'unique_name' => payload['unique_name'],
216
+ 'workspace_sid' => payload['workspace_sid'],
217
+ 'url' => payload['url'],
218
+ }
219
+
220
+ # Context
221
+ @instance_context = nil
222
+ @params = {
223
+ 'workspace_sid' => workspace_sid,
224
+ 'sid' => sid || @properties['sid'],
225
+ }
226
+ end
227
+
228
+ ##
229
+ # Generate an instance context for the instance, the context is capable of
230
+ # performing various actions. All instance actions are proxied to the context
231
+ # @param [Version] version Version that contains the resource
232
+ # @return [TaskChannelContext] TaskChannelContext for this TaskChannelInstance
233
+ def context
234
+ unless @instance_context
235
+ @instance_context = TaskChannelContext.new(
236
+ @version,
237
+ @params['workspace_sid'],
238
+ @params['sid'],
239
+ )
240
+ end
241
+ @instance_context
242
+ end
243
+
244
+ def account_sid
245
+ @properties['account_sid']
246
+ end
247
+
248
+ def date_created
249
+ @properties['date_created']
250
+ end
251
+
252
+ def date_updated
253
+ @properties['date_updated']
254
+ end
255
+
256
+ def friendly_name
257
+ @properties['friendly_name']
258
+ end
259
+
260
+ def sid
261
+ @properties['sid']
262
+ end
263
+
264
+ def unique_name
265
+ @properties['unique_name']
266
+ end
267
+
268
+ def workspace_sid
269
+ @properties['workspace_sid']
270
+ end
271
+
272
+ def url
273
+ @properties['url']
274
+ end
275
+
276
+ ##
277
+ # Fetch a TaskChannelInstance
278
+ # @return [TaskChannelInstance] Fetched TaskChannelInstance
279
+ def fetch
280
+ context.fetch
281
+ end
282
+
283
+ ##
284
+ # Provide a user friendly representation
285
+ def to_s
286
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
287
+ "<Twilio.Taskrouter.V1.TaskChannelInstance #{values}>"
288
+ end
289
+ end
290
+ end
291
+ end
292
+ end
293
+ end
294
+ end