algolia 3.0.0.beta.10 → 3.0.0.beta.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +19 -0
  3. data/Gemfile.lock +2 -2
  4. data/lib/algolia/api/ingestion_client.rb +912 -359
  5. data/lib/algolia/api/query_suggestions_client.rb +4 -10
  6. data/lib/algolia/api/search_client.rb +4 -4
  7. data/lib/algolia/api/usage_client.rb +4 -4
  8. data/lib/algolia/error.rb +10 -0
  9. data/lib/algolia/logger_helper.rb +11 -2
  10. data/lib/algolia/models/abtesting/{filter_effects_empty_search.rb → empty_search_filter.rb} +3 -3
  11. data/lib/algolia/models/abtesting/filter_effects.rb +2 -2
  12. data/lib/algolia/models/abtesting/{filter_effects_outliers.rb → outliers_filter.rb} +3 -3
  13. data/lib/algolia/models/analytics/{click_positions_inner.rb → click_position.rb} +3 -3
  14. data/lib/algolia/models/analytics/get_click_positions_response.rb +1 -1
  15. data/lib/algolia/models/analytics/top_search_with_analytics.rb +1 -1
  16. data/lib/algolia/models/analytics/top_search_with_revenue_analytics.rb +1 -1
  17. data/lib/algolia/models/ingestion/action.rb +45 -0
  18. data/lib/algolia/models/{search/search_for_hits_options.rb → ingestion/batch_request.rb} +22 -20
  19. data/lib/algolia/models/ingestion/{source_shopify_base.rb → batch_write_params.rb} +14 -12
  20. data/lib/algolia/models/ingestion/docker_streams_input.rb +1 -0
  21. data/lib/algolia/models/{recommend/recommendations_hits.rb → ingestion/list_tasks_response_v1.rb} +26 -14
  22. data/lib/algolia/models/ingestion/task.rb +30 -9
  23. data/lib/algolia/models/ingestion/task_create.rb +11 -12
  24. data/lib/algolia/models/{search/search_for_facets_options.rb → ingestion/task_create_v1.rb} +86 -51
  25. data/lib/algolia/models/ingestion/task_update.rb +8 -7
  26. data/lib/algolia/models/{search/browse_pagination.rb → ingestion/task_update_v1.rb} +50 -55
  27. data/lib/algolia/models/{recommend/looking_similar.rb → ingestion/task_v1.rb} +147 -30
  28. data/lib/algolia/models/ingestion/{transformation_try_response_error.rb → transformation_error.rb} +3 -3
  29. data/lib/algolia/models/ingestion/transformation_try_response.rb +1 -1
  30. data/lib/algolia/models/monitoring/{incidents_inner.rb → incident_entry.rb} +3 -3
  31. data/lib/algolia/models/monitoring/{indexing_time_response_metrics.rb → indexing_metric.rb} +3 -3
  32. data/lib/algolia/models/monitoring/indexing_time_response.rb +1 -1
  33. data/lib/algolia/models/monitoring/infrastructure_response.rb +1 -1
  34. data/lib/algolia/models/monitoring/{latency_response_metrics.rb → latency_metric.rb} +3 -3
  35. data/lib/algolia/models/monitoring/latency_response.rb +1 -1
  36. data/lib/algolia/models/monitoring/{infrastructure_response_metrics.rb → metrics.rb} +3 -6
  37. data/lib/algolia/models/monitoring/{time_inner.rb → time_entry.rb} +3 -3
  38. data/lib/algolia/models/{recommend/trending_items.rb → query-suggestions/config_status.rb} +46 -58
  39. data/lib/algolia/models/{recommend/related_products.rb → query-suggestions/log_file.rb} +36 -32
  40. data/lib/algolia/models/recommend/around_precision.rb +1 -1
  41. data/lib/algolia/models/recommend/fallback_params.rb +1 -1
  42. data/lib/algolia/models/recommend/{around_precision_from_value_inner.rb → range.rb} +3 -6
  43. data/lib/algolia/models/recommend/recommend_rule.rb +1 -1
  44. data/lib/algolia/models/recommend/{redirect_rule_index_metadata_data.rb → redirect_rule_index_data.rb} +3 -3
  45. data/lib/algolia/models/recommend/redirect_rule_index_metadata.rb +1 -1
  46. data/lib/algolia/models/recommend/{recommend_rule_metadata.rb → rule_metadata.rb} +3 -3
  47. data/lib/algolia/models/recommend/search_params.rb +1 -1
  48. data/lib/algolia/models/recommend/search_params_object.rb +1 -1
  49. data/lib/algolia/models/search/around_precision.rb +1 -1
  50. data/lib/algolia/models/search/browse_params_object.rb +1 -1
  51. data/lib/algolia/models/search/built_in_operation.rb +1 -2
  52. data/lib/algolia/models/search/built_in_operation_value.rb +105 -0
  53. data/lib/algolia/models/search/consequence_params.rb +1 -1
  54. data/lib/algolia/models/search/dictionary_entry.rb +0 -2
  55. data/lib/algolia/models/search/index_settings.rb +2 -2
  56. data/lib/algolia/models/search/{around_precision_from_value_inner.rb → range.rb} +3 -6
  57. data/lib/algolia/models/search/{redirect_rule_index_metadata_data.rb → redirect_rule_index_data.rb} +3 -3
  58. data/lib/algolia/models/search/redirect_rule_index_metadata.rb +1 -1
  59. data/lib/algolia/models/search/search_for_facets.rb +1 -1
  60. data/lib/algolia/models/search/search_for_hits.rb +1 -1
  61. data/lib/algolia/models/search/search_params_object.rb +1 -1
  62. data/lib/algolia/models/search/search_params_string.rb +1 -0
  63. data/lib/algolia/models/search/{index_settings_as_search_params.rb → settings_response.rb} +251 -11
  64. data/lib/algolia/models/usage/{get_usage400_response_error_errors_inner.rb → error_item.rb} +3 -3
  65. data/lib/algolia/models/usage/{get_usage400_response_error.rb → forbidden_error.rb} +4 -4
  66. data/lib/algolia/models/usage/{get_usage200_response.rb → index_usage.rb} +4 -4
  67. data/lib/algolia/models/usage/invalid_request_error.rb +231 -0
  68. data/lib/algolia/models/usage/{get_usage200_response_statistics_inner.rb → statistic_entry.rb} +3 -3
  69. data/lib/algolia/transport/transport.rb +8 -2
  70. data/lib/algolia/version.rb +1 -1
  71. metadata +32 -63
  72. data/lib/algolia/models/abtesting/custom_search_params.rb +0 -214
  73. data/lib/algolia/models/abtesting/error_base.rb +0 -212
  74. data/lib/algolia/models/analytics/error_base.rb +0 -212
  75. data/lib/algolia/models/ingestion/error_base.rb +0 -212
  76. data/lib/algolia/models/insights/error_base.rb +0 -212
  77. data/lib/algolia/models/monitoring/error_base.rb +0 -212
  78. data/lib/algolia/models/monitoring/get_servers403_response.rb +0 -211
  79. data/lib/algolia/models/personalization/error_base.rb +0 -212
  80. data/lib/algolia/models/query-suggestions/app_id.rb +0 -209
  81. data/lib/algolia/models/query-suggestions/error_base.rb +0 -212
  82. data/lib/algolia/models/recommend/base_recommend_request.rb +0 -281
  83. data/lib/algolia/models/recommend/base_search_params.rb +0 -635
  84. data/lib/algolia/models/recommend/base_search_params_without_query.rb +0 -616
  85. data/lib/algolia/models/recommend/base_search_response.rb +0 -499
  86. data/lib/algolia/models/recommend/error_base.rb +0 -212
  87. data/lib/algolia/models/recommend/frequently_bought_together.rb +0 -247
  88. data/lib/algolia/models/recommend/index_settings_as_search_params.rb +0 -788
  89. data/lib/algolia/models/recommend/recommended_for_you.rb +0 -244
  90. data/lib/algolia/models/recommend/search_pagination.rb +0 -282
  91. data/lib/algolia/models/recommend/search_params_query.rb +0 -212
  92. data/lib/algolia/models/recommend/trending_facets.rb +0 -258
  93. data/lib/algolia/models/search/base_get_api_key_response.rb +0 -224
  94. data/lib/algolia/models/search/base_index_settings.rb +0 -426
  95. data/lib/algolia/models/search/base_search_params.rb +0 -635
  96. data/lib/algolia/models/search/base_search_params_without_query.rb +0 -616
  97. data/lib/algolia/models/search/base_search_response.rb +0 -499
  98. data/lib/algolia/models/search/cursor.rb +0 -209
  99. data/lib/algolia/models/search/error_base.rb +0 -212
  100. data/lib/algolia/models/search/params.rb +0 -236
  101. data/lib/algolia/models/search/search_hits.rb +0 -240
  102. data/lib/algolia/models/search/search_pagination.rb +0 -282
  103. data/lib/algolia/models/search/search_params_query.rb +0 -212
  104. data/lib/algolia/models/usage/error_base.rb +0 -212
  105. data/lib/algolia/models/usage/get_usage400_response.rb +0 -213
