svix 1.56.0 → 1.58.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
@@ -0,0 +1,331 @@
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 BackgroundTaskFinishedEvent2
18
+ attr_accessor :data
19
+
20
+ attr_accessor :status
21
+
22
+ attr_accessor :task
23
+
24
+ # The QueueBackgroundTask's ID.
25
+ attr_accessor :task_id
26
+
27
+ class EnumAttributeValidator
28
+ attr_reader :datatype
29
+ attr_reader :allowable_values
30
+
31
+ def initialize(datatype, allowable_values)
32
+ @allowable_values = allowable_values.map do |value|
33
+ case datatype.to_s
34
+ when /Integer/i
35
+ value.to_i
36
+ when /Float/i
37
+ value.to_f
38
+ else
39
+ value
40
+ end
41
+ end
42
+ end
43
+
44
+ def valid?(value)
45
+ !value || allowable_values.include?(value)
46
+ end
47
+ end
48
+
49
+ # Attribute mapping from ruby-style variable name to JSON key.
50
+ def self.attribute_map
51
+ {
52
+ :'data' => :'data',
53
+ :'status' => :'status',
54
+ :'task' => :'task',
55
+ :'task_id' => :'taskId'
56
+ }
57
+ end
58
+
59
+ # Returns all the JSON keys this model knows about
60
+ def self.acceptable_attributes
61
+ attribute_map.values
62
+ end
63
+
64
+ # Attribute type mapping.
65
+ def self.openapi_types
66
+ {
67
+ :'data' => :'Data',
68
+ :'status' => :'BackgroundTaskStatus',
69
+ :'task' => :'BackgroundTaskType',
70
+ :'task_id' => :'String'
71
+ }
72
+ end
73
+
74
+ # List of attributes with nullable: true
75
+ def self.openapi_nullable
76
+ Set.new([
77
+ ])
78
+ end
79
+
80
+ # Initializes the object
81
+ # @param [Hash] attributes Model attributes in the form of hash
82
+ def initialize(attributes = {})
83
+ if (!attributes.is_a?(Hash))
84
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::BackgroundTaskFinishedEvent2` initialize method"
85
+ end
86
+
87
+ # check to see if the attribute exists and convert string to symbol for hash key
88
+ attributes = attributes.each_with_object({}) { |(k, v), h|
89
+ if (!self.class.attribute_map.key?(k.to_sym))
90
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::BackgroundTaskFinishedEvent2`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
91
+ end
92
+ h[k.to_sym] = v
93
+ }
94
+
95
+ if attributes.key?(:'data')
96
+ self.data = attributes[:'data']
97
+ else
98
+ self.data = nil
99
+ end
100
+
101
+ if attributes.key?(:'status')
102
+ self.status = attributes[:'status']
103
+ else
104
+ self.status = nil
105
+ end
106
+
107
+ if attributes.key?(:'task')
108
+ self.task = attributes[:'task']
109
+ else
110
+ self.task = nil
111
+ end
112
+
113
+ if attributes.key?(:'task_id')
114
+ self.task_id = attributes[:'task_id']
115
+ else
116
+ self.task_id = nil
117
+ end
118
+ end
119
+
120
+ # Show invalid properties with the reasons. Usually used together with valid?
121
+ # @return Array for valid properties with the reasons
122
+ def list_invalid_properties
123
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
124
+ invalid_properties = Array.new
125
+ if @data.nil?
126
+ invalid_properties.push('invalid value for "data", data cannot be nil.')
127
+ end
128
+
129
+ if @status.nil?
130
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
131
+ end
132
+
133
+ if @task.nil?
134
+ invalid_properties.push('invalid value for "task", task cannot be nil.')
135
+ end
136
+
137
+ if @task_id.nil?
138
+ invalid_properties.push('invalid value for "task_id", task_id cannot be nil.')
139
+ end
140
+
141
+ if @task_id.to_s.length > 33
142
+ invalid_properties.push('invalid value for "task_id", the character length must be smaller than or equal to 33.')
143
+ end
144
+
145
+ if @task_id.to_s.length < 33
146
+ invalid_properties.push('invalid value for "task_id", the character length must be great than or equal to 33.')
147
+ end
148
+
149
+ pattern = Regexp.new(/^qtask_[A-Za-z0-9]{27}$/)
150
+ if @task_id !~ pattern
151
+ invalid_properties.push("invalid value for \"task_id\", must conform to the pattern #{pattern}.")
152
+ end
153
+
154
+ invalid_properties
155
+ end
156
+
157
+ # Check to see if the all the properties in the model are valid
158
+ # @return true if the model is valid
159
+ def valid?
160
+ warn '[DEPRECATED] the `valid?` method is obsolete'
161
+ return false if @data.nil?
162
+ return false if @status.nil?
163
+ return false if @task.nil?
164
+ return false if @task_id.nil?
165
+ return false if @task_id.to_s.length > 33
166
+ return false if @task_id.to_s.length < 33
167
+ return false if @task_id !~ Regexp.new(/^qtask_[A-Za-z0-9]{27}$/)
168
+ true
169
+ end
170
+
171
+ # Custom attribute writer method with validation
172
+ # @param [Object] task_id Value to be assigned
173
+ def task_id=(task_id)
174
+ if task_id.nil?
175
+ fail ArgumentError, 'task_id cannot be nil'
176
+ end
177
+
178
+ if task_id.to_s.length > 33
179
+ fail ArgumentError, 'invalid value for "task_id", the character length must be smaller than or equal to 33.'
180
+ end
181
+
182
+ if task_id.to_s.length < 33
183
+ fail ArgumentError, 'invalid value for "task_id", the character length must be great than or equal to 33.'
184
+ end
185
+
186
+ pattern = Regexp.new(/^qtask_[A-Za-z0-9]{27}$/)
187
+ if task_id !~ pattern
188
+ fail ArgumentError, "invalid value for \"task_id\", must conform to the pattern #{pattern}."
189
+ end
190
+
191
+ @task_id = task_id
192
+ end
193
+
194
+ # Checks equality by comparing each attribute.
195
+ # @param [Object] Object to be compared
196
+ def ==(o)
197
+ return true if self.equal?(o)
198
+ self.class == o.class &&
199
+ data == o.data &&
200
+ status == o.status &&
201
+ task == o.task &&
202
+ task_id == o.task_id
203
+ end
204
+
205
+ # @see the `==` method
206
+ # @param [Object] Object to be compared
207
+ def eql?(o)
208
+ self == o
209
+ end
210
+
211
+ # Calculates hash code according to all attributes.
212
+ # @return [Integer] Hash code
213
+ def hash
214
+ [data, status, task, task_id].hash
215
+ end
216
+
217
+ # Builds the object from hash
218
+ # @param [Hash] attributes Model attributes in the form of hash
219
+ # @return [Object] Returns the model itself
220
+ def self.build_from_hash(attributes)
221
+ return nil unless attributes.is_a?(Hash)
222
+ attributes = attributes.transform_keys(&:to_sym)
223
+ transformed_hash = {}
224
+ openapi_types.each_pair do |key, type|
225
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
226
+ transformed_hash["#{key}"] = nil
227
+ elsif type =~ /\AArray<(.*)>/i
228
+ # check to ensure the input is an array given that the attribute
229
+ # is documented as an array but the input is not
230
+ if attributes[attribute_map[key]].is_a?(Array)
231
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
232
+ end
233
+ elsif !attributes[attribute_map[key]].nil?
234
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
235
+ end
236
+ end
237
+ new(transformed_hash)
238
+ end
239
+
240
+ # Deserializes the data based on type
241
+ # @param string type Data type
242
+ # @param string value Value to be deserialized
243
+ # @return [Object] Deserialized data
244
+ def self._deserialize(type, value)
245
+ case type.to_sym
246
+ when :Time
247
+ Time.parse(value)
248
+ when :Date
249
+ Date.parse(value)
250
+ when :String
251
+ value.to_s
252
+ when :Integer
253
+ value.to_i
254
+ when :Float
255
+ value.to_f
256
+ when :Boolean
257
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
258
+ true
259
+ else
260
+ false
261
+ end
262
+ when :Object
263
+ # generic object (usually a Hash), return directly
264
+ value
265
+ when /\AArray<(?<inner_type>.+)>\z/
266
+ inner_type = Regexp.last_match[:inner_type]
267
+ value.map { |v| _deserialize(inner_type, v) }
268
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
269
+ k_type = Regexp.last_match[:k_type]
270
+ v_type = Regexp.last_match[:v_type]
271
+ {}.tap do |hash|
272
+ value.each do |k, v|
273
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
274
+ end
275
+ end
276
+ else # model
277
+ # models (e.g. Pet) or oneOf
278
+ klass = Svix.const_get(type)
279
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
280
+ end
281
+ end
282
+
283
+ # Returns the string representation of the object
284
+ # @return [String] String presentation of the object
285
+ def to_s
286
+ to_hash.to_s
287
+ end
288
+
289
+ # to_body is an alias to to_hash (backward compatibility)
290
+ # @return [Hash] Returns the object in the form of hash
291
+ def to_body
292
+ to_hash
293
+ end
294
+
295
+ # Returns the object in the form of hash
296
+ # @return [Hash] Returns the object in the form of hash
297
+ def to_hash
298
+ hash = {}
299
+ self.class.attribute_map.each_pair do |attr, param|
300
+ value = self.send(attr)
301
+ if value.nil?
302
+ is_nullable = self.class.openapi_nullable.include?(attr)
303
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
304
+ end
305
+
306
+ hash[param] = _to_hash(value)
307
+ end
308
+ hash
309
+ end
310
+
311
+ # Outputs non-array value in the form of hash
312
+ # For object, use to_hash. Otherwise, just return the value
313
+ # @param [Object] value Any valid value
314
+ # @return [Hash] Returns the value in the form of hash
315
+ def _to_hash(value)
316
+ if value.is_a?(Array)
317
+ value.compact.map { |v| _to_hash(v) }
318
+ elsif value.is_a?(Hash)
319
+ {}.tap do |hash|
320
+ value.each { |k, v| hash[k] = _to_hash(v) }
321
+ end
322
+ elsif value.respond_to? :to_hash
323
+ value.to_hash
324
+ else
325
+ value
326
+ end
327
+ end
328
+
329
+ end
330
+
331
+ end
@@ -17,6 +17,7 @@ module Svix
17
17
  class BackgroundTaskOut
