svix 1.56.0 → 1.57.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 (98) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/lib/svix/api/application_api.rb +115 -10
  4. data/lib/svix/api/authentication_api.rb +101 -16
  5. data/lib/svix/api/background_tasks_api.rb +43 -17
  6. data/lib/svix/api/endpoint_api.rb +312 -96
  7. data/lib/svix/api/inbound_api.rb +4 -4
  8. data/lib/svix/api/integration_api.rb +102 -24
  9. data/lib/svix/api/message_api.rb +142 -39
  10. data/lib/svix/api/message_attempt_api.rb +135 -372
  11. data/lib/svix/api/statistics_api.rb +6 -6
  12. data/lib/svix/api/stream_api.rb +203 -142
  13. data/lib/svix/api/transformation_template_api.rb +88 -23
  14. data/lib/svix/api/webhook_endpoint_api.rb +253 -77
  15. data/lib/svix/background_tasks_api.rb +2 -2
  16. data/lib/svix/message_attempt_api.rb +7 -3
  17. data/lib/svix/models/active_application_out.rb +373 -0
  18. data/lib/svix/models/active_endpoint_out.rb +355 -0
  19. data/lib/svix/models/aggregate_event_types_out.rb +40 -0
  20. data/lib/svix/models/aggregated_event_types.rb +305 -0
  21. data/lib/svix/models/app_portal_access_in.rb +18 -0
  22. data/lib/svix/models/app_usage_stats_out.rb +40 -0
  23. data/lib/svix/models/application_message_failure.rb +277 -0
  24. data/lib/svix/models/application_message_id_pair.rb +317 -0
  25. data/lib/svix/models/application_out.rb +41 -2
  26. data/lib/svix/models/application_patch.rb +1 -1
  27. data/lib/svix/models/application_stats.rb +41 -2
  28. data/lib/svix/models/application_stats_out.rb +324 -0
  29. data/lib/svix/models/auth_token_out.rb +40 -1
  30. data/lib/svix/models/background_task_finished_event.rb +272 -0
  31. data/lib/svix/models/background_task_finished_event2.rb +331 -0
  32. data/lib/svix/models/background_task_out.rb +40 -0
  33. data/lib/svix/models/background_task_type.rb +2 -1
  34. data/lib/svix/models/{template_in.rb → connector_in.rb} +4 -4
  35. data/lib/svix/models/{transformation_template_kind.rb → connector_kind.rb} +3 -3
  36. data/lib/svix/models/create_stream_in.rb +12 -12
  37. data/lib/svix/models/data.rb +108 -0
  38. data/lib/svix/models/data_any_of.rb +240 -0
  39. data/lib/svix/models/data_any_of1.rb +223 -0
  40. data/lib/svix/models/data_any_of2.rb +241 -0
  41. data/lib/svix/models/data_any_of3.rb +223 -0
  42. data/lib/svix/models/data_any_of4.rb +240 -0
  43. data/lib/svix/models/endpoint_created_event_data.rb +82 -4
  44. data/lib/svix/models/endpoint_deleted_event_data.rb +82 -4
  45. data/lib/svix/models/endpoint_disabled_event.rb +1 -1
  46. data/lib/svix/models/endpoint_disabled_event_data.rb +119 -16
  47. data/lib/svix/models/endpoint_disabled_trigger.rb +40 -0
  48. data/lib/svix/models/endpoint_enabled_event.rb +272 -0
  49. data/lib/svix/models/endpoint_enabled_event_data.rb +410 -0
  50. data/lib/svix/models/endpoint_message_out.rb +40 -1
  51. data/lib/svix/models/endpoint_mtls_config_out.rb +215 -0
  52. data/lib/svix/models/endpoint_oauth_config_in.rb +2 -2
  53. data/lib/svix/models/endpoint_oauth_config_out.rb +315 -0
  54. data/lib/svix/models/endpoint_out.rb +40 -1
  55. data/lib/svix/models/endpoint_patch.rb +1 -1
  56. data/lib/svix/models/endpoint_updated_event_data.rb +82 -4
  57. data/lib/svix/models/environment_in.rb +17 -19
  58. data/lib/svix/models/environment_settings_out.rb +23 -1
  59. data/lib/svix/models/event_type_import_open_api_in.rb +14 -2
  60. data/lib/svix/models/export_event_type_out.rb +40 -0
  61. data/lib/svix/models/expung_all_contents_out.rb +315 -0
  62. data/lib/svix/models/inbound_path_params.rb +1 -1
  63. data/lib/svix/models/integration_in.rb +41 -1
  64. data/lib/svix/models/integration_out.rb +81 -2
  65. data/lib/svix/models/integration_update.rb +41 -1
  66. data/lib/svix/models/list_response_active_application_out.rb +261 -0
  67. data/lib/svix/models/message_attempt_endpoint_out.rb +120 -3
  68. data/lib/svix/models/message_attempt_exhausted_event_data.rb +122 -5
  69. data/lib/svix/models/message_attempt_failed_data.rb +40 -1
  70. data/lib/svix/models/message_attempt_failing_event_data.rb +122 -5
  71. data/lib/svix/models/message_attempt_out.rb +120 -3
  72. data/lib/svix/models/message_attempt_recovered_event_data.rb +122 -5
  73. data/lib/svix/models/message_broadcast_out.rb +40 -0
  74. data/lib/svix/models/message_endpoint_out.rb +40 -1
  75. data/lib/svix/models/message_out.rb +40 -1
  76. data/lib/svix/models/message_precheck_in.rb +288 -0
  77. data/lib/svix/models/message_precheck_out.rb +221 -0
  78. data/lib/svix/models/{oauth2_auth_method_in.rb → oauth2_auth_method_in_out.rb} +3 -3
  79. data/lib/svix/models/{oauth2_grant_type_in.rb → oauth2_grant_type_in_out.rb} +3 -3
  80. data/lib/svix/models/operational_webhook_endpoint_headers_in.rb +223 -0
  81. data/lib/svix/models/operational_webhook_endpoint_headers_out.rb +251 -0
  82. data/lib/svix/models/operational_webhook_endpoint_out.rb +40 -1
  83. data/lib/svix/models/polling_endpoint_message_out.rb +454 -0
  84. data/lib/svix/models/polling_endpoint_out.rb +255 -0
  85. data/lib/svix/models/recover_out.rb +40 -0
  86. data/lib/svix/models/replay_out.rb +40 -0
  87. data/lib/svix/models/rotate_poller_token_in.rb +1 -1
  88. data/lib/svix/models/sink_secret_out.rb +233 -0
  89. data/lib/svix/models/stream_in.rb +6 -7
  90. data/lib/svix/models/stream_out.rb +46 -7
  91. data/lib/svix/models/stream_patch.rb +6 -7
  92. data/lib/svix/models/stream_portal_access_in.rb +293 -0
  93. data/lib/svix/models/template_out.rb +81 -1
  94. data/lib/svix/models/template_patch.rb +1 -1
  95. data/lib/svix/models/template_update.rb +1 -1
  96. data/lib/svix/version.rb +1 -1
  97. metadata +35 -7
  98. data/lib/svix/operational_webhook_endpoint_api.rb +0 -37
@@ -16,21 +16,21 @@ require 'time'
16
16
  module Svix
17
17
  # Sent when a message delivery has failed (all of the retry attempts have been exhausted) as a \"message.attempt.exhausted\" type or after it's failed four times as a \"message.attempt.failing\" event.
18
18
  class MessageAttemptRecoveredEventData
19
- # The app's ID
19
+ # The Application's ID.
20
20
  attr_accessor :app_id
21
21
 
22
- # The app's UID
22
+ # The Application's UID.
23
23
  attr_accessor :app_uid
24
24
 
25
- # The ep's ID
25
+ # The Endpoint's ID.
26
26
  attr_accessor :endpoint_id
27
27
 
28
28
  attr_accessor :last_attempt
29
29
 
30
- # The msg's UID
30
+ # The Message's UID.
31
31
  attr_accessor :msg_event_id
32
32
 
33
- # The msg's ID
33
+ # The Message's ID.
34
34
  attr_accessor :msg_id
35
35
 
36
36
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -127,6 +127,19 @@ module Svix
127
127
  invalid_properties.push('invalid value for "app_id", app_id cannot be nil.')
128
128
  end
129
129
 
130
+ if @app_id.to_s.length > 31
131
+ invalid_properties.push('invalid value for "app_id", the character length must be smaller than or equal to 31.')
132
+ end
133
+
134
+ if @app_id.to_s.length < 31
135
+ invalid_properties.push('invalid value for "app_id", the character length must be great than or equal to 31.')
136
+ end
137
+
138
+ pattern = Regexp.new(/^app_[A-Za-z0-9]{27}$/)
139
+ if @app_id !~ pattern
140
+ invalid_properties.push("invalid value for \"app_id\", must conform to the pattern #{pattern}.")
141
+ end
142
+
130
143
  if !@app_uid.nil? && @app_uid.to_s.length > 256
