algolia 3.0.0.alpha.15 → 3.0.0.alpha.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (198) hide show
  1. checksums.yaml +4 -4
  2. data/.openapi-generator/FILES +10 -167
  3. data/CHANGELOG.md +14 -0
  4. data/Gemfile.lock +1 -1
  5. data/lib/algolia/api/analytics_client.rb +76 -76
  6. data/lib/algolia/api/ingestion_client.rb +267 -196
  7. data/lib/algolia/api/monitoring_client.rb +49 -49
  8. data/lib/algolia/api/query_suggestions_client.rb +14 -14
  9. data/lib/algolia/api/recommend_client.rb +22 -22
  10. data/lib/algolia/api/search_client.rb +8 -8
  11. data/lib/algolia/api/usage_client.rb +329 -0
  12. data/lib/algolia/models/analytics/get_status_response.rb +1 -1
  13. data/lib/algolia/models/ingestion/auth_algolia.rb +3 -2
  14. data/lib/algolia/models/ingestion/auth_algolia_insights.rb +212 -0
  15. data/lib/algolia/models/{recommend/consequence_query_object.rb → ingestion/auth_algolia_insights_partial.rb} +21 -24
  16. data/lib/algolia/models/ingestion/auth_algolia_partial.rb +3 -2
  17. data/lib/algolia/models/ingestion/auth_api_key.rb +2 -1
  18. data/lib/algolia/models/ingestion/auth_api_key_partial.rb +2 -1
  19. data/lib/algolia/models/ingestion/auth_basic.rb +3 -1
  20. data/lib/algolia/models/ingestion/auth_basic_partial.rb +3 -1
  21. data/lib/algolia/models/ingestion/auth_google_service_account.rb +3 -3
  22. data/lib/algolia/models/ingestion/auth_google_service_account_partial.rb +3 -3
  23. data/lib/algolia/models/ingestion/auth_input.rb +1 -0
  24. data/lib/algolia/models/ingestion/auth_input_partial.rb +1 -0
  25. data/lib/algolia/models/ingestion/auth_o_auth.rb +18 -8
  26. data/lib/algolia/models/ingestion/auth_o_auth_partial.rb +18 -8
  27. data/lib/algolia/models/ingestion/authentication.rb +5 -5
  28. data/lib/algolia/models/ingestion/authentication_create.rb +2 -2
  29. data/lib/algolia/models/ingestion/authentication_create_response.rb +4 -4
  30. data/lib/algolia/models/ingestion/authentication_search.rb +1 -1
  31. data/lib/algolia/models/ingestion/authentication_type.rb +2 -1
  32. data/lib/algolia/models/ingestion/authentication_update.rb +2 -2
  33. data/lib/algolia/models/ingestion/authentication_update_response.rb +4 -4
  34. data/lib/algolia/models/ingestion/big_commerce_channel.rb +2 -2
  35. data/lib/algolia/models/ingestion/big_commerce_metafield.rb +2 -2
  36. data/lib/algolia/models/ingestion/commercetools_custom_fields.rb +1 -1
  37. data/lib/algolia/models/ingestion/delete_response.rb +1 -1
  38. data/lib/algolia/models/ingestion/destination.rb +6 -6
  39. data/lib/algolia/models/ingestion/destination_create.rb +3 -3
  40. data/lib/algolia/models/ingestion/destination_create_response.rb +4 -4
  41. data/lib/algolia/models/ingestion/destination_index_name.rb +2 -2
  42. data/lib/algolia/models/ingestion/destination_index_prefix.rb +1 -1
  43. data/lib/algolia/models/ingestion/destination_search.rb +1 -1
  44. data/lib/algolia/models/ingestion/destination_type.rb +1 -2
  45. data/lib/algolia/models/ingestion/destination_update.rb +3 -3
  46. data/lib/algolia/models/ingestion/destination_update_response.rb +4 -4
  47. data/lib/algolia/models/ingestion/docker_source_discover.rb +2 -2
  48. data/lib/algolia/models/ingestion/event.rb +3 -3
  49. data/lib/algolia/models/ingestion/list_tasks_response.rb +1 -1
  50. data/lib/algolia/models/ingestion/mapping_format_schema.rb +32 -0
  51. data/lib/algolia/models/ingestion/mapping_input.rb +24 -3
  52. data/lib/algolia/models/ingestion/on_demand_date_utils_input.rb +3 -3
  53. data/lib/algolia/models/ingestion/on_demand_trigger.rb +2 -2
  54. data/lib/algolia/models/ingestion/on_demand_trigger_input.rb +1 -1
  55. data/lib/algolia/models/ingestion/pagination.rb +65 -0
  56. data/lib/algolia/models/ingestion/platform.rb +2 -1
  57. data/lib/algolia/models/ingestion/run.rb +7 -7
  58. data/lib/algolia/models/ingestion/run_response.rb +3 -3
  59. data/lib/algolia/models/ingestion/schedule_date_utils_input.rb +2 -2
  60. data/lib/algolia/models/ingestion/schedule_trigger.rb +4 -4
  61. data/lib/algolia/models/ingestion/schedule_trigger_input.rb +2 -2
  62. data/lib/algolia/models/ingestion/source.rb +4 -4
  63. data/lib/algolia/models/ingestion/source_big_commerce.rb +1 -1
  64. data/lib/algolia/models/ingestion/source_big_query.rb +5 -5
  65. data/lib/algolia/models/ingestion/source_commercetools.rb +2 -2
  66. data/lib/algolia/models/ingestion/source_create.rb +2 -1
  67. data/lib/algolia/models/ingestion/source_create_response.rb +3 -2
  68. data/lib/algolia/models/ingestion/source_csv.rb +3 -3
  69. data/lib/algolia/models/ingestion/source_docker.rb +3 -3
  70. data/lib/algolia/models/ingestion/source_ga4_big_query_export.rb +3 -3
  71. data/lib/algolia/models/ingestion/source_json.rb +2 -2
  72. data/lib/algolia/models/ingestion/source_type.rb +5 -3
  73. data/lib/algolia/models/ingestion/source_update.rb +2 -1
  74. data/lib/algolia/models/ingestion/source_update_commercetools.rb +2 -3
  75. data/lib/algolia/models/ingestion/source_update_docker.rb +3 -3
  76. data/lib/algolia/models/ingestion/source_update_response.rb +3 -2
  77. data/lib/algolia/models/ingestion/streaming_trigger.rb +1 -1
  78. data/lib/algolia/models/ingestion/streaming_utils_input.rb +1 -1
  79. data/lib/algolia/models/ingestion/subscription_trigger.rb +1 -1
  80. data/lib/algolia/models/ingestion/task.rb +7 -7
  81. data/lib/algolia/models/ingestion/task_create.rb +5 -5
  82. data/lib/algolia/models/ingestion/task_create_response.rb +3 -3
  83. data/lib/algolia/models/ingestion/task_input.rb +1 -0
  84. data/lib/algolia/models/ingestion/task_update.rb +4 -4
  85. data/lib/algolia/models/ingestion/task_update_response.rb +3 -3
  86. data/lib/algolia/models/ingestion/trigger.rb +1 -0
  87. data/lib/algolia/models/ingestion/trigger_update_input.rb +2 -2
  88. data/lib/algolia/models/ingestion/window.rb +3 -3
  89. data/lib/algolia/models/insights/added_to_cart_object_ids.rb +1 -1
  90. data/lib/algolia/models/insights/added_to_cart_object_ids_after_search.rb +1 -1
  91. data/lib/algolia/models/insights/clicked_filters.rb +1 -1
  92. data/lib/algolia/models/insights/clicked_object_ids.rb +1 -1
  93. data/lib/algolia/models/insights/clicked_object_ids_after_search.rb +1 -1
  94. data/lib/algolia/models/insights/converted_filters.rb +1 -1
  95. data/lib/algolia/models/insights/converted_object_ids.rb +1 -1
  96. data/lib/algolia/models/insights/converted_object_ids_after_search.rb +1 -1
  97. data/lib/algolia/models/insights/purchased_object_ids.rb +1 -1
  98. data/lib/algolia/models/insights/purchased_object_ids_after_search.rb +3 -1
  99. data/lib/algolia/models/insights/viewed_filters.rb +1 -1
  100. data/lib/algolia/models/insights/viewed_object_ids.rb +1 -1
  101. data/lib/algolia/models/monitoring/{get_inventory403_response.rb → get_servers403_response.rb} +3 -3
  102. data/lib/algolia/models/monitoring/incidents_inner.rb +1 -1
  103. data/lib/algolia/models/monitoring/probes_metric.rb +1 -1
  104. data/lib/algolia/models/monitoring/server.rb +2 -2
  105. data/lib/algolia/models/monitoring/time_inner.rb +1 -1
  106. data/lib/algolia/models/query-suggestions/app_id.rb +197 -0
  107. data/lib/algolia/models/query-suggestions/get_config_status200_response.rb +4 -4
  108. data/lib/algolia/models/query-suggestions/get_log_file200_response.rb +2 -2
  109. data/lib/algolia/models/query-suggestions/languages.rb +1 -1
  110. data/lib/algolia/models/query-suggestions/query_suggestions_configuration.rb +2 -3
  111. data/lib/algolia/models/query-suggestions/query_suggestions_configuration_response.rb +23 -34
  112. data/lib/algolia/models/query-suggestions/query_suggestions_configuration_with_index.rb +18 -20
  113. data/lib/algolia/models/query-suggestions/source_index.rb +3 -5
  114. data/lib/algolia/models/recommend/auto_facet_filter.rb +208 -0
  115. data/lib/algolia/models/recommend/base_recommend_request.rb +36 -7
  116. data/lib/algolia/models/recommend/base_search_params.rb +1 -1
  117. data/lib/algolia/models/recommend/base_search_params_without_query.rb +1 -1
  118. data/lib/algolia/models/recommend/bought_together_query.rb +319 -0
  119. data/lib/algolia/models/recommend/condition.rb +12 -62
  120. data/lib/algolia/models/recommend/consequence.rb +32 -54
  121. data/lib/algolia/models/recommend/deleted_at_response.rb +1 -1
  122. data/lib/algolia/models/recommend/{recommended_for_you_query_parameters.rb → fallback_params.rb} +9 -12
  123. data/lib/algolia/models/recommend/{edit_type.rb → fbt_model.rb} +5 -6
  124. data/lib/algolia/models/recommend/{base_trending_facets_query.rb → frequently_bought_together.rb} +20 -18
  125. data/lib/algolia/models/recommend/get_recommendations_params.rb +2 -2
  126. data/lib/algolia/models/recommend/{consequence_hide.rb → hide_consequence_object.rb} +4 -6
  127. data/lib/algolia/models/recommend/index_settings_as_search_params.rb +5 -5
  128. data/lib/algolia/models/recommend/{base_recommendations_query.rb → looking_similar.rb} +6 -15
  129. data/lib/algolia/models/recommend/{anchoring.rb → looking_similar_model.rb} +5 -8
  130. data/lib/algolia/models/recommend/looking_similar_query.rb +328 -0
  131. data/lib/algolia/models/recommend/{params.rb → params_consequence.rb} +26 -28
  132. data/lib/algolia/models/recommend/{promote_object_id.rb → promote_consequence_object.rb} +19 -9
  133. data/lib/algolia/models/recommend/{rule_response.rb → recommend_rule.rb} +13 -18
  134. data/lib/algolia/models/recommend/{rule_response_metadata.rb → recommend_rule_metadata.rb} +5 -4
  135. data/lib/algolia/models/recommend/recommendations_hits.rb +4 -24
  136. data/lib/algolia/models/recommend/recommendations_request.rb +3 -1
  137. data/lib/algolia/models/recommend/recommendations_results.rb +4 -24
  138. data/lib/algolia/models/recommend/{base_recommended_for_you_query.rb → recommended_for_you.rb} +5 -14
  139. data/lib/algolia/models/recommend/recommended_for_you_query.rb +35 -15
  140. data/lib/algolia/models/recommend/{recommendation_models.rb → related_model.rb} +4 -5
  141. data/lib/algolia/models/recommend/{edit.rb → related_products.rb} +27 -24
  142. data/lib/algolia/models/recommend/{recommendations_query.rb → related_query.rb} +39 -19
  143. data/lib/algolia/models/recommend/{consequence_params.rb → search_params.rb} +25 -44
  144. data/lib/algolia/models/recommend/search_params_object.rb +6 -6
  145. data/lib/algolia/models/recommend/search_recommend_rules_params.rb +58 -10
  146. data/lib/algolia/models/recommend/search_recommend_rules_response.rb +2 -2
  147. data/lib/algolia/models/recommend/trending_facet_hit.rb +2 -2
  148. data/lib/algolia/models/recommend/trending_facets.rb +243 -0
  149. data/lib/algolia/models/recommend/trending_facets_query.rb +50 -10
  150. data/lib/algolia/models/recommend/{base_trending_items_query.rb → trending_items.rb} +12 -15
  151. data/lib/algolia/models/recommend/trending_items_query.rb +42 -16
  152. data/lib/algolia/models/search/add_api_key_response.rb +1 -1
  153. data/lib/algolia/models/search/base_get_api_key_response.rb +1 -1
  154. data/lib/algolia/models/search/base_index_settings.rb +4 -4
  155. data/lib/algolia/models/search/base_search_params.rb +1 -1
  156. data/lib/algolia/models/search/base_search_params_without_query.rb +1 -1
  157. data/lib/algolia/models/search/browse_params_object.rb +6 -6
  158. data/lib/algolia/models/search/consequence_params.rb +6 -6
  159. data/lib/algolia/models/search/created_at_response.rb +1 -1
  160. data/lib/algolia/models/search/delete_api_key_response.rb +1 -1
  161. data/lib/algolia/models/search/delete_by_params.rb +1 -1
  162. data/lib/algolia/models/search/delete_source_response.rb +1 -1
  163. data/lib/algolia/models/search/deleted_at_response.rb +1 -1
  164. data/lib/algolia/models/search/fetched_index.rb +1 -1
  165. data/lib/algolia/models/search/get_api_key_response.rb +1 -1
  166. data/lib/algolia/models/search/index_settings.rb +9 -9
  167. data/lib/algolia/models/search/index_settings_as_search_params.rb +5 -5
  168. data/lib/algolia/models/search/log.rb +1 -1
  169. data/lib/algolia/models/search/remove_user_id_response.rb +1 -1
  170. data/lib/algolia/models/search/replace_source_response.rb +1 -1
  171. data/lib/algolia/models/search/save_object_response.rb +1 -1
  172. data/lib/algolia/models/search/save_synonym_response.rb +1 -1
  173. data/lib/algolia/models/search/search_for_facets.rb +6 -6
  174. data/lib/algolia/models/search/search_for_hits.rb +6 -6
  175. data/lib/algolia/models/search/search_params_object.rb +6 -6
  176. data/lib/algolia/models/search/search_user_ids_response.rb +1 -1
  177. data/lib/algolia/models/search/secured_api_key_restrictions.rb +1 -1
  178. data/lib/algolia/models/search/update_api_key_response.rb +1 -1
  179. data/lib/algolia/models/search/updated_at_response.rb +1 -1
  180. data/lib/algolia/models/search/updated_at_with_object_id_response.rb +1 -1
  181. data/lib/algolia/models/search/updated_rule_response.rb +1 -1
  182. data/lib/algolia/models/search/user_hit.rb +1 -1
  183. data/lib/algolia/models/search/user_id.rb +1 -1
  184. data/lib/algolia/models/usage/error_base.rb +205 -0
  185. data/lib/algolia/models/usage/get_usage200_response.rb +198 -0
  186. data/lib/algolia/models/usage/get_usage200_response_statistics_inner.rb +206 -0
  187. data/lib/algolia/models/{recommend/base_recommended_for_you_query_parameters.rb → usage/get_usage400_response.rb} +13 -14
  188. data/lib/algolia/models/usage/get_usage400_response_error.rb +216 -0
  189. data/lib/algolia/models/usage/get_usage400_response_error_errors_inner.rb +225 -0
  190. data/lib/algolia/models/usage/granularity.rb +33 -0
  191. data/lib/algolia/models/usage/statistic.rb +116 -0
  192. data/lib/algolia/models/{recommend/promote.rb → usage/statistic_value.rb} +5 -5
  193. data/lib/algolia/version.rb +1 -1
  194. metadata +37 -26
  195. data/lib/algolia/models/recommend/automatic_facet_filter.rb +0 -220
  196. data/lib/algolia/models/recommend/automatic_facet_filters.rb +0 -97
  197. data/lib/algolia/models/recommend/consequence_query.rb +0 -97
  198. data/lib/algolia/models/recommend/promote_object_ids.rb +0 -228