@@ -1,212 +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 Search
8
- # Error.
9
- class ErrorBase
10
- attr_accessor :message
11
-
12
- attr_accessor :additional_properties
13
-
14
- # Attribute mapping from ruby-style variable name to JSON key.
15
- def self.attribute_map
16
- {
17
- :message => :message
18
- }
19
- end
20
-
21
- # Returns all the JSON keys this model knows about
22
- def self.acceptable_attributes
23
- attribute_map.values
24
- end
25
-
26
- # Attribute type mapping.
27
- def self.types_mapping
28
- {
29
- :message => :"String"
30
- }
31
- end
32
-
33
- # List of attributes with nullable: true
34
- def self.openapi_nullable
35
- Set.new(
36
- []
37
- )
38
- end
39
-
40
- # Initializes the object
41
- # @param [Hash] attributes Model attributes in the form of hash
42
- def initialize(attributes = {})
43
- if (!attributes.is_a?(Hash))
44
- raise(
45
- ArgumentError,
46
- "The input argument (attributes) must be a hash in `Algolia::ErrorBase` initialize method"
47
- )
48
- end
49
-
50
- if attributes.key?(:message)
51
- self.message = attributes[:message]
52
- end
53
-
54
- # add extra attribute to additional_properties
55
- self.additional_properties ||= {}
56
- self.additional_properties.merge!(attributes.reject { |k, _| self.class.attribute_map.key?(k.to_sym) })
57
- end
58
-
59
- # Checks equality by comparing each attribute.
60
- # @param [Object] Object to be compared
61
- def ==(other)
62
- return true if self.equal?(other)
63
- self.class == other.class &&
64
- message == other.message
65
- end
66
-
67
- # @see the `==` method
68
- # @param [Object] Object to be compared
69
- def eql?(other)
70
- self == other
71
- end
72
-
73
- # Calculates hash code according to all attributes.
74
- # @return [Integer] Hash code
75
- def hash
76
- [message].hash
77
- end
78
-
79
- # Builds the object from hash
80
- # @param [Hash] attributes Model attributes in the form of hash
81
- # @return [Object] Returns the model itself
82
- def self.build_from_hash(attributes)
83
- return nil unless attributes.is_a?(Hash)
84
- attributes = attributes.transform_keys(&:to_sym)
85
- transformed_hash = {}
86
- types_mapping.each_pair do |key, type|
87
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
88
- transformed_hash[key.to_sym] = nil
89
- elsif type =~ /\AArray<(.*)>/i
90
- # check to ensure the input is an array given that the attribute
91
- # is documented as an array but the input is not
92
- if attributes[attribute_map[key]].is_a?(Array)
93
- transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
94
- _deserialize(::Regexp.last_match(1), v)
95
- }
96
- end
97
- elsif !attributes[attribute_map[key]].nil?
98
- transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
99
- end
100
- end
101
-
102
- # add extra attribute to transformed_hash
103
- transformed_hash.merge!(attributes.reject { |k, _| attribute_map.key?(k.to_sym) })
104
- new(transformed_hash)
105
- end
106
-
107
- # Deserializes the data based on type
108
- # @param string type Data type
109
- # @param string value Value to be deserialized
110
- # @return [Object] Deserialized data
111
- def self._deserialize(type, value)
112
- case type.to_sym
113
- when :Time
114
- Time.parse(value)
115
- when :Date
116
- Date.parse(value)
117
- when :String
118
- value.to_s
119
- when :Integer
120
- value.to_i
121
- when :Float
122
- value.to_f
123
- when :Boolean
124
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
125
- true
126
- else
127
- false
128
- end
129
-
130
- when :Object
131
- # generic object (usually a Hash), return directly
132
- value
133
- when /\AArray<(?<inner_type>.+)>\z/
134
- inner_type = Regexp.last_match[:inner_type]
135
- value.map { |v| _deserialize(inner_type, v) }
136
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
137
- k_type = Regexp.last_match[:k_type]
138
- v_type = Regexp.last_match[:v_type]
139
- {}.tap do |hash|
140
- value.each do |k, v|
141
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
142
- end
143
- end
144
- # model
145
- else
146
- # models (e.g. Pet) or oneOf
147
- klass = Algolia::Search.const_get(type)
148
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
149
- .build_from_hash(value)
150
- end
151
- end
152
-
153
- # Returns the string representation of the object
154
- # @return [String] String presentation of the object
155
- def to_s
156
- to_hash.to_s
157
- end
158
-
159
- # to_body is an alias to to_hash (backward compatibility)
160
- # @return [Hash] Returns the object in the form of hash
161
- def to_body
162
- to_hash
163
- end
164
-
165
- def to_json(*_args)
166
- to_hash.to_json
167
- end
168
-
169
- # Returns the object in the form of hash
170
- # @return [Hash] Returns the object in the form of hash
171
- def to_hash
172
- hash = {}
173
- self.class.attribute_map.each_pair do |attr, param|
174
- value = send(attr)
175
- if value.nil?
176
- is_nullable = self.class.openapi_nullable.include?(attr)
177
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
178
- end
179
-
180
- hash[param] = _to_hash(value)
181
- end
182
-
183
- # also add attributes from additional_properties to hash
184
- self.additional_properties&.each_pair do |k, v|
185
- hash[k.to_sym] = _to_hash(v)
186
- end
187
-
188
- hash
189
- end
190
-
191
- # Outputs non-array value in the form of hash
192
- # For object, use to_hash. Otherwise, just return the value
193
- # @param [Object] value Any valid value
194
- # @return [Hash] Returns the value in the form of hash
195
- def _to_hash(value)
196
- if value.is_a?(Array)
197
- value.compact.map { |v| _to_hash(v) }
198
- elsif value.is_a?(Hash)
199
- {}.tap do |hash|
200
- value.each { |k, v| hash[k] = _to_hash(v) }
201
- end
202
- elsif value.respond_to?(:to_hash)
203
- value.to_hash
204
- else
205
- value
206
- end
207
- end
208
-
209
- end
210
-
211
- end
212
- end
@@ -1,236 +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 Search
8
- # Parameters to apply to this search. You can use all search parameters, plus special `automaticFacetFilters`, `automaticOptionalFacetFilters`, and `query`.
9
- class Params
10
- attr_accessor :query
11
-
12
- attr_accessor :automatic_facet_filters
13
-
14
- attr_accessor :automatic_optional_facet_filters
15
-
16
- attr_accessor :rendering_content
17
-
18
- # Attribute mapping from ruby-style variable name to JSON key.
19
- def self.attribute_map
20
- {
21
- :query => :query,
22
- :automatic_facet_filters => :automaticFacetFilters,
23
- :automatic_optional_facet_filters => :automaticOptionalFacetFilters,
24
- :rendering_content => :renderingContent
25
- }
26
- end
27
-
28
- # Returns all the JSON keys this model knows about
29
- def self.acceptable_attributes
30
- attribute_map.values
31
- end
32
-
33
- # Attribute type mapping.
34
- def self.types_mapping
35
- {
36
- :query => :"ConsequenceQuery",
37
- :automatic_facet_filters => :"AutomaticFacetFilters",
38
- :automatic_optional_facet_filters => :"AutomaticFacetFilters",
39
- :rendering_content => :"RenderingContent"
40
- }
41
- end
42
-
43
- # List of attributes with nullable: true
44
- def self.openapi_nullable
45
- Set.new(
46
- []
47
- )
48
- end
49
-
50
- # Initializes the object
51
- # @param [Hash] attributes Model attributes in the form of hash
52
- def initialize(attributes = {})
53
- if (!attributes.is_a?(Hash))
54
- raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::Params` initialize method"
55
- end
56
-
57
- # check to see if the attribute exists and convert string to symbol for hash key
58
- attributes = attributes.each_with_object({}) { |(k, v), h|
59
- if (!self.class.attribute_map.key?(k.to_sym))
60
- raise(
61
- ArgumentError,
62
- "`#{k}` is not a valid attribute in `Algolia::Params`. Please check the name to make sure it's valid. List of attributes: " +
63
- self.class.attribute_map.keys.inspect
64
- )
65
- end
66
-
67
- h[k.to_sym] = v
68
- }
69
-
70
- if attributes.key?(:query)
71
- self.query = attributes[:query]
72
- end
73
-
74
- if attributes.key?(:automatic_facet_filters)
75
- self.automatic_facet_filters = attributes[:automatic_facet_filters]
76
- end
77
-
78
- if attributes.key?(:automatic_optional_facet_filters)
79
- self.automatic_optional_facet_filters = attributes[:automatic_optional_facet_filters]
80
- end
81
-
82
- if attributes.key?(:rendering_content)
83
- self.rendering_content = attributes[:rendering_content]
84
- end
85
- end
86
-
87
- # Checks equality by comparing each attribute.
88
- # @param [Object] Object to be compared
89
- def ==(other)
90
- return true if self.equal?(other)
91
- self.class == other.class &&
92
- query == other.query &&
93
- automatic_facet_filters == other.automatic_facet_filters &&
94
- automatic_optional_facet_filters == other.automatic_optional_facet_filters &&
95
- rendering_content == other.rendering_content
96
- end
97
-
98
- # @see the `==` method
99
- # @param [Object] Object to be compared
100
- def eql?(other)
101
- self == other
102
- end
103
-
104
- # Calculates hash code according to all attributes.
105
- # @return [Integer] Hash code
106
- def hash
107
- [query, automatic_facet_filters, automatic_optional_facet_filters, rendering_content].hash
108
- end
109
-
110
- # Builds the object from hash
111
- # @param [Hash] attributes Model attributes in the form of hash
112
- # @return [Object] Returns the model itself
113
- def self.build_from_hash(attributes)
114
- return nil unless attributes.is_a?(Hash)
115
- attributes = attributes.transform_keys(&:to_sym)
116
- transformed_hash = {}
117
- types_mapping.each_pair do |key, type|
118
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
119
- transformed_hash[key.to_sym] = nil
120
- elsif type =~ /\AArray<(.*)>/i
121
- # check to ensure the input is an array given that the attribute
122
- # is documented as an array but the input is not
123
- if attributes[attribute_map[key]].is_a?(Array)
124
- transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
125
- _deserialize(::Regexp.last_match(1), v)
126
- }
127
- end
128
- elsif !attributes[attribute_map[key]].nil?
129
- transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
130
- end
131
- end
132
-
133
- new(transformed_hash)
134
- end
135
-
136
- # Deserializes the data based on type
137
- # @param string type Data type
138
- # @param string value Value to be deserialized
139
- # @return [Object] Deserialized data
140
- def self._deserialize(type, value)
141
- case type.to_sym
142
- when :Time
143
- Time.parse(value)
144
- when :Date
145
- Date.parse(value)
146
- when :String
147
- value.to_s
148
- when :Integer
149
- value.to_i
150
- when :Float
151
- value.to_f
152
- when :Boolean
153
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
154
- true
155
- else
156
- false
157
- end
158
-
159
- when :Object
160
- # generic object (usually a Hash), return directly
161
- value
162
- when /\AArray<(?<inner_type>.+)>\z/
163
- inner_type = Regexp.last_match[:inner_type]
164
- value.map { |v| _deserialize(inner_type, v) }
165
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
166
- k_type = Regexp.last_match[:k_type]
167
- v_type = Regexp.last_match[:v_type]
168
- {}.tap do |hash|
169
- value.each do |k, v|
170
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
171
- end
172
- end
173
- # model
174
- else
175
- # models (e.g. Pet) or oneOf
176
- klass = Algolia::Search.const_get(type)
177
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
178
- .build_from_hash(value)
179
- end
180
- end
181
-
182
- # Returns the string representation of the object
183
- # @return [String] String presentation of the object
184
- def to_s
185
- to_hash.to_s
186
- end
187
-
188
- # to_body is an alias to to_hash (backward compatibility)
189
- # @return [Hash] Returns the object in the form of hash
190
- def to_body
191
- to_hash
192
- end
193
-
194
- def to_json(*_args)
195
- to_hash.to_json
196
- end
197
-
198
- # Returns the object in the form of hash
199
- # @return [Hash] Returns the object in the form of hash
200
- def to_hash
201
- hash = {}
202
- self.class.attribute_map.each_pair do |attr, param|
203
- value = send(attr)
204
- if value.nil?
205
- is_nullable = self.class.openapi_nullable.include?(attr)
206
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
207
- end
208
-
209
- hash[param] = _to_hash(value)
210
- end
211
-
212
- hash
213
- end
214
-
215
- # Outputs non-array value in the form of hash
216
- # For object, use to_hash. Otherwise, just return the value
217
- # @param [Object] value Any valid value
218
- # @return [Hash] Returns the value in the form of hash
219
- def _to_hash(value)
220
- if value.is_a?(Array)
221
- value.compact.map { |v| _to_hash(v) }
222
- elsif value.is_a?(Hash)
223
- {}.tap do |hash|
224
- value.each { |k, v| hash[k] = _to_hash(v) }
225
- end
226
- elsif value.respond_to?(:to_hash)
227
- value.to_hash
228
- else
229
- value
230
- end
231
- end
232
-
233
- end
234
-
235
- end
236
- end
@@ -1,240 +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 Search
8
- class SearchHits
9
- # Search results (hits). Hits are records from your index that match the search criteria, augmented with additional attributes, such as, for highlighting.
10
- attr_accessor :hits
11
-
12
- # Search query.
13
- attr_accessor :query
14
-
15
- # URL-encoded string of all search parameters.
16
- attr_accessor :params
17
-
18
- attr_accessor :additional_properties
19
-
20
- # Attribute mapping from ruby-style variable name to JSON key.
21
- def self.attribute_map
22
- {
23
- :hits => :hits,
24
- :query => :query,
25
- :params => :params
26
- }
27
- end
28
-
29
- # Returns all the JSON keys this model knows about
30
- def self.acceptable_attributes
31
- attribute_map.values
32
- end
33
-
34
- # Attribute type mapping.
35
- def self.types_mapping
36
- {
37
- :hits => :"Array<Hit>",
38
- :query => :"String",
39
- :params => :"String"
40
- }
41
- end
42
-
43
- # List of attributes with nullable: true
44
- def self.openapi_nullable
45
- Set.new(
46
- []
47
- )
48
- end
49
-
50
- # Initializes the object
51
- # @param [Hash] attributes Model attributes in the form of hash
52
- def initialize(attributes = {})
53
- if (!attributes.is_a?(Hash))
54
- raise(
55
- ArgumentError,
56
- "The input argument (attributes) must be a hash in `Algolia::SearchHits` initialize method"
57
- )
58
- end
59
-
60
- if attributes.key?(:hits)
61
- if (value = attributes[:hits]).is_a?(Array)
62
- self.hits = value
63
- end
64
- else
65
- self.hits = nil
66
- end
67
-
68
- if attributes.key?(:query)
69
- self.query = attributes[:query]
70
- else
71
- self.query = nil
72
- end
73
-
74
- if attributes.key?(:params)
75
- self.params = attributes[:params]
76
- else
77
- self.params = nil
78
- end
79
-
80
- # add extra attribute to additional_properties
81
- self.additional_properties ||= {}
82
- self.additional_properties.merge!(attributes.reject { |k, _| self.class.attribute_map.key?(k.to_sym) })
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
- hits == other.hits &&
91
- query == other.query &&
92
- params == other.params
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
- [hits, query, params].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
- # add extra attribute to transformed_hash
131
- transformed_hash.merge!(attributes.reject { |k, _| attribute_map.key?(k.to_sym) })
132
- new(transformed_hash)
133
- end
134
-
135
- # Deserializes the data based on type
136
- # @param string type Data type
137
- # @param string value Value to be deserialized
138
- # @return [Object] Deserialized data
139
- def self._deserialize(type, value)
140
- case type.to_sym
141
- when :Time
142
- Time.parse(value)
143
- when :Date
144
- Date.parse(value)
145
- when :String
146
- value.to_s
147
- when :Integer
148
- value.to_i
149
- when :Float
150
- value.to_f
151
- when :Boolean
152
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
153
- true
154
- else
155
- false
156
- end
157
-
158
- when :Object
159
- # generic object (usually a Hash), return directly
160
- value
161
- when /\AArray<(?<inner_type>.+)>\z/
162
- inner_type = Regexp.last_match[:inner_type]
163
- value.map { |v| _deserialize(inner_type, v) }
164
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
165
- k_type = Regexp.last_match[:k_type]
166
- v_type = Regexp.last_match[:v_type]
167
- {}.tap do |hash|
168
- value.each do |k, v|
169
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
170
- end
171
- end
172
- # model
173
- else
174
- # models (e.g. Pet) or oneOf
175
- klass = Algolia::Search.const_get(type)
176
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
177
- .build_from_hash(value)
178
- end
179
- end
180
-
181
- # Returns the string representation of the object
182
- # @return [String] String presentation of the object
183
- def to_s
184
- to_hash.to_s
185
- end
186
-
187
- # to_body is an alias to to_hash (backward compatibility)
188
- # @return [Hash] Returns the object in the form of hash
189
- def to_body
190
- to_hash
191
- end
192
-
193
- def to_json(*_args)
194
- to_hash.to_json
195
- end
196
-
197
- # Returns the object in the form of hash
198
- # @return [Hash] Returns the object in the form of hash
199
- def to_hash
200
- hash = {}
201
- self.class.attribute_map.each_pair do |attr, param|
202
- value = send(attr)
203
- if value.nil?
204
- is_nullable = self.class.openapi_nullable.include?(attr)
205
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
206
- end
207
-
208
- hash[param] = _to_hash(value)
209
- end
210
-
211
- # also add attributes from additional_properties to hash
212
- self.additional_properties&.each_pair do |k, v|
213
- hash[k.to_sym] = _to_hash(v)
214
- end
215
-
216
- hash
217
- end
218
-
219
- # Outputs non-array value in the form of hash
220
- # For object, use to_hash. Otherwise, just return the value
221
- # @param [Object] value Any valid value
222
- # @return [Hash] Returns the value in the form of hash
223
- def _to_hash(value)
224
- if value.is_a?(Array)
225
- value.compact.map { |v| _to_hash(v) }
226
- elsif value.is_a?(Hash)
227
- {}.tap do |hash|
228
- value.each { |k, v| hash[k] = _to_hash(v) }
229
- end
230
- elsif value.respond_to?(:to_hash)
231
- value.to_hash
232
- else
233
- value
234
- end
235
- end
236
-
237
- end
238
-
239
- end
240
- end