131
144
  invalid_properties.push('invalid value for "app_uid", the character length must be smaller than or equal to 256.')
132
145
  end
@@ -144,6 +157,19 @@ module Svix
144
157
  invalid_properties.push('invalid value for "endpoint_id", endpoint_id cannot be nil.')
145
158
  end
146
159
 
160
+ if @endpoint_id.to_s.length > 30
161
+ invalid_properties.push('invalid value for "endpoint_id", the character length must be smaller than or equal to 30.')
162
+ end
163
+
164
+ if @endpoint_id.to_s.length < 30
165
+ invalid_properties.push('invalid value for "endpoint_id", the character length must be great than or equal to 30.')
166
+ end
167
+
168
+ pattern = Regexp.new(/^ep_[A-Za-z0-9]{27}$/)
169
+ if @endpoint_id !~ pattern
170
+ invalid_properties.push("invalid value for \"endpoint_id\", must conform to the pattern #{pattern}.")
171
+ end
172
+
147
173
  if @last_attempt.nil?
148
174
  invalid_properties.push('invalid value for "last_attempt", last_attempt cannot be nil.')
149
175
  end
@@ -165,6 +191,19 @@ module Svix
165
191
  invalid_properties.push('invalid value for "msg_id", msg_id cannot be nil.')
166
192
  end
167
193
 
194
+ if @msg_id.to_s.length > 31
195
+ invalid_properties.push('invalid value for "msg_id", the character length must be smaller than or equal to 31.')
196
+ end
197
+
198
+ if @msg_id.to_s.length < 31
199
+ invalid_properties.push('invalid value for "msg_id", the character length must be great than or equal to 31.')
200
+ end
201
+
202
+ pattern = Regexp.new(/^msg_[A-Za-z0-9]{27}$/)
203
+ if @msg_id !~ pattern
204
+ invalid_properties.push("invalid value for \"msg_id\", must conform to the pattern #{pattern}.")
205
+ end
206
+
168
207
  invalid_properties
169
208
  end
170
209
 
@@ -173,18 +212,50 @@ module Svix
173
212
  def valid?
174
213
  warn '[DEPRECATED] the `valid?` method is obsolete'
175
214
  return false if @app_id.nil?
215
+ return false if @app_id.to_s.length > 31
216
+ return false if @app_id.to_s.length < 31
217
+ return false if @app_id !~ Regexp.new(/^app_[A-Za-z0-9]{27}$/)
176
218
  return false if !@app_uid.nil? && @app_uid.to_s.length > 256
177
219
  return false if !@app_uid.nil? && @app_uid.to_s.length < 1
178
220
  return false if !@app_uid.nil? && @app_uid !~ Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
179
221
  return false if @endpoint_id.nil?
222
+ return false if @endpoint_id.to_s.length > 30
223
+ return false if @endpoint_id.to_s.length < 30
224
+ return false if @endpoint_id !~ Regexp.new(/^ep_[A-Za-z0-9]{27}$/)
180
225
  return false if @last_attempt.nil?
181
226
  return false if !@msg_event_id.nil? && @msg_event_id.to_s.length > 256
182
227
  return false if !@msg_event_id.nil? && @msg_event_id.to_s.length < 1
183
228
  return false if !@msg_event_id.nil? && @msg_event_id !~ Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