@@ -0,0 +1,208 @@
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 Recommend
8
+ # Facet attribute. Only recommendations with the same value (or only recommendations with a different value) as the original viewed item are included.
9
+ class AutoFacetFilter
10
+ # Facet attribute.
11
+ attr_accessor :facet
12
+
13
+ # Whether the filter is negative. If true, recommendations must not have the same value for the `facet` attribute. If false, recommendations must have the same value for the `facet` attribute.
14
+ attr_accessor :negative
15
+
16
+ # Attribute mapping from ruby-style variable name to JSON key.
17
+ def self.attribute_map
18
+ {
19
+ :facet => :facet,
20
+ :negative => :negative
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
+ :facet => :String,
33
+ :negative => :Boolean
34
+ }
35
+ end
36
+
37
+ # List of attributes with nullable: true
38
+ def self.openapi_nullable
39
+ Set.new([])
40
+ end
41
+
42
+ # Initializes the object
43
+ # @param [Hash] attributes Model attributes in the form of hash
44
+ def initialize(attributes = {})
45
+ unless attributes.is_a?(Hash)
46
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::AutoFacetFilter` initialize method"
47
+ end
48
+
49
+ # check to see if the attribute exists and convert string to symbol for hash key
50
+ attributes = attributes.each_with_object({}) do |(k, v), h|
51
+ unless self.class.attribute_map.key?(k.to_sym)
52
+ raise ArgumentError,
53
+ "`#{k}` is not a valid attribute in `Algolia::AutoFacetFilter`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
54
+ end
55
+
56
+ h[k.to_sym] = v
57
+ end
58
+
59
+ if attributes.key?(:facet)
60
+ self.facet = attributes[:facet]
61
+ end
62
+
63
+ if attributes.key?(:negative)
64
+ self.negative = attributes[:negative]
65
+ end
66
+ end
67
+
68
+ # Checks equality by comparing each attribute.
69
+ # @param [Object] Object to be compared
70
+ def ==(other)
71
+ return true if equal?(other)
72
+
73
+ self.class == other.class &&
74
+ facet == other.facet &&
75
+ negative == other.negative
76
+ end
77
+
78
+ # @see the `==` method
79
+ # @param [Object] Object to be compared
80
+ def eql?(other)
81
+ self == other
82
+ end
83
+
84
+ # Calculates hash code according to all attributes.
85
+ # @return [Integer] Hash code
86
+ def hash
87
+ [facet, negative].hash
88
+ end
89
+
90
+ # Builds the object from hash
91
+ # @param [Hash] attributes Model attributes in the form of hash
92
+ # @return [Object] Returns the model itself
93
+ def self.build_from_hash(attributes)
94
+ return nil unless attributes.is_a?(Hash)
95
+
96
+ attributes = attributes.transform_keys(&:to_sym)
97
+ transformed_hash = {}
98
+ types_mapping.each_pair do |key, type|
99
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
100
+ transformed_hash[key.to_sym] = nil
101
+ elsif type =~ /\AArray<(.*)>/i
102
+ # check to ensure the input is an array given that the attribute
103
+ # is documented as an array but the input is not
104
+ if attributes[attribute_map[key]].is_a?(Array)
105
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
106
+ end
107
+ elsif !attributes[attribute_map[key]].nil?
108
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
109
+ end
110
+ end
111
+ new(transformed_hash)
112
+ end
113
+
114
+ # Deserializes the data based on type
115
+ # @param string type Data type
116
+ # @param string value Value to be deserialized
117
+ # @return [Object] Deserialized data
118
+ def self._deserialize(type, value)
119
+ case type.to_sym
120
+ when :Time
121
+ Time.parse(value)
122
+ when :Date
123
+ Date.parse(value)
124
+ when :String
125
+ value.to_s
126
+ when :Integer
127
+ value.to_i
128
+ when :Float
129
+ value.to_f
130
+ when :Boolean
131
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
132
+ true
133
+ else
134
+ false
135
+ end
136
+ when :Object
137
+ # generic object (usually a Hash), return directly
138
+ value
139
+ when /\AArray<(?<inner_type>.+)>\z/
140
+ inner_type = Regexp.last_match[:inner_type]
141
+ value.map { |v| _deserialize(inner_type, v) }
142
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
143
+ k_type = Regexp.last_match[:k_type]
144
+ v_type = Regexp.last_match[:v_type]
145
+ {}.tap do |hash|
146
+ value.each do |k, v|
147
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
148
+ end
149
+ end
150
+ else # model
151
+ # models (e.g. Pet) or oneOf
152
+ klass = Algolia::Recommend.const_get(type)
153
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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
+ hash
187
+ end
188
+
189
+ # Outputs non-array value in the form of hash
190
+ # For object, use to_hash. Otherwise, just return the value
191
+ # @param [Object] value Any valid value
192
+ # @return [Hash] Returns the value in the form of hash
193
+ def _to_hash(value)
194
+ if value.is_a?(Array)
195
+ value.compact.map { |v| _to_hash(v) }
196
+ elsif value.is_a?(Hash)
197
+ {}.tap do |hash|
198
+ value.each { |k, v| hash[k] = _to_hash(v) }
199
+ end
200
+ elsif value.respond_to? :to_hash
201
+ value.to_hash
202
+ else
203
+ value
204
+ end
205
+ end
206
+ end
207
+ end
208
+ end
@@ -9,18 +9,21 @@ module Algolia
9
9
  # Index name.
