twilio-ruby 5.40.1 → 5.40.2

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 (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +27 -0
  3. data/README.md +2 -2
  4. data/lib/twilio-ruby/framework/version.rb +2 -7
  5. data/lib/twilio-ruby/rest/conversations.rb +52 -0
  6. data/lib/twilio-ruby/rest/conversations/v1.rb +88 -1
  7. data/lib/twilio-ruby/rest/conversations/v1/configuration.rb +258 -0
  8. data/lib/twilio-ruby/rest/conversations/v1/conversation.rb +15 -4
  9. data/lib/twilio-ruby/rest/conversations/v1/conversation/message/delivery_receipt.rb +19 -10
  10. data/lib/twilio-ruby/rest/conversations/v1/credential.rb +427 -0
  11. data/lib/twilio-ruby/rest/conversations/v1/notification.rb +310 -0
  12. data/lib/twilio-ruby/rest/conversations/v1/role.rb +372 -0
  13. data/lib/twilio-ruby/rest/conversations/v1/service.rb +442 -0
  14. data/lib/twilio-ruby/rest/conversations/v1/service/binding.rb +385 -0
  15. data/lib/twilio-ruby/rest/conversations/v1/service/configuration.rb +259 -0
  16. data/lib/twilio-ruby/rest/conversations/v1/service/conversation.rb +586 -0
  17. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message.rb +546 -0
  18. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/message/delivery_receipt.rb +388 -0
  19. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb +513 -0
  20. data/lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb +454 -0
  21. data/lib/twilio-ruby/rest/conversations/v1/service/role.rb +393 -0
  22. data/lib/twilio-ruby/rest/conversations/v1/service/user.rb +419 -0
  23. data/lib/twilio-ruby/rest/conversations/v1/user.rb +398 -0
  24. data/lib/twilio-ruby/rest/events.rb +8 -0
  25. data/lib/twilio-ruby/rest/events/v1.rb +15 -0
  26. data/lib/twilio-ruby/rest/events/v1/event_type.rb +291 -0
  27. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance.rb +2 -2
  28. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/supporting_document.rb +18 -4
  29. data/lib/twilio-ruby/rest/proxy/v1/service/session.rb +27 -24
  30. data/lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb +12 -11
  31. data/lib/twilio-ruby/rest/serverless/v1/service.rb +13 -13
  32. data/lib/twilio-ruby/rest/serverless/v1/service/asset.rb +6 -6
  33. data/lib/twilio-ruby/rest/serverless/v1/service/asset/asset_version.rb +5 -5
  34. data/lib/twilio-ruby/rest/serverless/v1/service/build.rb +8 -8
  35. data/lib/twilio-ruby/rest/serverless/v1/service/environment.rb +6 -8
  36. data/lib/twilio-ruby/rest/serverless/v1/service/environment/deployment.rb +8 -8
  37. data/lib/twilio-ruby/rest/serverless/v1/service/environment/variable.rb +14 -14
  38. data/lib/twilio-ruby/rest/serverless/v1/service/function.rb +4 -4
  39. data/lib/twilio-ruby/rest/serverless/v1/service/function/function_version.rb +7 -7
  40. data/lib/twilio-ruby/rest/serverless/v1/service/function/function_version/function_version_content.rb +1 -1
  41. data/lib/twilio-ruby/rest/supersim/v1/sim.rb +17 -7
  42. data/lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb +2 -1
  43. data/lib/twilio-ruby/version.rb +1 -1
  44. data/spec/framework/version_spec.rb +42 -0
  45. data/spec/holodeck/holodeck.rb +3 -3
  46. data/spec/integration/conversations/v1/configuration_spec.rb +85 -0
  47. data/spec/integration/conversations/v1/conversation/message/delivery_receipt_spec.rb +4 -0
  48. data/spec/integration/conversations/v1/conversation/participant_spec.rb +6 -6
  49. data/spec/integration/conversations/v1/conversation_spec.rb +5 -0
  50. data/spec/integration/conversations/v1/credential_spec.rb +219 -0
  51. data/spec/integration/conversations/v1/notification_spec.rb +107 -0
  52. data/spec/integration/conversations/v1/role_spec.rb +249 -0
  53. data/spec/integration/conversations/v1/service/binding_spec.rb +166 -0
  54. data/spec/integration/conversations/v1/service/configuration_spec.rb +87 -0
  55. data/spec/integration/conversations/v1/service/conversation/message/delivery_receipt_spec.rb +144 -0
  56. data/spec/integration/conversations/v1/service/conversation/message_spec.rb +429 -0
  57. data/spec/integration/conversations/v1/service/conversation/participant_spec.rb +407 -0
  58. data/spec/integration/conversations/v1/service/conversation/webhook_spec.rb +299 -0
  59. data/spec/integration/conversations/v1/service/conversation_spec.rb +289 -0
  60. data/spec/integration/conversations/v1/service/role_spec.rb +260 -0
  61. data/spec/integration/conversations/v1/service/user_spec.rb +230 -0
  62. data/spec/integration/conversations/v1/service_spec.rb +174 -0
  63. data/spec/integration/conversations/v1/user_spec.rb +220 -0
  64. data/spec/integration/events/v1/event_type_spec.rb +133 -0
  65. data/spec/integration/numbers/v2/regulatory_compliance/supporting_document_spec.rb +27 -0
  66. data/spec/integration/supersim/v1/sim_spec.rb +23 -0
  67. metadata +50 -2
@@ -0,0 +1,454 @@
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 Conversations < Domain
12
+ class V1 < Version
13
+ class ServiceContext < InstanceContext
14
+ class ConversationContext < InstanceContext
15
+ ##
16
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
17
+ class WebhookList < ListResource
18
+ ##
19
+ # Initialize the WebhookList
20
+ # @param [Version] version Version that contains the resource
21
+ # @param [String] chat_service_sid The SID of the [Chat
22
+ # Service](https://www.twilio.com/docs/chat/rest/service-resource) the Participant
23
+ # resource is associated with.
24
+ # @param [String] conversation_sid The unique id of the
25
+ # [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this webhook.
26
+ # @return [WebhookList] WebhookList
27
+ def initialize(version, chat_service_sid: nil, conversation_sid: nil)
28
+ super(version)
29
+
30
+ # Path Solution
31
+ @solution = {chat_service_sid: chat_service_sid, conversation_sid: conversation_sid}
32
+ @uri = "/Services/#{@solution[:chat_service_sid]}/Conversations/#{@solution[:conversation_sid]}/Webhooks"
33
+ end
34
+
35
+ ##
36
+ # Create the WebhookInstance
37
+ # @param [webhook.Target] target The target of this webhook: `webhook`, `studio`,
38
+ # `trigger`
39
+ # @param [String] configuration_url The absolute url the webhook request should be
40
+ # sent to.
41
+ # @param [webhook.Method] configuration_method The HTTP method to be used when
42
+ # sending a webhook request.
43
+ # @param [String] configuration_filters The list of events, firing webhook event
44
+ # for this Conversation.
45
+ # @param [String] configuration_triggers The list of keywords, firing webhook
46
+ # event for this Conversation.
47
+ # @param [String] configuration_flow_sid The studio flow sid, where the webhook
48
+ # should be sent to.
49
+ # @param [String] configuration_replay_after The message index for which and it's
50
+ # successors the webhook will be replayed. Not set by default
51
+ # @return [WebhookInstance] Created WebhookInstance
52
+ def create(target: nil, configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset, configuration_replay_after: :unset)
53
+ data = Twilio::Values.of({
54
+ 'Target' => target,
55
+ 'Configuration.Url' => configuration_url,
56
+ 'Configuration.Method' => configuration_method,
57
+ 'Configuration.Filters' => Twilio.serialize_list(configuration_filters) { |e| e },
58
+ 'Configuration.Triggers' => Twilio.serialize_list(configuration_triggers) { |e| e },
59
+ 'Configuration.FlowSid' => configuration_flow_sid,
60
+ 'Configuration.ReplayAfter' => configuration_replay_after,
61
+ })
62
+
63
+ payload = @version.create('POST', @uri, data: data)
64
+
65
+ WebhookInstance.new(
66
+ @version,
67
+ payload,
68
+ chat_service_sid: @solution[:chat_service_sid],
69
+ conversation_sid: @solution[:conversation_sid],
70
+ )
71
+ end
72
+
73
+ ##
74
+ # Lists WebhookInstance records from the API as a list.
75
+ # Unlike stream(), this operation is eager and will load `limit` records into
76
+ # memory before returning.
77
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
78
+ # guarantees to never return more than limit. Default is no limit
79
+ # @param [Integer] page_size Number of records to fetch per request, when
80
+ # not set will use the default value of 50 records. If no page_size is defined
81
+ # but a limit is defined, stream() will attempt to read the limit with the most
82
+ # efficient page size, i.e. min(limit, 1000)
83
+ # @return [Array] Array of up to limit results
84
+ def list(limit: nil, page_size: nil)
85
+ self.stream(limit: limit, page_size: page_size).entries
86
+ end
87
+
88
+ ##
89
+ # Streams WebhookInstance records from the API as an Enumerable.
90
+ # This operation lazily loads records as efficiently as possible until the limit
91
+ # is reached.
92
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
93
+ # guarantees to never return more than limit. Default is no limit.
94
+ # @param [Integer] page_size Number of records to fetch per request, when
95
+ # not set will use the default value of 50 records. If no page_size is defined
96
+ # but a limit is defined, stream() will attempt to read the limit with the most
97
+ # efficient page size, i.e. min(limit, 1000)
98
+ # @return [Enumerable] Enumerable that will yield up to limit results
99
+ def stream(limit: nil, page_size: nil)
100
+ limits = @version.read_limits(limit, page_size)
101
+
102
+ page = self.page(page_size: limits[:page_size], )
103
+
104
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
105
+ end
106
+
107
+ ##
108
+ # When passed a block, yields WebhookInstance records from the API.
109
+ # This operation lazily loads records as efficiently as possible until the limit
110
+ # is reached.
111
+ def each
112
+ limits = @version.read_limits
113
+
114
+ page = self.page(page_size: limits[:page_size], )
115
+
116
+ @version.stream(page,
117
+ limit: limits[:limit],
118
+ page_limit: limits[:page_limit]).each {|x| yield x}
119
+ end
120
+
121
+ ##
122
+ # Retrieve a single page of WebhookInstance records from the API.
123
+ # Request is executed immediately.
124
+ # @param [String] page_token PageToken provided by the API
125
+ # @param [Integer] page_number Page Number, this value is simply for client state
126
+ # @param [Integer] page_size Number of records to return, defaults to 50
127
+ # @return [Page] Page of WebhookInstance
128
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
129
+ params = Twilio::Values.of({
130
+ 'PageToken' => page_token,
131
+ 'Page' => page_number,
132
+ 'PageSize' => page_size,
133
+ })
134
+
135
+ response = @version.page('GET', @uri, params: params)
136
+
137
+ WebhookPage.new(@version, response, @solution)
138
+ end
139
+
140
+ ##
141
+ # Retrieve a single page of WebhookInstance records from the API.
142
+ # Request is executed immediately.
143
+ # @param [String] target_url API-generated URL for the requested results page
144
+ # @return [Page] Page of WebhookInstance
145
+ def get_page(target_url)
146
+ response = @version.domain.request(
147
+ 'GET',
148
+ target_url
149
+ )
150
+ WebhookPage.new(@version, response, @solution)
151
+ end
152
+
153
+ ##
154
+ # Provide a user friendly representation
155
+ def to_s
156
+ '#<Twilio.Conversations.V1.WebhookList>'
157
+ end
158
+ end
159
+
160
+ ##
161
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
162
+ class WebhookPage < Page
163
+ ##
164
+ # Initialize the WebhookPage
165
+ # @param [Version] version Version that contains the resource
166
+ # @param [Response] response Response from the API
167
+ # @param [Hash] solution Path solution for the resource
168
+ # @return [WebhookPage] WebhookPage
169
+ def initialize(version, response, solution)
170
+ super(version, response)
171
+
172
+ # Path Solution
173
+ @solution = solution
174
+ end
175
+
176
+ ##
177
+ # Build an instance of WebhookInstance
178
+ # @param [Hash] payload Payload response from the API
179
+ # @return [WebhookInstance] WebhookInstance
180
+ def get_instance(payload)
181
+ WebhookInstance.new(
182
+ @version,
183
+ payload,
184
+ chat_service_sid: @solution[:chat_service_sid],
185
+ conversation_sid: @solution[:conversation_sid],
186
+ )
187
+ end
188
+
189
+ ##
190
+ # Provide a user friendly representation
191
+ def to_s
192
+ '<Twilio.Conversations.V1.WebhookPage>'
193
+ end
194
+ end
195
+
196
+ ##
197
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
198
+ class WebhookContext < InstanceContext
199
+ ##
200
+ # Initialize the WebhookContext
201
+ # @param [Version] version Version that contains the resource
202
+ # @param [String] chat_service_sid The SID of the [Chat
203
+ # Service](https://www.twilio.com/docs/chat/rest/service-resource) the Participant
204
+ # resource is associated with.
205
+ # @param [String] conversation_sid The unique id of the
206
+ # [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this webhook.
207
+ # @param [String] sid A 34 character string that uniquely identifies this
208
+ # resource.
209
+ # @return [WebhookContext] WebhookContext
210
+ def initialize(version, chat_service_sid, conversation_sid, sid)
211
+ super(version)
212
+
213
+ # Path Solution
214
+ @solution = {chat_service_sid: chat_service_sid, conversation_sid: conversation_sid, sid: sid, }
215
+ @uri = "/Services/#{@solution[:chat_service_sid]}/Conversations/#{@solution[:conversation_sid]}/Webhooks/#{@solution[:sid]}"
216
+ end
217
+
218
+ ##
219
+ # Update the WebhookInstance
220
+ # @param [String] configuration_url The absolute url the webhook request should be
221
+ # sent to.
222
+ # @param [webhook.Method] configuration_method The HTTP method to be used when
223
+ # sending a webhook request.
224
+ # @param [String] configuration_filters The list of events, firing webhook event
225
+ # for this Conversation.
226
+ # @param [String] configuration_triggers The list of keywords, firing webhook
227
+ # event for this Conversation.
228
+ # @param [String] configuration_flow_sid The studio flow sid, where the webhook
229
+ # should be sent to.
230
+ # @return [WebhookInstance] Updated WebhookInstance
231
+ def update(configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset)
232
+ data = Twilio::Values.of({
233
+ 'Configuration.Url' => configuration_url,
234
+ 'Configuration.Method' => configuration_method,
235
+ 'Configuration.Filters' => Twilio.serialize_list(configuration_filters) { |e| e },
236
+ 'Configuration.Triggers' => Twilio.serialize_list(configuration_triggers) { |e| e },
237
+ 'Configuration.FlowSid' => configuration_flow_sid,
238
+ })
239
+
240
+ payload = @version.update('POST', @uri, data: data)
241
+
242
+ WebhookInstance.new(
243
+ @version,
244
+ payload,
245
+ chat_service_sid: @solution[:chat_service_sid],
246
+ conversation_sid: @solution[:conversation_sid],
247
+ sid: @solution[:sid],
248
+ )
249
+ end
250
+
251
+ ##
252
+ # Delete the WebhookInstance
253
+ # @return [Boolean] true if delete succeeds, false otherwise
254
+ def delete
255
+ @version.delete('DELETE', @uri)
256
+ end
257
+
258
+ ##
259
+ # Fetch the WebhookInstance
260
+ # @return [WebhookInstance] Fetched WebhookInstance
261
+ def fetch
262
+ payload = @version.fetch('GET', @uri)
263
+
264
+ WebhookInstance.new(
265
+ @version,
266
+ payload,
267
+ chat_service_sid: @solution[:chat_service_sid],
268
+ conversation_sid: @solution[:conversation_sid],
269
+ sid: @solution[:sid],
270
+ )
271
+ end
272
+
273
+ ##
274
+ # Provide a user friendly representation
275
+ def to_s
276
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
277
+ "#<Twilio.Conversations.V1.WebhookContext #{context}>"
278
+ end
279
+
280
+ ##
281
+ # Provide a detailed, user friendly representation
282
+ def inspect
283
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
284
+ "#<Twilio.Conversations.V1.WebhookContext #{context}>"
285
+ end
286
+ end
287
+
288
+ ##
289
+ # PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
290
+ class WebhookInstance < InstanceResource
291
+ ##
292
+ # Initialize the WebhookInstance
293
+ # @param [Version] version Version that contains the resource
294
+ # @param [Hash] payload payload that contains response from Twilio
295
+ # @param [String] chat_service_sid The SID of the [Chat
296
+ # Service](https://www.twilio.com/docs/chat/rest/service-resource) the Participant
297
+ # resource is associated with.
298
+ # @param [String] conversation_sid The unique id of the
299
+ # [Conversation](https://www.twilio.com/docs/conversations/api/conversation-resource) for this webhook.
300
+ # @param [String] sid A 34 character string that uniquely identifies this
301
+ # resource.
302
+ # @return [WebhookInstance] WebhookInstance
303
+ def initialize(version, payload, chat_service_sid: nil, conversation_sid: nil, sid: nil)
304
+ super(version)
305
+
306
+ # Marshaled Properties
307
+ @properties = {
308
+ 'sid' => payload['sid'],
309
+ 'account_sid' => payload['account_sid'],
310
+ 'chat_service_sid' => payload['chat_service_sid'],
311
+ 'conversation_sid' => payload['conversation_sid'],
312
+ 'target' => payload['target'],
313
+ 'url' => payload['url'],
314
+ 'configuration' => payload['configuration'],
315
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
316
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
317
+ }
318
+
319
+ # Context
320
+ @instance_context = nil
321
+ @params = {
322
+ 'chat_service_sid' => chat_service_sid,
323
+ 'conversation_sid' => conversation_sid,
324
+ 'sid' => sid || @properties['sid'],
325
+ }
326
+ end
327
+
328
+ ##
329
+ # Generate an instance context for the instance, the context is capable of
330
+ # performing various actions. All instance actions are proxied to the context
331
+ # @return [WebhookContext] WebhookContext for this WebhookInstance
332
+ def context
333
+ unless @instance_context
334
+ @instance_context = WebhookContext.new(
335
+ @version,
336
+ @params['chat_service_sid'],
337
+ @params['conversation_sid'],
338
+ @params['sid'],
339
+ )
340
+ end
341
+ @instance_context
342
+ end
343
+
344
+ ##
345
+ # @return [String] A 34 character string that uniquely identifies this resource.
346
+ def sid
347
+ @properties['sid']
348
+ end
349
+
350
+ ##
351
+ # @return [String] The unique id of the Account responsible for this conversation.
352
+ def account_sid
353
+ @properties['account_sid']
354
+ end
355
+
356
+ ##
357
+ # @return [String] The SID of the Chat Service that the resource is associated with.
358
+ def chat_service_sid
359
+ @properties['chat_service_sid']
360
+ end
361
+
362
+ ##
363
+ # @return [String] The unique id of the Conversation for this webhook.
364
+ def conversation_sid
365
+ @properties['conversation_sid']
366
+ end
367
+
368
+ ##
369
+ # @return [String] The target of this webhook.
370
+ def target
371
+ @properties['target']
372
+ end
373
+
374
+ ##
375
+ # @return [String] An absolute URL for this webhook.
376
+ def url
377
+ @properties['url']
378
+ end
379
+
380
+ ##
381
+ # @return [Hash] The configuration of this webhook.
382
+ def configuration
383
+ @properties['configuration']
384
+ end
385
+
386
+ ##
387
+ # @return [Time] The date that this resource was created.
388
+ def date_created
389
+ @properties['date_created']
390
+ end
391
+
392
+ ##
393
+ # @return [Time] The date that this resource was last updated.
394
+ def date_updated
395
+ @properties['date_updated']
396
+ end
397
+
398
+ ##
399
+ # Update the WebhookInstance
400
+ # @param [String] configuration_url The absolute url the webhook request should be
401
+ # sent to.
402
+ # @param [webhook.Method] configuration_method The HTTP method to be used when
403
+ # sending a webhook request.
404
+ # @param [String] configuration_filters The list of events, firing webhook event
405
+ # for this Conversation.
406
+ # @param [String] configuration_triggers The list of keywords, firing webhook
407
+ # event for this Conversation.
408
+ # @param [String] configuration_flow_sid The studio flow sid, where the webhook
409
+ # should be sent to.
410
+ # @return [WebhookInstance] Updated WebhookInstance
411
+ def update(configuration_url: :unset, configuration_method: :unset, configuration_filters: :unset, configuration_triggers: :unset, configuration_flow_sid: :unset)
412
+ context.update(
413
+ configuration_url: configuration_url,
414
+ configuration_method: configuration_method,
415
+ configuration_filters: configuration_filters,
416
+ configuration_triggers: configuration_triggers,
417
+ configuration_flow_sid: configuration_flow_sid,
418
+ )
419
+ end
420
+
421
+ ##
422
+ # Delete the WebhookInstance
423
+ # @return [Boolean] true if delete succeeds, false otherwise
424
+ def delete
425
+ context.delete
426
+ end
427
+
428
+ ##
429
+ # Fetch the WebhookInstance
430
+ # @return [WebhookInstance] Fetched WebhookInstance
431
+ def fetch
432
+ context.fetch
433
+ end
434
+
435
+ ##
436
+ # Provide a user friendly representation
437
+ def to_s
438
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
439
+ "<Twilio.Conversations.V1.WebhookInstance #{values}>"
440
+ end
441
+
442
+ ##
443
+ # Provide a detailed, user friendly representation
444
+ def inspect
445
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
446
+ "<Twilio.Conversations.V1.WebhookInstance #{values}>"
447
+ end
448
+ end
449
+ end
450
+ end
451
+ end
452
+ end
453
+ end
454
+ end