algolia 3.4.0 → 3.5.1

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