10
10
  attr_accessor :index_name
11
11
 
12
- # Recommendations with a confidence score lower than `threshold` won't appear in results. > **Note**: Each recommendation has a confidence score of 0 to 100. The closer the score is to 100, the more relevant the recommendations are.
12
+ # Minimum score a recommendation must have to be included in the response.
13
13
  attr_accessor :threshold
14
14
 
15
- # Maximum number of recommendations to retrieve. If 0, all recommendations will be returned.
15
+ # Maximum number of recommendations to retrieve. By default, all recommendations are returned and no fallback request is made. Depending on the available recommendations and the other request parameters, the actual number of recommendations may be lower than this value.
16
16
  attr_accessor :max_recommendations
17
17
 
18
+ attr_accessor :query_parameters
19
+
18
20
  # Attribute mapping from ruby-style variable name to JSON key.
19
21
  def self.attribute_map
20
22
  {
21
23
  :index_name => :indexName,
22
24
  :threshold => :threshold,
23
- :max_recommendations => :maxRecommendations
25
+ :max_recommendations => :maxRecommendations,
26
+ :query_parameters => :queryParameters
24
27
  }
25
28
  end
26
29
 
@@ -33,8 +36,9 @@ module Algolia
33
36
  def self.types_mapping
34
37
  {
35
38
  :index_name => :String,
36
- :threshold => :Integer,
37
- :max_recommendations => :Integer
39
+ :threshold => :Float,
40
+ :max_recommendations => :Integer,
41
+ :query_parameters => :SearchParams
38
42
  }
