twilio-ruby 5.31.4 → 5.31.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +9 -0
  3. data/.rubocop_todo.yml +0 -11
  4. data/CHANGES.md +38 -0
  5. data/README.md +2 -2
  6. data/lib/twilio-ruby/rest/api/v2010/account/call.rb +27 -1
  7. data/lib/twilio-ruby/rest/api/v2010/account/conference/participant.rb +5 -1
  8. data/lib/twilio-ruby/rest/flex_api/v1/configuration.rb +7 -0
  9. data/lib/twilio-ruby/rest/messaging.rb +0 -15
  10. data/lib/twilio-ruby/rest/messaging/v1.rb +0 -22
  11. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/regulation.rb +322 -0
  12. data/lib/twilio-ruby/rest/studio/v2/flow.rb +49 -0
  13. data/lib/twilio-ruby/rest/studio/v2/flow/execution.rb +427 -0
  14. data/lib/twilio-ruby/rest/studio/v2/flow/execution/execution_context.rb +224 -0
  15. data/lib/twilio-ruby/rest/studio/v2/flow/execution/execution_step.rb +387 -0
  16. data/lib/twilio-ruby/rest/studio/v2/flow/execution/execution_step/execution_step_context.rb +239 -0
  17. data/lib/twilio-ruby/rest/studio/v2/flow/test_user.rb +215 -0
  18. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb +10 -3
  19. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_cumulative_statistics.rb +7 -0
  20. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_real_time_statistics.rb +14 -0
  21. data/lib/twilio-ruby/rest/verify/v2/service.rb +5 -3
  22. data/lib/twilio-ruby/rest/verify/v2/service/verification.rb +5 -4
  23. data/lib/twilio-ruby/version.rb +1 -1
  24. data/spec/integration/api/v2010/account/call_spec.rb +30 -10
  25. data/spec/integration/api/v2010/account/conference/participant_spec.rb +29 -0
  26. data/spec/integration/api/v2010/account/notification_spec.rb +1 -1
  27. data/spec/integration/api/v2010/account_spec.rb +45 -0
  28. data/spec/integration/flex_api/v1/configuration_spec.rb +3 -0
  29. data/spec/integration/numbers/v2/regulatory_compliance/regulation_spec.rb +183 -0
  30. data/spec/integration/studio/v2/flow/execution/execution_context_spec.rb +51 -0
  31. data/spec/integration/studio/v2/flow/execution/execution_step/execution_step_context_spec.rb +54 -0
  32. data/spec/integration/studio/v2/flow/execution/execution_step_spec.rb +101 -0
  33. data/spec/integration/studio/v2/flow/execution_spec.rb +169 -0
  34. data/spec/integration/studio/v2/flow/test_user_spec.rb +86 -0
  35. data/spec/integration/studio/v2/flow_spec.rb +16 -4
  36. data/spec/integration/taskrouter/v1/workspace/task_queue/task_queue_cumulative_statistics_spec.rb +6 -0
  37. data/spec/integration/taskrouter/v1/workspace/task_queue/task_queue_real_time_statistics_spec.rb +2 -0
  38. data/spec/integration/taskrouter/v1/workspace/task_spec.rb +4 -0
  39. data/twilio-ruby.gemspec +1 -1
  40. metadata +22 -19
  41. data/lib/twilio-ruby/rest/messaging/v1/session.rb +0 -513
  42. data/lib/twilio-ruby/rest/messaging/v1/session/message.rb +0 -439
  43. data/lib/twilio-ruby/rest/messaging/v1/session/participant.rb +0 -458
  44. data/lib/twilio-ruby/rest/messaging/v1/session/webhook.rb +0 -444
  45. data/lib/twilio-ruby/rest/messaging/v1/webhook.rb +0 -299
  46. data/spec/integration/messaging/v1/session/message_spec.rb +0 -238
  47. data/spec/integration/messaging/v1/session/participant_spec.rb +0 -256
  48. data/spec/integration/messaging/v1/session/webhook_spec.rb +0 -300
  49. data/spec/integration/messaging/v1/session_spec.rb +0 -227
  50. data/spec/integration/messaging/v1/webhook_spec.rb +0 -94