184
229
  return false if @msg_id.nil?
230
+ return false if @msg_id.to_s.length > 31
231
+ return false if @msg_id.to_s.length < 31
232
+ return false if @msg_id !~ Regexp.new(/^msg_[A-Za-z0-9]{27}$/)
185
233
  true
186
234
  end
187
235
 
236
+ # Custom attribute writer method with validation
237
+ # @param [Object] app_id Value to be assigned
238
+ def app_id=(app_id)
239
+ if app_id.nil?
240
+ fail ArgumentError, 'app_id cannot be nil'
241
+ end
242
+
243
+ if app_id.to_s.length > 31
244
+ fail ArgumentError, 'invalid value for "app_id", the character length must be smaller than or equal to 31.'
245
+ end
246
+
247
+ if app_id.to_s.length < 31
248
+ fail ArgumentError, 'invalid value for "app_id", the character length must be great than or equal to 31.'
249
+ end
250
+
251
+ pattern = Regexp.new(/^app_[A-Za-z0-9]{27}$/)
252
+ if app_id !~ pattern
253
+ fail ArgumentError, "invalid value for \"app_id\", must conform to the pattern #{pattern}."
254
+ end
255
+
256
+ @app_id = app_id
257
+ end
258
+
188
259
  # Custom attribute writer method with validation
189
260
  # @param [Object] app_uid Value to be assigned
190
261
  def app_uid=(app_uid)
@@ -204,6 +275,29 @@ module Svix
204
275
  @app_uid = app_uid
205
276
  end
206
277
 
278
+ # Custom attribute writer method with validation
279
+ # @param [Object] endpoint_id Value to be assigned
280
+ def endpoint_id=(endpoint_id)
281
+ if endpoint_id.nil?
282
+ fail ArgumentError, 'endpoint_id cannot be nil'
283
+ end
284
+
285
+ if endpoint_id.to_s.length > 30
286
+ fail ArgumentError, 'invalid value for "endpoint_id", the character length must be smaller than or equal to 30.'
287
+ end
288
+
289
+ if endpoint_id.to_s.length < 30
290
+ fail ArgumentError, 'invalid value for "endpoint_id", the character length must be great than or equal to 30.'
291
+ end
292
+
293
+ pattern = Regexp.new(/^ep_[A-Za-z0-9]{27}$/)
294
+ if endpoint_id !~ pattern
295
+ fail ArgumentError, "invalid value for \"endpoint_id\", must conform to the pattern #{pattern}."
296
+ end
297
+
298
+ @endpoint_id = endpoint_id
299
+ end
300
+
207
301
  # Custom attribute writer method with validation
208
302
  # @param [Object] msg_event_id Value to be assigned
209
303
  def msg_event_id=(msg_event_id)
@@ -223,6 +317,29 @@ module Svix
223
317
  @msg_event_id = msg_event_id
224
318
  end
225
319
 
320
+ # Custom attribute writer method with validation
321
+ # @param [Object] msg_id Value to be assigned
322
+ def msg_id=(msg_id)
323
+ if msg_id.nil?
324
+ fail ArgumentError, 'msg_id cannot be nil'
325
+ end
326
+
327
+ if msg_id.to_s.length > 31
328
+ fail ArgumentError, 'invalid value for "msg_id", the character length must be smaller than or equal to 31.'
329
+ end
330
+
331
+ if msg_id.to_s.length < 31
332
+ fail ArgumentError, 'invalid value for "msg_id", the character length must be great than or equal to 31.'
333
+ end
334
+
335
+ pattern = Regexp.new(/^msg_[A-Za-z0-9]{27}$/)
336
+ if msg_id !~ pattern
337
+ fail ArgumentError, "invalid value for \"msg_id\", must conform to the pattern #{pattern}."
338
+ end
339
+
340
+ @msg_id = msg_id
341
+ end
342
+
226
343
  # Checks equality by comparing each attribute.
227
344
  # @param [Object] Object to be compared
228
345
  def ==(o)
@@ -15,6 +15,7 @@ require 'time'
15
15
 
16
16
  module Svix
17
17
  class MessageBroadcastOut
