algolia 3.3.2 → 3.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/lib/algolia/api/ingestion_client.rb +0 -95
- data/lib/algolia/models/recommend/bought_together_query.rb +1 -1
- data/lib/algolia/models/recommend/facet_ordering.rb +1 -1
- data/lib/algolia/models/recommend/fallback_params.rb +228 -143
- data/lib/algolia/models/recommend/{facets.rb → index_settings_facets.rb} +6 -3
- data/lib/algolia/models/recommend/looking_similar_query.rb +1 -1
- data/lib/algolia/models/recommend/{search_params.rb → recommend_search_params.rb} +234 -146
- data/lib/algolia/models/recommend/recommended_for_you_query.rb +1 -1
- data/lib/algolia/models/recommend/related_query.rb +1 -1
- data/lib/algolia/models/recommend/trending_facets_query.rb +1 -1
- data/lib/algolia/models/recommend/trending_items_query.rb +2 -2
- data/lib/algolia/version.rb +1 -1
- metadata +4 -11
- data/lib/algolia/models/ingestion/generate_transformation_code_payload.rb +0 -233
- data/lib/algolia/models/ingestion/generate_transformation_code_response.rb +0 -211
- data/lib/algolia/models/ingestion/model.rb +0 -254
- data/lib/algolia/models/ingestion/transformation_models.rb +0 -216
- data/lib/algolia/models/recommend/mode.rb +0 -32
- data/lib/algolia/models/recommend/search_params_object.rb +0 -1197
- data/lib/algolia/models/recommend/semantic_search.rb +0 -217
@@ -44,7 +44,7 @@ module Algolia
|
|
44
44
|
:index_name => :"String",
|
45
45
|
:threshold => :"Float",
|
46
46
|
:max_recommendations => :"Integer",
|
47
|
-
:query_parameters => :"
|
47
|
+
:query_parameters => :"RecommendSearchParams",
|
48
48
|
:model => :"RecommendedForYouModel",
|
49
49
|
:fallback_parameters => :"FallbackParams"
|
50
50
|
}
|
@@ -48,7 +48,7 @@ module Algolia
|
|
48
48
|
:index_name => :"String",
|
49
49
|
:threshold => :"Float",
|
50
50
|
:max_recommendations => :"Integer",
|
51
|
-
:query_parameters => :"
|
51
|
+
:query_parameters => :"RecommendSearchParams",
|
52
52
|
:model => :"RelatedModel",
|
53
53
|
:object_id => :"String",
|
54
54
|
:fallback_parameters => :"FallbackParams"
|
@@ -48,7 +48,7 @@ module Algolia
|
|
48
48
|
:index_name => :"String",
|
49
49
|
:threshold => :"Float",
|
50
50
|
:max_recommendations => :"Integer",
|
51
|
-
:query_parameters => :"
|
51
|
+
:query_parameters => :"RecommendSearchParams",
|
52
52
|
:facet_name => :"Object",
|
53
53
|
:model => :"TrendingFacetsModel",
|
54
54
|
:fallback_parameters => :"FallbackParams"
|
@@ -52,11 +52,11 @@ module Algolia
|
|
52
52
|
:index_name => :"String",
|
53
53
|
:threshold => :"Float",
|
54
54
|
:max_recommendations => :"Integer",
|
55
|
-
:query_parameters => :"
|
55
|
+
:query_parameters => :"RecommendSearchParams",
|
56
56
|
:facet_name => :"String",
|
57
57
|
:facet_value => :"String",
|
58
58
|
:model => :"TrendingItemsModel",
|
59
|
-
:fallback_parameters => :"
|
59
|
+
:fallback_parameters => :"FallbackParams"
|
60
60
|
}
|
61
61
|
end
|
62
62
|
|
data/lib/algolia/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: algolia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- https://alg.li/support
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
11
|
+
date: 2024-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -270,8 +270,6 @@ files:
|
|
270
270
|
- lib/algolia/models/ingestion/event_sort_keys.rb
|
271
271
|
- lib/algolia/models/ingestion/event_status.rb
|
272
272
|
- lib/algolia/models/ingestion/event_type.rb
|
273
|
-
- lib/algolia/models/ingestion/generate_transformation_code_payload.rb
|
274
|
-
- lib/algolia/models/ingestion/generate_transformation_code_response.rb
|
275
273
|
- lib/algolia/models/ingestion/list_authentications_response.rb
|
276
274
|
- lib/algolia/models/ingestion/list_destinations_response.rb
|
277
275
|
- lib/algolia/models/ingestion/list_events_response.rb
|
@@ -285,7 +283,6 @@ files:
|
|
285
283
|
- lib/algolia/models/ingestion/mapping_kit_action.rb
|
286
284
|
- lib/algolia/models/ingestion/mapping_type_csv.rb
|
287
285
|
- lib/algolia/models/ingestion/method_type.rb
|
288
|
-
- lib/algolia/models/ingestion/model.rb
|
289
286
|
- lib/algolia/models/ingestion/on_demand_trigger.rb
|
290
287
|
- lib/algolia/models/ingestion/on_demand_trigger_input.rb
|
291
288
|
- lib/algolia/models/ingestion/on_demand_trigger_type.rb
|
@@ -358,7 +355,6 @@ files:
|
|
358
355
|
- lib/algolia/models/ingestion/transformation_create.rb
|
359
356
|
- lib/algolia/models/ingestion/transformation_create_response.rb
|
360
357
|
- lib/algolia/models/ingestion/transformation_error.rb
|
361
|
-
- lib/algolia/models/ingestion/transformation_models.rb
|
362
358
|
- lib/algolia/models/ingestion/transformation_search.rb
|
363
359
|
- lib/algolia/models/ingestion/transformation_try.rb
|
364
360
|
- lib/algolia/models/ingestion/transformation_try_response.rb
|
@@ -458,7 +454,6 @@ files:
|
|
458
454
|
- lib/algolia/models/recommend/facet_filters.rb
|
459
455
|
- lib/algolia/models/recommend/facet_ordering.rb
|
460
456
|
- lib/algolia/models/recommend/facet_stats.rb
|
461
|
-
- lib/algolia/models/recommend/facets.rb
|
462
457
|
- lib/algolia/models/recommend/fallback_params.rb
|
463
458
|
- lib/algolia/models/recommend/fbt_model.rb
|
464
459
|
- lib/algolia/models/recommend/get_recommend_task_response.rb
|
@@ -468,11 +463,11 @@ files:
|
|
468
463
|
- lib/algolia/models/recommend/highlight_result.rb
|
469
464
|
- lib/algolia/models/recommend/highlight_result_option.rb
|
470
465
|
- lib/algolia/models/recommend/ignore_plurals.rb
|
466
|
+
- lib/algolia/models/recommend/index_settings_facets.rb
|
471
467
|
- lib/algolia/models/recommend/looking_similar_model.rb
|
472
468
|
- lib/algolia/models/recommend/looking_similar_query.rb
|
473
469
|
- lib/algolia/models/recommend/match_level.rb
|
474
470
|
- lib/algolia/models/recommend/matched_geo_location.rb
|
475
|
-
- lib/algolia/models/recommend/mode.rb
|
476
471
|
- lib/algolia/models/recommend/numeric_filters.rb
|
477
472
|
- lib/algolia/models/recommend/optional_filters.rb
|
478
473
|
- lib/algolia/models/recommend/params_consequence.rb
|
@@ -485,6 +480,7 @@ files:
|
|
485
480
|
- lib/algolia/models/recommend/recommend_hit.rb
|
486
481
|
- lib/algolia/models/recommend/recommend_models.rb
|
487
482
|
- lib/algolia/models/recommend/recommend_rule.rb
|
483
|
+
- lib/algolia/models/recommend/recommend_search_params.rb
|
488
484
|
- lib/algolia/models/recommend/recommendations_hit.rb
|
489
485
|
- lib/algolia/models/recommend/recommendations_request.rb
|
490
486
|
- lib/algolia/models/recommend/recommendations_results.rb
|
@@ -500,11 +496,8 @@ files:
|
|
500
496
|
- lib/algolia/models/recommend/remove_words_if_no_results.rb
|
501
497
|
- lib/algolia/models/recommend/rendering_content.rb
|
502
498
|
- lib/algolia/models/recommend/rule_metadata.rb
|
503
|
-
- lib/algolia/models/recommend/search_params.rb
|
504
|
-
- lib/algolia/models/recommend/search_params_object.rb
|
505
499
|
- lib/algolia/models/recommend/search_recommend_rules_params.rb
|
506
500
|
- lib/algolia/models/recommend/search_recommend_rules_response.rb
|
507
|
-
- lib/algolia/models/recommend/semantic_search.rb
|
508
501
|
- lib/algolia/models/recommend/snippet_result.rb
|
509
502
|
- lib/algolia/models/recommend/snippet_result_option.rb
|
510
503
|
- lib/algolia/models/recommend/sort_remaining_by.rb
|
@@ -1,233 +0,0 @@
|
|
1
|
-
# 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.
|
2
|
-
|
3
|
-
require "date"
|
4
|
-
require "time"
|
5
|
-
|
6
|
-
module Algolia
|
7
|
-
module Ingestion
|
8
|
-
class GenerateTransformationCodePayload
|
9
|
-
attr_accessor :id
|
10
|
-
|
11
|
-
attr_accessor :system_prompt
|
12
|
-
|
13
|
-
attr_accessor :user_prompt
|
14
|
-
|
15
|
-
# Attribute mapping from ruby-style variable name to JSON key.
|
16
|
-
def self.attribute_map
|
17
|
-
{
|
18
|
-
:id => :id,
|
19
|
-
:system_prompt => :systemPrompt,
|
20
|
-
:user_prompt => :userPrompt
|
21
|
-
}
|
22
|
-
end
|
23
|
-
|
24
|
-
# Returns all the JSON keys this model knows about
|
25
|
-
def self.acceptable_attributes
|
26
|
-
attribute_map.values
|
27
|
-
end
|
28
|
-
|
29
|
-
# Attribute type mapping.
|
30
|
-
def self.types_mapping
|
31
|
-
{
|
32
|
-
:id => :"String",
|
33
|
-
:system_prompt => :"String",
|
34
|
-
:user_prompt => :"String"
|
35
|
-
}
|
36
|
-
end
|
37
|
-
|
38
|
-
# List of attributes with nullable: true
|
39
|
-
def self.openapi_nullable
|
40
|
-
Set.new(
|
41
|
-
[]
|
42
|
-
)
|
43
|
-
end
|
44
|
-
|
45
|
-
# Initializes the object
|
46
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
47
|
-
def initialize(attributes = {})
|
48
|
-
if (!attributes.is_a?(Hash))
|
49
|
-
raise(
|
50
|
-
ArgumentError,
|
51
|
-
"The input argument (attributes) must be a hash in `Algolia::GenerateTransformationCodePayload` initialize method"
|
52
|
-
)
|
53
|
-
end
|
54
|
-
|
55
|
-
# check to see if the attribute exists and convert string to symbol for hash key
|
56
|
-
attributes = attributes.each_with_object({}) { |(k, v), h|
|
57
|
-
if (!self.class.attribute_map.key?(k.to_sym))
|
58
|
-
raise(
|
59
|
-
ArgumentError,
|
60
|
-
"`#{k}` is not a valid attribute in `Algolia::GenerateTransformationCodePayload`. Please check the name to make sure it's valid. List of attributes: " +
|
61
|
-
self.class.attribute_map.keys.inspect
|
62
|
-
)
|
63
|
-
end
|
64
|
-
|
65
|
-
h[k.to_sym] = v
|
66
|
-
}
|
67
|
-
|
68
|
-
if attributes.key?(:id)
|
69
|
-
self.id = attributes[:id]
|
70
|
-
else
|
71
|
-
self.id = nil
|
72
|
-
end
|
73
|
-
|
74
|
-
if attributes.key?(:system_prompt)
|
75
|
-
self.system_prompt = attributes[:system_prompt]
|
76
|
-
end
|
77
|
-
|
78
|
-
if attributes.key?(:user_prompt)
|
79
|
-
self.user_prompt = attributes[:user_prompt]
|
80
|
-
else
|
81
|
-
self.user_prompt = nil
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
# Checks equality by comparing each attribute.
|
86
|
-
# @param [Object] Object to be compared
|
87
|
-
def ==(other)
|
88
|
-
return true if self.equal?(other)
|
89
|
-
self.class == other.class &&
|
90
|
-
id == other.id &&
|
91
|
-
system_prompt == other.system_prompt &&
|
92
|
-
user_prompt == other.user_prompt
|
93
|
-
end
|
94
|
-
|
95
|
-
# @see the `==` method
|
96
|
-
# @param [Object] Object to be compared
|
97
|
-
def eql?(other)
|
98
|
-
self == other
|
99
|
-
end
|
100
|
-
|
101
|
-
# Calculates hash code according to all attributes.
|
102
|
-
# @return [Integer] Hash code
|
103
|
-
def hash
|
104
|
-
[id, system_prompt, user_prompt].hash
|
105
|
-
end
|
106
|
-
|
107
|
-
# Builds the object from hash
|
108
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
109
|
-
# @return [Object] Returns the model itself
|
110
|
-
def self.build_from_hash(attributes)
|
111
|
-
return nil unless attributes.is_a?(Hash)
|
112
|
-
attributes = attributes.transform_keys(&:to_sym)
|
113
|
-
transformed_hash = {}
|
114
|
-
types_mapping.each_pair do |key, type|
|
115
|
-
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
116
|
-
transformed_hash[key.to_sym] = nil
|
117
|
-
elsif type =~ /\AArray<(.*)>/i
|
118
|
-
# check to ensure the input is an array given that the attribute
|
119
|
-
# is documented as an array but the input is not
|
120
|
-
if attributes[attribute_map[key]].is_a?(Array)
|
121
|
-
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
|
122
|
-
_deserialize(::Regexp.last_match(1), v)
|
123
|
-
}
|
124
|
-
end
|
125
|
-
elsif !attributes[attribute_map[key]].nil?
|
126
|
-
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
new(transformed_hash)
|
131
|
-
end
|
132
|
-
|
133
|
-
# Deserializes the data based on type
|
134
|
-
# @param string type Data type
|
135
|
-
# @param string value Value to be deserialized
|
136
|
-
# @return [Object] Deserialized data
|
137
|
-
def self._deserialize(type, value)
|
138
|
-
case type.to_sym
|
139
|
-
when :Time
|
140
|
-
Time.parse(value)
|
141
|
-
when :Date
|
142
|
-
Date.parse(value)
|
143
|
-
when :String
|
144
|
-
value.to_s
|
145
|
-
when :Integer
|
146
|
-
value.to_i
|
147
|
-
when :Float
|
148
|
-
value.to_f
|
149
|
-
when :Boolean
|
150
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
151
|
-
true
|
152
|
-
else
|
153
|
-
false
|
154
|
-
end
|
155
|
-
|
156
|
-
when :Object
|
157
|
-
# generic object (usually a Hash), return directly
|
158
|
-
value
|
159
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
160
|
-
inner_type = Regexp.last_match[:inner_type]
|
161
|
-
value.map { |v| _deserialize(inner_type, v) }
|
162
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
163
|
-
k_type = Regexp.last_match[:k_type]
|
164
|
-
v_type = Regexp.last_match[:v_type]
|
165
|
-
{}.tap do |hash|
|
166
|
-
value.each do |k, v|
|
167
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
168
|
-
end
|
169
|
-
end
|
170
|
-
# model
|
171
|
-
else
|
172
|
-
# models (e.g. Pet) or oneOf
|
173
|
-
klass = Algolia::Ingestion.const_get(type)
|
174
|
-
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
|
175
|
-
.build_from_hash(value)
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
# Returns the string representation of the object
|
180
|
-
# @return [String] String presentation of the object
|
181
|
-
def to_s
|
182
|
-
to_hash.to_s
|
183
|
-
end
|
184
|
-
|
185
|
-
# to_body is an alias to to_hash (backward compatibility)
|
186
|
-
# @return [Hash] Returns the object in the form of hash
|
187
|
-
def to_body
|
188
|
-
to_hash
|
189
|
-
end
|
190
|
-
|
191
|
-
def to_json(*_args)
|
192
|
-
to_hash.to_json
|
193
|
-
end
|
194
|
-
|
195
|
-
# Returns the object in the form of hash
|
196
|
-
# @return [Hash] Returns the object in the form of hash
|
197
|
-
def to_hash
|
198
|
-
hash = {}
|
199
|
-
self.class.attribute_map.each_pair do |attr, param|
|
200
|
-
value = send(attr)
|
201
|
-
if value.nil?
|
202
|
-
is_nullable = self.class.openapi_nullable.include?(attr)
|
203
|
-
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
204
|
-
end
|
205
|
-
|
206
|
-
hash[param] = _to_hash(value)
|
207
|
-
end
|
208
|
-
|
209
|
-
hash
|
210
|
-
end
|
211
|
-
|
212
|
-
# Outputs non-array value in the form of hash
|
213
|
-
# For object, use to_hash. Otherwise, just return the value
|
214
|
-
# @param [Object] value Any valid value
|
215
|
-
# @return [Hash] Returns the value in the form of hash
|
216
|
-
def _to_hash(value)
|
217
|
-
if value.is_a?(Array)
|
218
|
-
value.compact.map { |v| _to_hash(v) }
|
219
|
-
elsif value.is_a?(Hash)
|
220
|
-
{}.tap do |hash|
|
221
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
222
|
-
end
|
223
|
-
elsif value.respond_to?(:to_hash)
|
224
|
-
value.to_hash
|
225
|
-
else
|
226
|
-
value
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
end
|
231
|
-
|
232
|
-
end
|
233
|
-
end
|
@@ -1,211 +0,0 @@
|
|
1
|
-
# 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.
|
2
|
-
|
3
|
-
require "date"
|
4
|
-
require "time"
|
5
|
-
|
6
|
-
module Algolia
|
7
|
-
module Ingestion
|
8
|
-
class GenerateTransformationCodeResponse
|
9
|
-
attr_accessor :generated_code
|
10
|
-
|
11
|
-
# Attribute mapping from ruby-style variable name to JSON key.
|
12
|
-
def self.attribute_map
|
13
|
-
{
|
14
|
-
:generated_code => :generatedCode
|
15
|
-
}
|
16
|
-
end
|
17
|
-
|
18
|
-
# Returns all the JSON keys this model knows about
|
19
|
-
def self.acceptable_attributes
|
20
|
-
attribute_map.values
|
21
|
-
end
|
22
|
-
|
23
|
-
# Attribute type mapping.
|
24
|
-
def self.types_mapping
|
25
|
-
{
|
26
|
-
:generated_code => :"String"
|
27
|
-
}
|
28
|
-
end
|
29
|
-
|
30
|
-
# List of attributes with nullable: true
|
31
|
-
def self.openapi_nullable
|
32
|
-
Set.new(
|
33
|
-
[]
|
34
|
-
)
|
35
|
-
end
|
36
|
-
|
37
|
-
# Initializes the object
|
38
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
39
|
-
def initialize(attributes = {})
|
40
|
-
if (!attributes.is_a?(Hash))
|
41
|
-
raise(
|
42
|
-
ArgumentError,
|
43
|
-
"The input argument (attributes) must be a hash in `Algolia::GenerateTransformationCodeResponse` initialize method"
|
44
|
-
)
|
45
|
-
end
|
46
|
-
|
47
|
-
# check to see if the attribute exists and convert string to symbol for hash key
|
48
|
-
attributes = attributes.each_with_object({}) { |(k, v), h|
|
49
|
-
if (!self.class.attribute_map.key?(k.to_sym))
|
50
|
-
raise(
|
51
|
-
ArgumentError,
|
52
|
-
"`#{k}` is not a valid attribute in `Algolia::GenerateTransformationCodeResponse`. Please check the name to make sure it's valid. List of attributes: " +
|
53
|
-
self.class.attribute_map.keys.inspect
|
54
|
-
)
|
55
|
-
end
|
56
|
-
|
57
|
-
h[k.to_sym] = v
|
58
|
-
}
|
59
|
-
|
60
|
-
if attributes.key?(:generated_code)
|
61
|
-
self.generated_code = attributes[:generated_code]
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
# Checks equality by comparing each attribute.
|
66
|
-
# @param [Object] Object to be compared
|
67
|
-
def ==(other)
|
68
|
-
return true if self.equal?(other)
|
69
|
-
self.class == other.class &&
|
70
|
-
generated_code == other.generated_code
|
71
|
-
end
|
72
|
-
|
73
|
-
# @see the `==` method
|
74
|
-
# @param [Object] Object to be compared
|
75
|
-
def eql?(other)
|
76
|
-
self == other
|
77
|
-
end
|
78
|
-
|
79
|
-
# Calculates hash code according to all attributes.
|
80
|
-
# @return [Integer] Hash code
|
81
|
-
def hash
|
82
|
-
[generated_code].hash
|
83
|
-
end
|
84
|
-
|
85
|
-
# Builds the object from hash
|
86
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
87
|
-
# @return [Object] Returns the model itself
|
88
|
-
def self.build_from_hash(attributes)
|
89
|
-
return nil unless attributes.is_a?(Hash)
|
90
|
-
attributes = attributes.transform_keys(&:to_sym)
|
91
|
-
transformed_hash = {}
|
92
|
-
types_mapping.each_pair do |key, type|
|
93
|
-
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
94
|
-
transformed_hash[key.to_sym] = nil
|
95
|
-
elsif type =~ /\AArray<(.*)>/i
|
96
|
-
# check to ensure the input is an array given that the attribute
|
97
|
-
# is documented as an array but the input is not
|
98
|
-
if attributes[attribute_map[key]].is_a?(Array)
|
99
|
-
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
|
100
|
-
_deserialize(::Regexp.last_match(1), v)
|
101
|
-
}
|
102
|
-
end
|
103
|
-
elsif !attributes[attribute_map[key]].nil?
|
104
|
-
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
new(transformed_hash)
|
109
|
-
end
|
110
|
-
|
111
|
-
# Deserializes the data based on type
|
112
|
-
# @param string type Data type
|
113
|
-
# @param string value Value to be deserialized
|
114
|
-
# @return [Object] Deserialized data
|
115
|
-
def self._deserialize(type, value)
|
116
|
-
case type.to_sym
|
117
|
-
when :Time
|
118
|
-
Time.parse(value)
|
119
|
-
when :Date
|
120
|
-
Date.parse(value)
|
121
|
-
when :String
|
122
|
-
value.to_s
|
123
|
-
when :Integer
|
124
|
-
value.to_i
|
125
|
-
when :Float
|
126
|
-
value.to_f
|
127
|
-
when :Boolean
|
128
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
129
|
-
true
|
130
|
-
else
|
131
|
-
false
|
132
|
-
end
|
133
|
-
|
134
|
-
when :Object
|
135
|
-
# generic object (usually a Hash), return directly
|
136
|
-
value
|
137
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
138
|
-
inner_type = Regexp.last_match[:inner_type]
|
139
|
-
value.map { |v| _deserialize(inner_type, v) }
|
140
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
141
|
-
k_type = Regexp.last_match[:k_type]
|
142
|
-
v_type = Regexp.last_match[:v_type]
|
143
|
-
{}.tap do |hash|
|
144
|
-
value.each do |k, v|
|
145
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
146
|
-
end
|
147
|
-
end
|
148
|
-
# model
|
149
|
-
else
|
150
|
-
# models (e.g. Pet) or oneOf
|
151
|
-
klass = Algolia::Ingestion.const_get(type)
|
152
|
-
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
|
153
|
-
.build_from_hash(value)
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
# Returns the string representation of the object
|
158
|
-
# @return [String] String presentation of the object
|
159
|
-
def to_s
|
160
|
-
to_hash.to_s
|
161
|
-
end
|
162
|
-
|
163
|
-
# to_body is an alias to to_hash (backward compatibility)
|
164
|
-
# @return [Hash] Returns the object in the form of hash
|
165
|
-
def to_body
|
166
|
-
to_hash
|
167
|
-
end
|
168
|
-
|
169
|
-
def to_json(*_args)
|
170
|
-
to_hash.to_json
|
171
|
-
end
|
172
|
-
|
173
|
-
# Returns the object in the form of hash
|
174
|
-
# @return [Hash] Returns the object in the form of hash
|
175
|
-
def to_hash
|
176
|
-
hash = {}
|
177
|
-
self.class.attribute_map.each_pair do |attr, param|
|
178
|
-
value = send(attr)
|
179
|
-
if value.nil?
|
180
|
-
is_nullable = self.class.openapi_nullable.include?(attr)
|
181
|
-
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
182
|
-
end
|
183
|
-
|
184
|
-
hash[param] = _to_hash(value)
|
185
|
-
end
|
186
|
-
|
187
|
-
hash
|
188
|
-
end
|
189
|
-
|
190
|
-
# Outputs non-array value in the form of hash
|
191
|
-
# For object, use to_hash. Otherwise, just return the value
|
192
|
-
# @param [Object] value Any valid value
|
193
|
-
# @return [Hash] Returns the value in the form of hash
|
194
|
-
def _to_hash(value)
|
195
|
-
if value.is_a?(Array)
|
196
|
-
value.compact.map { |v| _to_hash(v) }
|
197
|
-
elsif value.is_a?(Hash)
|
198
|
-
{}.tap do |hash|
|
199
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
200
|
-
end
|
201
|
-
elsif value.respond_to?(:to_hash)
|
202
|
-
value.to_hash
|
203
|
-
else
|
204
|
-
value
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
end
|
209
|
-
|
210
|
-
end
|
211
|
-
end
|