@@ -188,6 +188,8 @@ module Twilio
188
188
 
189
189
  # Dependents
190
190
  @revisions = nil
191
+ @test_users = nil
192
+ @executions = nil
191
193
  end
192
194
 
193
195
  ##
@@ -255,6 +257,32 @@ module Twilio
255
257
  @revisions
256
258
  end
257
259
 
260
+ ##
261
+ # Access the test_users
262
+ # @return [FlowTestUserList]
263
+ # @return [FlowTestUserContext]
264
+ def test_users
265
+ FlowTestUserContext.new(@version, @solution[:sid], )
266
+ end
267
+
268
+ ##
269
+ # Access the executions
270
+ # @return [ExecutionList]
271
+ # @return [ExecutionContext] if sid was passed.
272
+ def executions(sid=:unset)
273
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
274
+
275
+ if sid != :unset
276
+ return ExecutionContext.new(@version, @solution[:sid], sid, )
277
+ end
278
+
279
+ unless @executions
280
+ @executions = ExecutionList.new(@version, flow_sid: @solution[:sid], )
281
+ end
282
+
283
+ @executions
284
+ end
285
+
258
286
  ##
259
287
  # Provide a user friendly representation
260
288
  def to_s
@@ -295,6 +323,7 @@ module Twilio
295
323
  'errors' => payload['errors'],
296
324
  'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
297
325
  'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
326
+ 'webhook_url' => payload['webhook_url'],
298
327
  'url' => payload['url'],
299
328
  'links' => payload['links'],
300
329
  }
@@ -381,6 +410,12 @@ module Twilio
381
410
  @properties['date_updated']
382
411
  end
383
412
 
413
+ ##
414
+ # @return [String] The webhook_url
415
+ def webhook_url
416
+ @properties['webhook_url']
417
+ end
418
+
384
419
  ##
385
420
  # @return [String] The absolute URL of the resource
386
421
  def url
@@ -431,6 +466,20 @@ module Twilio
431
466
  context.revisions
432
467
  end
433
468
 
469
+ ##
470
+ # Access the test_users
471
+ # @return [test_users] test_users
472
+ def test_users
473
+ context.test_users
474
+ end
475
+
476
+ ##
477
+ # Access the executions
478
+ # @return [executions] executions
479
+ def executions
480
+ context.executions
481
+ end
482
+
434
483
  ##
435
484
  # Provide a user friendly representation
436
485
  def to_s
