algolia 3.22.1 → 3.23.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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release.yml +1 -1
  3. data/CHANGELOG.md +5 -0
  4. data/Gemfile.lock +1 -1
  5. data/lib/algolia/api/abtesting_v3_client.rb +638 -0
  6. data/lib/algolia/models/abtesting-v3/ab_test.rb +300 -0
  7. data/lib/algolia/models/abtesting-v3/ab_test_configuration.rb +230 -0
  8. data/lib/algolia/models/abtesting-v3/ab_test_response.rb +235 -0
  9. data/lib/algolia/models/abtesting-v3/ab_tests_variant.rb +233 -0
  10. data/lib/algolia/models/abtesting-v3/ab_tests_variant_search_params.rb +259 -0
  11. data/lib/algolia/models/abtesting-v3/add_ab_tests_request.rb +260 -0
  12. data/lib/algolia/models/abtesting-v3/add_ab_tests_variant.rb +109 -0
  13. data/lib/algolia/models/abtesting-v3/create_metric.rb +222 -0
  14. data/lib/algolia/models/abtesting-v3/direction.rb +34 -0
  15. data/lib/algolia/models/abtesting-v3/effect_metric.rb +37 -0
  16. data/lib/algolia/models/abtesting-v3/empty_search_filter.rb +220 -0
  17. data/lib/algolia/models/abtesting-v3/error_base.rb +209 -0
  18. data/lib/algolia/models/abtesting-v3/error_correction_type.rb +34 -0
  19. data/lib/algolia/models/abtesting-v3/estimate_ab_test_request.rb +224 -0
  20. data/lib/algolia/models/abtesting-v3/estimate_ab_test_response.rb +221 -0
  21. data/lib/algolia/models/abtesting-v3/estimate_configuration.rb +223 -0
  22. data/lib/algolia/models/abtesting-v3/filter_effects.rb +218 -0
  23. data/lib/algolia/models/abtesting-v3/list_ab_tests_response.rb +239 -0
  24. data/lib/algolia/models/abtesting-v3/metric_date.rb +221 -0
  25. data/lib/algolia/models/abtesting-v3/metric_metadata.rb +220 -0
  26. data/lib/algolia/models/abtesting-v3/metric_name.rb +63 -0
  27. data/lib/algolia/models/abtesting-v3/metric_result.rb +315 -0
  28. data/lib/algolia/models/abtesting-v3/metrics_filter.rb +244 -0
  29. data/lib/algolia/models/abtesting-v3/minimum_detectable_effect.rb +223 -0
  30. data/lib/algolia/models/abtesting-v3/outliers_filter.rb +220 -0
  31. data/lib/algolia/models/abtesting-v3/schedule_ab_test_response.rb +211 -0
  32. data/lib/algolia/models/abtesting-v3/schedule_ab_tests_request.rb +272 -0
  33. data/lib/algolia/models/abtesting-v3/status.rb +36 -0
  34. data/lib/algolia/models/abtesting-v3/timeseries.rb +225 -0
  35. data/lib/algolia/models/abtesting-v3/timeseries_variant.rb +210 -0
  36. data/lib/algolia/models/abtesting-v3/variant.rb +275 -0
  37. data/lib/algolia/models/abtesting-v3/variant_metadata.rb +209 -0
  38. data/lib/algolia/version.rb +1 -1
  39. metadata +34 -1
