twilio-ruby 7.11.3 → 7.13.0

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 (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +277 -0
  3. data/Gemfile.lock +2 -2
  4. data/README.md +2 -2
  5. data/examples/WebhookSignatureValidation.md +61 -0
  6. data/lib/rack/twilio_webhook_authentication.rb +30 -5
  7. data/lib/twilio-ruby/rest/api/v2010/account/call.rb +7 -0
  8. data/lib/twilio-ruby/rest/api/v2010/account/conference.rb +4 -4
  9. data/lib/twilio-ruby/rest/client.rb +5 -0
  10. data/lib/twilio-ruby/rest/content/v1/content/approval_create.rb +108 -1
  11. data/lib/twilio-ruby/rest/content/v1/content.rb +10 -4
  12. data/lib/twilio-ruby/rest/conversations/v2/action.rb +9 -2
  13. data/lib/twilio-ruby/rest/conversations/v2/communication.rb +4 -1
  14. data/lib/twilio-ruby/rest/conversations/v2/configuration.rb +21 -0
  15. data/lib/twilio-ruby/rest/conversations/v2/conversation.rb +226 -7
  16. data/lib/twilio-ruby/rest/insights/v1/call/call_summary.rb +1 -1
  17. data/lib/twilio-ruby/rest/insights/v1/call_summaries.rb +1 -1
  18. data/lib/twilio-ruby/rest/insights/v3/custom_field_mapping.rb +512 -17
  19. data/lib/twilio-ruby/rest/insights/v3/{capacity.rb → custom_field_mappings_capacity.rb} +26 -26
  20. data/lib/twilio-ruby/rest/insights/v3.rb +17 -7
  21. data/lib/twilio-ruby/rest/memory/v1/bulk.rb +22 -1
  22. data/lib/twilio-ruby/rest/memory/v1/conversation_summary.rb +5 -5
  23. data/lib/twilio-ruby/rest/memory/v1/import.rb +21 -7
  24. data/lib/twilio-ruby/rest/memory/v1/observation.rb +9 -9
  25. data/lib/twilio-ruby/rest/memory/v1/revision.rb +1 -1
  26. data/lib/twilio-ruby/rest/memory/v1/store.rb +7 -0
  27. data/lib/twilio-ruby/rest/messaging/v2/channels_sender.rb +30 -2
  28. data/lib/twilio-ruby/rest/numbers/v1/sms_verification.rb +30 -6
  29. data/lib/twilio-ruby/rest/numbers/v1/sms_verification_check.rb +30 -6
  30. data/lib/twilio-ruby/rest/numbers/v1/voice_verification.rb +45 -6
  31. data/lib/twilio-ruby/rest/numbers/v1.rb +0 -6
  32. data/lib/twilio-ruby/rest/preview/hosted_numbers/authorization_document.rb +40 -0
  33. data/lib/twilio-ruby/rest/routes/v3/iso_country_code.rb +402 -0
  34. data/lib/twilio-ruby/rest/routes/v3.rb +43 -0
  35. data/lib/twilio-ruby/rest/trusthub/v1/a2p_brand_registration.rb +5 -5
  36. data/lib/twilio-ruby/rest/trusthub/v1/a2p_campaign_registration.rb +4 -4
  37. data/lib/twilio-ruby/rest/trusthub/v1.rb +2 -2
  38. data/lib/twilio-ruby/rest/webhooks/v1/auth_profile.rb +825 -0
  39. data/lib/twilio-ruby/rest/webhooks/v1/edge_zone.rb +320 -0
  40. data/lib/twilio-ruby/rest/webhooks/v1/operation.rb +513 -0
  41. data/lib/twilio-ruby/rest/webhooks/v1/rule.rb +818 -0
  42. data/lib/twilio-ruby/rest/webhooks/v1/setting.rb +1028 -0
  43. data/lib/twilio-ruby/rest/webhooks/v1/shared_key.rb +722 -0
  44. data/lib/twilio-ruby/rest/webhooks/v1/test.rb +228 -0
  45. data/lib/twilio-ruby/rest/webhooks/v1.rb +126 -0
  46. data/lib/twilio-ruby/rest/webhooks.rb +6 -0
  47. data/lib/twilio-ruby/rest/webhooks_base.rb +38 -0
  48. data/lib/twilio-ruby/security/request_validator.rb +54 -8
  49. data/lib/twilio-ruby/twiml/voice_response.rb +20 -5
  50. data/lib/twilio-ruby/version.rb +1 -1
  51. metadata +15 -5
  52. data/lib/twilio-ruby/rest/numbers/v1/voice_verification_check.rb +0 -165
  53. data/lib/twilio-ruby/rest/oauth/v2/oauth_authorization_server.rb +0 -200
@@ -0,0 +1,722 @@
1
+ ##
2
+ # This code was generated by
3
+ # ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
4
+ # | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
5
+ # | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
6
+ #
7
+ # Twilio - Webhooks Configuration
8
+ # Centralized webhook configuration with OAuth2 support, immutable resources, and zero-downtime credential rotation.
9
+ #
10
+ # NOTE: This class is auto generated by OpenAPI Generator.
11
+ # https://openapi-generator.tech
12
+ # Do not edit the class manually.
13
+ #
14
+
15
+
16
+ module Twilio
17
+ module REST
18
+ class Webhooks < WebhooksBase
19
+ class V1 < Version
20
+ class SharedKeyList < ListResource
21
+
22
+ class PatchSharedKey
23
+ # @param [friendly_name]: [String] Human-readable name for the SharedKey
24
+ attr_accessor :friendly_name
25
+ def initialize(payload)
26
+ @friendly_name = payload["friendly_name"]
27
+ end
28
+ def to_json(options = {})
29
+ {
30
+ "friendlyName": @friendly_name,
31
+ }.to_json(options)
32
+ end
33
+ end
34
+
35
+ class PostSharedKey
36
+ # @param [friendly_name]: [String] Human-readable name for the signing key (optional, defaults to blank)
37
+ attr_accessor :friendly_name
38
+ def initialize(payload)
39
+ @friendly_name = payload["friendly_name"]
40
+ end
41
+ def to_json(options = {})
42
+ {
43
+ "friendlyName": @friendly_name,
44
+ }.to_json(options)
45
+ end
46
+ end
47
+
48
+
49
+ class PatchSharedKey
50
+ # @param [friendly_name]: [String] Human-readable name for the SharedKey
51
+ attr_accessor :friendly_name
52
+ def initialize(payload)
53
+ @friendly_name = payload["friendly_name"]
54
+ end
55
+ def to_json(options = {})
56
+ {
57
+ "friendlyName": @friendly_name,
58
+ }.to_json(options)
59
+ end
60
+ end
61
+
62
+ class PostSharedKey
63
+ # @param [friendly_name]: [String] Human-readable name for the signing key (optional, defaults to blank)
64
+ attr_accessor :friendly_name
65
+ def initialize(payload)
66
+ @friendly_name = payload["friendly_name"]
67
+ end
68
+ def to_json(options = {})
69
+ {
70
+ "friendlyName": @friendly_name,
71
+ }.to_json(options)
72
+ end
73
+ end
74
+
75
+
76
+ ##
77
+ # Initialize the SharedKeyList
78
+ # @param [Version] version Version that contains the resource
79
+ # @return [SharedKeyList] SharedKeyList
80
+ def initialize(version)
81
+
82
+ apiV1Version = ApiV1Version.new version.domain, version
83
+ super(apiV1Version)
84
+ # Path Solution
85
+ @solution = { }
86
+ @uri = "/Webhooks/SharedKeys"
87
+
88
+ end
89
+ ##
90
+ # Create the SharedKeyInstance
91
+ # @param [String] idempotency_key Idempotency key for mutation operations. Must be a UUIDv7 (other UUID versions are rejected with a 400).
92
+ # @param [PostSharedKey] post_shared_key
93
+ # @return [SharedKeyInstance] Created SharedKeyInstance
94
+ def create(
95
+ idempotency_key: :unset,
96
+ post_shared_key: nil
97
+ )
98
+
99
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Idempotency-Key' => idempotency_key, })
100
+ headers['Content-Type'] = 'application/json'
101
+
102
+
103
+
104
+ headers['Accept'] = '*/*'
105
+ payload = @version.create('POST', @uri, headers: headers, data: post_shared_key.to_json)
106
+ SharedKeyInstance.new(
107
+ @version,
108
+ payload,
109
+ )
110
+ end
111
+
112
+ ##
113
+ # Create the SharedKeyInstanceMetadata
114
+ # @param [String] idempotency_key Idempotency key for mutation operations. Must be a UUIDv7 (other UUID versions are rejected with a 400).
115
+ # @param [PostSharedKey] post_shared_key
116
+ # @return [SharedKeyInstance] Created SharedKeyInstance
117
+ def create_with_metadata(
118
+ idempotency_key: :unset,
119
+ post_shared_key: nil
120
+ )
121
+
122
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Idempotency-Key' => idempotency_key, })
123
+ headers['Content-Type'] = 'application/json'
124
+
125
+
126
+
127
+ headers['Accept'] = '*/*'
128
+ response = @version.create_with_metadata('POST', @uri, headers: headers, data: post_shared_key.to_json)
129
+ shared_key_instance = SharedKeyInstance.new(
130
+ @version,
131
+ response.body,
132
+ )
133
+ SharedKeyInstanceMetadata.new(
134
+ @version,
135
+ shared_key_instance,
136
+ response.headers,
137
+ response.status_code
138
+ )
139
+ end
140
+
141
+
142
+ ##
143
+ # Lists SharedKeyInstance records from the API as a list.
144
+ # Unlike stream(), this operation is eager and will load `limit` records into
145
+ # memory before returning.
146
+ # @param [String] page_token Token for pagination
147
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
148
+ # guarantees to never return more than limit. Default is no limit
149
+ # @param [Integer] page_size Number of records to fetch per request, when
150
+ # not set will use the default value of 50 records. If no page_size is defined
151
+ # but a limit is defined, stream() will attempt to read the limit with the most
152
+ # efficient page size, i.e. min(limit, 1000)
153
+ # @return [Array] Array of up to limit results
154
+ def list(page_token: :unset, limit: nil, page_size: nil)
155
+ self.stream(
156
+ page_token: page_token,
157
+ limit: limit,
158
+ page_size: page_size
159
+ ).entries
160
+ end
161
+
162
+ ##
163
+ # Streams Instance records from the API as an Enumerable.
164
+ # This operation lazily loads records as efficiently as possible until the limit
165
+ # is reached.
166
+ # @param [String] page_token Token for pagination
167
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
168
+ # guarantees to never return more than limit. Default is no limit
169
+ # @param [Integer] page_size Number of records to fetch per request, when
170
+ # not set will use the default value of 50 records. If no page_size is defined
171
+ # but a limit is defined, stream() will attempt to read the limit with the most
172
+ # efficient page size, i.e. min(limit, 1000)
173
+ # @return [Enumerable] Enumerable that will yield up to limit results
174
+ def stream(page_token: :unset, limit: nil, page_size: nil)
175
+ limits = @version.read_limits(limit, page_size)
176
+
177
+ page = self.page(
178
+ page_token: page_token,
179
+ page_size: limits[:page_size], )
180
+
181
+ return [].each if page.nil?
182
+
183
+ result = @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
184
+ return [].each if result.nil?
185
+ result
186
+ end
187
+
188
+ ##
189
+ # Lists SharedKeyPageMetadata records from the API as a list.
190
+ # @param [String] page_token Token for pagination
191
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
192
+ # guarantees to never return more than limit. Default is no limit
193
+ # @param [Integer] page_size Number of records to fetch per request, when
194
+ # not set will use the default value of 50 records. If no page_size is defined
195
+ # but a limit is defined, stream() will attempt to read the limit with the most
196
+ # efficient page size, i.e. min(limit, 1000)
197
+ # @return [Array] Array of up to limit results
198
+ def list_with_metadata(page_token: :unset, limit: nil, page_size: nil)
199
+ limits = @version.read_limits(limit, page_size)
200
+ params = Twilio::Values.of({
201
+ 'pageToken' => page_token,
202
+
203
+ 'PageSize' => limits[:page_size],
204
+ });
205
+ headers = Twilio::Values.of({})
206
+
207
+ response = @version.page('GET', @uri, params: params, headers: headers)
208
+
209
+ SharedKeyPageMetadata.new(@version, response, @solution, limits[:limit])
210
+ end
211
+
212
+ ##
213
+ # When passed a block, yields SharedKeyInstance records from the API.
214
+ # This operation lazily loads records as efficiently as possible until the limit
215
+ # is reached.
216
+ def each
217
+ limits = @version.read_limits
218
+
219
+ page = self.page(page_size: limits[:page_size], )
220
+
221
+ return [].each if page.nil?
222
+
223
+ result = @version.stream(page,
224
+ limit: limits[:limit],
225
+ page_limit: limits[:page_limit])
226
+ return [].each if result.nil?
227
+ result.each {|x| yield x}
228
+ end
229
+
230
+ ##
231
+ # Retrieve a single page of SharedKeyInstance records from the API.
232
+ # Request is executed immediately.
233
+ # @param [String] page_token Token for pagination
234
+
235
+ # @return [Page] Page of SharedKeyInstance
236
+ def page(page_token: :unset, page_size: :unset)
237
+ params = Twilio::Values.of({
238
+ 'pageToken' => page_token,
239
+ 'PageSize' => page_size,
240
+ })
241
+ headers = Twilio::Values.of({})
242
+
243
+
244
+
245
+ response = @version.page('GET', @uri, params: params, headers: headers)
246
+
247
+ SharedKeyPage.new(@version, response, @solution)
248
+ end
249
+
250
+ ##
251
+ # Retrieve a single page of SharedKeyInstance records from the API.
252
+ # Request is executed immediately.
253
+ # @param [String] target_url API-generated URL for the requested results page
254
+ # @return [Page] Page of SharedKeyInstance
255
+ def get_page(target_url)
256
+ response = @version.domain.request(
257
+ 'GET',
258
+ target_url
259
+ )
260
+ SharedKeyPage.new(@version, response, @solution)
261
+ end
262
+
263
+
264
+
265
+ # Provide a user friendly representation
266
+ def to_s
267
+ '#<Twilio.Webhooks.V1.SharedKeyList>'
268
+ end
269
+ end
270
+
271
+
272
+ class SharedKeyContext < InstanceContext
273
+ ##
274
+ # Initialize the SharedKeyContext
275
+ # @param [Version] version Version that contains the resource
276
+ # @param [String] shared_key_id
277
+ # @return [SharedKeyContext] SharedKeyContext
278
+ def initialize(version, shared_key_id)
279
+
280
+ apiV1Version = ApiV1Version.new version.domain, version
281
+ super(apiV1Version)
282
+
283
+ # Path Solution
284
+ @solution = { shared_key_id: shared_key_id, }
285
+ @uri = "/Webhooks/SharedKeys/#{@solution[:shared_key_id]}"
286
+
287
+
288
+ end
289
+ ##
290
+ # Delete the SharedKeyInstance
291
+ # @return [Boolean] True if delete succeeds, false otherwise
292
+ def delete
293
+
294
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
295
+
296
+
297
+
298
+ response = @version.delete_with_metadata('DELETE', @uri, headers: headers)
299
+ SharedKeyInstance.new(
300
+ @version,
301
+ response.body,
302
+ shared_key_id: @solution[:shared_key_id],
303
+ )
304
+
305
+ end
306
+
307
+ ##
308
+ # Delete the SharedKeyInstanceMetadata
309
+ # @return [Boolean] True if delete succeeds, false otherwise
310
+ def delete_with_metadata
311
+
312
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
313
+
314
+
315
+
316
+ response = @version.delete_with_metadata('DELETE', @uri, headers: headers)
317
+ sharedKey_instance = SharedKeyInstance.new(
318
+ @version,
319
+ response.body,
320
+ account_sid: @solution[:account_sid],
321
+ sid: @solution[:sid],
322
+ )
323
+ SharedKeyInstanceMetadata.new(@version, sharedKey_instance, response.headers, response.status_code)
324
+ end
325
+
326
+ ##
327
+ # Fetch the SharedKeyInstance
328
+ # @return [SharedKeyInstance] Fetched SharedKeyInstance
329
+ def fetch
330
+
331
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
332
+
333
+
334
+
335
+
336
+ headers['Accept'] = '*/*'
337
+ payload = @version.fetch('GET', @uri, headers: headers)
338
+ SharedKeyInstance.new(
339
+ @version,
340
+ payload,
341
+ shared_key_id: @solution[:shared_key_id],
342
+ )
343
+ end
344
+
345
+ ##
346
+ # Fetch the SharedKeyInstanceMetadata
347
+ # @return [SharedKeyInstance] Fetched SharedKeyInstance
348
+ def fetch_with_metadata
349
+
350
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
351
+
352
+
353
+
354
+
355
+ headers['Accept'] = '*/*'
356
+ response = @version.fetch_with_metadata('GET', @uri, headers: headers)
357
+ shared_key_instance = SharedKeyInstance.new(
358
+ @version,
359
+ response.body,
360
+ shared_key_id: @solution[:shared_key_id],
361
+ )
362
+ SharedKeyInstanceMetadata.new(
363
+ @version,
364
+ shared_key_instance,
365
+ response.headers,
366
+ response.status_code
367
+ )
368
+ end
369
+
370
+ ##
371
+ # Patch the SharedKeyInstance
372
+ # @param [PatchSharedKey] patch_shared_key
373
+ # @return [SharedKeyInstance] Patched SharedKeyInstance
374
+ def patch(patch_shared_key: nil
375
+ )
376
+
377
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
378
+ headers['Content-Type'] = 'application/json'
379
+
380
+
381
+
382
+ headers['Accept'] = '*/*'
383
+ payload = @version.patch('PATCH', @uri, headers: headers, data: patch_shared_key.to_json)
384
+ SharedKeyInstance.new(
385
+ @version,
386
+ payload,
387
+ shared_key_id: @solution[:shared_key_id],
388
+ )
389
+ end
390
+
391
+ ##
392
+ # Patch the SharedKeyInstanceMetadata
393
+ # @param [PatchSharedKey] patch_shared_key
394
+ # @return [SharedKeyInstance] Patchd SharedKeyInstance
395
+ def patch_with_metadata(patch_shared_key: nil
396
+ )
397
+
398
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
399
+ headers['Content-Type'] = 'application/json'
400
+
401
+
402
+
403
+ headers['Accept'] = '*/*'
404
+ response = @version.patch_with_metadata('PATCH', @uri, headers: headers, data: patch_shared_key.to_json)
405
+ shared_key_instance = SharedKeyInstance.new(
406
+ @version,
407
+ response.body,
408
+ shared_key_id: @solution[:shared_key_id],
409
+ )
410
+ SharedKeyInstanceMetadata.new(
411
+ @version,
412
+ shared_key_instance,
413
+ response.headers,
414
+ response.status_code
415
+ )
416
+ end
417
+
418
+
419
+ ##
420
+ # Provide a user friendly representation
421
+ def to_s
422
+ context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
423
+ "#<Twilio.Webhooks.V1.SharedKeyContext #{context}>"
424
+ end
425
+
426
+ ##
427
+ # Provide a detailed, user friendly representation
428
+ def inspect
429
+ context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
430
+ "#<Twilio.Webhooks.V1.SharedKeyContext #{context}>"
431
+ end
432
+ end
433
+
434
+ class SharedKeyInstanceMetadata < InstanceResourceMetadata
435
+ ##
436
+ # Initializes a new SharedKeyInstanceMetadata.
437
+ # @param [Version] version Version that contains the resource
438
+ # @param [}SharedKeyInstance] shared_key_instance The instance associated with the metadata.
439
+ # @param [Hash] headers Header object with response headers.
440
+ # @param [Integer] status_code The HTTP status code of the response.
441
+ # @return [SharedKeyInstanceMetadata] The initialized instance with metadata.
442
+ def initialize(version, shared_key_instance, headers, status_code)
443
+ super(version, headers, status_code)
444
+ @shared_key_instance = shared_key_instance
445
+ end
446
+
447
+ def shared_key
448
+ @shared_key_instance
449
+ end
450
+
451
+ def headers
452
+ @headers
453
+ end
454
+
455
+ def status_code
456
+ @status_code
457
+ end
458
+
459
+ def to_s
460
+ "<Twilio.Api.V2010.SharedKeyInstanceMetadata status=#{@status_code}>"
461
+ end
462
+ end
463
+
464
+ class SharedKeyListResponse < InstanceListResource
465
+ # @param [Array<SharedKeyInstance>] instance
466
+ # @param [Hash{String => Object}] headers
467
+ # @param [Integer] status_code
468
+ def initialize(version, payload, key)
469
+ @shared_key_instance = payload.body[key].map do |data|
470
+ SharedKeyInstance.new(version, data)
471
+ end
472
+ @headers = payload.headers
473
+ @status_code = payload.status_code
474
+ end
475
+
476
+ def shared_key_instance
477
+ @instance
478
+ end
479
+ end
480
+
481
+ class SharedKeyPage < TokenPage
482
+ ##
483
+ # Initialize the SharedKeyPage
484
+ # @param [Version] version Version that contains the resource
485
+ # @param [Response] response Response from the API
486
+ # @param [Hash] solution Path solution for the resource
487
+ # @return [SharedKeyPage] SharedKeyPage
488
+ def initialize(version, response, solution)
489
+
490
+ apiV1Version = ApiV1Version.new version.domain, version
491
+ super(apiV1Version, response)
492
+
493
+ # Path Solution
494
+ @solution = solution
495
+ end
496
+
497
+ ##
498
+ # Build an instance of SharedKeyInstance
499
+ # @param [Hash] payload Payload response from the API
500
+ # @return [SharedKeyInstance] SharedKeyInstance
501
+ def get_instance(payload)
502
+ SharedKeyInstance.new(@version, payload)
503
+ end
504
+
505
+ ##
506
+ # Provide a user friendly representation
507
+ def to_s
508
+ '<Twilio.Webhooks.V1.SharedKeyPage>'
509
+ end
510
+ end
511
+
512
+ class SharedKeyPageMetadata < PageMetadata
513
+ attr_reader :shared_key_page
514
+
515
+ def initialize(version, response, solution, limit)
516
+ super(version, response)
517
+ @shared_key_page = []
518
+ @limit = limit
519
+ key = get_key(response.body)
520
+ records = 0
521
+ while( limit != :unset && records < limit )
522
+ @shared_key_page << SharedKeyListResponse.new(version, @payload, key, limit - records)
523
+ @payload = self.next_page
524
+ break unless @payload
525
+ records += (@payload.body[key] || []).size
526
+ end
527
+ # Path Solution
528
+ @solution = solution
529
+ end
530
+
531
+ def each
532
+ @shared_key_page.each do |record|
533
+ yield record
534
+ end
535
+ end
536
+
537
+ def to_s
538
+ '<Twilio::REST::Webhooks::V1PageMetadata>';
539
+ end
540
+ end
541
+ class SharedKeyListResponse < InstanceListResource
542
+
543
+ # @param [Array<SharedKeyInstance>] instance
544
+ # @param [Hash{String => Object}] headers
545
+ # @param [Integer] status_code
546
+ def initialize(version, payload, key, limit = :unset)
547
+ data_list = payload.body[key] || []
548
+ if limit != :unset
549
+ data_list = data_list[0, limit]
550
+ end
551
+ @shared_key = data_list.map do |data|
552
+ SharedKeyInstance.new(version, data)
553
+ end
554
+ @headers = payload.headers
555
+ @status_code = payload.status_code
556
+ end
557
+
558
+ def shared_key
559
+ @shared_key
560
+ end
561
+
562
+ def headers
563
+ @headers
564
+ end
565
+
566
+ def status_code
567
+ @status_code
568
+ end
569
+ end
570
+
571
+ class SharedKeyInstance < InstanceResource
572
+ ##
573
+ # Initialize the SharedKeyInstance
574
+ # @param [Version] version Version that contains the resource
575
+ # @param [Hash] payload payload that contains response from Twilio
576
+ # @param [String] account_sid The SID of the
577
+ # {Account}[https://www.twilio.com/docs/iam/api/account] that created this SharedKey
578
+ # resource.
579
+ # @param [String] sid The SID of the Call resource to fetch.
580
+ # @return [SharedKeyInstance] SharedKeyInstance
581
+ def initialize(version, payload , shared_key_id: nil)
582
+
583
+ apiV1Version = ApiV1Version.new version.domain, version
584
+ super(apiV1Version)
585
+
586
+ # Marshaled Properties
587
+ @properties = {
588
+ 'id' => payload['id'],
589
+ 'friendly_name' => payload['friendly_name'],
590
+ 'created_at' => Twilio.deserialize_iso8601_datetime(payload['created_at']),
591
+ 'updated_at' => Twilio.deserialize_iso8601_datetime(payload['updated_at']),
592
+ 'secret' => payload['secret'],
593
+ 'type' => payload['type'],
594
+ 'title' => payload['title'],
595
+ 'status' => payload['status'] == nil ? payload['status'] : payload['status'].to_i,
596
+ 'detail' => payload['detail'],
597
+ 'code' => payload['code'] == nil ? payload['code'] : payload['code'].to_i,
598
+ }
599
+
600
+ # Context
601
+ @instance_context = nil
602
+ @params = { 'shared_key_id' => shared_key_id || @properties['shared_key_id'] , }
603
+ end
604
+
605
+ ##
606
+ # Generate an instance context for the instance, the context is capable of
607
+ # performing various actions. All instance actions are proxied to the context
608
+ # @return [SharedKeyContext] CallContext for this CallInstance
609
+ def context
610
+ unless @instance_context
611
+ @instance_context = SharedKeyContext.new(@version , @params['shared_key_id'])
612
+ end
613
+ @instance_context
614
+ end
615
+
616
+ ##
617
+ # @return [String] Unique SharedKey identifier (TypeID/TTID format)
618
+ def id
619
+ @properties['id']
620
+ end
621
+
622
+ ##
623
+ # @return [String] Human-readable name for identification
624
+ def friendly_name
625
+ @properties['friendly_name']
626
+ end
627
+
628
+ ##
629
+ # @return [Time]
630
+ def created_at
631
+ @properties['created_at']
632
+ end
633
+
634
+ ##
635
+ # @return [Time]
636
+ def updated_at
637
+ @properties['updated_at']
638
+ end
639
+
640
+ ##
641
+ # @return [String] Signing secret (only returned on POST, cannot be retrieved later)
642
+ def secret
643
+ @properties['secret']
644
+ end
645
+
646
+ ##
647
+ # @return [String]
648
+ def type
649
+ @properties['type']
650
+ end
651
+
652
+ ##
653
+ # @return [String]
654
+ def title
655
+ @properties['title']
656
+ end
657
+
658
+ ##
659
+ # @return [String]
660
+ def status
661
+ @properties['status']
662
+ end
663
+
664
+ ##
665
+ # @return [String]
666
+ def detail
667
+ @properties['detail']
668
+ end
669
+
670
+ ##
671
+ # @return [String]
672
+ def code
673
+ @properties['code']
674
+ end
675
+
676
+ ##
677
+ # Delete the SharedKeyInstance
678
+ # @return [Boolean] True if delete succeeds, false otherwise
679
+ def delete
680
+
681
+ context.delete
682
+ end
683
+
684
+ ##
685
+ # Fetch the SharedKeyInstance
686
+ # @return [SharedKeyInstance] Fetched SharedKeyInstance
687
+ def fetch
688
+
689
+ context.fetch
690
+ end
691
+
692
+ ##
693
+ # Patch the SharedKeyInstance
694
+ # @param [PatchSharedKey] patch_shared_key
695
+ # @return [SharedKeyInstance] Patched SharedKeyInstance
696
+ def patch(patch_shared_key: nil
697
+ )
698
+
699
+ context.patch(
700
+ patch_shared_key: patch_shared_key,
701
+ )
702
+ end
703
+
704
+ ##
705
+ # Provide a user friendly representation
706
+ def to_s
707
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
708
+ "<Twilio.Webhooks.V1.SharedKeyInstance #{values}>"
709
+ end
710
+
711
+ ##
712
+ # Provide a detailed, user friendly representation
713
+ def inspect
714
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
715
+ "<Twilio.Webhooks.V1.SharedKeyInstance #{values}>"
716
+ end
717
+ end
718
+
719
+ end
720
+ end
721
+ end
722
+ end