18
18
  attr_accessor :data
19
19
 
20
+ # The QueueBackgroundTask's ID.
20
21
  attr_accessor :id
21
22
 
22
23
  attr_accessor :status
@@ -129,6 +130,19 @@ module Svix
129
130
  invalid_properties.push('invalid value for "id", id cannot be nil.')
130
131
  end
131
132
 
133
+ if @id.to_s.length > 33
134
+ invalid_properties.push('invalid value for "id", the character length must be smaller than or equal to 33.')
135
+ end
136
+
137
+ if @id.to_s.length < 33
138
+ invalid_properties.push('invalid value for "id", the character length must be great than or equal to 33.')
139
+ end
140
+
141
+ pattern = Regexp.new(/^qtask_[A-Za-z0-9]{27}$/)
142
+ if @id !~ pattern
143
+ invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.")
144
+ end
145
+
132
146
  if @status.nil?
133
147
  invalid_properties.push('invalid value for "status", status cannot be nil.')
134
148
  end
@@ -146,11 +160,37 @@ module Svix
146
160
  warn '[DEPRECATED] the `valid?` method is obsolete'
147
161
  return false if @data.nil?
148
162
  return false if @id.nil?
163
+ return false if @id.to_s.length > 33
164
+ return false if @id.to_s.length < 33
165
+ return false if @id !~ Regexp.new(/^qtask_[A-Za-z0-9]{27}$/)
149
166
  return false if @status.nil?
