twilio-ruby 5.25.2 → 5.25.3

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