39
43
  end
40
44
 
@@ -68,11 +72,17 @@ module Algolia
68
72
 
69
73
  if attributes.key?(:threshold)
70
74
  self.threshold = attributes[:threshold]
75
+ else
76
+ self.threshold = nil
71
77
  end
72
78
 
73
79
  if attributes.key?(:max_recommendations)
74
80
  self.max_recommendations = attributes[:max_recommendations]
75
81
  end
82
+
83
+ if attributes.key?(:query_parameters)
84
+ self.query_parameters = attributes[:query_parameters]
85
+ end
76
86
  end
77
87
 
78
88
  # Custom attribute writer method with validation
@@ -93,6 +103,24 @@ module Algolia
93
103
  @threshold = threshold
94
104
  end
95
105
 
106
+ # Custom attribute writer method with validation
107
+ # @param [Object] max_recommendations Value to be assigned
108
+ def max_recommendations=(max_recommendations)
109
+ if max_recommendations.nil?
110
+ raise ArgumentError, 'max_recommendations cannot be nil'
111
+ end
112
+
113
+ if max_recommendations > 1000
114
+ raise ArgumentError, 'invalid value for "max_recommendations", must be smaller than or equal to 1000.'
115
+ end
116
+
117
+ if max_recommendations < 1
118
+ raise ArgumentError, 'invalid value for "max_recommendations", must be greater than or equal to 1.'
119
+ end
120
+
121
+ @max_recommendations = max_recommendations
122
+ end
123
+
96
124
  # Checks equality by comparing each attribute.