150
167
  return false if @task.nil?
151
168
  true
152
169
  end
153
170
 
171
+ # Custom attribute writer method with validation
172
+ # @param [Object] id Value to be assigned
173
+ def id=(id)
174
+ if id.nil?
175
+ fail ArgumentError, 'id cannot be nil'
176
+ end
177
+
178
+ if id.to_s.length > 33
179
+ fail ArgumentError, 'invalid value for "id", the character length must be smaller than or equal to 33.'
180
+ end
181
+
182
+ if id.to_s.length < 33
183
+ fail ArgumentError, 'invalid value for "id", the character length must be great than or equal to 33.'
184
+ end
185
+
186
+ pattern = Regexp.new(/^qtask_[A-Za-z0-9]{27}$/)
187
+ if id !~ pattern
188
+ fail ArgumentError, "invalid value for \"id\", must conform to the pattern #{pattern}."
189
+ end
190
+
191
+ @id = id
192
+ end
193
+
154
194
  # Checks equality by comparing each attribute.
155
195
  # @param [Object] Object to be compared
156
196
  def ==(o)
@@ -21,9 +21,10 @@ module Svix
21
21
  MESSAGE_BROADCAST = "message.broadcast".freeze
22
22
  SDK_GENERATE = "sdk.generate".freeze