18
+ # The QueueBackgroundTask's ID.
18
19
  attr_accessor :id
19
20
 
20
21
  attr_accessor :status
@@ -115,6 +116,19 @@ module Svix
115
116
  invalid_properties.push('invalid value for "id", id cannot be nil.')
116
117
  end
117
118
 
119
+ if @id.to_s.length > 33
120
+ invalid_properties.push('invalid value for "id", the character length must be smaller than or equal to 33.')
121
+ end
122
+
123
+ if @id.to_s.length < 33
124
+ invalid_properties.push('invalid value for "id", the character length must be great than or equal to 33.')
125
+ end
126
+
127
+ pattern = Regexp.new(/^qtask_[A-Za-z0-9]{27}$/)
128
+ if @id !~ pattern
129
+ invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.")
130
+ end
131
+
118
132
  if @status.nil?
119
133
  invalid_properties.push('invalid value for "status", status cannot be nil.')
120
134
  end
@@ -131,11 +145,37 @@ module Svix
131
145
  def valid?
132
146
  warn '[DEPRECATED] the `valid?` method is obsolete'
133
147
  return false if @id.nil?
148
+ return false if @id.to_s.length > 33
149
+ return false if @id.to_s.length < 33
150
+ return false if @id !~ Regexp.new(/^qtask_[A-Za-z0-9]{27}$/)
134
151
  return false if @status.nil?
135
152
  return false if @task.nil?
136
153
  true
137
154
  end
138
155
 
156
+ # Custom attribute writer method with validation
157
+ # @param [Object] id Value to be assigned
158
+ def id=(id)
159
+ if id.nil?
160
+ fail ArgumentError, 'id cannot be nil'
161
+ end
162
+
163
+ if id.to_s.length > 33
164
+ fail ArgumentError, 'invalid value for "id", the character length must be smaller than or equal to 33.'
165
+ end
166
+
167
+ if id.to_s.length < 33
168
+ fail ArgumentError, 'invalid value for "id", the character length must be great than or equal to 33.'
169
+ end
170
+
171
+ pattern = Regexp.new(/^qtask_[A-Za-z0-9]{27}$/)
172
+ if id !~ pattern
173
+ fail ArgumentError, "invalid value for \"id\", must conform to the pattern #{pattern}."
174
+ end
175
+
176
+ @id = id
177
+ end
178
+
139
179
  # Checks equality by comparing each attribute.
140
180
  # @param [Object] Object to be compared
141
181
  def ==(o)
@@ -27,7 +27,7 @@ module Svix
27
27
 
28
28
  attr_accessor :filter_types
29
29
 
30
- # The ep's ID
30
+ # The Endpoint's ID.
31
31
  attr_accessor :id
32
32
 
33
33
  attr_accessor :next_attempt
@@ -238,6 +238,19 @@ module Svix
238
238
  invalid_properties.push('invalid value for "id", id cannot be nil.')
239
239
  end
240
240
 
241
+ if @id.to_s.length > 30
242
+ invalid_properties.push('invalid value for "id", the character length must be smaller than or equal to 30.')
243
+ end
244
+
245
+ if @id.to_s.length < 30
246
+ invalid_properties.push('invalid value for "id", the character length must be great than or equal to 30.')
247
+ end
248
+
249
+ pattern = Regexp.new(/^ep_[A-Za-z0-9]{27}$/)
250
+ if @id !~ pattern
251
+ invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.")
252
+ end
253
+
241
254
  if !@rate_limit.nil? && @rate_limit < 0
242
255
  invalid_properties.push('invalid value for "rate_limit", must be greater than or equal to 0.')
243
256
  end
@@ -296,6 +309,9 @@ module Svix
296
309
  return false if @description.nil?
297
310
  return false if !@filter_types.nil? && @filter_types.length < 1
298
311
  return false if @id.nil?
312
+ return false if @id.to_s.length > 30
313
+ return false if @id.to_s.length < 30
314
+ return false if @id !~ Regexp.new(/^ep_[A-Za-z0-9]{27}$/)
299
315
  return false if !@rate_limit.nil? && @rate_limit < 0
300
316
  return false if @status.nil?