@@ -0,0 +1,259 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
4
+
5
+ require "date"
6
+ require "time"
7
+
8
+ module Algolia
9
+ module AbtestingV3
10
+ class AbTestsVariantSearchParams
11
+ # Index name of the A/B test variant (case-sensitive).
12
+ attr_accessor :index
13
+
14
+ # Percentage of search requests each variant receives.
15
+ attr_accessor :traffic_percentage
16
+
17
+ # Description for this variant.
18
+ attr_accessor :description
19
+
20
+ attr_accessor :custom_search_parameters
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :index => :index,
26
+ :traffic_percentage => :trafficPercentage,
27
+ :description => :description,
28
+ :custom_search_parameters => :customSearchParameters
29
+ }
30
+ end
31
+
32
+ # Returns the keys that uniquely identify this oneOf variant when present
33
+ def self.discriminator_attributes
34
+ [
35
+ :customSearchParameters
36
+ ]
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.types_mapping
41
+ {
42
+ :index => :"String",
43
+ :traffic_percentage => :"Integer",
44
+ :description => :"String",
45
+ :custom_search_parameters => :"Object"
46
+ }
47
+ end
48
+
49
+ # List of attributes with nullable: true
50
+ def self.openapi_nullable
51
+ Set.new(
52
+ []
53
+ )
54
+ end
55
+
56
+ # List of class defined in allOf (OpenAPI v3)
57
+ def self.openapi_all_of
58
+ [
59
+ :"AbTestsVariant",
60
+ :"CustomSearchParams"
61
+ ]
62
+ end
63
+
64
+ # Initializes the object
65
+ # @param [Hash] attributes Model attributes in the form of hash
66
+ def initialize(attributes = {})
67
+ if (!attributes.is_a?(Hash))
68
+ raise(
69
+ ArgumentError,
70
+ "The input argument (attributes) must be a hash in `Algolia::AbTestsVariantSearchParams` initialize method"
71
+ )
72
+ end
73
+
74
+ # check to see if the attribute exists and convert string to symbol for hash key
75
+ attributes = attributes.each_with_object({}) { |(k, v), h|
76
+ if (!self.class.attribute_map.key?(k.to_sym))
77
+ raise(
78
+ ArgumentError,
79
+ "`#{k}` is not a valid attribute in `Algolia::AbTestsVariantSearchParams`. Please check the name to make sure it's valid. List of attributes: " +
80
+ self.class.attribute_map.keys.inspect
81
+ )
82
+ end
83
+
84
+ h[k.to_sym] = v
85
+ }
86
+
87
+ if attributes.key?(:index)
88
+ self.index = attributes[:index]
89
+ else
90
+ self.index = nil
91
+ end
92
+
93
+ if attributes.key?(:traffic_percentage)
94
+ self.traffic_percentage = attributes[:traffic_percentage]
95
+ else
96
+ self.traffic_percentage = nil
97
+ end
98
+
99
+ if attributes.key?(:description)
100
+ self.description = attributes[:description]
101
+ end
102
+
103
+ if attributes.key?(:custom_search_parameters)
104
+ self.custom_search_parameters = attributes[:custom_search_parameters]
105
+ else
106
+ self.custom_search_parameters = nil
107
+ end
108
+ end
109
+
110
+ # Checks equality by comparing each attribute.
111
+ # @param [Object] Object to be compared
112
+ def ==(other)
113
+ return true if self.equal?(other)
114
+ self.class == other.class &&
115
+ index == other.index &&
116
+ traffic_percentage == other.traffic_percentage &&
117
+ description == other.description &&
118
+ custom_search_parameters == other.custom_search_parameters
119
+ end
120
+
121
+ # @see the `==` method
122
+ # @param [Object] Object to be compared
123
+ def eql?(other)
124
+ self == other
125
+ end
126
+
127
+ # Calculates hash code according to all attributes.
128
+ # @return [Integer] Hash code
129
+ def hash
130
+ [index, traffic_percentage, description, custom_search_parameters].hash
131
+ end
132
+
133
+ # Builds the object from hash
134
+ # @param [Hash] attributes Model attributes in the form of hash
135
+ # @return [Object] Returns the model itself
136
+ def self.build_from_hash(attributes)
137
+ return nil unless attributes.is_a?(Hash)
138
+ attributes = attributes.transform_keys(&:to_sym)
139
+ transformed_hash = {}
140
+ types_mapping.each_pair do |key, type|
141
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
142
+ transformed_hash[key.to_sym] = nil
143
+ elsif type =~ /\AArray<(.*)>/i
144
+ # check to ensure the input is an array given that the attribute
145
+ # is documented as an array but the input is not
146
+ if attributes[attribute_map[key]].is_a?(Array)
147
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
148
+ _deserialize(::Regexp.last_match(1), v)
149
+ }
150
+ end
151
+ elsif !attributes[attribute_map[key]].nil?
152
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
153
+ end
154
+ end
155
+
156
+ new(transformed_hash)
157
+ end
158
+
159
+ # Deserializes the data based on type
160
+ # @param string type Data type
161
+ # @param string value Value to be deserialized
162
+ # @return [Object] Deserialized data
163
+ def self._deserialize(type, value)
164
+ case type.to_sym
165
+ when :Time
166
+ Time.parse(value)
167
+ when :Date
168
+ Date.parse(value)
169
+ when :String
170
+ value.to_s
171
+ when :Integer
172
+ value.to_i
173
+ when :Float
174
+ value.to_f
175
+ when :Boolean
176
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
177
+ true
178
+ else
179
+ false
180
+ end
181
+
182
+ when :Object
183
+ # generic object (usually a Hash), return directly
184
+ value
185
+ when /\AArray<(?<inner_type>.+)>\z/
186
+ inner_type = Regexp.last_match[:inner_type]
187
+ value.map { |v| _deserialize(inner_type, v) }
188
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
189
+ k_type = Regexp.last_match[:k_type]
190
+ v_type = Regexp.last_match[:v_type]
191
+ {}.tap do |hash|
192
+ value.each do |k, v|
193
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
194
+ end
195
+ end
196
+ # model
197
+ else
198
+ # models (e.g. Pet) or oneOf
199
+ klass = Algolia::AbtestingV3.const_get(type)
200
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
201
+ .build_from_hash(value)
202
+ end
203
+ end
204
+
205
+ # Returns the string representation of the object
206
+ # @return [String] String presentation of the object
207
+ def to_s
208
+ to_hash.to_s
209
+ end
210
+
211
+ # to_body is an alias to to_hash (backward compatibility)
212
+ # @return [Hash] Returns the object in the form of hash
213
+ def to_body
214
+ to_hash
215
+ end
216
+
217
+ def to_json(*_args)
218
+ to_hash.to_json
219
+ end
220
+
221
+ # Returns the object in the form of hash
222
+ # @return [Hash] Returns the object in the form of hash
223
+ def to_hash
224
+ hash = {}
225
+ self.class.attribute_map.each_pair do |attr, param|
226
+ value = send(attr)
227
+ if value.nil?
228
+ is_nullable = self.class.openapi_nullable.include?(attr)
229
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
230
+ end
231
+
232
+ hash[param] = _to_hash(value)
233
+ end
234
+
235
+ hash
236
+ end
237
+
238
+ # Outputs non-array value in the form of hash
239
+ # For object, use to_hash. Otherwise, just return the value
240
+ # @param [Object] value Any valid value
241
+ # @return [Hash] Returns the value in the form of hash
242
+ def _to_hash(value)
243
+ if value.is_a?(Array)
244
+ value.compact.map { |v| _to_hash(v) }
245
+ elsif value.is_a?(Hash)
246
+ {}.tap do |hash|
247
+ value.each { |k, v| hash[k] = _to_hash(v) }
248
+ end
249
+ elsif value.respond_to?(:to_hash)
250
+ value.to_hash
251
+ else
252
+ value
253
+ end
254
+ end
255
+
256
+ end
257
+
258
+ end
259
+ end
@@ -0,0 +1,260 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
4
+
5
+ require "date"
6
+ require "time"
7
+
8
+ module Algolia
9
+ module AbtestingV3
10
+ class AddABTestsRequest
11
+ # A/B test name.
12
+ attr_accessor :name
13
+
14
+ # A/B test variants.
15
+ attr_accessor :variants
16
+
17
+ # A/B test metrics involved in the test. Only these metrics will be considered when calculating results.
18
+ attr_accessor :metrics
19
+
20
+ attr_accessor :configuration
21
+
22
+ # End date and time of the A/B test, in RFC 3339 format.
23
+ attr_accessor :end_at
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :name => :name,
29
+ :variants => :variants,
30
+ :metrics => :metrics,
31
+ :configuration => :configuration,
32
+ :end_at => :endAt
33
+ }
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.types_mapping
38
+ {
39
+ :name => :"String",
40
+ :variants => :"Array<AddABTestsVariant>",
41
+ :metrics => :"Array<CreateMetric>",
42
+ :configuration => :"ABTestConfiguration",
43
+ :end_at => :"String"
44
+ }
45
+ end
46
+
47
+ # List of attributes with nullable: true
48
+ def self.openapi_nullable
49
+ Set.new(
50
+ []
51
+ )
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ if (!attributes.is_a?(Hash))
58
+ raise(
59
+ ArgumentError,
60
+ "The input argument (attributes) must be a hash in `Algolia::AddABTestsRequest` initialize method"
61
+ )
62
+ end
63
+
64
+ # check to see if the attribute exists and convert string to symbol for hash key
65
+ attributes = attributes.each_with_object({}) { |(k, v), h|
66
+ if (!self.class.attribute_map.key?(k.to_sym))
67
+ raise(
68
+ ArgumentError,
69
+ "`#{k}` is not a valid attribute in `Algolia::AddABTestsRequest`. Please check the name to make sure it's valid. List of attributes: " +
70
+ self.class.attribute_map.keys.inspect
71
+ )
72
+ end
73
+
74
+ h[k.to_sym] = v
75
+ }
76
+
77
+ if attributes.key?(:name)
78
+ self.name = attributes[:name]
79
+ else
80
+ self.name = nil
81
+ end
82
+
83
+ if attributes.key?(:variants)
84
+ if (value = attributes[:variants]).is_a?(Array)
85
+ self.variants = value
86
+ end
87
+ else
88
+ self.variants = nil
89
+ end
90
+
91
+ if attributes.key?(:metrics)
92
+ if (value = attributes[:metrics]).is_a?(Array)
93
+ self.metrics = value
94
+ end
95
+ else
96
+ self.metrics = nil
97
+ end
98
+
99
+ if attributes.key?(:configuration)
100
+ self.configuration = attributes[:configuration]
101
+ end
102
+
103
+ if attributes.key?(:end_at)
104
+ self.end_at = attributes[:end_at]
105
+ else
106
+ self.end_at = nil
107
+ end
108
+ end
109
+
110
+ # Checks equality by comparing each attribute.
111
+ # @param [Object] Object to be compared
112
+ def ==(other)
113
+ return true if self.equal?(other)
114
+ self.class == other.class &&
115
+ name == other.name &&
116
+ variants == other.variants &&
117
+ metrics == other.metrics &&
118
+ configuration == other.configuration &&
119
+ end_at == other.end_at
120
+ end
121
+
122
+ # @see the `==` method
123
+ # @param [Object] Object to be compared
124
+ def eql?(other)
125
+ self == other
126
+ end
127
+
128
+ # Calculates hash code according to all attributes.
129
+ # @return [Integer] Hash code
130
+ def hash
131
+ [name, variants, metrics, configuration, end_at].hash
132
+ end
133
+
134
+ # Builds the object from hash
135
+ # @param [Hash] attributes Model attributes in the form of hash
136
+ # @return [Object] Returns the model itself
137
+ def self.build_from_hash(attributes)
138
+ return nil unless attributes.is_a?(Hash)
139
+ attributes = attributes.transform_keys(&:to_sym)
140
+ transformed_hash = {}
141
+ types_mapping.each_pair do |key, type|
142
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
143
+ transformed_hash[key.to_sym] = nil
144
+ elsif type =~ /\AArray<(.*)>/i
145
+ # check to ensure the input is an array given that the attribute
146
+ # is documented as an array but the input is not
147
+ if attributes[attribute_map[key]].is_a?(Array)
148
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
149
+ _deserialize(::Regexp.last_match(1), v)
150
+ }
151
+ end
152
+ elsif !attributes[attribute_map[key]].nil?
153
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
154
+ end
155
+ end
156
+
157
+ new(transformed_hash)
158
+ end
159
+
160
+ # Deserializes the data based on type
161
+ # @param string type Data type
162
+ # @param string value Value to be deserialized
163
+ # @return [Object] Deserialized data
164
+ def self._deserialize(type, value)
165
+ case type.to_sym
166
+ when :Time
167
+ Time.parse(value)
168
+ when :Date
169
+ Date.parse(value)
170
+ when :String
171
+ value.to_s
172
+ when :Integer
173
+ value.to_i
174
+ when :Float
175
+ value.to_f
176
+ when :Boolean
177
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
178
+ true
179
+ else
180
+ false
181
+ end
182
+
183
+ when :Object
184
+ # generic object (usually a Hash), return directly
185
+ value
186
+ when /\AArray<(?<inner_type>.+)>\z/
187
+ inner_type = Regexp.last_match[:inner_type]
188
+ value.map { |v| _deserialize(inner_type, v) }
189
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
190
+ k_type = Regexp.last_match[:k_type]
191
+ v_type = Regexp.last_match[:v_type]
192
+ {}.tap do |hash|
193
+ value.each do |k, v|
194
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
195
+ end
196
+ end
197
+ # model
198
+ else
199
+ # models (e.g. Pet) or oneOf
200
+ klass = Algolia::AbtestingV3.const_get(type)
201
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
202
+ .build_from_hash(value)
203
+ end
204
+ end
205
+
206
+ # Returns the string representation of the object
207
+ # @return [String] String presentation of the object
208
+ def to_s
209
+ to_hash.to_s
210
+ end
211
+
212
+ # to_body is an alias to to_hash (backward compatibility)
213
+ # @return [Hash] Returns the object in the form of hash
214
+ def to_body
215
+ to_hash
216
+ end
217
+
218
+ def to_json(*_args)
219
+ to_hash.to_json
220
+ end
221
+
222
+ # Returns the object in the form of hash
223
+ # @return [Hash] Returns the object in the form of hash
224
+ def to_hash
225
+ hash = {}
226
+ self.class.attribute_map.each_pair do |attr, param|
227
+ value = send(attr)
228
+ if value.nil?
229
+ is_nullable = self.class.openapi_nullable.include?(attr)
230
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
231
+ end
232
+
233
+ hash[param] = _to_hash(value)
234
+ end
235
+
236
+ hash
237
+ end
238
+
239
+ # Outputs non-array value in the form of hash
240
+ # For object, use to_hash. Otherwise, just return the value
241
+ # @param [Object] value Any valid value
242
+ # @return [Hash] Returns the value in the form of hash
243
+ def _to_hash(value)
244
+ if value.is_a?(Array)
245
+ value.compact.map { |v| _to_hash(v) }
246
+ elsif value.is_a?(Hash)
247
+ {}.tap do |hash|
248
+ value.each { |k, v| hash[k] = _to_hash(v) }
249
+ end
250
+ elsif value.respond_to?(:to_hash)
251
+ value.to_hash
252
+ else
253
+ value
254
+ end
255
+ end
256
+
257
+ end
258
+
259
+ end
260
+ end
@@ -0,0 +1,109 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
4
+
5
+ require "date"
6
+ require "time"
7
+
8
+ module Algolia
9
+ module AbtestingV3
10
+ module AddABTestsVariant
11
+ class << self
12
+ # List of class defined in oneOf (OpenAPI v3)
13
+ def openapi_one_of
14
+ [
15
+ :"AbTestsVariant",
16
+ :"AbTestsVariantSearchParams"
17
+ ]
18
+ end
19
+
20
+ # Builds the object
21
+ # @param [Mixed] Data to be matched against the list of oneOf items
22
+ # @return [Object] Returns the model or the data itself
23
+ def build(data)
24
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
25
+ # Note:
26
+ # - We do not attempt to check whether exactly one item matches.
27
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
28
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
29
+ # - TODO: scalar values are de facto behaving as if they were nullable.
30
+ # - TODO: logging when debugging is set.
31
+ openapi_one_of.each do |klass|
32
+ begin
33
+ # "nullable: true"
34
+ next if klass == :AnyType
35
+ typed_data = find_and_cast_into_type(klass, data)
36
+ return typed_data if typed_data
37
+ # rescue all errors so we keep iterating even if the current item lookup raises
38
+ rescue
39
+ end
40
+ end
41
+
42
+ openapi_one_of.include?(:AnyType) ? data : nil
43
+ end
44
+
45
+ private
46
+
47
+ SchemaMismatchError = Class.new(StandardError)
48
+
49
+ def find_and_cast_into_type(klass, data)
50
+ return if data.nil?
51
+
52
+ case klass.to_s
53
+ when "Boolean"
54
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
55
+ when "Float"
56
+ return data if data.instance_of?(Float)
57
+ when "Integer"
58
+ return data if data.instance_of?(Integer)
59
+ when "Time"
60
+ return Time.parse(data)
61
+ when "Date"
62
+ return Date.parse(data)
63
+ when "String"
64
+ return data if data.instance_of?(String)
65
+ # "type: object"
66
+ when "Object"
67
+ return data if data.instance_of?(Hash)
68
+ # "type: array"
69
+ when /\AArray<(?<sub_type>.+)>\z/
70
+ if data.instance_of?(Array)
71
+ sub_type = Regexp.last_match[:sub_type]
72
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
73
+ end
74
+ # "type: object" with "additionalProperties: { ... }"
75
+ when /\AHash<String, (?<sub_type>.+)>\z/
76
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
77
+ sub_type = Regexp.last_match[:sub_type]
78
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
79
+ end
80
+ # model
81
+ else
82
+ const = Algolia::AbtestingV3.const_get(klass)
83
+ if const
84
+ if const.respond_to?(:openapi_one_of)
85
+ # nested oneOf model
86
+ model = const.build(data)
87
+ elsif const.respond_to?(:discriminator_attributes)
88
+ if const.discriminator_attributes.all? { |attr| data.key?(attr) }
89
+ model = const.build_from_hash(data)
90
+ end
91
+ else
92
+ # maybe it's an enum, or doens't have discriminators
93
+ model = const.build_from_hash(data)
94
+ end
95
+
96
+ return model if model
97
+ end
98
+ end
99
+
100
+ # if no match by now, raise
101
+ raise
102
+ rescue
103
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
104
+ end
105
+ end
106
+ end
107
+
108
+ end
109
+ end