23
23
  EVENT_TYPE_AGGREGATE = "event-type.aggregate".freeze
24
+ APPLICATION_PURGE_CONTENT = "application.purge_content".freeze
24
25
 
25
26
  def self.all_vars
26
- @all_vars ||= [ENDPOINT_REPLAY, ENDPOINT_RECOVER, APPLICATION_STATS, MESSAGE_BROADCAST, SDK_GENERATE, EVENT_TYPE_AGGREGATE].freeze
27
+ @all_vars ||= [ENDPOINT_REPLAY, ENDPOINT_RECOVER, APPLICATION_STATS, MESSAGE_BROADCAST, SDK_GENERATE, EVENT_TYPE_AGGREGATE, APPLICATION_PURGE_CONTENT].freeze
27
28
  end
28
29
 
29
30
  # Builds the enum from string
@@ -14,7 +14,7 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module Svix
17
- class TemplateIn
17
+ class ConnectorIn
18
18
  attr_accessor :description
19
19
 
20
20
  attr_accessor :feature_flag
@@ -83,7 +83,7 @@ module Svix
83
83
  :'filter_types' => :'Array<String>',
84
84
  :'instructions' => :'String',
85
85
  :'instructions_link' => :'String',
86
- :'kind' => :'TransformationTemplateKind',
86
+ :'kind' => :'ConnectorKind',
87
87
  :'logo' => :'String',
88
88
  :'name' => :'String',
89
89
  :'transformation' => :'String'
@@ -103,13 +103,13 @@ module Svix
103
103
  # @param [Hash] attributes Model attributes in the form of hash
104
104
  def initialize(attributes = {})
105
105
  if (!attributes.is_a?(Hash))
106
- fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::TemplateIn` initialize method"
106
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::ConnectorIn` initialize method"
107
107
  end
108
108
 
109
109
  # check to see if the attribute exists and convert string to symbol for hash key
110
110
  attributes = attributes.each_with_object({}) { |(k, v), h|
111
111
  if (!self.class.attribute_map.key?(k.to_sym))
112
- fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::TemplateIn`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
112
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::ConnectorIn`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
113
113
  end
114
114
  h[k.to_sym] = v
115
115
  }
@@ -14,7 +14,7 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module Svix
17
- class TransformationTemplateKind
17
+ class ConnectorKind
18
18
  CUSTOM = "Custom".freeze
19
19
  CUSTOMER_IO = "CustomerIO".freeze
20
20
  DISCORD = "Discord".freeze
@@ -43,8 +43,8 @@ module Svix
43
43
  # @param [String] The enum value in the form of the string
44
44
  # @return [String] The enum value
45
45
  def build_from_hash(value)
46
- return value if TransformationTemplateKind.all_vars.include?(value)
47
- raise "Invalid ENUM value #{value} for class #TransformationTemplateKind"
46
+ return value if ConnectorKind.all_vars.include?(value)
47
+ raise "Invalid ENUM value #{value} for class #ConnectorKind"
48
48
  end
49
49
  end
50
50
  end
@@ -15,14 +15,14 @@ require 'time'
15
15
 
16
16
  module Svix
17
17
  class CreateStreamIn
18
- attr_accessor :messages
18
+ attr_accessor :events
19
19
 
20
20
  attr_accessor :stream
21
21
 
22
22
  # Attribute mapping from ruby-style variable name to JSON key.
23
23
  def self.attribute_map
24
24
  {
25
- :'messages' => :'messages',
25
+ :'events' => :'events',
26
26
  :'stream' => :'stream'
27
27
  }
28
28
  end
@@ -35,7 +35,7 @@ module Svix
35
35
  # Attribute type mapping.
36
36
  def self.openapi_types
37
37
  {
38
- :'messages' => :'Array<EventIn>',
38
+ :'events' => :'Array<EventIn>',
39
39
  :'stream' => :'StreamIn'
40
40
  }
41
41
  end
@@ -61,12 +61,12 @@ module Svix
61
61
  h[k.to_sym] = v
62
62
  }
63
63
 
64
- if attributes.key?(:'messages')
65
- if (value = attributes[:'messages']).is_a?(Array)
66
- self.messages = value
64
+ if attributes.key?(:'events')
65
+ if (value = attributes[:'events']).is_a?(Array)
66
+ self.events = value
67
67
  end
68
68
  else
