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,320 @@
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 EdgeZoneList < ListResource
21
+
22
+ ##
23
+ # Initialize the EdgeZoneList
24
+ # @param [Version] version Version that contains the resource
25
+ # @return [EdgeZoneList] EdgeZoneList
26
+ def initialize(version)
27
+
28
+ apiV1Version = ApiV1Version.new version.domain, version
29
+ super(apiV1Version)
30
+ # Path Solution
31
+ @solution = { }
32
+ @uri = "/Webhooks/EdgeZones"
33
+
34
+ end
35
+
36
+ ##
37
+ # Lists EdgeZoneInstance records from the API as a list.
38
+ # Unlike stream(), this operation is eager and will load `limit` records into
39
+ # memory before returning.
40
+ # @param [String] page_token Token for pagination
41
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
42
+ # guarantees to never return more than limit. Default is no limit
43
+ # @param [Integer] page_size Number of records to fetch per request, when
44
+ # not set will use the default value of 50 records. If no page_size is defined
45
+ # but a limit is defined, stream() will attempt to read the limit with the most
46
+ # efficient page size, i.e. min(limit, 1000)
47
+ # @return [Array] Array of up to limit results
48
+ def list(page_token: :unset, limit: nil, page_size: nil)
49
+ self.stream(
50
+ page_token: page_token,
51
+ limit: limit,
52
+ page_size: page_size
53
+ ).entries
54
+ end
55
+
56
+ ##
57
+ # Streams Instance records from the API as an Enumerable.
58
+ # This operation lazily loads records as efficiently as possible until the limit
59
+ # is reached.
60
+ # @param [String] page_token Token for pagination
61
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
62
+ # guarantees to never return more than limit. Default is no limit
63
+ # @param [Integer] page_size Number of records to fetch per request, when
64
+ # not set will use the default value of 50 records. If no page_size is defined
65
+ # but a limit is defined, stream() will attempt to read the limit with the most
66
+ # efficient page size, i.e. min(limit, 1000)
67
+ # @return [Enumerable] Enumerable that will yield up to limit results
68
+ def stream(page_token: :unset, limit: nil, page_size: nil)
69
+ limits = @version.read_limits(limit, page_size)
70
+
71
+ page = self.page(
72
+ page_token: page_token,
73
+ page_size: limits[:page_size], )
74
+
75
+ return [].each if page.nil?
76
+
77
+ result = @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
78
+ return [].each if result.nil?
79
+ result
80
+ end
81
+
82
+ ##
83
+ # Lists EdgeZonePageMetadata records from the API as a list.
84
+ # @param [String] page_token Token for pagination
85
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
86
+ # guarantees to never return more than limit. Default is no limit
87
+ # @param [Integer] page_size Number of records to fetch per request, when
88
+ # not set will use the default value of 50 records. If no page_size is defined
89
+ # but a limit is defined, stream() will attempt to read the limit with the most
90
+ # efficient page size, i.e. min(limit, 1000)
91
+ # @return [Array] Array of up to limit results
92
+ def list_with_metadata(page_token: :unset, limit: nil, page_size: nil)
93
+ limits = @version.read_limits(limit, page_size)
94
+ params = Twilio::Values.of({
95
+ 'pageToken' => page_token,
96
+
97
+ 'PageSize' => limits[:page_size],
98
+ });
99
+ headers = Twilio::Values.of({})
100
+
101
+ response = @version.page('GET', @uri, params: params, headers: headers)
102
+
103
+ EdgeZonePageMetadata.new(@version, response, @solution, limits[:limit])
104
+ end
105
+
106
+ ##
107
+ # When passed a block, yields EdgeZoneInstance records from the API.
108
+ # This operation lazily loads records as efficiently as possible until the limit
109
+ # is reached.
110
+ def each
111
+ limits = @version.read_limits
112
+
113
+ page = self.page(page_size: limits[:page_size], )
114
+
115
+ return [].each if page.nil?
116
+
117
+ result = @version.stream(page,
118
+ limit: limits[:limit],
119
+ page_limit: limits[:page_limit])
120
+ return [].each if result.nil?
121
+ result.each {|x| yield x}
122
+ end
123
+
124
+ ##
125
+ # Retrieve a single page of EdgeZoneInstance records from the API.
126
+ # Request is executed immediately.
127
+ # @param [String] page_token Token for pagination
128
+
129
+ # @return [Page] Page of EdgeZoneInstance
130
+ def page(page_token: :unset, page_size: :unset)
131
+ params = Twilio::Values.of({
132
+ 'pageToken' => page_token,
133
+ 'PageSize' => page_size,
134
+ })
135
+ headers = Twilio::Values.of({})
136
+
137
+
138
+
139
+ response = @version.page('GET', @uri, params: params, headers: headers)
140
+
141
+ EdgeZonePage.new(@version, response, @solution)
142
+ end
143
+
144
+ ##
145
+ # Retrieve a single page of EdgeZoneInstance records from the API.
146
+ # Request is executed immediately.
147
+ # @param [String] target_url API-generated URL for the requested results page
148
+ # @return [Page] Page of EdgeZoneInstance
149
+ def get_page(target_url)
150
+ response = @version.domain.request(
151
+ 'GET',
152
+ target_url
153
+ )
154
+ EdgeZonePage.new(@version, response, @solution)
155
+ end
156
+
157
+
158
+
159
+ # Provide a user friendly representation
160
+ def to_s
161
+ '#<Twilio.Webhooks.V1.EdgeZoneList>'
162
+ end
163
+ end
164
+
165
+ class EdgeZonePage < TokenPage
166
+ ##
167
+ # Initialize the EdgeZonePage
168
+ # @param [Version] version Version that contains the resource
169
+ # @param [Response] response Response from the API
170
+ # @param [Hash] solution Path solution for the resource
171
+ # @return [EdgeZonePage] EdgeZonePage
172
+ def initialize(version, response, solution)
173
+
174
+ apiV1Version = ApiV1Version.new version.domain, version
175
+ super(apiV1Version, response)
176
+
177
+ # Path Solution
178
+ @solution = solution
179
+ end
180
+
181
+ ##
182
+ # Build an instance of EdgeZoneInstance
183
+ # @param [Hash] payload Payload response from the API
184
+ # @return [EdgeZoneInstance] EdgeZoneInstance
185
+ def get_instance(payload)
186
+ EdgeZoneInstance.new(@version, payload)
187
+ end
188
+
189
+ ##
190
+ # Provide a user friendly representation
191
+ def to_s
192
+ '<Twilio.Webhooks.V1.EdgeZonePage>'
193
+ end
194
+ end
195
+
196
+ class EdgeZonePageMetadata < PageMetadata
197
+ attr_reader :edge_zone_page
198
+
199
+ def initialize(version, response, solution, limit)
200
+ super(version, response)
201
+ @edge_zone_page = []
202
+ @limit = limit
203
+ key = get_key(response.body)
204
+ records = 0
205
+ while( limit != :unset && records < limit )
206
+ @edge_zone_page << EdgeZoneListResponse.new(version, @payload, key, limit - records)
207
+ @payload = self.next_page
208
+ break unless @payload
209
+ records += (@payload.body[key] || []).size
210
+ end
211
+ # Path Solution
212
+ @solution = solution
213
+ end
214
+
215
+ def each
216
+ @edge_zone_page.each do |record|
217
+ yield record
218
+ end
219
+ end
220
+
221
+ def to_s
222
+ '<Twilio::REST::Webhooks::V1PageMetadata>';
223
+ end
224
+ end
225
+ class EdgeZoneListResponse < InstanceListResource
226
+
227
+ # @param [Array<EdgeZoneInstance>] instance
228
+ # @param [Hash{String => Object}] headers
229
+ # @param [Integer] status_code
230
+ def initialize(version, payload, key, limit = :unset)
231
+ data_list = payload.body[key] || []
232
+ if limit != :unset
233
+ data_list = data_list[0, limit]
234
+ end
235
+ @edge_zone = data_list.map do |data|
236
+ EdgeZoneInstance.new(version, data)
237
+ end
238
+ @headers = payload.headers
239
+ @status_code = payload.status_code
240
+ end
241
+
242
+ def edge_zone
243
+ @edge_zone
244
+ end
245
+
246
+ def headers
247
+ @headers
248
+ end
249
+
250
+ def status_code
251
+ @status_code
252
+ end
253
+ end
254
+
255
+ class EdgeZoneInstance < InstanceResource
256
+ ##
257
+ # Initialize the EdgeZoneInstance
258
+ # @param [Version] version Version that contains the resource
259
+ # @param [Hash] payload payload that contains response from Twilio
260
+ # @param [String] account_sid The SID of the
261
+ # {Account}[https://www.twilio.com/docs/iam/api/account] that created this EdgeZone
262
+ # resource.
263
+ # @param [String] sid The SID of the Call resource to fetch.
264
+ # @return [EdgeZoneInstance] EdgeZoneInstance
265
+ def initialize(version, payload )
266
+
267
+ apiV1Version = ApiV1Version.new version.domain, version
268
+ super(apiV1Version)
269
+
270
+ # Marshaled Properties
271
+ @properties = {
272
+ 'id' => payload['id'],
273
+ 'friendly_name' => payload['friendly_name'],
274
+ 'description' => payload['description'],
275
+ 'edge_locations' => payload['edge_locations'],
276
+ }
277
+ end
278
+
279
+
280
+ ##
281
+ # @return [String] Stable zone identifier. Use this value in Settings.edgeZones.
282
+ def id
283
+ @properties['id']
284
+ end
285
+
286
+ ##
287
+ # @return [String] Human-readable zone name.
288
+ def friendly_name
289
+ @properties['friendly_name']
290
+ end
291
+
292
+ ##
293
+ # @return [String] Routing guidance for this zone.
294
+ def description
295
+ @properties['description']
296
+ end
297
+
298
+ ##
299
+ # @return [Array<EdgeLocation>] PoPs currently active within this zone.
300
+ def edge_locations
301
+ @properties['edge_locations']
302
+ end
303
+
304
+ ##
305
+ # Provide a user friendly representation
306
+ def to_s
307
+ "<Twilio.Webhooks.V1.EdgeZoneInstance>"
308
+ end
309
+
310
+ ##
311
+ # Provide a detailed, user friendly representation
312
+ def inspect
313
+ "<Twilio.Webhooks.V1.EdgeZoneInstance>"
314
+ end
315
+ end
316
+
317
+ end
318
+ end
319
+ end
320
+ end