algolia 3.5.0 → 3.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -0
  3. data/Gemfile.lock +1 -1
  4. data/lib/algolia/api/abtesting_client.rb +17 -16
  5. data/lib/algolia/api/analytics_client.rb +173 -333
  6. data/lib/algolia/api/ingestion_client.rb +40 -200
  7. data/lib/algolia/api/insights_client.rb +18 -32
  8. data/lib/algolia/api/monitoring_client.rb +33 -25
  9. data/lib/algolia/api/personalization_client.rb +16 -8
  10. data/lib/algolia/api/query_suggestions_client.rb +17 -9
  11. data/lib/algolia/api/recommend_client.rb +17 -9
  12. data/lib/algolia/api/search_client.rb +63 -110
  13. data/lib/algolia/configuration.rb +16 -1
  14. data/lib/algolia/models/abtesting/ab_test_configuration.rb +0 -2
  15. data/lib/algolia/models/abtesting/ab_tests_variant.rb +0 -18
  16. data/lib/algolia/models/abtesting/ab_tests_variant_search_params.rb +0 -18
  17. data/lib/algolia/models/abtesting/add_ab_tests_request.rb +0 -18
  18. data/lib/algolia/models/abtesting/minimum_detectable_effect.rb +0 -18
  19. data/lib/algolia/models/abtesting/schedule_ab_tests_request.rb +0 -18
  20. data/lib/algolia/models/abtesting/variant.rb +0 -20
  21. data/lib/algolia/models/analytics/click_position.rb +0 -32
  22. data/lib/algolia/models/analytics/daily_add_to_cart_rates.rb +0 -28
  23. data/lib/algolia/models/analytics/daily_average_clicks.rb +0 -24
  24. data/lib/algolia/models/analytics/daily_click_through_rates.rb +0 -28
  25. data/lib/algolia/models/analytics/daily_conversion_rates.rb +0 -28
  26. data/lib/algolia/models/analytics/daily_no_click_rates.rb +0 -32
  27. data/lib/algolia/models/analytics/daily_no_results_rates.rb +0 -18
  28. data/lib/algolia/models/analytics/daily_purchase_rates.rb +0 -14
  29. data/lib/algolia/models/analytics/daily_searches_no_clicks.rb +0 -14
  30. data/lib/algolia/models/analytics/daily_searches_no_results.rb +0 -14
  31. data/lib/algolia/models/analytics/get_add_to_cart_rate_response.rb +0 -28
  32. data/lib/algolia/models/analytics/get_average_click_position_response.rb +0 -24
  33. data/lib/algolia/models/analytics/get_click_positions_response.rb +0 -18
  34. data/lib/algolia/models/analytics/get_click_through_rate_response.rb +0 -28
  35. data/lib/algolia/models/analytics/get_conversion_rate_response.rb +0 -28
  36. data/lib/algolia/models/analytics/get_no_click_rate_response.rb +0 -32
  37. data/lib/algolia/models/analytics/get_no_results_rate_response.rb +0 -18
  38. data/lib/algolia/models/analytics/get_purchase_rate_response.rb +0 -14
  39. data/lib/algolia/models/analytics/top_hit_with_analytics.rb +0 -56
  40. data/lib/algolia/models/analytics/top_hit_with_revenue_analytics.rb +0 -98
  41. data/lib/algolia/models/analytics/top_search_with_analytics.rb +0 -90
  42. data/lib/algolia/models/analytics/top_search_with_revenue_analytics.rb +0 -132
  43. data/lib/algolia/models/ingestion/event.rb +1 -25
  44. data/lib/algolia/models/ingestion/pagination.rb +0 -60
  45. data/lib/algolia/models/ingestion/run.rb +0 -18
  46. data/lib/algolia/models/ingestion/source_csv.rb +0 -21
  47. data/lib/algolia/models/ingestion/task.rb +0 -18
  48. data/lib/algolia/models/ingestion/task_create.rb +0 -18
  49. data/lib/algolia/models/ingestion/task_create_v1.rb +0 -18
  50. data/lib/algolia/models/ingestion/task_update.rb +0 -18
  51. data/lib/algolia/models/ingestion/task_update_v1.rb +0 -18
  52. data/lib/algolia/models/ingestion/task_v1.rb +0 -18
  53. data/lib/algolia/models/ingestion/transformation.rb +1 -1
  54. data/lib/algolia/models/ingestion/transformation_create.rb +1 -1
  55. data/lib/algolia/models/insights/added_to_cart_object_ids.rb +0 -123
  56. data/lib/algolia/models/insights/added_to_cart_object_ids_after_search.rb +0 -149
  57. data/lib/algolia/models/insights/clicked_filters.rb +0 -105
  58. data/lib/algolia/models/insights/clicked_object_ids.rb +0 -105
  59. data/lib/algolia/models/insights/clicked_object_ids_after_search.rb +0 -149
  60. data/lib/algolia/models/insights/converted_filters.rb +0 -105
  61. data/lib/algolia/models/insights/converted_object_ids.rb +0 -105
  62. data/lib/algolia/models/insights/converted_object_ids_after_search.rb +0 -131
  63. data/lib/algolia/models/insights/insights_events.rb +0 -18
  64. data/lib/algolia/models/insights/object_data_after_search.rb +0 -26
  65. data/lib/algolia/models/insights/purchased_object_ids.rb +0 -123
  66. data/lib/algolia/models/insights/purchased_object_ids_after_search.rb +0 -123
  67. data/lib/algolia/models/insights/viewed_filters.rb +0 -105
  68. data/lib/algolia/models/insights/viewed_object_ids.rb +0 -105
  69. data/lib/algolia/models/personalization/personalization_strategy_params.rb +0 -18
  70. data/lib/algolia/models/query-suggestions/configuration.rb +0 -17
  71. data/lib/algolia/models/query-suggestions/configuration_response.rb +0 -17
  72. data/lib/algolia/models/query-suggestions/configuration_with_index.rb +0 -17
  73. data/lib/algolia/models/query-suggestions/source_index.rb +0 -28
  74. data/lib/algolia/models/recommend/banner_image.rb +4 -2
  75. data/lib/algolia/models/recommend/bought_together_query.rb +0 -36
  76. data/lib/algolia/models/recommend/condition.rb +0 -15
  77. data/lib/algolia/models/recommend/consequence.rb +0 -28
  78. data/lib/algolia/models/recommend/fallback_params.rb +3 -95
  79. data/lib/algolia/models/recommend/looking_similar_query.rb +0 -36
  80. data/lib/algolia/models/recommend/promote_consequence_object.rb +0 -14
  81. data/lib/algolia/models/recommend/ranking_info.rb +0 -112
  82. data/lib/algolia/models/recommend/recommend_hit.rb +0 -20
  83. data/lib/algolia/models/recommend/recommend_search_params.rb +3 -95
  84. data/lib/algolia/models/recommend/recommendations_results.rb +13 -61
  85. data/lib/algolia/models/recommend/recommended_for_you_query.rb +0 -36
  86. data/lib/algolia/models/recommend/related_query.rb +0 -36
  87. data/lib/algolia/models/recommend/search_recommend_rules_params.rb +2 -52
  88. data/lib/algolia/models/recommend/search_recommend_rules_response.rb +0 -14
  89. data/lib/algolia/models/recommend/trending_facet_hit.rb +0 -20
  90. data/lib/algolia/models/recommend/trending_facets_query.rb +0 -36
  91. data/lib/algolia/models/recommend/trending_items_query.rb +0 -36
  92. data/lib/algolia/models/recommend/widgets.rb +5 -2
  93. data/lib/algolia/models/search/banner_image.rb +4 -2
  94. data/lib/algolia/models/search/browse_params_object.rb +1 -129
  95. data/lib/algolia/models/search/browse_response.rb +13 -61
  96. data/lib/algolia/models/search/condition.rb +0 -15
  97. data/lib/algolia/models/search/consequence.rb +0 -28
  98. data/lib/algolia/models/search/consequence_params.rb +1 -129
  99. data/lib/algolia/models/search/get_api_key_response.rb +2 -0
  100. data/lib/algolia/models/search/get_objects_response.rb +0 -2
  101. data/lib/algolia/models/search/index_settings.rb +3 -81
  102. data/lib/algolia/models/search/log.rb +0 -34
  103. data/lib/algolia/models/search/promote_object_ids.rb +0 -14
  104. data/lib/algolia/models/search/ranking_info.rb +0 -112
  105. data/lib/algolia/models/search/rule.rb +0 -18
  106. data/lib/algolia/models/search/search_dictionary_entries_params.rb +0 -32
  107. data/lib/algolia/models/search/search_dictionary_entries_response.rb +1 -15
  108. data/lib/algolia/models/search/search_for_facet_values_request.rb +0 -14
  109. data/lib/algolia/models/search/search_for_facets.rb +1 -129
  110. data/lib/algolia/models/search/search_for_hits.rb +1 -129
  111. data/lib/algolia/models/search/search_params_object.rb +1 -129
  112. data/lib/algolia/models/search/search_response.rb +13 -61
  113. data/lib/algolia/models/search/search_rules_params.rb +2 -34
  114. data/lib/algolia/models/search/search_synonyms_params.rb +0 -32
  115. data/lib/algolia/models/search/search_user_ids_params.rb +0 -32
  116. data/lib/algolia/models/search/search_user_ids_response.rb +1 -33
  117. data/lib/algolia/models/search/settings_response.rb +3 -81
  118. data/lib/algolia/models/search/user_hit.rb +0 -15
  119. data/lib/algolia/models/search/user_id.rb +0 -15
  120. data/lib/algolia/models/search/widgets.rb +5 -2
  121. data/lib/algolia/user_agent.rb +8 -2
  122. data/lib/algolia/version.rb +1 -1
  123. metadata +2 -11
  124. data/lib/algolia/models/query-suggestions/base_query_suggestions_configuration_response.rb +0 -230
  125. data/lib/algolia/models/query-suggestions/base_query_suggestions_configuration_with_index.rb +0 -212
  126. data/lib/algolia/models/query-suggestions/get_config_status200_response.rb +0 -252
  127. data/lib/algolia/models/query-suggestions/get_log_file200_response.rb +0 -263
  128. data/lib/algolia/models/query-suggestions/query_suggestions_configuration.rb +0 -276
  129. data/lib/algolia/models/query-suggestions/query_suggestions_configuration_response.rb +0 -316
  130. data/lib/algolia/models/query-suggestions/query_suggestions_configuration_with_index.rb +0 -295
  131. data/lib/algolia/models/recommend/banners.rb +0 -209
  132. data/lib/algolia/models/search/banners.rb +0 -209