301
317
  return false if !@uid.nil? && @uid.to_s.length > 256
@@ -334,6 +350,29 @@ module Svix
334
350
  @filter_types = filter_types
335
351
  end
336
352
 
353
+ # Custom attribute writer method with validation
354
+ # @param [Object] id Value to be assigned
355
+ def id=(id)
356
+ if id.nil?
357
+ fail ArgumentError, 'id cannot be nil'
358
+ end
359
+
360
+ if id.to_s.length > 30
361
+ fail ArgumentError, 'invalid value for "id", the character length must be smaller than or equal to 30.'
362
+ end
363
+
364
+ if id.to_s.length < 30
365
+ fail ArgumentError, 'invalid value for "id", the character length must be great than or equal to 30.'
366
+ end
367
+
368
+ pattern = Regexp.new(/^ep_[A-Za-z0-9]{27}$/)
369
+ if id !~ pattern
370
+ fail ArgumentError, "invalid value for \"id\", must conform to the pattern #{pattern}."
371
+ end
372
+
373
+ @id = id
374
+ end
375
+
337
376
  # Custom attribute writer method with validation
338
377
  # @param [Object] rate_limit Value to be assigned
339
378
  def rate_limit=(rate_limit)
@@ -24,7 +24,7 @@ module Svix
24
24
  # The event type's name
25
25
  attr_accessor :event_type
26
26
 
27
- # The msg's ID
27
+ # The Message's ID.
28
28
  attr_accessor :id
29
29
 
30
30
  attr_accessor :payload
@@ -172,6 +172,19 @@ module Svix
172
172
  invalid_properties.push('invalid value for "id", id cannot be nil.')
173
173
  end
174
174
 
175
+ if @id.to_s.length > 31
176
+ invalid_properties.push('invalid value for "id", the character length must be smaller than or equal to 31.')
177
+ end
178
+
179
+ if @id.to_s.length < 31
180
+ invalid_properties.push('invalid value for "id", the character length must be great than or equal to 31.')
181
+ end
182
+
183
+ pattern = Regexp.new(/^msg_[A-Za-z0-9]{27}$/)
184
+ if @id !~ pattern
185
+ invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.")
186
+ end
187
+
175
188
  if @payload.nil?
176
189
  invalid_properties.push('invalid value for "payload", payload cannot be nil.')
177
190
  end
@@ -196,6 +209,9 @@ module Svix
196
209
  return false if @event_type.to_s.length > 256
197
210
  return false if @event_type !~ Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
198
211
  return false if @id.nil?
212
+ return false if @id.to_s.length > 31
213
+ return false if @id.to_s.length < 31
214
+ return false if @id !~ Regexp.new(/^msg_[A-Za-z0-9]{27}$/)
199
215
  return false if @payload.nil?
200
216
  return false if @timestamp.nil?
201
217
  true
@@ -253,6 +269,29 @@ module Svix
253
269
  @event_type = event_type
254
270
  end
255
271
 
272
+ # Custom attribute writer method with validation
273
+ # @param [Object] id Value to be assigned
274
+ def id=(id)
275
+ if id.nil?
276
+ fail ArgumentError, 'id cannot be nil'
277
+ end
278
+
279
+ if id.to_s.length > 31
280
+ fail ArgumentError, 'invalid value for "id", the character length must be smaller than or equal to 31.'
281
+ end
282
+
283
+ if id.to_s.length < 31
284
+ fail ArgumentError, 'invalid value for "id", the character length must be great than or equal to 31.'
285
+ end
286
+
287
+ pattern = Regexp.new(/^msg_[A-Za-z0-9]{27}$/)
288
+ if id !~ pattern
289
+ fail ArgumentError, "invalid value for \"id\", must conform to the pattern #{pattern}."
290
+ end
291
+
292
+ @id = id
293
+ end
294
+
256
295
  # Custom attribute writer method with validation
257
296
  # @param [Object] tags Value to be assigned
258
297
  def tags=(tags)