@@ -0,0 +1,427 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+ #
7
+ # frozen_string_literal: true
8
+
9
+ module Twilio
10
+ module REST
11
+ class Studio < Domain
12
+ class V2 < Version
13
+ class FlowContext < InstanceContext
14
+ ##
15
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
16
+ class ExecutionList < ListResource
17
+ ##
18
+ # Initialize the ExecutionList
19
+ # @param [Version] version Version that contains the resource
20
+ # @param [String] flow_sid The flow_sid
21
+ # @return [ExecutionList] ExecutionList
22
+ def initialize(version, flow_sid: nil)
23
+ super(version)
24
+
25
+ # Path Solution
26
+ @solution = {flow_sid: flow_sid}
27
+ @uri = "/Flows/#{@solution[:flow_sid]}/Executions"
28
+ end
29
+
30
+ ##
31
+ # Lists ExecutionInstance records from the API as a list.
32
+ # Unlike stream(), this operation is eager and will load `limit` records into
33
+ # memory before returning.
34
+ # @param [Time] date_created_from The date_created_from
35
+ # @param [Time] date_created_to The date_created_to
36
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
37
+ # guarantees to never return more than limit. Default is no limit
38
+ # @param [Integer] page_size Number of records to fetch per request, when
39
+ # not set will use the default value of 50 records. If no page_size is defined
40
+ # but a limit is defined, stream() will attempt to read the limit with the most
41
+ # efficient page size, i.e. min(limit, 1000)
42
+ # @return [Array] Array of up to limit results
43
+ def list(date_created_from: :unset, date_created_to: :unset, limit: nil, page_size: nil)
44
+ self.stream(
45
+ date_created_from: date_created_from,
46
+ date_created_to: date_created_to,
47
+ limit: limit,
48
+ page_size: page_size
49
+ ).entries
50
+ end
51
+
52
+ ##
53
+ # Streams ExecutionInstance records from the API as an Enumerable.
54
+ # This operation lazily loads records as efficiently as possible until the limit
55
+ # is reached.
56
+ # @param [Time] date_created_from The date_created_from
57
+ # @param [Time] date_created_to The date_created_to
58
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
59
+ # guarantees to never return more than limit. Default is no limit.
60
+ # @param [Integer] page_size Number of records to fetch per request, when
61
+ # not set will use the default value of 50 records. If no page_size is defined
62
+ # but a limit is defined, stream() will attempt to read the limit with the most
63
+ # efficient page size, i.e. min(limit, 1000)
64
+ # @return [Enumerable] Enumerable that will yield up to limit results
65
+ def stream(date_created_from: :unset, date_created_to: :unset, limit: nil, page_size: nil)
66
+ limits = @version.read_limits(limit, page_size)
67
+
68
+ page = self.page(
69
+ date_created_from: date_created_from,
70
+ date_created_to: date_created_to,
71
+ page_size: limits[:page_size],
72
+ )
73
+
74
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
75
+ end
76
+
77
+ ##
78
+ # When passed a block, yields ExecutionInstance records from the API.
79
+ # This operation lazily loads records as efficiently as possible until the limit
80
+ # is reached.
81
+ def each
82
+ limits = @version.read_limits
83
+
84
+ page = self.page(page_size: limits[:page_size], )
85
+
86
+ @version.stream(page,
87
+ limit: limits[:limit],
88
+ page_limit: limits[:page_limit]).each {|x| yield x}
89
+ end
90
+
91
+ ##
92
+ # Retrieve a single page of ExecutionInstance records from the API.
93
+ # Request is executed immediately.
94
+ # @param [Time] date_created_from The date_created_from
95
+ # @param [Time] date_created_to The date_created_to
96
+ # @param [String] page_token PageToken provided by the API
97
+ # @param [Integer] page_number Page Number, this value is simply for client state
98
+ # @param [Integer] page_size Number of records to return, defaults to 50
99
+ # @return [Page] Page of ExecutionInstance
100
+ def page(date_created_from: :unset, date_created_to: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
101
+ params = Twilio::Values.of({
102
+ 'DateCreatedFrom' => Twilio.serialize_iso8601_datetime(date_created_from),
103
+ 'DateCreatedTo' => Twilio.serialize_iso8601_datetime(date_created_to),
104
+ 'PageToken' => page_token,
105
+ 'Page' => page_number,
106
+ 'PageSize' => page_size,
107
+ })
108
+ response = @version.page(
109
+ 'GET',
110
+ @uri,
111
+ params
112
+ )
113
+ ExecutionPage.new(@version, response, @solution)
114
+ end
115
+
116
+ ##
117
+ # Retrieve a single page of ExecutionInstance records from the API.
118
+ # Request is executed immediately.
119
+ # @param [String] target_url API-generated URL for the requested results page
120
+ # @return [Page] Page of ExecutionInstance
121
+ def get_page(target_url)
122
+ response = @version.domain.request(
123
+ 'GET',
124
+ target_url
125
+ )
126
+ ExecutionPage.new(@version, response, @solution)
127
+ end
128
+
129
+ ##
130
+ # Retrieve a single page of ExecutionInstance records from the API.
131
+ # Request is executed immediately.
132
+ # @param [String] to The to
133
+ # @param [String] from The from
134
+ # @param [Hash] parameters The parameters
135
+ # @return [ExecutionInstance] Newly created ExecutionInstance
136
+ def create(to: nil, from: nil, parameters: :unset)
137
+ data = Twilio::Values.of({
138
+ 'To' => to,
139
+ 'From' => from,
140
+ 'Parameters' => Twilio.serialize_object(parameters),
141
+ })
142
+
143
+ payload = @version.create(
144
+ 'POST',
145
+ @uri,
146
+ data: data
147
+ )
148
+
149
+ ExecutionInstance.new(@version, payload, flow_sid: @solution[:flow_sid], )
150
+ end
151
+
152
+ ##
153
+ # Provide a user friendly representation
154
+ def to_s
155
+ '#<Twilio.Studio.V2.ExecutionList>'
156
+ end
157
+ end
158
+
159
+ ##
160
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
161
+ class ExecutionPage < Page
162
+ ##
163
+ # Initialize the ExecutionPage
164
+ # @param [Version] version Version that contains the resource
165
+ # @param [Response] response Response from the API
166
+ # @param [Hash] solution Path solution for the resource
167
+ # @return [ExecutionPage] ExecutionPage
168
+ def initialize(version, response, solution)
169
+ super(version, response)
170
+
171
+ # Path Solution
172
+ @solution = solution
173
+ end
174
+
175
+ ##
176
+ # Build an instance of ExecutionInstance
177
+ # @param [Hash] payload Payload response from the API
178
+ # @return [ExecutionInstance] ExecutionInstance
179
+ def get_instance(payload)
180
+ ExecutionInstance.new(@version, payload, flow_sid: @solution[:flow_sid], )
181
+ end
182
+
183
+ ##
184
+ # Provide a user friendly representation
185
+ def to_s
186
+ '<Twilio.Studio.V2.ExecutionPage>'
187
+ end
188
+ end
189
+
190
+ ##
191
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
192
+ class ExecutionContext < InstanceContext
193
+ ##
194
+ # Initialize the ExecutionContext
195
+ # @param [Version] version Version that contains the resource
196
+ # @param [String] flow_sid The flow_sid
197
+ # @param [String] sid The sid
198
+ # @return [ExecutionContext] ExecutionContext
199
+ def initialize(version, flow_sid, sid)
200
+ super(version)
201
+
202
+ # Path Solution
203
+ @solution = {flow_sid: flow_sid, sid: sid, }
204
+ @uri = "/Flows/#{@solution[:flow_sid]}/Executions/#{@solution[:sid]}"
205
+
206
+ # Dependents
207
+ @steps = nil
208
+ @execution_context = nil
209
+ end
210
+
211
+ ##
212
+ # Fetch a ExecutionInstance
213
+ # @return [ExecutionInstance] Fetched ExecutionInstance
214
+ def fetch
215
+ params = Twilio::Values.of({})
216
+
217
+ payload = @version.fetch(
218
+ 'GET',
219
+ @uri,
220
+ params,
221
+ )
222
+
223
+ ExecutionInstance.new(@version, payload, flow_sid: @solution[:flow_sid], sid: @solution[:sid], )
224
+ end
225
+
226
+ ##
227
+ # Deletes the ExecutionInstance
228
+ # @return [Boolean] true if delete succeeds, false otherwise
229
+ def delete
230
+ @version.delete('delete', @uri)
231
+ end
232
+
233
+ ##
234
+ # Access the steps
235
+ # @return [ExecutionStepList]
236
+ # @return [ExecutionStepContext] if sid was passed.
237
+ def steps(sid=:unset)
238
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
239
+
240
+ if sid != :unset
241
+ return ExecutionStepContext.new(@version, @solution[:flow_sid], @solution[:sid], sid, )
242
+ end
243
+
244
+ unless @steps
245
+ @steps = ExecutionStepList.new(
246
+ @version,
247
+ flow_sid: @solution[:flow_sid],
248
+ execution_sid: @solution[:sid],
249
+ )
250
+ end
251
+
252
+ @steps
253
+ end
254
+
255
+ ##
256
+ # Access the execution_context
257
+ # @return [ExecutionContextList]
258
+ # @return [ExecutionContextContext]
259
+ def execution_context
260
+ ExecutionContextContext.new(@version, @solution[:flow_sid], @solution[:sid], )
261
+ end
262
+
263
+ ##
264
+ # Provide a user friendly representation
265
+ def to_s
266
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
267
+ "#<Twilio.Studio.V2.ExecutionContext #{context}>"
268
+ end
269
+
270
+ ##
271
+ # Provide a detailed, user friendly representation
272
+ def inspect
273
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
274
+ "#<Twilio.Studio.V2.ExecutionContext #{context}>"
275
+ end
276
+ end
277
+
278
+ ##
279
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
280
+ class ExecutionInstance < InstanceResource
281
+ ##
282
+ # Initialize the ExecutionInstance
283
+ # @param [Version] version Version that contains the resource
284
+ # @param [Hash] payload payload that contains response from Twilio
285
+ # @param [String] flow_sid The flow_sid
286
+ # @param [String] sid The sid
287
+ # @return [ExecutionInstance] ExecutionInstance
288
+ def initialize(version, payload, flow_sid: nil, sid: nil)
289
+ super(version)
290
+
291
+ # Marshaled Properties
292
+ @properties = {
293
+ 'sid' => payload['sid'],
294
+ 'account_sid' => payload['account_sid'],
295
+ 'flow_sid' => payload['flow_sid'],
296
+ 'contact_channel_address' => payload['contact_channel_address'],
297
+ 'context' => payload['context'],
298
+ 'status' => payload['status'],
299
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
300
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
301
+ 'url' => payload['url'],
302
+ 'links' => payload['links'],
303
+ }
304
+
305
+ # Context
306
+ @instance_context = nil
307
+ @params = {'flow_sid' => flow_sid, 'sid' => sid || @properties['sid'], }
308
+ end
309
+
310
+ ##
311
+ # Generate an instance context for the instance, the context is capable of
312
+ # performing various actions. All instance actions are proxied to the context
313
+ # @return [ExecutionContext] ExecutionContext for this ExecutionInstance
314
+ def context
315
+ unless @instance_context
316
+ @instance_context = ExecutionContext.new(@version, @params['flow_sid'], @params['sid'], )
317
+ end
318
+ @instance_context
319
+ end
320
+
321
+ ##
322
+ # @return [String] The sid
323
+ def sid
324
+ @properties['sid']
325
+ end
326
+
327
+ ##
328
+ # @return [String] The account_sid
329
+ def account_sid
330
+ @properties['account_sid']
331
+ end
332
+
333
+ ##
334
+ # @return [String] The flow_sid
335
+ def flow_sid
336
+ @properties['flow_sid']
337
+ end
338
+
339
+ ##
340
+ # @return [String] The contact_channel_address
341
+ def contact_channel_address
342
+ @properties['contact_channel_address']
343
+ end
344
+
345
+ ##
346
+ # @return [Hash] The context
347
+ def context
348
+ @properties['context']
349
+ end
350
+
351
+ ##
352
+ # @return [execution.Status] The status
353
+ def status
354
+ @properties['status']
355
+ end
356
+
357
+ ##
358
+ # @return [Time] The date_created
359
+ def date_created
360
+ @properties['date_created']
361
+ end
362
+
363
+ ##
364
+ # @return [Time] The date_updated
365
+ def date_updated
366
+ @properties['date_updated']
367
+ end
368
+
369
+ ##
370
+ # @return [String] The url
371
+ def url
372
+ @properties['url']
373
+ end
374
+
375
+ ##
376
+ # @return [String] The links
377
+ def links
378
+ @properties['links']
379
+ end
380
+
381
+ ##
382
+ # Fetch a ExecutionInstance
383
+ # @return [ExecutionInstance] Fetched ExecutionInstance
384
+ def fetch
385
+ context.fetch
386
+ end
387
+
388
+ ##
389
+ # Deletes the ExecutionInstance
390
+ # @return [Boolean] true if delete succeeds, false otherwise
391
+ def delete
392
+ context.delete
393
+ end
394
+
395
+ ##
396
+ # Access the steps
397
+ # @return [steps] steps
398
+ def steps
399
+ context.steps
400
+ end
401
+
402
+ ##
403
+ # Access the execution_context
404
+ # @return [execution_context] execution_context
405
+ def execution_context
406
+ context.execution_context
407
+ end
408
+
409
+ ##
410
+ # Provide a user friendly representation
411
+ def to_s
412
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
413
+ "<Twilio.Studio.V2.ExecutionInstance #{values}>"
414
+ end
415
+
416
+ ##
417
+ # Provide a detailed, user friendly representation
418
+ def inspect
419
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
420
+ "<Twilio.Studio.V2.ExecutionInstance #{values}>"
421
+ end
422
+ end
423
+ end
424
+ end
425
+ end
426
+ end
427
+ end