97
125
  # @param [Object] Object to be compared
98
126
  def ==(other)
@@ -101,7 +129,8 @@ module Algolia
101
129
  self.class == other.class &&
102
130
  index_name == other.index_name &&
103
131
  threshold == other.threshold &&
104
- max_recommendations == other.max_recommendations
132
+ max_recommendations == other.max_recommendations &&
133
+ query_parameters == other.query_parameters
105
134
  end
106
135
 
107
136
  # @see the `==` method
@@ -113,7 +142,7 @@ module Algolia
113
142
  # Calculates hash code according to all attributes.
114
143
  # @return [Integer] Hash code
115
144
  def hash
116
- [index_name, threshold, max_recommendations].hash
145
+ [index_name, threshold, max_recommendations, query_parameters].hash
117
146
  end
118
147
 
119
148
  # Builds the object from hash
@@ -12,7 +12,7 @@ module Algolia
12
12
  # Keywords to be used instead of the search query to conduct a more broader search. Using the `similarQuery` parameter changes other settings: - `queryType` is set to `prefixNone`. - `removeStopWords` is set to true. - `words` is set as the first ranking criterion. - All remaining words are treated as `optionalWords`. Since the `similarQuery` is supposed to do a broad search, they usually return many results. Combine it with `filters` to narrow down the list of results.
13
13
  attr_accessor :similar_query
14
14
 