@@ -0,0 +1,288 @@
1
+ =begin
2
+ #Svix API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.1.1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.9.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Svix
17
+ class MessagePrecheckIn
18
+ attr_accessor :channels
19
+
20
+ # The event type's name
21
+ attr_accessor :event_type
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'channels' => :'channels',
27
+ :'event_type' => :'eventType'
28
+ }
29
+ end
30
+
31
+ # Returns all the JSON keys this model knows about
32
+ def self.acceptable_attributes
33
+ attribute_map.values
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.openapi_types
38
+ {
39
+ :'channels' => :'Array<String>',
40
+ :'event_type' => :'String'
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new([
47
+ :'channels',
48
+ ])
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::MessagePrecheckIn` initialize method"
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!self.class.attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::MessagePrecheckIn`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'channels')
67
+ if (value = attributes[:'channels']).is_a?(Array)
68
+ self.channels = value
69
+ end
70
+ end
71
+
72
+ if attributes.key?(:'event_type')
73
+ self.event_type = attributes[:'event_type']
74
+ else
75
+ self.event_type = nil
76
+ end
77
+ end
78
+
79
+ # Show invalid properties with the reasons. Usually used together with valid?
80
+ # @return Array for valid properties with the reasons
81
+ def list_invalid_properties
82
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
83
+ invalid_properties = Array.new
84
+ if !@channels.nil? && @channels.length > 10
85
+ invalid_properties.push('invalid value for "channels", number of items must be less than or equal to 10.')
86
+ end
87
+
88
+ if !@channels.nil? && @channels.length < 1
89
+ invalid_properties.push('invalid value for "channels", number of items must be greater than or equal to 1.')
90
+ end
91
+
92
+ if @event_type.nil?
93
+ invalid_properties.push('invalid value for "event_type", event_type cannot be nil.')
94
+ end
95
+
96
+ if @event_type.to_s.length > 256
97
+ invalid_properties.push('invalid value for "event_type", the character length must be smaller than or equal to 256.')
98
+ end
99
+
100
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
101
+ if @event_type !~ pattern
102
+ invalid_properties.push("invalid value for \"event_type\", must conform to the pattern #{pattern}.")
103
+ end
104
+
105
+ invalid_properties
106
+ end
107
+
108
+ # Check to see if the all the properties in the model are valid
109
+ # @return true if the model is valid
110
+ def valid?
111
+ warn '[DEPRECATED] the `valid?` method is obsolete'
112
+ return false if !@channels.nil? && @channels.length > 10
113
+ return false if !@channels.nil? && @channels.length < 1
114
+ return false if @event_type.nil?
115
+ return false if @event_type.to_s.length > 256
116
+ return false if @event_type !~ Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
117
+ true
118
+ end
119
+
120
+ # Custom attribute writer method with validation
121
+ # @param [Object] channels Value to be assigned
122
+ def channels=(channels)
123
+ if !channels.nil? && channels.length > 10
124
+ fail ArgumentError, 'invalid value for "channels", number of items must be less than or equal to 10.'
125
+ end
126
+
127
+ if !channels.nil? && channels.length < 1
128
+ fail ArgumentError, 'invalid value for "channels", number of items must be greater than or equal to 1.'
129
+ end
130
+
131
+ @channels = channels
132
+ end
133
+
134
+ # Custom attribute writer method with validation
135
+ # @param [Object] event_type Value to be assigned
136
+ def event_type=(event_type)
137
+ if event_type.nil?
138
+ fail ArgumentError, 'event_type cannot be nil'
139
+ end
140
+
141
+ if event_type.to_s.length > 256
142
+ fail ArgumentError, 'invalid value for "event_type", the character length must be smaller than or equal to 256.'
143
+ end
144
+
145
+ pattern = Regexp.new(/^[a-zA-Z0-9\-_.]+$/)
146
+ if event_type !~ pattern
147
+ fail ArgumentError, "invalid value for \"event_type\", must conform to the pattern #{pattern}."
148
+ end
149
+
150
+ @event_type = event_type
151
+ end
152
+
153
+ # Checks equality by comparing each attribute.
154
+ # @param [Object] Object to be compared
155
+ def ==(o)
156
+ return true if self.equal?(o)
157
+ self.class == o.class &&
158
+ channels == o.channels &&
159
+ event_type == o.event_type
160
+ end
161
+
162
+ # @see the `==` method
163
+ # @param [Object] Object to be compared
164
+ def eql?(o)
165
+ self == o
166
+ end
167
+
168
+ # Calculates hash code according to all attributes.
169
+ # @return [Integer] Hash code
170
+ def hash
171
+ [channels, event_type].hash
172
+ end
173
+
174
+ # Builds the object from hash
175
+ # @param [Hash] attributes Model attributes in the form of hash
176
+ # @return [Object] Returns the model itself
177
+ def self.build_from_hash(attributes)
178
+ return nil unless attributes.is_a?(Hash)
179
+ attributes = attributes.transform_keys(&:to_sym)
180
+ transformed_hash = {}
181
+ openapi_types.each_pair do |key, type|
182
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
183
+ transformed_hash["#{key}"] = nil
184
+ elsif type =~ /\AArray<(.*)>/i
185
+ # check to ensure the input is an array given that the attribute
186
+ # is documented as an array but the input is not
187
+ if attributes[attribute_map[key]].is_a?(Array)
188
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
189
+ end
190
+ elsif !attributes[attribute_map[key]].nil?
191
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
192
+ end
193
+ end
194
+ new(transformed_hash)
195
+ end
196
+
197
+ # Deserializes the data based on type
198
+ # @param string type Data type
199
+ # @param string value Value to be deserialized
200
+ # @return [Object] Deserialized data
201
+ def self._deserialize(type, value)
202
+ case type.to_sym
203
+ when :Time
204
+ Time.parse(value)
205
+ when :Date
206
+ Date.parse(value)
207
+ when :String
208
+ value.to_s
209
+ when :Integer
210
+ value.to_i
211
+ when :Float
212
+ value.to_f
213
+ when :Boolean
214
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
215
+ true
216
+ else
217
+ false
218
+ end
219
+ when :Object
220
+ # generic object (usually a Hash), return directly
221
+ value
222
+ when /\AArray<(?<inner_type>.+)>\z/
223
+ inner_type = Regexp.last_match[:inner_type]
224
+ value.map { |v| _deserialize(inner_type, v) }
225
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
226
+ k_type = Regexp.last_match[:k_type]
227
+ v_type = Regexp.last_match[:v_type]
228
+ {}.tap do |hash|
229
+ value.each do |k, v|
230
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
231
+ end
232
+ end
233
+ else # model
234
+ # models (e.g. Pet) or oneOf
235
+ klass = Svix.const_get(type)
236
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
237
+ end
238
+ end
239
+
240
+ # Returns the string representation of the object
241
+ # @return [String] String presentation of the object
242
+ def to_s
243
+ to_hash.to_s
244
+ end
245
+
246
+ # to_body is an alias to to_hash (backward compatibility)
247
+ # @return [Hash] Returns the object in the form of hash
248
+ def to_body
249
+ to_hash
250
+ end
251
+
252
+ # Returns the object in the form of hash
253
+ # @return [Hash] Returns the object in the form of hash
254
+ def to_hash
255
+ hash = {}
256
+ self.class.attribute_map.each_pair do |attr, param|
257
+ value = self.send(attr)
258
+ if value.nil?
259
+ is_nullable = self.class.openapi_nullable.include?(attr)
260
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
261
+ end
262
+
263
+ hash[param] = _to_hash(value)
264
+ end
265
+ hash
266
+ end
267
+
268
+ # Outputs non-array value in the form of hash
269
+ # For object, use to_hash. Otherwise, just return the value
270
+ # @param [Object] value Any valid value
271
+ # @return [Hash] Returns the value in the form of hash
272
+ def _to_hash(value)
273
+ if value.is_a?(Array)
274
+ value.compact.map { |v| _to_hash(v) }
275
+ elsif value.is_a?(Hash)
276
+ {}.tap do |hash|
277
+ value.each { |k, v| hash[k] = _to_hash(v) }
278
+ end
279
+ elsif value.respond_to? :to_hash
280
+ value.to_hash
281
+ else
282
+ value
283
+ end
284
+ end
285
+
286
+ end
287
+
288
+ end