twilio-ruby 7.12.0 → 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 (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +201 -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/client.rb +5 -0
  9. data/lib/twilio-ruby/rest/content/v1/content/approval_create.rb +108 -1
  10. data/lib/twilio-ruby/rest/content/v1/content.rb +8 -2
  11. data/lib/twilio-ruby/rest/conversations/v2/configuration.rb +7 -0
  12. data/lib/twilio-ruby/rest/conversations/v2/conversation.rb +194 -7
  13. data/lib/twilio-ruby/rest/memory/v1/bulk.rb +22 -1
  14. data/lib/twilio-ruby/rest/memory/v1/import.rb +21 -7
  15. data/lib/twilio-ruby/rest/memory/v1/store.rb +7 -0
  16. data/lib/twilio-ruby/rest/trusthub/v1/a2p_brand_registration.rb +5 -5
  17. data/lib/twilio-ruby/rest/trusthub/v1/a2p_campaign_registration.rb +4 -4
  18. data/lib/twilio-ruby/rest/trusthub/v1.rb +2 -2
  19. data/lib/twilio-ruby/rest/webhooks/v1/auth_profile.rb +825 -0
  20. data/lib/twilio-ruby/rest/webhooks/v1/edge_zone.rb +320 -0
  21. data/lib/twilio-ruby/rest/webhooks/v1/operation.rb +513 -0
  22. data/lib/twilio-ruby/rest/webhooks/v1/rule.rb +818 -0
  23. data/lib/twilio-ruby/rest/webhooks/v1/setting.rb +1028 -0
  24. data/lib/twilio-ruby/rest/webhooks/v1/shared_key.rb +722 -0
  25. data/lib/twilio-ruby/rest/webhooks/v1/test.rb +228 -0
  26. data/lib/twilio-ruby/rest/webhooks/v1.rb +126 -0
  27. data/lib/twilio-ruby/rest/webhooks.rb +6 -0
  28. data/lib/twilio-ruby/rest/webhooks_base.rb +38 -0
  29. data/lib/twilio-ruby/security/request_validator.rb +54 -8
  30. data/lib/twilio-ruby/twiml/voice_response.rb +20 -5
  31. data/lib/twilio-ruby/version.rb +1 -1
  32. metadata +13 -3
  33. data/lib/twilio-ruby/rest/oauth/v2/oauth_authorization_server.rb +0 -200
@@ -0,0 +1,1028 @@
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 SettingList < ListResource
21
+
22
+ class InlineAuthValue
23
+ # @param [scheme]: [String]
24
+ # @param [token_url]: [String] OAuth2 token endpoint URL
25
+ # @param [client_id]: [String] OAuth2 client identifier
26
+ # @param [client_secret]: [String] OAuth2 client secret (write-only, never returned)
27
+ # @param [scope]: [String] OAuth2 scope to request
28
+ # @param [audience]: [String] OAuth2 audience parameter
29
+ # @param [client_credentials_auth_method]: [String] Client credentials authentication method (defaults to CLIENT_SECRET_POST)
30
+ # @param [username]: [String]
31
+ # @param [password]: [String] Password (write-only, never returned)
32
+ attr_accessor :scheme, :token_url, :client_id, :client_secret, :scope, :audience, :client_credentials_auth_method, :username, :password
33
+ def initialize(payload)
34
+ @scheme = payload["scheme"]
35
+ @token_url = payload["token_url"]
36
+ @client_id = payload["client_id"]
37
+ @client_secret = payload["client_secret"]
38
+ @scope = payload["scope"]
39
+ @audience = payload["audience"]
40
+ @client_credentials_auth_method = payload["client_credentials_auth_method"]
41
+ @username = payload["username"]
42
+ @password = payload["password"]
43
+ end
44
+ def to_json(options = {})
45
+ {
46
+ "scheme": @scheme,
47
+ "tokenUrl": @token_url,
48
+ "clientId": @client_id,
49
+ "clientSecret": @client_secret,
50
+ "scope": @scope,
51
+ "audience": @audience,
52
+ "clientCredentialsAuthMethod": @client_credentials_auth_method,
53
+ "username": @username,
54
+ "password": @password,
55
+ }.to_json(options)
56
+ end
57
+ end
58
+
59
+ class PatchSetting
60
+ # @param [friendly_name]: [String] Human-readable name
61
+ # @param [description]: [String] Optional description of the Setting's purpose and usage
62
+ attr_accessor :friendly_name, :description
63
+ def initialize(payload)
64
+ @friendly_name = payload["friendly_name"]
65
+ @description = payload["description"]
66
+ end
67
+ def to_json(options = {})
68
+ {
69
+ "friendlyName": @friendly_name,
70
+ "description": @description,
71
+ }.to_json(options)
72
+ end
73
+ end
74
+
75
+ class PostAuthSetting
76
+ # @param [source]: [String] Indicates credentials come from an AuthProfile resource
77
+ # @param [value]: [SettingList.PostInlineAuthValue]
78
+ # @param [auth_profile_id]: [String] AuthProfile resource ID (TypeID/TTID format)
79
+ attr_accessor :source, :value, :auth_profile_id
80
+ def initialize(payload)
81
+ @source = payload["source"]
82
+ @value = payload["value"]
83
+ @auth_profile_id = payload["auth_profile_id"]
84
+ end
85
+ def to_json(options = {})
86
+ {
87
+ "source": @source,
88
+ "value": @value,
89
+ "authProfileId": @auth_profile_id,
90
+ }.to_json(options)
91
+ end
92
+ end
93
+
94
+ class PostInlineAuthValue
95
+ # @param [scheme]: [String]
96
+ # @param [token_url]: [String] OAuth2 token endpoint URL
97
+ # @param [client_id]: [String] OAuth2 client identifier
98
+ # @param [client_secret]: [String] OAuth2 client secret (write-only, never returned)
99
+ # @param [scope]: [String] OAuth2 scope to request
100
+ # @param [audience]: [String] OAuth2 audience parameter
101
+ # @param [client_credentials_auth_method]: [String] Client credentials authentication method (defaults to CLIENT_SECRET_POST)
102
+ # @param [username]: [String]
103
+ # @param [password]: [String] Password (write-only, never returned)
104
+ attr_accessor :scheme, :token_url, :client_id, :client_secret, :scope, :audience, :client_credentials_auth_method, :username, :password
105
+ def initialize(payload)
106
+ @scheme = payload["scheme"]
107
+ @token_url = payload["token_url"]
108
+ @client_id = payload["client_id"]
109
+ @client_secret = payload["client_secret"]
110
+ @scope = payload["scope"]
111
+ @audience = payload["audience"]
112
+ @client_credentials_auth_method = payload["client_credentials_auth_method"]
113
+ @username = payload["username"]
114
+ @password = payload["password"]
115
+ end
116
+ def to_json(options = {})
117
+ {
118
+ "scheme": @scheme,
119
+ "tokenUrl": @token_url,
120
+ "clientId": @client_id,
121
+ "clientSecret": @client_secret,
122
+ "scope": @scope,
123
+ "audience": @audience,
124
+ "clientCredentialsAuthMethod": @client_credentials_auth_method,
125
+ "username": @username,
126
+ "password": @password,
127
+ }.to_json(options)
128
+ end
129
+ end
130
+
131
+ class PostSetting
132
+ # @param [friendly_name]: [String] Human-readable name (optional, defaults to blank)
133
+ # @param [description]: [String] Optional description of the Setting's purpose and usage
134
+ # @param [auth]: [SettingList.PostAuthSetting]
135
+ # @param [signature]: [SettingList.SignatureSetting]
136
+ # @param [connection]: [SettingList.ConnectionSetting] HTTP connection settings. If omitted, system defaults are applied.
137
+ # @param [edge_zones]: [SettingList.EdgeZones] Edge zone configuration for webhook delivery. When omitted, all zones are eligible and Twilio selects freely. When set, `zones` lists preferred zones in priority order.
138
+ attr_accessor :friendly_name, :description, :auth, :signature, :connection, :edge_zones
139
+ def initialize(payload)
140
+ @friendly_name = payload["friendly_name"]
141
+ @description = payload["description"]
142
+ @auth = payload["auth"]
143
+ @signature = payload["signature"]
144
+ @connection = payload["connection"]
145
+ @edge_zones = payload["edge_zones"]
146
+ end
147
+ def to_json(options = {})
148
+ {
149
+ "friendlyName": @friendly_name,
150
+ "description": @description,
151
+ "auth": @auth,
152
+ "signature": @signature,
153
+ "connection": @connection,
154
+ "edgeZones": @edge_zones,
155
+ }.to_json(options)
156
+ end
157
+ end
158
+
159
+ class RetryPolicy
160
+ # @param [retry_count]: [String] Number of retry attempts (default: 0, no retries)
161
+ # @param [retry_on]: [Array<String>] Conditions that trigger retries: - HTTP_4XX: Retry on 4xx HTTP status codes - HTTP_5XX: Retry on 5xx HTTP status codes - CONNECTION_TIMEOUT: Retry on TCP/TLS connection failures - READ_TIMEOUT: Retry when server doesn't respond in time - ALL: Retry on all failure types
162
+ attr_accessor :retry_count, :retry_on
163
+ def initialize(payload)
164
+ @retry_count = payload["retry_count"]
165
+ @retry_on = payload["retry_on"]
166
+ end
167
+ def to_json(options = {})
168
+ {
169
+ "retryCount": @retry_count,
170
+ "retryOn": @retry_on,
171
+ }.to_json(options)
172
+ end
173
+ end
174
+
175
+
176
+ class InlineAuthValue
177
+ # @param [scheme]: [String]
178
+ # @param [token_url]: [String] OAuth2 token endpoint URL
179
+ # @param [client_id]: [String] OAuth2 client identifier
180
+ # @param [client_secret]: [String] OAuth2 client secret (write-only, never returned)
181
+ # @param [scope]: [String] OAuth2 scope to request
182
+ # @param [audience]: [String] OAuth2 audience parameter
183
+ # @param [client_credentials_auth_method]: [String] Client credentials authentication method (defaults to CLIENT_SECRET_POST)
184
+ # @param [username]: [String]
185
+ # @param [password]: [String] Password (write-only, never returned)
186
+ attr_accessor :scheme, :token_url, :client_id, :client_secret, :scope, :audience, :client_credentials_auth_method, :username, :password
187
+ def initialize(payload)
188
+ @scheme = payload["scheme"]
189
+ @token_url = payload["token_url"]
190
+ @client_id = payload["client_id"]
191
+ @client_secret = payload["client_secret"]
192
+ @scope = payload["scope"]
193
+ @audience = payload["audience"]
194
+ @client_credentials_auth_method = payload["client_credentials_auth_method"]
195
+ @username = payload["username"]
196
+ @password = payload["password"]
197
+ end
198
+ def to_json(options = {})
199
+ {
200
+ "scheme": @scheme,
201
+ "tokenUrl": @token_url,
202
+ "clientId": @client_id,
203
+ "clientSecret": @client_secret,
204
+ "scope": @scope,
205
+ "audience": @audience,
206
+ "clientCredentialsAuthMethod": @client_credentials_auth_method,
207
+ "username": @username,
208
+ "password": @password,
209
+ }.to_json(options)
210
+ end
211
+ end
212
+
213
+ class PatchSetting
214
+ # @param [friendly_name]: [String] Human-readable name
215
+ # @param [description]: [String] Optional description of the Setting's purpose and usage
216
+ attr_accessor :friendly_name, :description
217
+ def initialize(payload)
218
+ @friendly_name = payload["friendly_name"]
219
+ @description = payload["description"]
220
+ end
221
+ def to_json(options = {})
222
+ {
223
+ "friendlyName": @friendly_name,
224
+ "description": @description,
225
+ }.to_json(options)
226
+ end
227
+ end
228
+
229
+ class PostAuthSetting
230
+ # @param [source]: [String] Indicates credentials come from an AuthProfile resource
231
+ # @param [value]: [SettingList.PostInlineAuthValue]
232
+ # @param [auth_profile_id]: [String] AuthProfile resource ID (TypeID/TTID format)
233
+ attr_accessor :source, :value, :auth_profile_id
234
+ def initialize(payload)
235
+ @source = payload["source"]
236
+ @value = payload["value"]
237
+ @auth_profile_id = payload["auth_profile_id"]
238
+ end
239
+ def to_json(options = {})
240
+ {
241
+ "source": @source,
242
+ "value": @value,
243
+ "authProfileId": @auth_profile_id,
244
+ }.to_json(options)
245
+ end
246
+ end
247
+
248
+ class PostInlineAuthValue
249
+ # @param [scheme]: [String]
250
+ # @param [token_url]: [String] OAuth2 token endpoint URL
251
+ # @param [client_id]: [String] OAuth2 client identifier
252
+ # @param [client_secret]: [String] OAuth2 client secret (write-only, never returned)
253
+ # @param [scope]: [String] OAuth2 scope to request
254
+ # @param [audience]: [String] OAuth2 audience parameter
255
+ # @param [client_credentials_auth_method]: [String] Client credentials authentication method (defaults to CLIENT_SECRET_POST)
256
+ # @param [username]: [String]
257
+ # @param [password]: [String] Password (write-only, never returned)
258
+ attr_accessor :scheme, :token_url, :client_id, :client_secret, :scope, :audience, :client_credentials_auth_method, :username, :password
259
+ def initialize(payload)
260
+ @scheme = payload["scheme"]
261
+ @token_url = payload["token_url"]
262
+ @client_id = payload["client_id"]
263
+ @client_secret = payload["client_secret"]
264
+ @scope = payload["scope"]
265
+ @audience = payload["audience"]
266
+ @client_credentials_auth_method = payload["client_credentials_auth_method"]
267
+ @username = payload["username"]
268
+ @password = payload["password"]
269
+ end
270
+ def to_json(options = {})
271
+ {
272
+ "scheme": @scheme,
273
+ "tokenUrl": @token_url,
274
+ "clientId": @client_id,
275
+ "clientSecret": @client_secret,
276
+ "scope": @scope,
277
+ "audience": @audience,
278
+ "clientCredentialsAuthMethod": @client_credentials_auth_method,
279
+ "username": @username,
280
+ "password": @password,
281
+ }.to_json(options)
282
+ end
283
+ end
284
+
285
+ class PostSetting
286
+ # @param [friendly_name]: [String] Human-readable name (optional, defaults to blank)
287
+ # @param [description]: [String] Optional description of the Setting's purpose and usage
288
+ # @param [auth]: [SettingList.PostAuthSetting]
289
+ # @param [signature]: [SettingList.SignatureSetting]
290
+ # @param [connection]: [SettingList.ConnectionSetting] HTTP connection settings. If omitted, system defaults are applied.
291
+ # @param [edge_zones]: [SettingList.EdgeZones] Edge zone configuration for webhook delivery. When omitted, all zones are eligible and Twilio selects freely. When set, `zones` lists preferred zones in priority order.
292
+ attr_accessor :friendly_name, :description, :auth, :signature, :connection, :edge_zones
293
+ def initialize(payload)
294
+ @friendly_name = payload["friendly_name"]
295
+ @description = payload["description"]
296
+ @auth = payload["auth"]
297
+ @signature = payload["signature"]
298
+ @connection = payload["connection"]
299
+ @edge_zones = payload["edge_zones"]
300
+ end
301
+ def to_json(options = {})
302
+ {
303
+ "friendlyName": @friendly_name,
304
+ "description": @description,
305
+ "auth": @auth,
306
+ "signature": @signature,
307
+ "connection": @connection,
308
+ "edgeZones": @edge_zones,
309
+ }.to_json(options)
310
+ end
311
+ end
312
+
313
+ class RetryPolicy
314
+ # @param [retry_count]: [String] Number of retry attempts (default: 0, no retries)
315
+ # @param [retry_on]: [Array<String>] Conditions that trigger retries: - HTTP_4XX: Retry on 4xx HTTP status codes - HTTP_5XX: Retry on 5xx HTTP status codes - CONNECTION_TIMEOUT: Retry on TCP/TLS connection failures - READ_TIMEOUT: Retry when server doesn't respond in time - ALL: Retry on all failure types
316
+ attr_accessor :retry_count, :retry_on
317
+ def initialize(payload)
318
+ @retry_count = payload["retry_count"]
319
+ @retry_on = payload["retry_on"]
320
+ end
321
+ def to_json(options = {})
322
+ {
323
+ "retryCount": @retry_count,
324
+ "retryOn": @retry_on,
325
+ }.to_json(options)
326
+ end
327
+ end
328
+
329
+
330
+ ##
331
+ # Initialize the SettingList
332
+ # @param [Version] version Version that contains the resource
333
+ # @return [SettingList] SettingList
334
+ def initialize(version)
335
+
336
+ apiV1Version = ApiV1Version.new version.domain, version
337
+ super(apiV1Version)
338
+ # Path Solution
339
+ @solution = { }
340
+ @uri = "/Webhooks/Settings"
341
+
342
+ end
343
+ ##
344
+ # Create the SettingInstance
345
+ # @param [String] idempotency_key Idempotency key for mutation operations. Must be a UUIDv7 (other UUID versions are rejected with a 400).
346
+ # @param [PostSetting] post_setting
347
+ # @return [SettingInstance] Created SettingInstance
348
+ def create(
349
+ idempotency_key: :unset,
350
+ post_setting: nil
351
+ )
352
+
353
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Idempotency-Key' => idempotency_key, })
354
+ headers['Content-Type'] = 'application/json'
355
+
356
+
357
+
358
+ headers['Accept'] = '*/*'
359
+ payload = @version.create('POST', @uri, headers: headers, data: post_setting.to_json)
360
+ SettingInstance.new(
361
+ @version,
362
+ payload,
363
+ )
364
+ end
365
+
366
+ ##
367
+ # Create the SettingInstanceMetadata
368
+ # @param [String] idempotency_key Idempotency key for mutation operations. Must be a UUIDv7 (other UUID versions are rejected with a 400).
369
+ # @param [PostSetting] post_setting
370
+ # @return [SettingInstance] Created SettingInstance
371
+ def create_with_metadata(
372
+ idempotency_key: :unset,
373
+ post_setting: nil
374
+ )
375
+
376
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'Idempotency-Key' => idempotency_key, })
377
+ headers['Content-Type'] = 'application/json'
378
+
379
+
380
+
381
+ headers['Accept'] = '*/*'
382
+ response = @version.create_with_metadata('POST', @uri, headers: headers, data: post_setting.to_json)
383
+ setting_instance = SettingInstance.new(
384
+ @version,
385
+ response.body,
386
+ )
387
+ SettingInstanceMetadata.new(
388
+ @version,
389
+ setting_instance,
390
+ response.headers,
391
+ response.status_code
392
+ )
393
+ end
394
+
395
+
396
+ ##
397
+ # Lists SettingInstance records from the API as a list.
398
+ # Unlike stream(), this operation is eager and will load `limit` records into
399
+ # memory before returning.
400
+ # @param [String] page_token Token for pagination
401
+ # @param [String] auth_profile_id Filter Settings that reference this AuthProfile ID
402
+ # @param [String] shared_key_id Filter Settings that reference this SharedKey ID
403
+ # @param [String] type Whether to list your own Settings or Twilio-managed system Settings. - CUSTOMER (default): Settings created by you - SYSTEM: Twilio-managed Settings, such as the account's default legacy configuration
404
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
405
+ # guarantees to never return more than limit. Default is no limit
406
+ # @param [Integer] page_size Number of records to fetch per request, when
407
+ # not set will use the default value of 50 records. If no page_size is defined
408
+ # but a limit is defined, stream() will attempt to read the limit with the most
409
+ # efficient page size, i.e. min(limit, 1000)
410
+ # @return [Array] Array of up to limit results
411
+ def list(page_token: :unset, auth_profile_id: :unset, shared_key_id: :unset, type: :unset, limit: nil, page_size: nil)
412
+ self.stream(
413
+ page_token: page_token,
414
+ auth_profile_id: auth_profile_id,
415
+ shared_key_id: shared_key_id,
416
+ type: type,
417
+ limit: limit,
418
+ page_size: page_size
419
+ ).entries
420
+ end
421
+
422
+ ##
423
+ # Streams Instance records from the API as an Enumerable.
424
+ # This operation lazily loads records as efficiently as possible until the limit
425
+ # is reached.
426
+ # @param [String] page_token Token for pagination
427
+ # @param [String] auth_profile_id Filter Settings that reference this AuthProfile ID
428
+ # @param [String] shared_key_id Filter Settings that reference this SharedKey ID
429
+ # @param [String] type Whether to list your own Settings or Twilio-managed system Settings. - CUSTOMER (default): Settings created by you - SYSTEM: Twilio-managed Settings, such as the account's default legacy configuration
430
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
431
+ # guarantees to never return more than limit. Default is no limit
432
+ # @param [Integer] page_size Number of records to fetch per request, when
433
+ # not set will use the default value of 50 records. If no page_size is defined
434
+ # but a limit is defined, stream() will attempt to read the limit with the most
435
+ # efficient page size, i.e. min(limit, 1000)
436
+ # @return [Enumerable] Enumerable that will yield up to limit results
437
+ def stream(page_token: :unset, auth_profile_id: :unset, shared_key_id: :unset, type: :unset, limit: nil, page_size: nil)
438
+ limits = @version.read_limits(limit, page_size)
439
+
440
+ page = self.page(
441
+ page_token: page_token,
442
+ auth_profile_id: auth_profile_id,
443
+ shared_key_id: shared_key_id,
444
+ type: type,
445
+ page_size: limits[:page_size], )
446
+
447
+ return [].each if page.nil?
448
+
449
+ result = @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
450
+ return [].each if result.nil?
451
+ result
452
+ end
453
+
454
+ ##
455
+ # Lists SettingPageMetadata records from the API as a list.
456
+ # @param [String] page_token Token for pagination
457
+ # @param [String] auth_profile_id Filter Settings that reference this AuthProfile ID
458
+ # @param [String] shared_key_id Filter Settings that reference this SharedKey ID
459
+ # @param [String] type Whether to list your own Settings or Twilio-managed system Settings. - CUSTOMER (default): Settings created by you - SYSTEM: Twilio-managed Settings, such as the account's default legacy configuration
460
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
461
+ # guarantees to never return more than limit. Default is no limit
462
+ # @param [Integer] page_size Number of records to fetch per request, when
463
+ # not set will use the default value of 50 records. If no page_size is defined
464
+ # but a limit is defined, stream() will attempt to read the limit with the most
465
+ # efficient page size, i.e. min(limit, 1000)
466
+ # @return [Array] Array of up to limit results
467
+ def list_with_metadata(page_token: :unset, auth_profile_id: :unset, shared_key_id: :unset, type: :unset, limit: nil, page_size: nil)
468
+ limits = @version.read_limits(limit, page_size)
469
+ params = Twilio::Values.of({
470
+ 'pageToken' => page_token,
471
+ 'authProfileId' => auth_profile_id,
472
+ 'sharedKeyId' => shared_key_id,
473
+ 'type' => type,
474
+
475
+ 'PageSize' => limits[:page_size],
476
+ });
477
+ headers = Twilio::Values.of({})
478
+
479
+ response = @version.page('GET', @uri, params: params, headers: headers)
480
+
481
+ SettingPageMetadata.new(@version, response, @solution, limits[:limit])
482
+ end
483
+
484
+ ##
485
+ # When passed a block, yields SettingInstance records from the API.
486
+ # This operation lazily loads records as efficiently as possible until the limit
487
+ # is reached.
488
+ def each
489
+ limits = @version.read_limits
490
+
491
+ page = self.page(page_size: limits[:page_size], )
492
+
493
+ return [].each if page.nil?
494
+
495
+ result = @version.stream(page,
496
+ limit: limits[:limit],
497
+ page_limit: limits[:page_limit])
498
+ return [].each if result.nil?
499
+ result.each {|x| yield x}
500
+ end
501
+
502
+ ##
503
+ # Retrieve a single page of SettingInstance records from the API.
504
+ # Request is executed immediately.
505
+ # @param [String] page_token Token for pagination
506
+ # @param [String] auth_profile_id Filter Settings that reference this AuthProfile ID
507
+ # @param [String] shared_key_id Filter Settings that reference this SharedKey ID
508
+ # @param [String] type Whether to list your own Settings or Twilio-managed system Settings. - CUSTOMER (default): Settings created by you - SYSTEM: Twilio-managed Settings, such as the account's default legacy configuration
509
+
510
+ # @return [Page] Page of SettingInstance
511
+ def page(page_token: :unset, auth_profile_id: :unset, shared_key_id: :unset, type: :unset, page_size: :unset)
512
+ params = Twilio::Values.of({
513
+ 'pageToken' => page_token,
514
+ 'authProfileId' => auth_profile_id,
515
+ 'sharedKeyId' => shared_key_id,
516
+ 'type' => type,
517
+ 'PageSize' => page_size,
518
+ })
519
+ headers = Twilio::Values.of({})
520
+
521
+
522
+
523
+ response = @version.page('GET', @uri, params: params, headers: headers)
524
+
525
+ SettingPage.new(@version, response, @solution)
526
+ end
527
+
528
+ ##
529
+ # Retrieve a single page of SettingInstance records from the API.
530
+ # Request is executed immediately.
531
+ # @param [String] target_url API-generated URL for the requested results page
532
+ # @return [Page] Page of SettingInstance
533
+ def get_page(target_url)
534
+ response = @version.domain.request(
535
+ 'GET',
536
+ target_url
537
+ )
538
+ SettingPage.new(@version, response, @solution)
539
+ end
540
+
541
+
542
+
543
+ # Provide a user friendly representation
544
+ def to_s
545
+ '#<Twilio.Webhooks.V1.SettingList>'
546
+ end
547
+ end
548
+
549
+
550
+ class SettingContext < InstanceContext
551
+ ##
552
+ # Initialize the SettingContext
553
+ # @param [Version] version Version that contains the resource
554
+ # @param [String] setting_id
555
+ # @return [SettingContext] SettingContext
556
+ def initialize(version, setting_id)
557
+
558
+ apiV1Version = ApiV1Version.new version.domain, version
559
+ super(apiV1Version)
560
+
561
+ # Path Solution
562
+ @solution = { setting_id: setting_id, }
563
+ @uri = "/Webhooks/Settings/#{@solution[:setting_id]}"
564
+
565
+
566
+ end
567
+ ##
568
+ # Delete the SettingInstance
569
+ # @return [Boolean] True if delete succeeds, false otherwise
570
+ def delete
571
+
572
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
573
+
574
+
575
+
576
+ response = @version.delete_with_metadata('DELETE', @uri, headers: headers)
577
+ SettingInstance.new(
578
+ @version,
579
+ response.body,
580
+ setting_id: @solution[:setting_id],
581
+ )
582
+
583
+ end
584
+
585
+ ##
586
+ # Delete the SettingInstanceMetadata
587
+ # @return [Boolean] True if delete succeeds, false otherwise
588
+ def delete_with_metadata
589
+
590
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
591
+
592
+
593
+
594
+ response = @version.delete_with_metadata('DELETE', @uri, headers: headers)
595
+ setting_instance = SettingInstance.new(
596
+ @version,
597
+ response.body,
598
+ account_sid: @solution[:account_sid],
599
+ sid: @solution[:sid],
600
+ )
601
+ SettingInstanceMetadata.new(@version, setting_instance, response.headers, response.status_code)
602
+ end
603
+
604
+ ##
605
+ # Fetch the SettingInstance
606
+ # @return [SettingInstance] Fetched SettingInstance
607
+ def fetch
608
+
609
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
610
+
611
+
612
+
613
+
614
+ headers['Accept'] = '*/*'
615
+ payload = @version.fetch('GET', @uri, headers: headers)
616
+ SettingInstance.new(
617
+ @version,
618
+ payload,
619
+ setting_id: @solution[:setting_id],
620
+ )
621
+ end
622
+
623
+ ##
624
+ # Fetch the SettingInstanceMetadata
625
+ # @return [SettingInstance] Fetched SettingInstance
626
+ def fetch_with_metadata
627
+
628
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
629
+
630
+
631
+
632
+
633
+ headers['Accept'] = '*/*'
634
+ response = @version.fetch_with_metadata('GET', @uri, headers: headers)
635
+ setting_instance = SettingInstance.new(
636
+ @version,
637
+ response.body,
638
+ setting_id: @solution[:setting_id],
639
+ )
640
+ SettingInstanceMetadata.new(
641
+ @version,
642
+ setting_instance,
643
+ response.headers,
644
+ response.status_code
645
+ )
646
+ end
647
+
648
+ ##
649
+ # Patch the SettingInstance
650
+ # @param [PatchSetting] patch_setting
651
+ # @return [SettingInstance] Patched SettingInstance
652
+ def patch(patch_setting: nil
653
+ )
654
+
655
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
656
+ headers['Content-Type'] = 'application/json'
657
+
658
+
659
+
660
+ headers['Accept'] = '*/*'
661
+ payload = @version.patch('PATCH', @uri, headers: headers, data: patch_setting.to_json)
662
+ SettingInstance.new(
663
+ @version,
664
+ payload,
665
+ setting_id: @solution[:setting_id],
666
+ )
667
+ end
668
+
669
+ ##
670
+ # Patch the SettingInstanceMetadata
671
+ # @param [PatchSetting] patch_setting
672
+ # @return [SettingInstance] Patchd SettingInstance
673
+ def patch_with_metadata(patch_setting: nil
674
+ )
675
+
676
+ headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
677
+ headers['Content-Type'] = 'application/json'
678
+
679
+
680
+
681
+ headers['Accept'] = '*/*'
682
+ response = @version.patch_with_metadata('PATCH', @uri, headers: headers, data: patch_setting.to_json)
683
+ setting_instance = SettingInstance.new(
684
+ @version,
685
+ response.body,
686
+ setting_id: @solution[:setting_id],
687
+ )
688
+ SettingInstanceMetadata.new(
689
+ @version,
690
+ setting_instance,
691
+ response.headers,
692
+ response.status_code
693
+ )
694
+ end
695
+
696
+
697
+ ##
698
+ # Provide a user friendly representation
699
+ def to_s
700
+ context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
701
+ "#<Twilio.Webhooks.V1.SettingContext #{context}>"
702
+ end
703
+
704
+ ##
705
+ # Provide a detailed, user friendly representation
706
+ def inspect
707
+ context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
708
+ "#<Twilio.Webhooks.V1.SettingContext #{context}>"
709
+ end
710
+ end
711
+
712
+ class SettingInstanceMetadata < InstanceResourceMetadata
713
+ ##
714
+ # Initializes a new SettingInstanceMetadata.
715
+ # @param [Version] version Version that contains the resource
716
+ # @param [}SettingInstance] setting_instance The instance associated with the metadata.
717
+ # @param [Hash] headers Header object with response headers.
718
+ # @param [Integer] status_code The HTTP status code of the response.
719
+ # @return [SettingInstanceMetadata] The initialized instance with metadata.
720
+ def initialize(version, setting_instance, headers, status_code)
721
+ super(version, headers, status_code)
722
+ @setting_instance = setting_instance
723
+ end
724
+
725
+ def setting
726
+ @setting_instance
727
+ end
728
+
729
+ def headers
730
+ @headers
731
+ end
732
+
733
+ def status_code
734
+ @status_code
735
+ end
736
+
737
+ def to_s
738
+ "<Twilio.Api.V2010.SettingInstanceMetadata status=#{@status_code}>"
739
+ end
740
+ end
741
+
742
+ class SettingListResponse < InstanceListResource
743
+ # @param [Array<SettingInstance>] instance
744
+ # @param [Hash{String => Object}] headers
745
+ # @param [Integer] status_code
746
+ def initialize(version, payload, key)
747
+ @setting_instance = payload.body[key].map do |data|
748
+ SettingInstance.new(version, data)
749
+ end
750
+ @headers = payload.headers
751
+ @status_code = payload.status_code
752
+ end
753
+
754
+ def setting_instance
755
+ @instance
756
+ end
757
+ end
758
+
759
+ class SettingPage < TokenPage
760
+ ##
761
+ # Initialize the SettingPage
762
+ # @param [Version] version Version that contains the resource
763
+ # @param [Response] response Response from the API
764
+ # @param [Hash] solution Path solution for the resource
765
+ # @return [SettingPage] SettingPage
766
+ def initialize(version, response, solution)
767
+
768
+ apiV1Version = ApiV1Version.new version.domain, version
769
+ super(apiV1Version, response)
770
+
771
+ # Path Solution
772
+ @solution = solution
773
+ end
774
+
775
+ ##
776
+ # Build an instance of SettingInstance
777
+ # @param [Hash] payload Payload response from the API
778
+ # @return [SettingInstance] SettingInstance
779
+ def get_instance(payload)
780
+ SettingInstance.new(@version, payload)
781
+ end
782
+
783
+ ##
784
+ # Provide a user friendly representation
785
+ def to_s
786
+ '<Twilio.Webhooks.V1.SettingPage>'
787
+ end
788
+ end
789
+
790
+ class SettingPageMetadata < PageMetadata
791
+ attr_reader :setting_page
792
+
793
+ def initialize(version, response, solution, limit)
794
+ super(version, response)
795
+ @setting_page = []
796
+ @limit = limit
797
+ key = get_key(response.body)
798
+ records = 0
799
+ while( limit != :unset && records < limit )
800
+ @setting_page << SettingListResponse.new(version, @payload, key, limit - records)
801
+ @payload = self.next_page
802
+ break unless @payload
803
+ records += (@payload.body[key] || []).size
804
+ end
805
+ # Path Solution
806
+ @solution = solution
807
+ end
808
+
809
+ def each
810
+ @setting_page.each do |record|
811
+ yield record
812
+ end
813
+ end
814
+
815
+ def to_s
816
+ '<Twilio::REST::Webhooks::V1PageMetadata>';
817
+ end
818
+ end
819
+ class SettingListResponse < InstanceListResource
820
+
821
+ # @param [Array<SettingInstance>] instance
822
+ # @param [Hash{String => Object}] headers
823
+ # @param [Integer] status_code
824
+ def initialize(version, payload, key, limit = :unset)
825
+ data_list = payload.body[key] || []
826
+ if limit != :unset
827
+ data_list = data_list[0, limit]
828
+ end
829
+ @setting = data_list.map do |data|
830
+ SettingInstance.new(version, data)
831
+ end
832
+ @headers = payload.headers
833
+ @status_code = payload.status_code
834
+ end
835
+
836
+ def setting
837
+ @setting
838
+ end
839
+
840
+ def headers
841
+ @headers
842
+ end
843
+
844
+ def status_code
845
+ @status_code
846
+ end
847
+ end
848
+
849
+ class SettingInstance < InstanceResource
850
+ ##
851
+ # Initialize the SettingInstance
852
+ # @param [Version] version Version that contains the resource
853
+ # @param [Hash] payload payload that contains response from Twilio
854
+ # @param [String] account_sid The SID of the
855
+ # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Setting
856
+ # resource.
857
+ # @param [String] sid The SID of the Call resource to fetch.
858
+ # @return [SettingInstance] SettingInstance
859
+ def initialize(version, payload , setting_id: nil)
860
+
861
+ apiV1Version = ApiV1Version.new version.domain, version
862
+ super(apiV1Version)
863
+
864
+ # Marshaled Properties
865
+ @properties = {
866
+ 'id' => payload['id'],
867
+ 'type' => payload['type'],
868
+ 'friendly_name' => payload['friendly_name'],
869
+ 'description' => payload['description'],
870
+ 'auth' => payload['auth'],
871
+ 'signature' => payload['signature'],
872
+ 'connection' => payload['connection'],
873
+ 'edge_zones' => payload['edge_zones'],
874
+ 'created_at' => Twilio.deserialize_iso8601_datetime(payload['created_at']),
875
+ 'updated_at' => Twilio.deserialize_iso8601_datetime(payload['updated_at']),
876
+ 'title' => payload['title'],
877
+ 'status' => payload['status'] == nil ? payload['status'] : payload['status'].to_i,
878
+ 'detail' => payload['detail'],
879
+ 'code' => payload['code'] == nil ? payload['code'] : payload['code'].to_i,
880
+ }
881
+
882
+ # Context
883
+ @instance_context = nil
884
+ @params = { 'setting_id' => setting_id || @properties['setting_id'] , }
885
+ end
886
+
887
+ ##
888
+ # Generate an instance context for the instance, the context is capable of
889
+ # performing various actions. All instance actions are proxied to the context
890
+ # @return [SettingContext] CallContext for this CallInstance
891
+ def context
892
+ unless @instance_context
893
+ @instance_context = SettingContext.new(@version , @params['setting_id'])
894
+ end
895
+ @instance_context
896
+ end
897
+
898
+ ##
899
+ # @return [String] Unique Setting identifier (TypeID/TTID format)
900
+ def id
901
+ @properties['id']
902
+ end
903
+
904
+ ##
905
+ # @return [String] Setting ownership (read-only): - **system**: Managed by Twilio - Twilio provides managed Settings to simplify your onboarding journey - Cannot be modified or deleted - Used for default account configuration - **customer**: Created by you - Can update friendlyName via PATCH - Can delete via DELETE (if not in use) - Core config (auth, signature) is immutable
906
+ def type
907
+ @properties['type']
908
+ end
909
+
910
+ ##
911
+ # @return [String] Human-readable name
912
+ def friendly_name
913
+ @properties['friendly_name']
914
+ end
915
+
916
+ ##
917
+ # @return [String] Optional description of the Setting's purpose and usage
918
+ def description
919
+ @properties['description']
920
+ end
921
+
922
+ ##
923
+ # @return [AuthSetting]
924
+ def auth
925
+ @properties['auth']
926
+ end
927
+
928
+ ##
929
+ # @return [SignatureSetting]
930
+ def signature
931
+ @properties['signature']
932
+ end
933
+
934
+ ##
935
+ # @return [ConnectionSetting] HTTP connection settings. If omitted, system defaults are applied.
936
+ def connection
937
+ @properties['connection']
938
+ end
939
+
940
+ ##
941
+ # @return [EdgeZones] Edge zone configuration for webhook delivery. When omitted, all zones are eligible and Twilio selects freely. When set, `zones` lists preferred zones in priority order.
942
+ def edge_zones
943
+ @properties['edge_zones']
944
+ end
945
+
946
+ ##
947
+ # @return [Time]
948
+ def created_at
949
+ @properties['created_at']
950
+ end
951
+
952
+ ##
953
+ # @return [Time]
954
+ def updated_at
955
+ @properties['updated_at']
956
+ end
957
+
958
+ ##
959
+ # @return [String]
960
+ def title
961
+ @properties['title']
962
+ end
963
+
964
+ ##
965
+ # @return [String]
966
+ def status
967
+ @properties['status']
968
+ end
969
+
970
+ ##
971
+ # @return [String]
972
+ def detail
973
+ @properties['detail']
974
+ end
975
+
976
+ ##
977
+ # @return [String]
978
+ def code
979
+ @properties['code']
980
+ end
981
+
982
+ ##
983
+ # Delete the SettingInstance
984
+ # @return [Boolean] True if delete succeeds, false otherwise
985
+ def delete
986
+
987
+ context.delete
988
+ end
989
+
990
+ ##
991
+ # Fetch the SettingInstance
992
+ # @return [SettingInstance] Fetched SettingInstance
993
+ def fetch
994
+
995
+ context.fetch
996
+ end
997
+
998
+ ##
999
+ # Patch the SettingInstance
1000
+ # @param [PatchSetting] patch_setting
1001
+ # @return [SettingInstance] Patched SettingInstance
1002
+ def patch(patch_setting: nil
1003
+ )
1004
+
1005
+ context.patch(
1006
+ patch_setting: patch_setting,
1007
+ )
1008
+ end
1009
+
1010
+ ##
1011
+ # Provide a user friendly representation
1012
+ def to_s
1013
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
1014
+ "<Twilio.Webhooks.V1.SettingInstance #{values}>"
1015
+ end
1016
+
1017
+ ##
1018
+ # Provide a detailed, user friendly representation
1019
+ def inspect
1020
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
1021
+ "<Twilio.Webhooks.V1.SettingInstance #{values}>"
1022
+ end
1023
+ end
1024
+
1025
+ end
1026
+ end
1027
+ end
1028
+ end