69
- self.messages = nil
69
+ self.events = nil
70
70
  end
71
71
 
72
72
  if attributes.key?(:'stream')
@@ -79,8 +79,8 @@ module Svix
79
79
  def list_invalid_properties
80
80
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
81
81
  invalid_properties = Array.new
82
- if @messages.nil?
83
- invalid_properties.push('invalid value for "messages", messages cannot be nil.')
82
+ if @events.nil?
83
+ invalid_properties.push('invalid value for "events", events cannot be nil.')
84
84
  end
85
85
 
86
86
  invalid_properties
@@ -90,7 +90,7 @@ module Svix
90
90
  # @return true if the model is valid
91
91
  def valid?
92
92
  warn '[DEPRECATED] the `valid?` method is obsolete'
93
- return false if @messages.nil?
93
+ return false if @events.nil?
94
94
  true
95
95
  end
96
96
 
@@ -99,7 +99,7 @@ module Svix
99
99
  def ==(o)
100
100
  return true if self.equal?(o)
101
101
  self.class == o.class &&
102
- messages == o.messages &&
102
+ events == o.events &&
103
103
  stream == o.stream
104
104
  end
105
105
 
@@ -112,7 +112,7 @@ module Svix
112
112
  # Calculates hash code according to all attributes.
113
113
  # @return [Integer] Hash code
114
114
  def hash
115
- [messages, stream].hash
115
+ [events, stream].hash
116
116
  end
117
117
 
118
118
  # Builds the object from hash
@@ -0,0 +1,108 @@
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
+ # A copy of [`backgroundtask::Data`], but serialized with camelCase fields for customers.
18
+ module Data
19
+ class << self
20
+ # List of class defined in anyOf (OpenAPI v3)
21
+ def openapi_any_of
22
+ [
23
+ :'DataAnyOf',
24
+ :'DataAnyOf1',
25
+ :'DataAnyOf2',
26
+ :'DataAnyOf3',
27
+ :'DataAnyOf4'
28
+ ]
29
+ end
30
+
31
+ # Builds the object
32
+ # @param [Mixed] Data to be matched against the list of anyOf items
33
+ # @return [Object] Returns the model or the data itself
34
+ def build(data)
35
+ # Go through the list of anyOf items and attempt to identify the appropriate one.
36
+ # Note:
37
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
38
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
39
+ # - TODO: scalar values are de facto behaving as if they were nullable.
40
+ # - TODO: logging when debugging is set.
41
+ openapi_any_of.each do |klass|
42
+ begin
43
+ next if klass == :AnyType # "nullable: true"
44
+ typed_data = find_and_cast_into_type(klass, data)
45
+ return typed_data if typed_data
46
+ rescue # rescue all errors so we keep iterating even if the current item lookup raises
47
+ end
48
+ end
49
+
50
+ openapi_any_of.include?(:AnyType) ? data : nil
51
+ end
52
+
53
+ private
54
+
55
+ SchemaMismatchError = Class.new(StandardError)
56
+
57
+ # Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
58
+ def find_and_cast_into_type(klass, data)
59
+ return if data.nil?
60
+
61
+ case klass.to_s
62
+ when 'Boolean'
63
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
64
+ when 'Float'
65
+ return data if data.instance_of?(Float)
66
+ when 'Integer'
67
+ return data if data.instance_of?(Integer)
68
+ when 'Time'
69
+ return Time.parse(data)
70
+ when 'Date'
71
+ return Date.parse(data)
72
+ when 'String'
73
+ return data if data.instance_of?(String)
74
+ when 'Object' # "type: object"
75
+ return data if data.instance_of?(Hash)
76
+ when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
77
+ if data.instance_of?(Array)
78
+ sub_type = Regexp.last_match[:sub_type]
79
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
80
+ end
81
+ when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
82
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
83
+ sub_type = Regexp.last_match[:sub_type]
84
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
85
+ end
86
+ else # model
87
+ const = Svix.const_get(klass)
88
+ if const
89
+ if const.respond_to?(:openapi_any_of) # nested anyOf model
90
+ model = const.build(data)
91
+ return model if model
92
+ else
93
+ # raise if data contains keys that are not known to the model
94
+ raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
95
+ model = const.build_from_hash(data)
96
+ return model if model
97
+ end
98
+ end
99
+ end
100
+
101
+ raise # if no match by now, raise
102
+ rescue
103
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
104
+ end
105
+ end
106
+ end
107
+
108
+ end