svix 0.83.1 → 0.84.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/svix/api/application_api.rb +247 -181
  4. data/lib/svix/api/authentication_api.rb +82 -150
  5. data/lib/svix/api/background_tasks_api.rb +161 -0
  6. data/lib/svix/api/endpoint_api.rb +561 -485
  7. data/lib/svix/api/environment_api.rb +16 -16
  8. data/lib/svix/api/environment_settings_api.rb +7 -10
  9. data/lib/svix/api/event_type_api.rb +152 -81
  10. data/lib/svix/api/health_api.rb +6 -9
  11. data/lib/svix/api/integration_api.rb +123 -134
  12. data/lib/svix/api/message_api.rb +96 -102
  13. data/lib/svix/api/message_attempt_api.rb +382 -406
  14. data/lib/svix/api/statistics_api.rb +107 -45
  15. data/lib/svix/api_client.rb +0 -1
  16. data/lib/svix/application_api.rb +22 -22
  17. data/lib/svix/authentication_api.rb +3 -3
  18. data/lib/svix/configuration.rb +0 -7
  19. data/lib/svix/endpoint_api.rb +16 -16
  20. data/lib/svix/event_type_api.rb +19 -19
  21. data/lib/svix/integration_api.rb +26 -26
  22. data/lib/svix/message_api.rb +4 -4
  23. data/lib/svix/message_attempt_api.rb +8 -8
  24. data/lib/svix/models/app_portal_access_in.rb +1 -0
  25. data/lib/svix/models/application_in.rb +34 -1
  26. data/lib/svix/models/application_out.rb +20 -2
  27. data/lib/svix/models/application_patch.rb +299 -0
  28. data/lib/svix/models/application_stats.rb +0 -1
  29. data/lib/svix/models/{webhook_types.rb → background_task_out.rb} +40 -69
  30. data/lib/svix/models/background_task_out_common.rb +251 -0
  31. data/lib/svix/models/background_task_status.rb +38 -0
  32. data/lib/svix/models/background_task_type.rb +38 -0
  33. data/lib/svix/models/calculate_app_stats_in.rb +255 -0
  34. data/lib/svix/models/endpoint_created_event.rb +5 -0
  35. data/lib/svix/models/endpoint_created_event_data.rb +0 -2
  36. data/lib/svix/models/endpoint_deleted_event.rb +5 -0
  37. data/lib/svix/models/endpoint_deleted_event_data.rb +0 -2
  38. data/lib/svix/models/endpoint_disabled_event.rb +5 -0
  39. data/lib/svix/models/endpoint_disabled_event_data.rb +1 -2
  40. data/lib/svix/models/endpoint_in.rb +19 -10
  41. data/lib/svix/models/endpoint_message_out.rb +1 -0
  42. data/lib/svix/models/endpoint_out.rb +33 -15
  43. data/lib/svix/models/endpoint_patch.rb +405 -0
  44. data/lib/svix/models/endpoint_secret_rotate_in.rb +2 -0
  45. data/lib/svix/models/endpoint_transformation_in.rb +0 -2
  46. data/lib/svix/models/endpoint_transformation_simulate_in.rb +6 -0
  47. data/lib/svix/models/endpoint_update.rb +19 -10
  48. data/lib/svix/models/endpoint_updated_event.rb +5 -0
  49. data/lib/svix/models/endpoint_updated_event_data.rb +0 -2
  50. data/lib/svix/models/event_type_example_out.rb +4 -2
  51. data/lib/svix/models/event_type_patch.rb +275 -0
  52. data/lib/svix/models/event_type_schema_in.rb +0 -1
  53. data/lib/svix/models/http_validation_error.rb +5 -0
  54. data/lib/svix/models/list_response_application_stats.rb +15 -5
  55. data/lib/svix/models/list_response_background_task_out.rb +259 -0
  56. data/lib/svix/models/list_response_integration_out.rb +15 -5
  57. data/lib/svix/models/list_response_message_endpoint_out.rb +15 -5
  58. data/lib/svix/models/message_attempt_exhausted_event.rb +5 -0
  59. data/lib/svix/models/message_attempt_exhausted_event_data.rb +1 -2
  60. data/lib/svix/models/message_attempt_failing_event.rb +5 -0
  61. data/lib/svix/models/message_attempt_failing_event_data.rb +1 -2
  62. data/lib/svix/models/message_attempt_headers_out.rb +27 -1
  63. data/lib/svix/models/message_endpoint_out.rb +45 -29
  64. data/lib/svix/models/message_in.rb +0 -1
  65. data/lib/svix/models/{one_time_token_out.rb → recover_out.rb} +41 -13
  66. data/lib/svix/models/{one_time_token_in.rb → replay_out.rb} +41 -13
  67. data/lib/svix/models/transformation_http_method.rb +1 -1
  68. data/lib/svix/models/validation_error.rb +4 -0
  69. data/lib/svix/version.rb +1 -1
  70. metadata +14 -5