@@ -1,263 +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 QuerySuggestions
8
- class GetLogFile200Response
9
- # Date and time of the log entry, in RFC 3339 format.
10
- attr_accessor :timestamp
11
-
12
- attr_accessor :level
13
-
14
- # Details about this log entry.
15
- attr_accessor :message
16
-
17
- # Level indicating the position of a suggestion in a hierarchy of records. For example, a `contextLevel` of 1 indicates that this suggestion belongs to a previous suggestion with `contextLevel` 0.
18
- attr_accessor :context_level
19
-
20
- class EnumAttributeValidator
21
- attr_reader :datatype
22
- attr_reader :allowable_values
23
-
24
- def initialize(datatype, allowable_values)
25
- @allowable_values = allowable_values.map do |value|
26
- case datatype.to_s
27
- when /Integer/i
28
- value.to_i
29
- when /Float/i
30
- value.to_f
31
- else
32
- value
33
- end
34
- end
35
- end
36
-
37
- def valid?(value)
38
- !value || allowable_values.include?(value)
39
- end
40
- end
41
-
42
- # Attribute mapping from ruby-style variable name to JSON key.
43
- def self.attribute_map
44
- {
45
- :timestamp => :timestamp,
46
- :level => :level,
47
- :message => :message,
48
- :context_level => :contextLevel
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.types_mapping
59
- {
60
- :timestamp => :"String",
61
- :level => :"LogLevel",
62
- :message => :"String",
63
- :context_level => :"Integer"
64
- }
65
- end
66
-
67
- # List of attributes with nullable: true
68
- def self.openapi_nullable
69
- Set.new(
70
- []
71
- )
72
- end
73
-
74
- # Initializes the object
75
- # @param [Hash] attributes Model attributes in the form of hash
76
- def initialize(attributes = {})
77
- if (!attributes.is_a?(Hash))
78
- raise(
79
- ArgumentError,
80
- "The input argument (attributes) must be a hash in `Algolia::GetLogFile200Response` initialize method"
81
- )
82
- end
83
-
84
- # check to see if the attribute exists and convert string to symbol for hash key
85
- attributes = attributes.each_with_object({}) { |(k, v), h|
86
- if (!self.class.attribute_map.key?(k.to_sym))
87
- raise(
88
- ArgumentError,
89
- "`#{k}` is not a valid attribute in `Algolia::GetLogFile200Response`. Please check the name to make sure it's valid. List of attributes: " +
90
- self.class.attribute_map.keys.inspect
91
- )
92
- end
93
-
94
- h[k.to_sym] = v
95
- }
96
-
97
- if attributes.key?(:timestamp)
98
- self.timestamp = attributes[:timestamp]
99
- end
100
-
101
- if attributes.key?(:level)
102
- self.level = attributes[:level]
103
- end
104
-
105
- if attributes.key?(:message)
106
- self.message = attributes[:message]
107
- end
108
-
109
- if attributes.key?(:context_level)
110
- self.context_level = attributes[:context_level]
111
- end
112
- end
113
-
114
- # Checks equality by comparing each attribute.
115
- # @param [Object] Object to be compared
116
- def ==(other)
117
- return true if self.equal?(other)
118
- self.class == other.class &&
119
- timestamp == other.timestamp &&
120
- level == other.level &&
121
- message == other.message &&
122
- context_level == other.context_level
123
- end
124
-
125
- # @see the `==` method
126
- # @param [Object] Object to be compared
127
- def eql?(other)
128
- self == other
129
- end
130
-
131
- # Calculates hash code according to all attributes.
132
- # @return [Integer] Hash code
133
- def hash
134
- [timestamp, level, message, context_level].hash
135
- end
136
-
137
- # Builds the object from hash
138
- # @param [Hash] attributes Model attributes in the form of hash
139
- # @return [Object] Returns the model itself
140
- def self.build_from_hash(attributes)
141
- return nil unless attributes.is_a?(Hash)
142
- attributes = attributes.transform_keys(&:to_sym)
143
- transformed_hash = {}
144
- types_mapping.each_pair do |key, type|
145
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
146
- transformed_hash[key.to_sym] = nil
147
- elsif type =~ /\AArray<(.*)>/i
148
- # check to ensure the input is an array given that the attribute
149
- # is documented as an array but the input is not
150
- if attributes[attribute_map[key]].is_a?(Array)
151
- transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
152
- _deserialize(::Regexp.last_match(1), v)
153
- }
154
- end
155
- elsif !attributes[attribute_map[key]].nil?
156
- transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
157
- end
158
- end
159
-
160
- new(transformed_hash)
161
- end
162
-
163
- # Deserializes the data based on type
164
- # @param string type Data type
165
- # @param string value Value to be deserialized
166
- # @return [Object] Deserialized data
167
- def self._deserialize(type, value)
168
- case type.to_sym
169
- when :Time
170
- Time.parse(value)
171
- when :Date
172
- Date.parse(value)
173
- when :String
174
- value.to_s
175
- when :Integer
176
- value.to_i
177
- when :Float
178
- value.to_f
179
- when :Boolean
180
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
181
- true
182
- else
183
- false
184
- end
185
-
186
- when :Object
187
- # generic object (usually a Hash), return directly
188
- value
189
- when /\AArray<(?<inner_type>.+)>\z/
190
- inner_type = Regexp.last_match[:inner_type]
191
- value.map { |v| _deserialize(inner_type, v) }
192
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
193
- k_type = Regexp.last_match[:k_type]
194
- v_type = Regexp.last_match[:v_type]
195
- {}.tap do |hash|
196
- value.each do |k, v|
197
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
198
- end
199
- end
200
- # model
201
- else
202
- # models (e.g. Pet) or oneOf
203
- klass = Algolia::QuerySuggestions.const_get(type)
204
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
205
- .build_from_hash(value)
206
- end
207
- end
208
-
209
- # Returns the string representation of the object
210
- # @return [String] String presentation of the object
211
- def to_s
212
- to_hash.to_s
213
- end
214
-
215
- # to_body is an alias to to_hash (backward compatibility)
216
- # @return [Hash] Returns the object in the form of hash
217
- def to_body
218
- to_hash
219
- end
220
-
221
- def to_json(*_args)
222
- to_hash.to_json
223
- end
224
-
225
- # Returns the object in the form of hash
226
- # @return [Hash] Returns the object in the form of hash
227
- def to_hash
228
- hash = {}
229
- self.class.attribute_map.each_pair do |attr, param|
230
- value = send(attr)
231
- if value.nil?
232
- is_nullable = self.class.openapi_nullable.include?(attr)
233
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
234
- end
235
-
236
- hash[param] = _to_hash(value)
237
- end
238
-
239
- hash
240
- end
241
-
242
- # Outputs non-array value in the form of hash
243
- # For object, use to_hash. Otherwise, just return the value
244
- # @param [Object] value Any valid value
245
- # @return [Hash] Returns the value in the form of hash
246
- def _to_hash(value)
247
- if value.is_a?(Array)
248
- value.compact.map { |v| _to_hash(v) }
249
- elsif value.is_a?(Hash)
250
- {}.tap do |hash|
251
- value.each { |k, v| hash[k] = _to_hash(v) }
252
- end
253
- elsif value.respond_to?(:to_hash)
254
- value.to_hash
255
- else
256
- value
257
- end
258
- end
259
-
260
- end
261
-
262
- end
263
- end
@@ -1,276 +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 QuerySuggestions
8
- # Query Suggestions configuration.
9
- class QuerySuggestionsConfiguration
10
- # Algolia indices from which to get the popular searches for query suggestions.
11
- attr_accessor :source_indices
12
-
13
- attr_accessor :languages
14
-
15
- attr_accessor :exclude
16
-
17
- # Whether to turn on personalized query suggestions.
18
- attr_accessor :enable_personalization
19
-
20
- # Whether to include suggestions with special characters.
21
- attr_accessor :allow_special_characters
22
-
23
- # Attribute mapping from ruby-style variable name to JSON key.
24
- def self.attribute_map
25
- {
26
- :source_indices => :sourceIndices,
27
- :languages => :languages,
28
- :exclude => :exclude,
29
- :enable_personalization => :enablePersonalization,
30
- :allow_special_characters => :allowSpecialCharacters
31
- }
32
- end
33
-
34
- # Returns all the JSON keys this model knows about
35
- def self.acceptable_attributes
36
- attribute_map.values
37
- end
38
-
39
- # Attribute type mapping.
40
- def self.types_mapping
41
- {
42
- :source_indices => :"Array<SourceIndex>",
43
- :languages => :Languages,
44
- :exclude => :"Array<String>",
45
- :enable_personalization => :Boolean,
46
- :allow_special_characters => :Boolean
47
- }
48
- end
49
-
50
- # List of attributes with nullable: true
51
- def self.openapi_nullable
52
- Set.new(
53
- [
54
- :exclude
55
- ]
56
- )
57
- end
58
-
59
- # Initializes the object
60
- # @param [Hash] attributes Model attributes in the form of hash
61
- def initialize(attributes = {})
62
- unless attributes.is_a?(Hash)
63
- raise(
64
- ArgumentError,
65
- "The input argument (attributes) must be a hash in `Algolia::QuerySuggestionsConfiguration` initialize method"
66
- )
67
- end
68
-
69
- # check to see if the attribute exists and convert string to symbol for hash key
70
- attributes = attributes.each_with_object({}) do |(k, v), h|
71
- unless self.class.attribute_map.key?(k.to_sym)
72
- raise(
73
- ArgumentError,
74
- "`#{k}` is not a valid attribute in `Algolia::QuerySuggestionsConfiguration`. Please check the name to make sure it's valid. List of attributes: " +
75
- self.class.attribute_map.keys.inspect
76
- )
77
- end
78
-
79
- h[k.to_sym] = v
80
- end
81
-
82
- if attributes.key?(:source_indices)
83
- if (value = attributes[:source_indices]).is_a?(Array)
84
- self.source_indices = value
85
- end
86
- else
87
- self.source_indices = nil
88
- end
89
-
90
- if attributes.key?(:languages)
91
- self.languages = attributes[:languages]
92
- end
93
-
94
- if attributes.key?(:exclude)
95
- if (value = attributes[:exclude]).is_a?(Array)
96
- self.exclude = value
97
- end
98
- end
99
-
100
- if attributes.key?(:enable_personalization)
101
- self.enable_personalization = attributes[:enable_personalization]
102
- end
103
-
104
- if attributes.key?(:allow_special_characters)
105
- self.allow_special_characters = attributes[:allow_special_characters]
106
- end
107
- end
108
-
109
- # Custom attribute writer method with validation
110
- # @param [Object] source_indices Value to be assigned
111
- def source_indices=(source_indices)
112
- if source_indices.nil?
113
- raise ArgumentError, "source_indices cannot be nil"
114
- end
115
-
116
- if source_indices.length < 1
117
- raise(
118
- ArgumentError,
119
- "invalid value for \"source_indices\", number of items must be greater than or equal to 1."
120
- )
121
- end
122
-
123
- @source_indices = source_indices
124
- end
125
-
126
- # Checks equality by comparing each attribute.
127
- # @param [Object] Object to be compared
128
- def ==(other)
129
- return true if equal?(other)
130
-
131
- self.class == other.class &&
132
- source_indices == other.source_indices &&
133
- languages == other.languages &&
134
- exclude == other.exclude &&
135
- enable_personalization == other.enable_personalization &&
136
- allow_special_characters == other.allow_special_characters
137
- end
138
-
139
- # @see the `==` method
140
- # @param [Object] Object to be compared
141
- def eql?(other)
142
- self == other
143
- end
144
-
145
- # Calculates hash code according to all attributes.
146
- # @return [Integer] Hash code
147
- def hash
148
- [source_indices, languages, exclude, enable_personalization, allow_special_characters].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
- return nil unless attributes.is_a?(Hash)
156
-
157
- attributes = attributes.transform_keys(&:to_sym)
158
- transformed_hash = {}
159
- types_mapping.each_pair do |key, type|
160
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
161
- transformed_hash[key.to_sym] = nil
162
- elsif type =~ /\AArray<(.*)>/i
163
- # check to ensure the input is an array given that the attribute
164
- # is documented as an array but the input is not
165
- if attributes[attribute_map[key]].is_a?(Array)
166
- transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
167
- _deserialize(::Regexp.last_match(1), v)
168
- }
169
- end
170
- elsif !attributes[attribute_map[key]].nil?
171
- transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
172
- end
173
- end
174
-
175
- new(transformed_hash)
176
- end
177
-
178
- # Deserializes the data based on type
179
- # @param string type Data type
180
- # @param string value Value to be deserialized
181
- # @return [Object] Deserialized data
182
- def self._deserialize(type, value)
183
- case type.to_sym
184
- when :Time
185
- Time.parse(value)
186
- when :Date
187
- Date.parse(value)
188
- when :String
189
- value.to_s
190
- when :Integer
191
- value.to_i
192
- when :Float
193
- value.to_f
194
- when :Boolean
195
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
196
- true
197
- else
198
- false
199
- end
200
-
201
- when :Object
202
- # generic object (usually a Hash), return directly
203
- value
204
- when /\AArray<(?<inner_type>.+)>\z/
205
- inner_type = Regexp.last_match[:inner_type]
206
- value.map { |v| _deserialize(inner_type, v) }
207
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
208
- k_type = Regexp.last_match[:k_type]
209
- v_type = Regexp.last_match[:v_type]
210
- {}.tap do |hash|
211
- value.each do |k, v|
212
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
213
- end
214
- end
215
- # model
216
- else
217
- # models (e.g. Pet) or oneOf
218
- klass = Algolia::QuerySuggestions.const_get(type)
219
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
220
- .build_from_hash(value)
221
- end
222
- end
223
-
224
- # Returns the string representation of the object
225
- # @return [String] String presentation of the object
226
- def to_s
227
- to_hash.to_s
228
- end
229
-
230
- # to_body is an alias to to_hash (backward compatibility)
231
- # @return [Hash] Returns the object in the form of hash
232
- def to_body
233
- to_hash
234
- end
235
-
236
- def to_json(*_args)
237
- to_hash.to_json
238
- end
239
-
240
- # Returns the object in the form of hash
241
- # @return [Hash] Returns the object in the form of hash
242
- def to_hash
243
- hash = {}
244
- self.class.attribute_map.each_pair do |attr, param|
245
- value = send(attr)
246
- if value.nil?
247
- is_nullable = self.class.openapi_nullable.include?(attr)
248
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
249
- end
250
-
251
- hash[param] = _to_hash(value)
252
- end
253
-
254
- hash
255
- end
256
-
257
- # Outputs non-array value in the form of hash
258
- # For object, use to_hash. Otherwise, just return the value
259
- # @param [Object] value Any valid value
260
- # @return [Hash] Returns the value in the form of hash
261
- def _to_hash(value)
262
- if value.is_a?(Array)
263
- value.compact.map { |v| _to_hash(v) }
264
- elsif value.is_a?(Hash)
265
- {}.tap do |hash|
266
- value.each { |k, v| hash[k] = _to_hash(v) }
267
- end
268
- elsif value.respond_to?(:to_hash)
269
- value.to_hash
270
- else
271
- value
272
- end
273
- end
274
- end
275
- end
276
- end