15
- # Filter the search so that only records with matching values are included in the results. These filters are supported: - **Numeric filters.** `<facet> <op> <number>`, where `<op>` is one of `<`, `<=`, `=`, `!=`, `>`, `>=`. - **Ranges.** `<facet>:<lower> TO <upper>` where `<lower>` and `<upper>` are the lower and upper limits of the range (inclusive). - **Facet filters.** `<facet>:<value>` where `<facet>` is a facet attribute (case-sensitive) and `<value>` a facet value. - **Tag filters.** `_tags:<value>` or just `<value>` (case-sensitive). - **Boolean filters.** `<facet>: true | false`. You can combine filters with `AND`, `OR`, and `NOT` operators with the following restrictions: - You can only combine filters of the same type with `OR`. **Not supported:** `facet:value OR num > 3`. - You can't use `NOT` with combinations of filters. **Not supported:** `NOT(facet:value OR facet:value)` - You can't combine conjunctions (`AND`) with `OR`. **Not supported:** `facet:value OR (facet:value AND facet:value)` Use quotes around your filters, if the facet attribute name or facet value has spaces, keywords (`OR`, `AND`, `NOT`), or quotes. If a facet attribute is an array, the filter matches if it matches at least one element of the array. For more information, see [Filters](https://www.algolia.com/doc/guides/managing-results/refine-results/filtering/).
15
+ # Filter expression to only include items that match the filter criteria in the response. You can use these filter expressions: - **Numeric filters.** `<facet> <op> <number>`, where `<op>` is one of `<`, `<=`, `=`, `!=`, `>`, `>=`. - **Ranges.** `<facet>:<lower> TO <upper>` where `<lower>` and `<upper>` are the lower and upper limits of the range (inclusive). - **Facet filters.** `<facet>:<value>` where `<facet>` is a facet attribute (case-sensitive) and `<value>` a facet value. - **Tag filters.** `_tags:<value>` or just `<value>` (case-sensitive). - **Boolean filters.** `<facet>: true | false`. You can combine filters with `AND`, `OR`, and `NOT` operators with the following restrictions: - You can only combine filters of the same type with `OR`. **Not supported:** `facet:value OR num > 3`. - You can't use `NOT` with combinations of filters. **Not supported:** `NOT(facet:value OR facet:value)` - You can't combine conjunctions (`AND`) with `OR`. **Not supported:** `facet:value OR (facet:value AND facet:value)` Use quotes around your filters, if the facet attribute name or facet value has spaces, keywords (`OR`, `AND`, `NOT`), or quotes. If a facet attribute is an array, the filter matches if it matches at least one element of the array. For more information, see [Filters](https://www.algolia.com/doc/guides/managing-results/refine-results/filtering/).
16
16
  attr_accessor :filters
17
17
 
18
18
  attr_accessor :facet_filters
@@ -9,7 +9,7 @@ module Algolia
9
9
  # Keywords to be used instead of the search query to conduct a more broader search. Using the `similarQuery` parameter changes other settings: - `queryType` is set to `prefixNone`. - `removeStopWords` is set to true. - `words` is set as the first ranking criterion. - All remaining words are treated as `optionalWords`. Since the `similarQuery` is supposed to do a broad search, they usually return many results. Combine it with `filters` to narrow down the list of results.
10
10
  attr_accessor :similar_query
11
11
 
12
- # Filter the search so that only records with matching values are included in the results. These filters are supported: - **Numeric filters.** `<facet> <op> <number>`, where `<op>` is one of `<`, `<=`, `=`, `!=`, `>`, `>=`. - **Ranges.** `<facet>:<lower> TO <upper>` where `<lower>` and `<upper>` are the lower and upper limits of the range (inclusive). - **Facet filters.** `<facet>:<value>` where `<facet>` is a facet attribute (case-sensitive) and `<value>` a facet value. - **Tag filters.** `_tags:<value>` or just `<value>` (case-sensitive). - **Boolean filters.** `<facet>: true | false`. You can combine filters with `AND`, `OR`, and `NOT` operators with the following restrictions: - You can only combine filters of the same type with `OR`. **Not supported:** `facet:value OR num > 3`. - You can't use `NOT` with combinations of filters. **Not supported:** `NOT(facet:value OR facet:value)` - You can't combine conjunctions (`AND`) with `OR`. **Not supported:** `facet:value OR (facet:value AND facet:value)` Use quotes around your filters, if the facet attribute name or facet value has spaces, keywords (`OR`, `AND`, `NOT`), or quotes. If a facet attribute is an array, the filter matches if it matches at least one element of the array. For more information, see [Filters](https://www.algolia.com/doc/guides/managing-results/refine-results/filtering/).
12
+ # Filter expression to only include items that match the filter criteria in the response. You can use these filter expressions: - **Numeric filters.** `<facet> <op> <number>`, where `<op>` is one of `<`, `<=`, `=`, `!=`, `>`, `>=`. - **Ranges.** `<facet>:<lower> TO <upper>` where `<lower>` and `<upper>` are the lower and upper limits of the range (inclusive). - **Facet filters.** `<facet>:<value>` where `<facet>` is a facet attribute (case-sensitive) and `<value>` a facet value. - **Tag filters.** `_tags:<value>` or just `<value>` (case-sensitive). - **Boolean filters.** `<facet>: true | false`. You can combine filters with `AND`, `OR`, and `NOT` operators with the following restrictions: - You can only combine filters of the same type with `OR`. **Not supported:** `facet:value OR num > 3`. - You can't use `NOT` with combinations of filters. **Not supported:** `NOT(facet:value OR facet:value)` - You can't combine conjunctions (`AND`) with `OR`. **Not supported:** `facet:value OR (facet:value AND facet:value)` Use quotes around your filters, if the facet attribute name or facet value has spaces, keywords (`OR`, `AND`, `NOT`), or quotes. If a facet attribute is an array, the filter matches if it matches at least one element of the array. For more information, see [Filters](https://www.algolia.com/doc/guides/managing-results/refine-results/filtering/).
13
13
  attr_accessor :filters