@@ -14,15 +14,14 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module Svix
17
+ # Sent when an endpoint has been automatically disabled after continuous failures.
17
18
  class EndpointDisabledEventData
18
19
  attr_accessor :app_id
19
20
 
20
- # Optional unique identifier for the application
21
21
  attr_accessor :app_uid
22
22
 
23
23
  attr_accessor :endpoint_id
24
24
 
25
- # Optional unique identifier for the endpoint
26
25
  attr_accessor :endpoint_uid
27
26
 
28
27
  attr_accessor :fail_since
@@ -80,7 +80,6 @@ module Svix
80
80
  Set.new([
81
81
  :'channels',
82
82
  :'filter_types',
83
- :'metadata',
84
83
  :'rate_limit',
85
84
  :'secret',
86
85
  :'uid',
@@ -169,10 +168,6 @@ module Svix
169
168
  invalid_properties.push('invalid value for "filter_types", number of items must be greater than or equal to 1.')
170
169
  end
171
170
 
172
- if !@rate_limit.nil? && @rate_limit > 65535
173
- invalid_properties.push('invalid value for "rate_limit", must be smaller than or equal to 65535.')
174
- end
175
-
176
171
  if !@rate_limit.nil? && @rate_limit < 1
177
172
  invalid_properties.push('invalid value for "rate_limit", must be greater than or equal to 1.')
178
173
  end
@@ -211,6 +206,10 @@ module Svix
211
206
  invalid_properties.push('invalid value for "version", version cannot be nil.')
212
207
  end
213
208
 
209
+ if @version < 1
210
+ invalid_properties.push('invalid value for "version", must be greater than or equal to 1.')
211
+ end
212
+
214
213
  invalid_properties
215
214
  end
216
215
 
@@ -220,7 +219,6 @@ module Svix
220
219
  return false if !@channels.nil? && @channels.length > 10
221
220
  return false if !@channels.nil? && @channels.length < 1
222
221
  return false if !@filter_types.nil? && @filter_types.length < 1
223
- return false if !@rate_limit.nil? && @rate_limit > 65535
224
222
  return false if !@rate_limit.nil? && @rate_limit < 1
225
223
  return false if !@secret.nil? && @secret !~ Regexp.new(/^(whsec_)?[a-zA-Z0-9+\/=]{32,100}$/)
226
224
  return false if !@uid.nil? && @uid.to_s.length > 256
@@ -230,6 +228,7 @@ module Svix
230
228
  return false if @url.to_s.length > 65536
231
229
  return false if @url.to_s.length < 1
232
230
  return false if @version.nil?
231
+ return false if @version < 1
233
232
  true
234
233
  end
235
234
 
@@ -260,10 +259,6 @@ module Svix
260
259
  # Custom attribute writer method with validation
261
260
  # @param [Object] rate_limit Value to be assigned
262
261
  def rate_limit=(rate_limit)
263
- if !rate_limit.nil? && rate_limit > 65535
264
- fail ArgumentError, 'invalid value for "rate_limit", must be smaller than or equal to 65535.'
265
- end
266
-
267
262
  if !rate_limit.nil? && rate_limit < 1
268
263
  fail ArgumentError, 'invalid value for "rate_limit", must be greater than or equal to 1.'
269
264
  end
@@ -319,6 +314,20 @@ module Svix
319
314
  @url = url
320
315
  end
321
316
 
317
+ # Custom attribute writer method with validation
318
+ # @param [Object] version Value to be assigned
319
+ def version=(version)
320
+ if version.nil?
321
+ fail ArgumentError, 'version cannot be nil'
322
+ end
323
+
324
+ if version < 1
325
+ fail ArgumentError, 'invalid value for "version", must be greater than or equal to 1.'
326
+ end
327
+
328
+ @version = version
329
+ end
330
+
322
331
  # Checks equality by comparing each attribute.
323
332
  # @param [Object] Object to be compared
324
333
  def ==(o)
@@ -14,6 +14,7 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module Svix
17
+ # A model containing information on a given message plus additional fields on the last attempt for that message.
17
18
  class EndpointMessageOut
18
19
  # List of free-form identifiers that endpoints can filter by
19
20
  attr_accessor :channels
@@ -20,6 +20,7 @@ module Svix
20
20
 
21
21
  attr_accessor :created_at
22
22
 
23
+ # An example endpoint name
23
24
  attr_accessor :description
24
25
 
25
26
  attr_accessor :disabled
@@ -87,7 +88,6 @@ module Svix
87
88
  Set.new([
88
89
  :'channels',
89
90
  :'filter_types',
90
- :'metadata',
91
91
  :'rate_limit',
92
92
  :'uid',
93
93
  ])
@@ -120,8 +120,6 @@ module Svix
120
120
 
121
121
  if attributes.key?(:'description')
122
122
  self.description = attributes[:'description']
123
- else
124
- self.description = ''
125
123
  end
126
124
 
127
125
  if attributes.key?(:'disabled')
@@ -183,6 +181,10 @@ module Svix
183
181
  invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
184
182
  end
185
183
 
184
+ if @description.nil?
185
+ invalid_properties.push('invalid value for "description", description cannot be nil.')
186
+ end
187
+
186
188
  if !@filter_types.nil? && @filter_types.length < 1
187
189
  invalid_properties.push('invalid value for "filter_types", number of items must be greater than or equal to 1.')
188
190
  end
@@ -191,12 +193,12 @@ module Svix
191
193
  invalid_properties.push('invalid value for "id", id cannot be nil.')
192
194
  end
193
195
 
194
- if !@rate_limit.nil? && @rate_limit > 65535
195
- invalid_properties.push('invalid value for "rate_limit", must be smaller than or equal to 65535.')
196
+ if @metadata.nil?
197
+ invalid_properties.push('invalid value for "metadata", metadata cannot be nil.')
196
198
  end
197
199
 
198
- if !@rate_limit.nil? && @rate_limit < 1
199
- invalid_properties.push('invalid value for "rate_limit", must be greater than or equal to 1.')
200
+ if !@rate_limit.nil? && @rate_limit < 0
201
+ invalid_properties.push('invalid value for "rate_limit", must be greater than or equal to 0.')
200
202
  end
201
203
 
202
204
  if !@uid.nil? && @uid.to_s.length > 256
@@ -232,6 +234,10 @@ module Svix
232
234
  invalid_properties.push('invalid value for "version", version cannot be nil.')
233
235
  end
234
236
 
237
+ if @version < 1
238
+ invalid_properties.push('invalid value for "version", must be greater than or equal to 1.')
239
+ end
240
+
235
241
  invalid_properties
236
242
  end
237
243
 
@@ -241,10 +247,11 @@ module Svix
241
247
  return false if !@channels.nil? && @channels.length > 10
242
248
  return false if !@channels.nil? && @channels.length < 1
243
249
  return false if @created_at.nil?
250
+ return false if @description.nil?
244
251
  return false if !@filter_types.nil? && @filter_types.length < 1
245
252
  return false if @id.nil?
246
- return false if !@rate_limit.nil? && @rate_limit > 65535
247
- return false if !@rate_limit.nil? && @rate_limit < 1
253
+ return false if @metadata.nil?
254
+ return false if !@rate_limit.nil? && @rate_limit < 0
248
255
  return false if !@uid.nil? && @uid.to_s.length > 256
249
256
  return false if !@uid.nil? && @uid.to_s.length < 1
250
257
  return false if !@uid.nil? && @uid !~ Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
@@ -253,6 +260,7 @@ module Svix
253
260
  return false if @url.to_s.length > 65536
254
261
  return false if @url.to_s.length < 1
255
262
  return false if @version.nil?
263
+ return false if @version < 1
256
264
  true
257
265
  end
258
266
 
@@ -283,12 +291,8 @@ module Svix
283
291
  # Custom attribute writer method with validation
284
292
  # @param [Object] rate_limit Value to be assigned
285
293
  def rate_limit=(rate_limit)
286
- if !rate_limit.nil? && rate_limit > 65535
287
- fail ArgumentError, 'invalid value for "rate_limit", must be smaller than or equal to 65535.'
288
- end
289
-
290
- if !rate_limit.nil? && rate_limit < 1
291
- fail ArgumentError, 'invalid value for "rate_limit", must be greater than or equal to 1.'
294
+ if !rate_limit.nil? && rate_limit < 0
295
+ fail ArgumentError, 'invalid value for "rate_limit", must be greater than or equal to 0.'
292
296
  end
293
297
 
294
298
  @rate_limit = rate_limit
@@ -331,6 +335,20 @@ module Svix
331
335
  @url = url
332
336
  end
333
337
 
338
+ # Custom attribute writer method with validation
339
+ # @param [Object] version Value to be assigned
340
+ def version=(version)
341
+ if version.nil?
342
+ fail ArgumentError, 'version cannot be nil'
343
+ end
344
+
345
+ if version < 1
346
+ fail ArgumentError, 'invalid value for "version", must be greater than or equal to 1.'
347
+ end
348
+
349
+ @version = version
350
+ end
351
+
334
352
  # Checks equality by comparing each attribute.
335
353
  # @param [Object] Object to be compared
336
354
  def ==(o)
@@ -0,0 +1,405 @@
1
+ =begin
2
+ #Svix API
3
+
4
+ #Welcome to the Svix API documentation! Useful links: [Homepage](https://www.svix.com) | [Support email](mailto:support+docs@svix.com) | [Blog](https://www.svix.com/blog/) | [Slack Community](https://www.svix.com/slack/) # Introduction This is the reference documentation and schemas for the [Svix webhook service](https://www.svix.com) API. For tutorials and other documentation please refer to [the documentation](https://docs.svix.com). ## Main concepts In Svix you have four important entities you will be interacting with: - `messages`: these are the webhooks being sent. They can have contents and a few other properties. - `application`: this is where `messages` are sent to. Usually you want to create one application for each user on your platform. - `endpoint`: endpoints are the URLs messages will be sent to. Each application can have multiple `endpoints` and each message sent to that application will be sent to all of them (unless they are not subscribed to the sent event type). - `event-type`: event types are identifiers denoting the type of the message being sent. Event types are primarily used to decide which events are sent to which endpoint. ## Authentication Get your authentication token (`AUTH_TOKEN`) from the [Svix dashboard](https://dashboard.svix.com) and use it as part of the `Authorization` header as such: `Authorization: Bearer ${AUTH_TOKEN}`. <SecurityDefinitions /> ## Code samples The code samples assume you already have the respective libraries installed and you know how to use them. For the latest information on how to do that, please refer to [the documentation](https://docs.svix.com/). ## Idempotency Svix supports [idempotency](https://en.wikipedia.org/wiki/Idempotence) for safely retrying requests without accidentally performing the same operation twice. This is useful when an API call is disrupted in transit and you do not receive a response. To perform an idempotent request, pass the idempotency key in the `Idempotency-Key` header to the request. The idempotency key should be a unique value generated by the client. You can create the key in however way you like, though we suggest using UUID v4, or any other string with enough entropy to avoid collisions. Svix's idempotency works by saving the resulting status code and body of the first request made for any given idempotency key for any successful request. Subsequent requests with the same key return the same result. Please note that idempotency is only supported for `POST` requests. ## Cross-Origin Resource Sharing This API features Cross-Origin Resource Sharing (CORS) implemented in compliance with [W3C spec](https://www.w3.org/TR/cors/). And that allows cross-domain communication from the browser. All responses have a wildcard same-origin which makes them completely public and accessible to everyone, including any code on any site.
5
+
6
+ The version of the OpenAPI document: 1.4
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Svix
17
+ class EndpointPatch
18
+ attr_accessor :channels
19
+
20
+ attr_accessor :description
21
+
22
+ attr_accessor :disabled
23
+
24
+ attr_accessor :filter_types
25
+
26
+ attr_accessor :metadata
27
+
28
+ attr_accessor :rate_limit
29
+
30
+ # The endpoint's verification secret. If `null` is passed, a secret is automatically generated. Format: `base64` encoded random bytes optionally prefixed with `whsec_`. Recommended size: 24.
31
+ attr_accessor :secret
32
+
33
+ attr_accessor :uid
34
+
35
+ attr_accessor :url
36
+
37
+ attr_accessor :version
38
+
39
+ # Attribute mapping from ruby-style variable name to JSON key.
40
+ def self.attribute_map
41
+ {
42
+ :'channels' => :'channels',
43
+ :'description' => :'description',
44
+ :'disabled' => :'disabled',
45
+ :'filter_types' => :'filterTypes',
46
+ :'metadata' => :'metadata',
47
+ :'rate_limit' => :'rateLimit',
48
+ :'secret' => :'secret',
49
+ :'uid' => :'uid',
50
+ :'url' => :'url',
51
+ :'version' => :'version'
52
+ }
53
+ end
54
+
55
+ # Returns all the JSON keys this model knows about
56
+ def self.acceptable_attributes
57
+ attribute_map.values
58
+ end
59
+
60
+ # Attribute type mapping.
61
+ def self.openapi_types
62
+ {
63
+ :'channels' => :'Array<String>',
64
+ :'description' => :'String',
65
+ :'disabled' => :'Boolean',
66
+ :'filter_types' => :'Array<String>',
67
+ :'metadata' => :'Hash<String, String>',
68
+ :'rate_limit' => :'Integer',
69
+ :'secret' => :'String',
70
+ :'uid' => :'String',
71
+ :'url' => :'String',
72
+ :'version' => :'Integer'
73
+ }
74
+ end
75
+
76
+ # List of attributes with nullable: true
77
+ def self.openapi_nullable
78
+ Set.new([
79
+ :'channels',
80
+ :'filter_types',
81
+ :'rate_limit',
82
+ :'secret',
83
+ :'uid',
84
+ ])
85
+ end
86
+
87
+ # Initializes the object
88
+ # @param [Hash] attributes Model attributes in the form of hash
89
+ def initialize(attributes = {})
90
+ if (!attributes.is_a?(Hash))
91
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::EndpointPatch` initialize method"
92
+ end
93
+
94
+ # check to see if the attribute exists and convert string to symbol for hash key
95
+ attributes = attributes.each_with_object({}) { |(k, v), h|
96
+ if (!self.class.attribute_map.key?(k.to_sym))
97
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::EndpointPatch`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
98
+ end
99
+ h[k.to_sym] = v
100
+ }
101
+
102
+ if attributes.key?(:'channels')
103
+ if (value = attributes[:'channels']).is_a?(Array)
104
+ self.channels = value
105
+ end
106
+ end
107
+
108
+ if attributes.key?(:'description')
109
+ self.description = attributes[:'description']
110
+ end
111
+
112
+ if attributes.key?(:'disabled')
113
+ self.disabled = attributes[:'disabled']
114
+ end
115
+
116
+ if attributes.key?(:'filter_types')
117
+ if (value = attributes[:'filter_types']).is_a?(Array)
118
+ self.filter_types = value
119
+ end
120
+ end
121
+
122
+ if attributes.key?(:'metadata')
123
+ if (value = attributes[:'metadata']).is_a?(Hash)
124
+ self.metadata = value
125
+ end
126
+ end
127
+
128
+ if attributes.key?(:'rate_limit')
129
+ self.rate_limit = attributes[:'rate_limit']
130
+ end
131
+
132
+ if attributes.key?(:'secret')
133
+ self.secret = attributes[:'secret']
134
+ end
135
+
136
+ if attributes.key?(:'uid')
137
+ self.uid = attributes[:'uid']
138
+ end
139
+
140
+ if attributes.key?(:'url')
141
+ self.url = attributes[:'url']
142
+ end
143
+
144
+ if attributes.key?(:'version')
145
+ self.version = attributes[:'version']
146
+ end
147
+ end
148
+
149
+ # Show invalid properties with the reasons. Usually used together with valid?
150
+ # @return Array for valid properties with the reasons
151
+ def list_invalid_properties
152
+ invalid_properties = Array.new
153
+ if !@rate_limit.nil? && @rate_limit < 0
154
+ invalid_properties.push('invalid value for "rate_limit", must be greater than or equal to 0.')
155
+ end
156
+
157
+ pattern = Regexp.new(/^(whsec_)?[a-zA-Z0-9+\/=]{32,100}$/)
158
+ if !@secret.nil? && @secret !~ pattern
159
+ invalid_properties.push("invalid value for \"secret\", must conform to the pattern #{pattern}.")
160
+ end
161
+
162
+ if !@uid.nil? && @uid.to_s.length > 256
163
+ invalid_properties.push('invalid value for "uid", the character length must be smaller than or equal to 256.')
164
+ end
165
+
166
+ if !@uid.nil? && @uid.to_s.length < 1
167
+ invalid_properties.push('invalid value for "uid", the character length must be great than or equal to 1.')
168
+ end
169
+
170
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
171
+ if !@uid.nil? && @uid !~ pattern
172
+ invalid_properties.push("invalid value for \"uid\", must conform to the pattern #{pattern}.")
173
+ end
174
+
175
+ if !@version.nil? && @version < 0
176
+ invalid_properties.push('invalid value for "version", must be greater than or equal to 0.')
177
+ end
178
+
179
+ invalid_properties
180
+ end
181
+
182
+ # Check to see if the all the properties in the model are valid
183
+ # @return true if the model is valid
184
+ def valid?
185
+ return false if !@rate_limit.nil? && @rate_limit < 0
186
+ return false if !@secret.nil? && @secret !~ Regexp.new(/^(whsec_)?[a-zA-Z0-9+\/=]{32,100}$/)
187
+ return false if !@uid.nil? && @uid.to_s.length > 256
188
+ return false if !@uid.nil? && @uid.to_s.length < 1
189
+ return false if !@uid.nil? && @uid !~ Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
190
+ return false if !@version.nil? && @version < 0
191
+ true
192
+ end
193
+
194
+ # Custom attribute writer method with validation
195
+ # @param [Object] channels Value to be assigned
196
+ def channels=(channels)
197
+ @channels = channels
198
+ end
199
+
200
+ # Custom attribute writer method with validation
201
+ # @param [Object] filter_types Value to be assigned
202
+ def filter_types=(filter_types)
203
+ @filter_types = filter_types
204
+ end
205
+
206
+ # Custom attribute writer method with validation
207
+ # @param [Object] rate_limit Value to be assigned
208
+ def rate_limit=(rate_limit)
209
+ if !rate_limit.nil? && rate_limit < 0
210
+ fail ArgumentError, 'invalid value for "rate_limit", must be greater than or equal to 0.'
211
+ end
212
+
213
+ @rate_limit = rate_limit
214
+ end
215
+
216
+ # Custom attribute writer method with validation
217
+ # @param [Object] secret Value to be assigned
218
+ def secret=(secret)
219
+ pattern = Regexp.new(/^(whsec_)?[a-zA-Z0-9+\/=]{32,100}$/)
220
+ if !secret.nil? && secret !~ pattern
221
+ fail ArgumentError, "invalid value for \"secret\", must conform to the pattern #{pattern}."
222
+ end
223
+
224
+ @secret = secret
225
+ end
226
+
227
+ # Custom attribute writer method with validation
228
+ # @param [Object] uid Value to be assigned
229
+ def uid=(uid)
230
+ if !uid.nil? && uid.to_s.length > 256
231
+ fail ArgumentError, 'invalid value for "uid", the character length must be smaller than or equal to 256.'
232
+ end
233
+
234
+ if !uid.nil? && uid.to_s.length < 1
235
+ fail ArgumentError, 'invalid value for "uid", the character length must be great than or equal to 1.'
236
+ end
237
+
238
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
239
+ if !uid.nil? && uid !~ pattern
240
+ fail ArgumentError, "invalid value for \"uid\", must conform to the pattern #{pattern}."
241
+ end
242
+
243
+ @uid = uid
244
+ end
245
+
246
+ # Custom attribute writer method with validation
247
+ # @param [Object] version Value to be assigned
248
+ def version=(version)
249
+ if !version.nil? && version < 0
250
+ fail ArgumentError, 'invalid value for "version", must be greater than or equal to 0.'
251
+ end
252
+
253
+ @version = version
254
+ end
255
+
256
+ # Checks equality by comparing each attribute.
257
+ # @param [Object] Object to be compared
258
+ def ==(o)
259
+ return true if self.equal?(o)
260
+ self.class == o.class &&
261
+ channels == o.channels &&
262
+ description == o.description &&
263
+ disabled == o.disabled &&
264
+ filter_types == o.filter_types &&
265
+ metadata == o.metadata &&
266
+ rate_limit == o.rate_limit &&
267
+ secret == o.secret &&
268
+ uid == o.uid &&
269
+ url == o.url &&
270
+ version == o.version
271
+ end
272
+
273
+ # @see the `==` method
274
+ # @param [Object] Object to be compared
275
+ def eql?(o)
276
+ self == o
277
+ end
278
+
279
+ # Calculates hash code according to all attributes.
280
+ # @return [Integer] Hash code
281
+ def hash
282
+ [channels, description, disabled, filter_types, metadata, rate_limit, secret, uid, url, version].hash
283
+ end
284
+
285
+ # Builds the object from hash
286
+ # @param [Hash] attributes Model attributes in the form of hash
287
+ # @return [Object] Returns the model itself
288
+ def self.build_from_hash(attributes)
289
+ new.build_from_hash(attributes)
290
+ end
291
+
292
+ # Builds the object from hash
293
+ # @param [Hash] attributes Model attributes in the form of hash
294
+ # @return [Object] Returns the model itself
295
+ def build_from_hash(attributes)
296
+ return nil unless attributes.is_a?(Hash)
297
+ self.class.openapi_types.each_pair do |key, type|
298
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
299
+ self.send("#{key}=", nil)
300
+ elsif type =~ /\AArray<(.*)>/i
301
+ # check to ensure the input is an array given that the attribute
302
+ # is documented as an array but the input is not
303
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
304
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
305
+ end
306
+ elsif !attributes[self.class.attribute_map[key]].nil?
307
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
308
+ end
309
+ end
310
+
311
+ self
312
+ end
313
+
314
+ # Deserializes the data based on type
315
+ # @param string type Data type
316
+ # @param string value Value to be deserialized
317
+ # @return [Object] Deserialized data
318
+ def _deserialize(type, value)
319
+ case type.to_sym
320
+ when :Time
321
+ Time.parse(value)
322
+ when :Date
323
+ Date.parse(value)
324
+ when :String
325
+ value.to_s
326
+ when :Integer
327
+ value.to_i
328
+ when :Float
329
+ value.to_f
330
+ when :Boolean
331
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
332
+ true
333
+ else
334
+ false
335
+ end
336
+ when :Object
337
+ # generic object (usually a Hash), return directly
338
+ value
339
+ when /\AArray<(?<inner_type>.+)>\z/
340
+ inner_type = Regexp.last_match[:inner_type]
341
+ value.map { |v| _deserialize(inner_type, v) }
342
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
343
+ k_type = Regexp.last_match[:k_type]
344
+ v_type = Regexp.last_match[:v_type]
345
+ {}.tap do |hash|
346
+ value.each do |k, v|
347
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
348
+ end
349
+ end
350
+ else # model
351
+ # models (e.g. Pet) or oneOf
352
+ klass = Svix.const_get(type)
353
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
354
+ end
355
+ end
356
+
357
+ # Returns the string representation of the object
358
+ # @return [String] String presentation of the object
359
+ def to_s
360
+ to_hash.to_s
361
+ end
362
+
363
+ # to_body is an alias to to_hash (backward compatibility)
364
+ # @return [Hash] Returns the object in the form of hash
365
+ def to_body
366
+ to_hash
367
+ end
368
+
369
+ # Returns the object in the form of hash
370
+ # @return [Hash] Returns the object in the form of hash
371
+ def to_hash
372
+ hash = {}
373
+ self.class.attribute_map.each_pair do |attr, param|
374
+ value = self.send(attr)
375
+ if value.nil?
376
+ is_nullable = self.class.openapi_nullable.include?(attr)
377
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
378
+ end
379
+
380
+ hash[param] = _to_hash(value)
381
+ end
382
+ hash
383
+ end
384
+
385
+ # Outputs non-array value in the form of hash
386
+ # For object, use to_hash. Otherwise, just return the value
387
+ # @param [Object] value Any valid value
388
+ # @return [Hash] Returns the value in the form of hash
389
+ def _to_hash(value)
390
+ if value.is_a?(Array)
391
+ value.compact.map { |v| _to_hash(v) }
392
+ elsif value.is_a?(Hash)
393
+ {}.tap do |hash|
394
+ value.each { |k, v| hash[k] = _to_hash(v) }
395
+ end
396
+ elsif value.respond_to? :to_hash
397
+ value.to_hash
398
+ else
399
+ value
400
+ end
401
+ end
402
+
403
+ end
404
+
405
+ end
@@ -61,6 +61,8 @@ module Svix
61
61
 
62
62
  if attributes.key?(:'key')
63
63
  self.key = attributes[:'key']
64
+ else
65
+ self.key = 'null'
64
66
  end
65
67
  end
66
68
 
@@ -68,8 +68,6 @@ module Svix
68
68
 
69
69
  if attributes.key?(:'enabled')
70
70
  self.enabled = attributes[:'enabled']
71
- else
72
- self.enabled = false
73
71
  end
74
72
  end
75
73
 
@@ -138,6 +138,12 @@ module Svix
138
138
  true
139
139
  end
140
140
 
141
+ # Custom attribute writer method with validation
142
+ # @param [Object] channels Value to be assigned
143
+ def channels=(channels)
144
+ @channels = channels
145
+ end
146
+
141
147
  # Custom attribute writer method with validation
142
148
  # @param [Object] code Value to be assigned
143
149
  def code=(code)