svix 1.35.0 → 1.37.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 +1 -1
- data/lib/svix/models/azure_blob_storage_config.rb +251 -0
- data/lib/svix/models/custom_strings_override.rb +11 -1
- data/lib/svix/models/environment_in.rb +13 -1
- data/lib/svix/models/environment_out.rb +17 -1
- data/lib/svix/models/google_cloud_storage_config.rb +239 -0
- data/lib/svix/models/message_attempt_endpoint_out.rb +1 -0
- data/lib/svix/models/message_attempt_out.rb +1 -0
- data/lib/svix/models/redshift_config.rb +311 -0
- data/lib/svix/models/s3_config.rb +10 -10
- data/lib/svix/models/sink_http_config.rb +12 -1
- data/lib/svix/models/sink_in.rb +1 -2
- data/lib/svix/models/sink_in_one_of3.rb +2 -2
- data/lib/svix/models/sink_out.rb +1 -2
- data/lib/svix/models/snowflake_config.rb +285 -0
- data/lib/svix/models/stream_in.rb +35 -2
- data/lib/svix/models/stream_out.rb +35 -1
- data/lib/svix/models/stream_patch.rb +35 -2
- data/lib/svix/models/stream_sink_in.rb +5 -1
- data/lib/svix/models/stream_sink_in_one_of.rb +3 -3
- data/lib/svix/models/stream_sink_in_one_of1.rb +3 -3
- data/lib/svix/models/stream_sink_in_one_of2.rb +3 -3
- data/lib/svix/models/{sink_in_one_of4.rb → stream_sink_in_one_of3.rb} +23 -23
- data/lib/svix/models/stream_sink_in_one_of4.rb +271 -0
- data/lib/svix/models/stream_sink_in_one_of5.rb +271 -0
- data/lib/svix/models/stream_sink_in_one_of6.rb +271 -0
- data/lib/svix/models/stream_sink_out.rb +5 -1
- data/lib/svix/models/stream_sink_patch.rb +5 -1
- data/lib/svix/version.rb +1 -1
- metadata +10 -3
@@ -14,10 +14,10 @@ require 'date'
|
|
14
14
|
require 'time'
|
15
15
|
|
16
16
|
module Svix
|
17
|
-
class
|
18
|
-
attr_accessor :
|
17
|
+
class StreamSinkInOneOf3
|
18
|
+
attr_accessor :config
|
19
19
|
|
20
|
-
attr_accessor :
|
20
|
+
attr_accessor :type
|
21
21
|
|
22
22
|
class EnumAttributeValidator
|
23
23
|
attr_reader :datatype
|
@@ -44,8 +44,8 @@ module Svix
|
|
44
44
|
# Attribute mapping from ruby-style variable name to JSON key.
|
45
45
|
def self.attribute_map
|
46
46
|
{
|
47
|
-
:'
|
48
|
-
:'
|
47
|
+
:'config' => :'config',
|
48
|
+
:'type' => :'type'
|
49
49
|
}
|
50
50
|
end
|
51
51
|
|
@@ -57,8 +57,8 @@ module Svix
|
|
57
57
|
# Attribute type mapping.
|
58
58
|
def self.openapi_types
|
59
59
|
{
|
60
|
-
:'
|
61
|
-
:'
|
60
|
+
:'config' => :'S3Config',
|
61
|
+
:'type' => :'String'
|
62
62
|
}
|
63
63
|
end
|
64
64
|
|
@@ -72,23 +72,23 @@ module Svix
|
|
72
72
|
# @param [Hash] attributes Model attributes in the form of hash
|
73
73
|
def initialize(attributes = {})
|
74
74
|
if (!attributes.is_a?(Hash))
|
75
|
-
fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::
|
75
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Svix::StreamSinkInOneOf3` initialize method"
|
76
76
|
end
|
77
77
|
|
78
78
|
# check to see if the attribute exists and convert string to symbol for hash key
|
79
79
|
attributes = attributes.each_with_object({}) { |(k, v), h|
|
80
80
|
if (!self.class.attribute_map.key?(k.to_sym))
|
81
|
-
fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::
|
81
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Svix::StreamSinkInOneOf3`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
82
82
|
end
|
83
83
|
h[k.to_sym] = v
|
84
84
|
}
|
85
85
|
|
86
|
-
if attributes.key?(:'
|
87
|
-
self.
|
86
|
+
if attributes.key?(:'config')
|
87
|
+
self.config = attributes[:'config']
|
88
88
|
end
|
89
89
|
|
90
|
-
if attributes.key?(:'
|
91
|
-
self.
|
90
|
+
if attributes.key?(:'type')
|
91
|
+
self.type = attributes[:'type']
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
@@ -96,12 +96,12 @@ module Svix
|
|
96
96
|
# @return Array for valid properties with the reasons
|
97
97
|
def list_invalid_properties
|
98
98
|
invalid_properties = Array.new
|
99
|
-
if @
|
100
|
-
invalid_properties.push('invalid value for "
|
99
|
+
if @config.nil?
|
100
|
+
invalid_properties.push('invalid value for "config", config cannot be nil.')
|
101
101
|
end
|
102
102
|
|
103
|
-
if @
|
104
|
-
invalid_properties.push('invalid value for "
|
103
|
+
if @type.nil?
|
104
|
+
invalid_properties.push('invalid value for "type", type cannot be nil.')
|
105
105
|
end
|
106
106
|
|
107
107
|
invalid_properties
|
@@ -110,17 +110,17 @@ module Svix
|
|
110
110
|
# Check to see if the all the properties in the model are valid
|
111
111
|
# @return true if the model is valid
|
112
112
|
def valid?
|
113
|
+
return false if @config.nil?
|
113
114
|
return false if @type.nil?
|
114
|
-
type_validator = EnumAttributeValidator.new('String', ["
|
115
|
+
type_validator = EnumAttributeValidator.new('String', ["amazonS3"])
|
115
116
|
return false unless type_validator.valid?(@type)
|
116
|
-
return false if @url.nil?
|
117
117
|
true
|
118
118
|
end
|
119
119
|
|
120
120
|
# Custom attribute writer method checking allowed values (enum).
|
121
121
|
# @param [Object] type Object to be assigned
|
122
122
|
def type=(type)
|
123
|
-
validator = EnumAttributeValidator.new('String', ["
|
123
|
+
validator = EnumAttributeValidator.new('String', ["amazonS3"])
|
124
124
|
unless validator.valid?(type)
|
125
125
|
fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
|
126
126
|
end
|
@@ -132,8 +132,8 @@ module Svix
|
|
132
132
|
def ==(o)
|
133
133
|
return true if self.equal?(o)
|
134
134
|
self.class == o.class &&
|
135
|
-
|
136
|
-
|
135
|
+
config == o.config &&
|
136
|
+
type == o.type
|
137
137
|
end
|
138
138
|
|
139
139
|
# @see the `==` method
|
@@ -145,7 +145,7 @@ module Svix
|
|
145
145
|
# Calculates hash code according to all attributes.
|
146
146
|
# @return [Integer] Hash code
|
147
147
|
def hash
|
148
|
-
[
|
148
|
+
[config, type].hash
|
149
149
|
end
|
150
150
|
|
151
151
|
# Builds the object from hash
|
@@ -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 StreamSinkInOneOf4
|
18
|
+
attr_accessor :config
|
19
|
+
|
20
|
+
attr_accessor :type
|
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
|
+
:'config' => :'config',
|
48
|
+
:'type' => :'type'
|
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
|
+
:'config' => :'SnowflakeConfig',
|
61
|
+
:'type' => :'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::StreamSinkInOneOf4` 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::StreamSinkInOneOf4`. 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?(:'config')
|
87
|
+
self.config = attributes[:'config']
|
88
|
+
end
|
89
|
+
|
90
|
+
if attributes.key?(:'type')
|
91
|
+
self.type = attributes[:'type']
|
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 @config.nil?
|
100
|
+
invalid_properties.push('invalid value for "config", config cannot be nil.')
|
101
|
+
end
|
102
|
+
|
103
|
+
if @type.nil?
|
104
|
+
invalid_properties.push('invalid value for "type", type 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 @config.nil?
|
114
|
+
return false if @type.nil?
|
115
|
+
type_validator = EnumAttributeValidator.new('String', ["snowflake"])
|
116
|
+
return false unless type_validator.valid?(@type)
|
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', ["snowflake"])
|
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
|
+
config == o.config &&
|
136
|
+
type == o.type
|
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
|
+
[config, type].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,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 StreamSinkInOneOf5
|
18
|
+
attr_accessor :config
|
19
|
+
|
20
|
+
attr_accessor :type
|
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
|
+
:'config' => :'config',
|
48
|
+
:'type' => :'type'
|
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
|
+
:'config' => :'GoogleCloudStorageConfig',
|
61
|
+
:'type' => :'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::StreamSinkInOneOf5` 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::StreamSinkInOneOf5`. 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?(:'config')
|
87
|
+
self.config = attributes[:'config']
|
88
|
+
end
|
89
|
+
|
90
|
+
if attributes.key?(:'type')
|
91
|
+
self.type = attributes[:'type']
|
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 @config.nil?
|
100
|
+
invalid_properties.push('invalid value for "config", config cannot be nil.')
|
101
|
+
end
|
102
|
+
|
103
|
+
if @type.nil?
|
104
|
+
invalid_properties.push('invalid value for "type", type 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 @config.nil?
|
114
|
+
return false if @type.nil?
|
115
|
+
type_validator = EnumAttributeValidator.new('String', ["googleCloudStorage"])
|
116
|
+
return false unless type_validator.valid?(@type)
|
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', ["googleCloudStorage"])
|
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
|
+
config == o.config &&
|
136
|
+
type == o.type
|
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
|
+
[config, type].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
|