14
14
 
15
15
  attr_accessor :facet_filters
@@ -0,0 +1,319 @@
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 Recommend
8
+ class BoughtTogetherQuery
9
+ # Index name.
10
+ attr_accessor :index_name
11
+
12
+ # Minimum score a recommendation must have to be included in the response.
13
+ attr_accessor :threshold
14
+
15
+ # Maximum number of recommendations to retrieve. By default, all recommendations are returned and no fallback request is made. Depending on the available recommendations and the other request parameters, the actual number of recommendations may be lower than this value.
16
+ attr_accessor :max_recommendations
17
+
18
+ attr_accessor :query_parameters
19
+
20
+ attr_accessor :model
21
+
22
+ # Unique record identifier.
23
+ attr_accessor :object_id
24
+
25
+ class EnumAttributeValidator
26
+ attr_reader :datatype
27
+ attr_reader :allowable_values
28
+
29
+ def initialize(datatype, allowable_values)
30
+ @allowable_values = allowable_values.map do |value|
31
+ case datatype.to_s
32
+ when /Integer/i
33
+ value.to_i
34
+ when /Float/i
35
+ value.to_f
36
+ else
37
+ value
38
+ end
39
+ end
40
+ end
41
+
42
+ def valid?(value)
43
+ !value || allowable_values.include?(value)
44
+ end
45
+ end
46
+
47
+ # Attribute mapping from ruby-style variable name to JSON key.
48
+ def self.attribute_map
49
+ {
50
+ :index_name => :indexName,
51
+ :threshold => :threshold,
52
+ :max_recommendations => :maxRecommendations,
53
+ :query_parameters => :queryParameters,
54
+ :model => :model,
55
+ :object_id => :objectID
56
+ }
57
+ end
58
+
59
+ # Returns all the JSON keys this model knows about
60
+ def self.acceptable_attributes
61
+ attribute_map.values
62
+ end
63
+
64
+ # Attribute type mapping.
65
+ def self.types_mapping
66
+ {
67
+ :index_name => :String,
68
+ :threshold => :Float,
69
+ :max_recommendations => :Integer,
70
+ :query_parameters => :SearchParams,
71
+ :model => :FbtModel,
72
+ :object_id => :String
73
+ }
74
+ end
75
+
76
+ # List of attributes with nullable: true
77
+ def self.openapi_nullable
78
+ Set.new([])
79
+ end
80
+
81
+ # List of class defined in allOf (OpenAPI v3)
82
+ def self.openapi_all_of
83
+ [
84
+ :BaseRecommendRequest,
85
+ :FrequentlyBoughtTogether
86
+ ]
87
+ end
88
+
89
+ # Initializes the object
90
+ # @param [Hash] attributes Model attributes in the form of hash
91
+ def initialize(attributes = {})
92
+ unless attributes.is_a?(Hash)
93
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::BoughtTogetherQuery` initialize method"
94
+ end
95
+
96
+ # check to see if the attribute exists and convert string to symbol for hash key
97
+ attributes = attributes.each_with_object({}) do |(k, v), h|
98
+ unless self.class.attribute_map.key?(k.to_sym)
99
+ raise ArgumentError,
100
+ "`#{k}` is not a valid attribute in `Algolia::BoughtTogetherQuery`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
101
+ end
102
+
103
+ h[k.to_sym] = v
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?(:threshold)
113
+ self.threshold = attributes[:threshold]
114
+ else
115
+ self.threshold = nil
116
+ end
117
+
118
+ if attributes.key?(:max_recommendations)
119
+ self.max_recommendations = attributes[:max_recommendations]
120
+ end
121
+
122
+ if attributes.key?(:query_parameters)
123
+ self.query_parameters = attributes[:query_parameters]
124
+ end
125
+
126
+ if attributes.key?(:model)
127
+ self.model = attributes[:model]
128
+ else
129
+ self.model = nil
130
+ end
131
+
132
+ if attributes.key?(:object_id)
133
+ self.object_id = attributes[:object_id]
134
+ else
135
+ self.object_id = nil
136
+ end
137
+ end
138
+
139
+ # Custom attribute writer method with validation
140
+ # @param [Object] threshold Value to be assigned
141
+ def threshold=(threshold)
142
+ if threshold.nil?
143
+ raise ArgumentError, 'threshold cannot be nil'
144
+ end
145
+
146
+ if threshold > 100
147
+ raise ArgumentError, 'invalid value for "threshold", must be smaller than or equal to 100.'
148
+ end
149
+
150
+ if threshold < 0
151
+ raise ArgumentError, 'invalid value for "threshold", must be greater than or equal to 0.'
152
+ end
153
+
154
+ @threshold = threshold
155
+ end
156
+
157
+ # Custom attribute writer method with validation
158
+ # @param [Object] max_recommendations Value to be assigned
159
+ def max_recommendations=(max_recommendations)
160
+ if max_recommendations.nil?
161
+ raise ArgumentError, 'max_recommendations cannot be nil'
162
+ end
163
+
164
+ if max_recommendations > 1000
165
+ raise ArgumentError, 'invalid value for "max_recommendations", must be smaller than or equal to 1000.'
166
+ end
167
+
168
+ if max_recommendations < 1
169
+ raise ArgumentError, 'invalid value for "max_recommendations", must be greater than or equal to 1.'
170
+ end
171
+
172
+ @max_recommendations = max_recommendations
173
+ end
174
+
175
+ # Checks equality by comparing each attribute.
176
+ # @param [Object] Object to be compared
177
+ def ==(other)
178
+ return true if equal?(other)
179
+
180
+ self.class == other.class &&
181
+ index_name == other.index_name &&
182
+ threshold == other.threshold &&
183
+ max_recommendations == other.max_recommendations &&
184
+ query_parameters == other.query_parameters &&
185
+ model == other.model &&
186
+ object_id == other.object_id
187
+ end
188
+
189
+ # @see the `==` method
190
+ # @param [Object] Object to be compared
191
+ def eql?(other)
192
+ self == other
193
+ end
194
+
195
+ # Calculates hash code according to all attributes.
196
+ # @return [Integer] Hash code
197
+ def hash
198
+ [index_name, threshold, max_recommendations, query_parameters, model, object_id].hash
199
+ end
200
+
201
+ # Builds the object from hash
202
+ # @param [Hash] attributes Model attributes in the form of hash
203
+ # @return [Object] Returns the model itself
204
+ def self.build_from_hash(attributes)
205
+ return nil unless attributes.is_a?(Hash)
206
+
207
+ attributes = attributes.transform_keys(&:to_sym)
208
+ transformed_hash = {}
209
+ types_mapping.each_pair do |key, type|
210
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
211
+ transformed_hash[key.to_sym] = nil
212
+ elsif type =~ /\AArray<(.*)>/i
213
+ # check to ensure the input is an array given that the attribute
214
+ # is documented as an array but the input is not
215
+ if attributes[attribute_map[key]].is_a?(Array)
216
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
217
+ end
218
+ elsif !attributes[attribute_map[key]].nil?
219
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
220
+ end
221
+ end
222
+ new(transformed_hash)
223
+ end
224
+
225
+ # Deserializes the data based on type
226
+ # @param string type Data type
227
+ # @param string value Value to be deserialized
228
+ # @return [Object] Deserialized data
229
+ def self._deserialize(type, value)
230
+ case type.to_sym
231
+ when :Time
232
+ Time.parse(value)
233
+ when :Date
234
+ Date.parse(value)
235
+ when :String
236
+ value.to_s
237
+ when :Integer
238
+ value.to_i
239
+ when :Float
240
+ value.to_f
241
+ when :Boolean
242
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
243
+ true
244
+ else
245
+ false
246
+ end
247
+ when :Object
248
+ # generic object (usually a Hash), return directly
249
+ value
250
+ when /\AArray<(?<inner_type>.+)>\z/
251
+ inner_type = Regexp.last_match[:inner_type]
252
+ value.map { |v| _deserialize(inner_type, v) }
253
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
254
+ k_type = Regexp.last_match[:k_type]
255
+ v_type = Regexp.last_match[:v_type]
256
+ {}.tap do |hash|
257
+ value.each do |k, v|
258
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
259
+ end
260
+ end
261
+ else # model
262
+ # models (e.g. Pet) or oneOf
263
+ klass = Algolia::Recommend.const_get(type)
264
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
265
+ end
266
+ end
267
+
268
+ # Returns the string representation of the object
269
+ # @return [String] String presentation of the object
270
+ def to_s
271
+ to_hash.to_s
272
+ end
273
+
274
+ # to_body is an alias to to_hash (backward compatibility)
275
+ # @return [Hash] Returns the object in the form of hash
276
+ def to_body
277
+ to_hash
278
+ end
279
+
280
+ def to_json(*_args)
281
+ to_hash.to_json
282
+ end
283
+
284
+ # Returns the object in the form of hash
285
+ # @return [Hash] Returns the object in the form of hash
286
+ def to_hash
287
+ hash = {}
288
+ self.class.attribute_map.each_pair do |attr, param|
289
+ value = send(attr)
290
+ if value.nil?
291
+ is_nullable = self.class.openapi_nullable.include?(attr)
292
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
293
+ end
294
+
295
+ hash[param] = _to_hash(value)
296
+ end
297
+ hash
298
+ end
299
+
300
+ # Outputs non-array value in the form of hash
301
+ # For object, use to_hash. Otherwise, just return the value
302
+ # @param [Object] value Any valid value
303
+ # @return [Hash] Returns the value in the form of hash
304
+ def _to_hash(value)
305
+ if value.is_a?(Array)
306
+ value.compact.map { |v| _to_hash(v) }
307
+ elsif value.is_a?(Hash)
308
+ {}.tap do |hash|
309
+ value.each { |k, v| hash[k] = _to_hash(v) }
310
+ end
311
+ elsif value.respond_to? :to_hash
312
+ value.to_hash
313
+ else
314
+ value
315
+ end
316
+ end
317
+ end
318
+ end
319
+ end