lib/algolia/models/insights/error_base.rb in algolia-3.0.0.alpha.5 vs lib/algolia/models/insights/error_base.rb in algolia-3.0.0.alpha.6
- old
+ new
@@ -80,23 +80,28 @@
attributes = attributes.transform_keys(&:to_sym)
transformed_hash = {}
types_mapping.each_pair do |key, type|
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
- transformed_hash[key.to_s] = nil
+ transformed_hash[key.to_sym] = nil
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[attribute_map[key]].is_a?(Array)
- transformed_hash[key.to_s] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
end
elsif !attributes[attribute_map[key]].nil?
- transformed_hash[key.to_s] = _deserialize(type, attributes[attribute_map[key]])
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
end
end
- transformed_hash.merge!(attributes.reject { |k, _| attribute_map.key?(k.to_sym) })
+ # merge additional_properties into transformed_hash
+ unless @additional_properties.nil?
+ @additional_properties.each_pair do |k, v|
+ transformed_hash[k.to_sym] = v
+ end
+ end
new(transformed_hash)
end
# Deserializes the data based on type
# @param string type Data type
@@ -149,9 +154,13 @@
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
+ end
+
+ def to_json(*_args)
+ to_hash.to_json
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash