svix 1.24.0 → 1.26.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/svix/api/authentication_api.rb +87 -0
- data/lib/svix/api/endpoint_api.rb +277 -2
- data/lib/svix/api/events_api.rb +3 -3
- data/lib/svix/api/message_api.rb +317 -101
- data/lib/svix/api/transformation_template_api.rb +195 -24
- data/lib/svix/models/auth_token_out.rb +284 -0
- data/lib/svix/models/create_message_token_in.rb +250 -0
- data/lib/svix/models/create_stream_in.rb +225 -0
- data/lib/svix/models/endpoint_created_event_data.rb +1 -0
- data/lib/svix/models/endpoint_deleted_event_data.rb +1 -0
- data/lib/svix/models/endpoint_mtls_config_in.rb +15 -19
- data/lib/svix/models/endpoint_oauth_config_in.rb +13 -2
- data/lib/svix/models/endpoint_updated_event_data.rb +1 -0
- data/lib/svix/models/environment_settings_out.rb +15 -4
- data/lib/svix/models/event_in.rb +223 -0
- data/lib/svix/models/event_out.rb +237 -0
- data/lib/svix/models/event_stream_out.rb +253 -0
- data/lib/svix/models/event_type_from_open_api.rb +280 -0
- data/lib/svix/models/event_type_import_open_api_in.rb +13 -1
- data/lib/svix/models/event_type_import_open_api_out_data.rb +16 -4
- data/lib/svix/models/event_type_in.rb +38 -1
- data/lib/svix/models/event_type_out.rb +38 -1
- data/lib/svix/models/event_type_patch.rb +38 -1
- data/lib/svix/models/event_type_update.rb +38 -1
- data/lib/svix/models/hubspot_oauth_config_in.rb +223 -0
- data/lib/svix/models/{oauth_payload_out.rb → incoming_webhook_payload_out.rb} +3 -3
- data/lib/svix/models/kafka_security_protocol_type.rb +38 -0
- data/lib/svix/models/list_response_sink_out.rb +259 -0
- data/lib/svix/models/{message_stream_out.rb → message_events_out.rb} +3 -3
- data/lib/svix/models/message_subscriber_auth_token_out.rb +237 -0
- data/lib/svix/models/{oauth_payload_in.rb → o_auth_payload_in.rb} +3 -3
- data/lib/svix/models/o_auth_payload_out.rb +239 -0
- data/lib/svix/models/{oauth2_grant_type.rb → oauth2_grant_type_in.rb} +4 -3
- data/lib/svix/models/settings_in.rb +15 -4
- data/lib/svix/models/settings_out.rb +15 -4
- data/lib/svix/models/sink_in.rb +107 -0
- data/lib/svix/models/sink_in_one_of.rb +285 -0
- data/lib/svix/models/sink_in_one_of1.rb +313 -0
- data/lib/svix/models/sink_in_one_of2.rb +321 -0
- data/lib/svix/models/sink_in_one_of3.rb +271 -0
- data/lib/svix/models/sink_out.rb +107 -0
- data/lib/svix/version.rb +1 -1
- metadata +24 -6
@@ -0,0 +1,321 @@
|
|
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
|
+
OpenAPI Generator version: 5.2.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Svix
|
17
|
+
class SinkInOneOf2
|
18
|
+
attr_accessor :brokers
|
19
|
+
|
20
|
+
# Password for SASL, if `security_protocol` is `sasl-ssl`.
|
21
|
+
attr_accessor :sasl_password
|
22
|
+
|
23
|
+
# Username for SASL, if `security_protocol` is `sasl-ssl`.
|
24
|
+
attr_accessor :sasl_username
|
25
|
+
|
26
|
+
attr_accessor :security_protocol
|
27
|
+
|
28
|
+
attr_accessor :topic
|
29
|
+
|
30
|
+
attr_accessor :type
|
31
|
+
|
32
|
+
class EnumAttributeValidator
|
33
|
+
attr_reader :datatype
|
34
|
+
attr_reader :allowable_values
|
35
|
+
|
36
|
+
def initialize(datatype, allowable_values)
|
37
|
+
@allowable_values = allowable_values.map do |value|
|
38
|
+
case datatype.to_s
|
39
|
+
when /Integer/i
|
40
|
+
value.to_i
|
41
|
+
when /Float/i
|
42
|
+
value.to_f
|
43
|
+
else
|
44
|
+
value
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def valid?(value)
|
50
|
+
!value || allowable_values.include?(value)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
55
|
+
def self.attribute_map
|
56
|
+
{
|
57
|
+
:'brokers' => :'brokers',
|
58
|
+
:'sasl_password' => :'saslPassword',
|
59
|
+
:'sasl_username' => :'saslUsername',
|
60
|
+
:'security_protocol' => :'securityProtocol',
|
61
|
+
:'topic' => :'topic',
|
62
|
+
:'type' => :'type'
|
63
|
+
}
|
64
|
+
end
|
65
|
+
|
66
|
+
# Returns all the JSON keys this model knows about
|
67
|
+
def self.acceptable_attributes
|
68
|
+
attribute_map.values
|
69
|
+
end
|
70
|
+
|
71
|
+
# Attribute type mapping.
|
72
|
+
def self.openapi_types
|
73
|
+
{
|
74
|
+
:'brokers' => :'String',
|
75
|
+
:'sasl_password' => :'String',
|
76
|
+
:'sasl_username' => :'String',
|
77
|
+
:'security_protocol' => :'KafkaSecurityProtocolType',
|
78
|
+
:'topic' => :'String',
|
79
|
+
:'type' => :'String'
|
80
|
+
}
|
81
|
+
end
|
82
|
+
|
83
|
+
# List of attributes with nullable: true
|
84
|
+
def self.openapi_nullable
|
85
|
+
Set.new([
|
86
|
+
:'sasl_password',
|
87
|
+
:'sasl_username',
|
88
|
+
])
|
89
|
+
end
|
90
|
+
|
91
|
+
# Initializes the object
|
92
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
93
|
+
def initialize(attributes = {})
|
94
|
+
if (!attributes.is_a?(Hash))
|
95
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::SinkInOneOf2` initialize method"
|
96
|
+
end
|
97
|
+
|
98
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
99
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
100
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
101
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::SinkInOneOf2`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
102
|
+
end
|
103
|
+
h[k.to_sym] = v
|
104
|
+
}
|
105
|
+
|
106
|
+
if attributes.key?(:'brokers')
|
107
|
+
self.brokers = attributes[:'brokers']
|
108
|
+
end
|
109
|
+
|
110
|
+
if attributes.key?(:'sasl_password')
|
111
|
+
self.sasl_password = attributes[:'sasl_password']
|
112
|
+
end
|
113
|
+
|
114
|
+
if attributes.key?(:'sasl_username')
|
115
|
+
self.sasl_username = attributes[:'sasl_username']
|
116
|
+
end
|
117
|
+
|
118
|
+
if attributes.key?(:'security_protocol')
|
119
|
+
self.security_protocol = attributes[:'security_protocol']
|
120
|
+
end
|
121
|
+
|
122
|
+
if attributes.key?(:'topic')
|
123
|
+
self.topic = attributes[:'topic']
|
124
|
+
end
|
125
|
+
|
126
|
+
if attributes.key?(:'type')
|
127
|
+
self.type = attributes[:'type']
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
132
|
+
# @return Array for valid properties with the reasons
|
133
|
+
def list_invalid_properties
|
134
|
+
invalid_properties = Array.new
|
135
|
+
if @brokers.nil?
|
136
|
+
invalid_properties.push('invalid value for "brokers", brokers cannot be nil.')
|
137
|
+
end
|
138
|
+
|
139
|
+
if @security_protocol.nil?
|
140
|
+
invalid_properties.push('invalid value for "security_protocol", security_protocol cannot be nil.')
|
141
|
+
end
|
142
|
+
|
143
|
+
if @topic.nil?
|
144
|
+
invalid_properties.push('invalid value for "topic", topic cannot be nil.')
|
145
|
+
end
|
146
|
+
|
147
|
+
if @type.nil?
|
148
|
+
invalid_properties.push('invalid value for "type", type cannot be nil.')
|
149
|
+
end
|
150
|
+
|
151
|
+
invalid_properties
|
152
|
+
end
|
153
|
+
|
154
|
+
# Check to see if the all the properties in the model are valid
|
155
|
+
# @return true if the model is valid
|
156
|
+
def valid?
|
157
|
+
return false if @brokers.nil?
|
158
|
+
return false if @security_protocol.nil?
|
159
|
+
return false if @topic.nil?
|
160
|
+
return false if @type.nil?
|
161
|
+
type_validator = EnumAttributeValidator.new('String', ["kafka"])
|
162
|
+
return false unless type_validator.valid?(@type)
|
163
|
+
true
|
164
|
+
end
|
165
|
+
|
166
|
+
# Custom attribute writer method checking allowed values (enum).
|
167
|
+
# @param [Object] type Object to be assigned
|
168
|
+
def type=(type)
|
169
|
+
validator = EnumAttributeValidator.new('String', ["kafka"])
|
170
|
+
unless validator.valid?(type)
|
171
|
+
fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
|
172
|
+
end
|
173
|
+
@type = type
|
174
|
+
end
|
175
|
+
|
176
|
+
# Checks equality by comparing each attribute.
|
177
|
+
# @param [Object] Object to be compared
|
178
|
+
def ==(o)
|
179
|
+
return true if self.equal?(o)
|
180
|
+
self.class == o.class &&
|
181
|
+
brokers == o.brokers &&
|
182
|
+
sasl_password == o.sasl_password &&
|
183
|
+
sasl_username == o.sasl_username &&
|
184
|
+
security_protocol == o.security_protocol &&
|
185
|
+
topic == o.topic &&
|
186
|
+
type == o.type
|
187
|
+
end
|
188
|
+
|
189
|
+
# @see the `==` method
|
190
|
+
# @param [Object] Object to be compared
|
191
|
+
def eql?(o)
|
192
|
+
self == o
|
193
|
+
end
|
194
|
+
|
195
|
+
# Calculates hash code according to all attributes.
|
196
|
+
# @return [Integer] Hash code
|
197
|
+
def hash
|
198
|
+
[brokers, sasl_password, sasl_username, security_protocol, topic, type].hash
|
199
|
+
end
|
200
|
+
|
201
|
+
# Builds the object from hash
|
202
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
203
|
+
# @return [Object] Returns the model itself
|
204
|
+
def self.build_from_hash(attributes)
|
205
|
+
new.build_from_hash(attributes)
|
206
|
+
end
|
207
|
+
|
208
|
+
# Builds the object from hash
|
209
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
210
|
+
# @return [Object] Returns the model itself
|
211
|
+
def build_from_hash(attributes)
|
212
|
+
return nil unless attributes.is_a?(Hash)
|
213
|
+
self.class.openapi_types.each_pair do |key, type|
|
214
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
215
|
+
self.send("#{key}=", nil)
|
216
|
+
elsif type =~ /\AArray<(.*)>/i
|
217
|
+
# check to ensure the input is an array given that the attribute
|
218
|
+
# is documented as an array but the input is not
|
219
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
220
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
221
|
+
end
|
222
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
223
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
self
|
228
|
+
end
|
229
|
+
|
230
|
+
# Deserializes the data based on type
|
231
|
+
# @param string type Data type
|
232
|
+
# @param string value Value to be deserialized
|
233
|
+
# @return [Object] Deserialized data
|
234
|
+
def _deserialize(type, value)
|
235
|
+
case type.to_sym
|
236
|
+
when :Time
|
237
|
+
Time.parse(value)
|
238
|
+
when :Date
|
239
|
+
Date.parse(value)
|
240
|
+
when :String
|
241
|
+
value.to_s
|
242
|
+
when :Integer
|
243
|
+
value.to_i
|
244
|
+
when :Float
|
245
|
+
value.to_f
|
246
|
+
when :Boolean
|
247
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
248
|
+
true
|
249
|
+
else
|
250
|
+
false
|
251
|
+
end
|
252
|
+
when :Object
|
253
|
+
# generic object (usually a Hash), return directly
|
254
|
+
value
|
255
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
256
|
+
inner_type = Regexp.last_match[:inner_type]
|
257
|
+
value.map { |v| _deserialize(inner_type, v) }
|
258
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
259
|
+
k_type = Regexp.last_match[:k_type]
|
260
|
+
v_type = Regexp.last_match[:v_type]
|
261
|
+
{}.tap do |hash|
|
262
|
+
value.each do |k, v|
|
263
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
264
|
+
end
|
265
|
+
end
|
266
|
+
else # model
|
267
|
+
# models (e.g. Pet) or oneOf
|
268
|
+
klass = Svix.const_get(type)
|
269
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
# Returns the string representation of the object
|
274
|
+
# @return [String] String presentation of the object
|
275
|
+
def to_s
|
276
|
+
to_hash.to_s
|
277
|
+
end
|
278
|
+
|
279
|
+
# to_body is an alias to to_hash (backward compatibility)
|
280
|
+
# @return [Hash] Returns the object in the form of hash
|
281
|
+
def to_body
|
282
|
+
to_hash
|
283
|
+
end
|
284
|
+
|
285
|
+
# Returns the object in the form of hash
|
286
|
+
# @return [Hash] Returns the object in the form of hash
|
287
|
+
def to_hash
|
288
|
+
hash = {}
|
289
|
+
self.class.attribute_map.each_pair do |attr, param|
|
290
|
+
value = self.send(attr)
|
291
|
+
if value.nil?
|
292
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
293
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
294
|
+
end
|
295
|
+
|
296
|
+
hash[param] = _to_hash(value)
|
297
|
+
end
|
298
|
+
hash
|
299
|
+
end
|
300
|
+
|
301
|
+
# Outputs non-array value in the form of hash
|
302
|
+
# For object, use to_hash. Otherwise, just return the value
|
303
|
+
# @param [Object] value Any valid value
|
304
|
+
# @return [Hash] Returns the value in the form of hash
|
305
|
+
def _to_hash(value)
|
306
|
+
if value.is_a?(Array)
|
307
|
+
value.compact.map { |v| _to_hash(v) }
|
308
|
+
elsif value.is_a?(Hash)
|
309
|
+
{}.tap do |hash|
|
310
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
311
|
+
end
|
312
|
+
elsif value.respond_to? :to_hash
|
313
|
+
value.to_hash
|
314
|
+
else
|
315
|
+
value
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
end
|
320
|
+
|
321
|
+
end
|
@@ -0,0 +1,271 @@
|
|
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
|
+
OpenAPI Generator version: 5.2.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Svix
|
17
|
+
class SinkInOneOf3
|
18
|
+
attr_accessor :type
|
19
|
+
|
20
|
+
attr_accessor :url
|
21
|
+
|
22
|
+
class EnumAttributeValidator
|
23
|
+
attr_reader :datatype
|
24
|
+
attr_reader :allowable_values
|
25
|
+
|
26
|
+
def initialize(datatype, allowable_values)
|
27
|
+
@allowable_values = allowable_values.map do |value|
|
28
|
+
case datatype.to_s
|
29
|
+
when /Integer/i
|
30
|
+
value.to_i
|
31
|
+
when /Float/i
|
32
|
+
value.to_f
|
33
|
+
else
|
34
|
+
value
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def valid?(value)
|
40
|
+
!value || allowable_values.include?(value)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
45
|
+
def self.attribute_map
|
46
|
+
{
|
47
|
+
:'type' => :'type',
|
48
|
+
:'url' => :'url'
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
# Returns all the JSON keys this model knows about
|
53
|
+
def self.acceptable_attributes
|
54
|
+
attribute_map.values
|
55
|
+
end
|
56
|
+
|
57
|
+
# Attribute type mapping.
|
58
|
+
def self.openapi_types
|
59
|
+
{
|
60
|
+
:'type' => :'String',
|
61
|
+
:'url' => :'String'
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
# List of attributes with nullable: true
|
66
|
+
def self.openapi_nullable
|
67
|
+
Set.new([
|
68
|
+
])
|
69
|
+
end
|
70
|
+
|
71
|
+
# Initializes the object
|
72
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
73
|
+
def initialize(attributes = {})
|
74
|
+
if (!attributes.is_a?(Hash))
|
75
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::SinkInOneOf3` initialize method"
|
76
|
+
end
|
77
|
+
|
78
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
79
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
80
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
81
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::SinkInOneOf3`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
82
|
+
end
|
83
|
+
h[k.to_sym] = v
|
84
|
+
}
|
85
|
+
|
86
|
+
if attributes.key?(:'type')
|
87
|
+
self.type = attributes[:'type']
|
88
|
+
end
|
89
|
+
|
90
|
+
if attributes.key?(:'url')
|
91
|
+
self.url = attributes[:'url']
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
96
|
+
# @return Array for valid properties with the reasons
|
97
|
+
def list_invalid_properties
|
98
|
+
invalid_properties = Array.new
|
99
|
+
if @type.nil?
|
100
|
+
invalid_properties.push('invalid value for "type", type cannot be nil.')
|
101
|
+
end
|
102
|
+
|
103
|
+
if @url.nil?
|
104
|
+
invalid_properties.push('invalid value for "url", url cannot be nil.')
|
105
|
+
end
|
106
|
+
|
107
|
+
invalid_properties
|
108
|
+
end
|
109
|
+
|
110
|
+
# Check to see if the all the properties in the model are valid
|
111
|
+
# @return true if the model is valid
|
112
|
+
def valid?
|
113
|
+
return false if @type.nil?
|
114
|
+
type_validator = EnumAttributeValidator.new('String', ["otelV1HttpTrace"])
|
115
|
+
return false unless type_validator.valid?(@type)
|
116
|
+
return false if @url.nil?
|
117
|
+
true
|
118
|
+
end
|
119
|
+
|
120
|
+
# Custom attribute writer method checking allowed values (enum).
|
121
|
+
# @param [Object] type Object to be assigned
|
122
|
+
def type=(type)
|
123
|
+
validator = EnumAttributeValidator.new('String', ["otelV1HttpTrace"])
|
124
|
+
unless validator.valid?(type)
|
125
|
+
fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
|
126
|
+
end
|
127
|
+
@type = type
|
128
|
+
end
|
129
|
+
|
130
|
+
# Checks equality by comparing each attribute.
|
131
|
+
# @param [Object] Object to be compared
|
132
|
+
def ==(o)
|
133
|
+
return true if self.equal?(o)
|
134
|
+
self.class == o.class &&
|
135
|
+
type == o.type &&
|
136
|
+
url == o.url
|
137
|
+
end
|
138
|
+
|
139
|
+
# @see the `==` method
|
140
|
+
# @param [Object] Object to be compared
|
141
|
+
def eql?(o)
|
142
|
+
self == o
|
143
|
+
end
|
144
|
+
|
145
|
+
# Calculates hash code according to all attributes.
|
146
|
+
# @return [Integer] Hash code
|
147
|
+
def hash
|
148
|
+
[type, url].hash
|
149
|
+
end
|
150
|
+
|
151
|
+
# Builds the object from hash
|
152
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
153
|
+
# @return [Object] Returns the model itself
|
154
|
+
def self.build_from_hash(attributes)
|
155
|
+
new.build_from_hash(attributes)
|
156
|
+
end
|
157
|
+
|
158
|
+
# Builds the object from hash
|
159
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
160
|
+
# @return [Object] Returns the model itself
|
161
|
+
def build_from_hash(attributes)
|
162
|
+
return nil unless attributes.is_a?(Hash)
|
163
|
+
self.class.openapi_types.each_pair do |key, type|
|
164
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
165
|
+
self.send("#{key}=", nil)
|
166
|
+
elsif type =~ /\AArray<(.*)>/i
|
167
|
+
# check to ensure the input is an array given that the attribute
|
168
|
+
# is documented as an array but the input is not
|
169
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
170
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
171
|
+
end
|
172
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
173
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
self
|
178
|
+
end
|
179
|
+
|
180
|
+
# Deserializes the data based on type
|
181
|
+
# @param string type Data type
|
182
|
+
# @param string value Value to be deserialized
|
183
|
+
# @return [Object] Deserialized data
|
184
|
+
def _deserialize(type, value)
|
185
|
+
case type.to_sym
|
186
|
+
when :Time
|
187
|
+
Time.parse(value)
|
188
|
+
when :Date
|
189
|
+
Date.parse(value)
|
190
|
+
when :String
|
191
|
+
value.to_s
|
192
|
+
when :Integer
|
193
|
+
value.to_i
|
194
|
+
when :Float
|
195
|
+
value.to_f
|
196
|
+
when :Boolean
|
197
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
198
|
+
true
|
199
|
+
else
|
200
|
+
false
|
201
|
+
end
|
202
|
+
when :Object
|
203
|
+
# generic object (usually a Hash), return directly
|
204
|
+
value
|
205
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
206
|
+
inner_type = Regexp.last_match[:inner_type]
|
207
|
+
value.map { |v| _deserialize(inner_type, v) }
|
208
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
209
|
+
k_type = Regexp.last_match[:k_type]
|
210
|
+
v_type = Regexp.last_match[:v_type]
|
211
|
+
{}.tap do |hash|
|
212
|
+
value.each do |k, v|
|
213
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
214
|
+
end
|
215
|
+
end
|
216
|
+
else # model
|
217
|
+
# models (e.g. Pet) or oneOf
|
218
|
+
klass = Svix.const_get(type)
|
219
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
# Returns the string representation of the object
|
224
|
+
# @return [String] String presentation of the object
|
225
|
+
def to_s
|
226
|
+
to_hash.to_s
|
227
|
+
end
|
228
|
+
|
229
|
+
# to_body is an alias to to_hash (backward compatibility)
|
230
|
+
# @return [Hash] Returns the object in the form of hash
|
231
|
+
def to_body
|
232
|
+
to_hash
|
233
|
+
end
|
234
|
+
|
235
|
+
# Returns the object in the form of hash
|
236
|
+
# @return [Hash] Returns the object in the form of hash
|
237
|
+
def to_hash
|
238
|
+
hash = {}
|
239
|
+
self.class.attribute_map.each_pair do |attr, param|
|
240
|
+
value = self.send(attr)
|
241
|
+
if value.nil?
|
242
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
243
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
244
|
+
end
|
245
|
+
|
246
|
+
hash[param] = _to_hash(value)
|
247
|
+
end
|
248
|
+
hash
|
249
|
+
end
|
250
|
+
|
251
|
+
# Outputs non-array value in the form of hash
|
252
|
+
# For object, use to_hash. Otherwise, just return the value
|
253
|
+
# @param [Object] value Any valid value
|
254
|
+
# @return [Hash] Returns the value in the form of hash
|
255
|
+
def _to_hash(value)
|
256
|
+
if value.is_a?(Array)
|
257
|
+
value.compact.map { |v| _to_hash(v) }
|
258
|
+
elsif value.is_a?(Hash)
|
259
|
+
{}.tap do |hash|
|
260
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
261
|
+
end
|
262
|
+
elsif value.respond_to? :to_hash
|
263
|
+
value.to_hash
|
264
|
+
else
|
265
|
+
value
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
end
|
270
|
+
|
271
|
+
end
|
@@ -0,0 +1,107 @@
|
|
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
|
+
OpenAPI Generator version: 5.2.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Svix
|
17
|
+
module SinkOut
|
18
|
+
class << self
|
19
|
+
# List of class defined in oneOf (OpenAPI v3)
|
20
|
+
def openapi_one_of
|
21
|
+
[
|
22
|
+
:'SinkInOneOf',
|
23
|
+
:'SinkInOneOf1',
|
24
|
+
:'SinkInOneOf2',
|
25
|
+
:'SinkInOneOf3'
|
26
|
+
]
|
27
|
+
end
|
28
|
+
|
29
|
+
# Builds the object
|
30
|
+
# @param [Mixed] Data to be matched against the list of oneOf items
|
31
|
+
# @return [Object] Returns the model or the data itself
|
32
|
+
def build(data)
|
33
|
+
# Go through the list of oneOf items and attempt to identify the appropriate one.
|
34
|
+
# Note:
|
35
|
+
# - We do not attempt to check whether exactly one item matches.
|
36
|
+
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
37
|
+
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
38
|
+
# - TODO: scalar values are defacto behaving as if they were nullable.
|
39
|
+
# - TODO: logging when debugging is set.
|
40
|
+
openapi_one_of.each do |klass|
|
41
|
+
begin
|
42
|
+
next if klass == :AnyType # "nullable: true"
|
43
|
+
typed_data = find_and_cast_into_type(klass, data)
|
44
|
+
return typed_data if typed_data
|
45
|
+
rescue # rescue all errors so we keep iterating even if the current item lookup raises
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
openapi_one_of.include?(:AnyType) ? data : nil
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
SchemaMismatchError = Class.new(StandardError)
|
55
|
+
|
56
|
+
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
|
57
|
+
def find_and_cast_into_type(klass, data)
|
58
|
+
return if data.nil?
|
59
|
+
|
60
|
+
case klass.to_s
|
61
|
+
when 'Boolean'
|
62
|
+
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
63
|
+
when 'Float'
|
64
|
+
return data if data.instance_of?(Float)
|
65
|
+
when 'Integer'
|
66
|
+
return data if data.instance_of?(Integer)
|
67
|
+
when 'Time'
|
68
|
+
return Time.parse(data)
|
69
|
+
when 'Date'
|
70
|
+
return Date.parse(data)
|
71
|
+
when 'String'
|
72
|
+
return data if data.instance_of?(String)
|
73
|
+
when 'Object' # "type: object"
|
74
|
+
return data if data.instance_of?(Hash)
|
75
|
+
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
|
76
|
+
if data.instance_of?(Array)
|
77
|
+
sub_type = Regexp.last_match[:sub_type]
|
78
|
+
return data.map { |item| find_and_cast_into_type(sub_type, item) }
|
79
|
+
end
|
80
|
+
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
|
81
|
+
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
82
|
+
sub_type = Regexp.last_match[:sub_type]
|
83
|
+
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
84
|
+
end
|
85
|
+
else # model
|
86
|
+
const = Svix.const_get(klass)
|
87
|
+
if const
|
88
|
+
if const.respond_to?(:openapi_one_of) # nested oneOf model
|
89
|
+
model = const.build(data)
|
90
|
+
return model if model
|
91
|
+
else
|
92
|
+
# raise if data contains keys that are not known to the model
|
93
|
+
raise unless (data.keys - const.acceptable_attributes).empty?
|
94
|
+
model = const.build_from_hash(data)
|
95
|
+
return model if model && model.valid?
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
raise # if no match by now, raise
|
101
|
+
rescue
|
102
|
+
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
data/lib/svix/version.rb
CHANGED