algolia 3.0.0.alpha.16 → 3.0.0.alpha.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. checksums.yaml +4 -4
  2. data/.openapi-generator/FILES +10 -167
  3. data/CHANGELOG.md +16 -0
  4. data/Gemfile.lock +4 -4
  5. data/lib/algolia/api/abtesting_client.rb +20 -20
  6. data/lib/algolia/api/analytics_client.rb +76 -76
  7. data/lib/algolia/api/personalization_client.rb +12 -12
  8. data/lib/algolia/api/recommend_client.rb +22 -22
  9. data/lib/algolia/api/search_client.rb +8 -8
  10. data/lib/algolia/api/usage_client.rb +329 -0
  11. data/lib/algolia/models/abtesting/ab_test.rb +41 -16
  12. data/lib/algolia/models/abtesting/ab_test_configuration.rb +217 -0
  13. data/lib/algolia/models/abtesting/ab_test_response.rb +2 -2
  14. data/lib/algolia/models/abtesting/ab_tests_variant.rb +21 -3
  15. data/lib/algolia/models/abtesting/ab_tests_variant_search_params.rb +21 -3
  16. data/lib/algolia/models/abtesting/add_ab_tests_request.rb +1 -1
  17. data/lib/algolia/models/abtesting/custom_search_params.rb +1 -1
  18. data/lib/algolia/models/abtesting/effect.rb +35 -0
  19. data/lib/algolia/models/abtesting/empty_search.rb +198 -0
  20. data/lib/algolia/models/abtesting/list_ab_tests_response.rb +1 -1
  21. data/lib/algolia/models/abtesting/minimum_detectable_effect.rb +247 -0
  22. data/lib/algolia/models/abtesting/outliers.rb +198 -0
  23. data/lib/algolia/models/abtesting/status.rb +35 -0
  24. data/lib/algolia/models/abtesting/variant.rb +31 -13
  25. data/lib/algolia/models/analytics/get_status_response.rb +1 -1
  26. data/lib/algolia/models/ingestion/auth_algolia_insights.rb +212 -0
  27. data/lib/algolia/models/{recommend/consequence_query_object.rb → ingestion/auth_algolia_insights_partial.rb} +21 -24
  28. data/lib/algolia/models/ingestion/auth_input.rb +1 -0
  29. data/lib/algolia/models/ingestion/auth_input_partial.rb +1 -0
  30. data/lib/algolia/models/ingestion/authentication_type.rb +2 -1
  31. data/lib/algolia/models/ingestion/destination_index_name.rb +1 -1
  32. data/lib/algolia/models/ingestion/shopify_input.rb +212 -0
  33. data/lib/algolia/models/ingestion/shopify_market.rb +227 -0
  34. data/lib/algolia/models/ingestion/shopify_metafield.rb +221 -0
  35. data/lib/algolia/models/ingestion/source_input.rb +2 -1
  36. data/lib/algolia/models/ingestion/source_shopify.rb +278 -0
  37. data/lib/algolia/models/{recommend/base_recommended_for_you_query_parameters.rb → ingestion/source_shopify_base.rb} +14 -14
  38. data/lib/algolia/models/ingestion/source_update_input.rb +2 -1
  39. data/lib/algolia/models/ingestion/source_update_shopify.rb +258 -0
  40. data/lib/algolia/models/ingestion/task_input.rb +1 -0
  41. data/lib/algolia/models/insights/added_to_cart_object_ids.rb +2 -2
  42. data/lib/algolia/models/insights/added_to_cart_object_ids_after_search.rb +2 -2
  43. data/lib/algolia/models/insights/clicked_filters.rb +2 -2
  44. data/lib/algolia/models/insights/clicked_object_ids.rb +2 -2
  45. data/lib/algolia/models/insights/clicked_object_ids_after_search.rb +2 -2
  46. data/lib/algolia/models/insights/converted_filters.rb +2 -2
  47. data/lib/algolia/models/insights/converted_object_ids.rb +2 -2
  48. data/lib/algolia/models/insights/converted_object_ids_after_search.rb +2 -2
  49. data/lib/algolia/models/insights/purchased_object_ids.rb +2 -2
  50. data/lib/algolia/models/insights/purchased_object_ids_after_search.rb +2 -2
  51. data/lib/algolia/models/insights/viewed_filters.rb +2 -2
  52. data/lib/algolia/models/insights/viewed_object_ids.rb +2 -2
  53. data/lib/algolia/models/monitoring/incidents_inner.rb +1 -1
  54. data/lib/algolia/models/monitoring/probes_metric.rb +1 -1
  55. data/lib/algolia/models/monitoring/time_inner.rb +1 -1
  56. data/lib/algolia/models/personalization/delete_user_profile_response.rb +2 -2
  57. data/lib/algolia/models/personalization/event_scoring.rb +25 -4
  58. data/lib/algolia/models/personalization/event_type.rb +34 -0
  59. data/lib/algolia/models/personalization/facet_scoring.rb +2 -2
  60. data/lib/algolia/models/personalization/get_user_token_response.rb +3 -3
  61. data/lib/algolia/models/personalization/personalization_strategy_params.rb +21 -3
  62. data/lib/algolia/models/query-suggestions/get_config_status200_response.rb +3 -3
  63. data/lib/algolia/models/query-suggestions/get_log_file200_response.rb +1 -1
  64. data/lib/algolia/models/query-suggestions/query_suggestions_configuration_response.rb +1 -1
  65. data/lib/algolia/models/query-suggestions/query_suggestions_configuration_with_index.rb +1 -1
  66. data/lib/algolia/models/query-suggestions/source_index.rb +1 -1
  67. data/lib/algolia/models/recommend/auto_facet_filter.rb +208 -0
  68. data/lib/algolia/models/recommend/base_recommend_request.rb +37 -8
  69. data/lib/algolia/models/recommend/base_search_params.rb +4 -4
  70. data/lib/algolia/models/recommend/base_search_params_without_query.rb +4 -4
  71. data/lib/algolia/models/recommend/bought_together_query.rb +319 -0
  72. data/lib/algolia/models/recommend/condition.rb +12 -62
  73. data/lib/algolia/models/recommend/consequence.rb +32 -54
  74. data/lib/algolia/models/recommend/deleted_at_response.rb +1 -1
  75. data/lib/algolia/models/recommend/{recommended_for_you_query_parameters.rb → fallback_params.rb} +17 -20
  76. data/lib/algolia/models/recommend/{edit_type.rb → fbt_model.rb} +5 -6
  77. data/lib/algolia/models/recommend/{base_trending_facets_query.rb → frequently_bought_together.rb} +20 -18
  78. data/lib/algolia/models/recommend/get_recommendations_params.rb +2 -2
  79. data/lib/algolia/models/recommend/{consequence_hide.rb → hide_consequence_object.rb} +4 -6
  80. data/lib/algolia/models/recommend/index_settings_as_search_params.rb +10 -10
  81. data/lib/algolia/models/recommend/{base_recommendations_query.rb → looking_similar.rb} +6 -15
  82. data/lib/algolia/models/recommend/{anchoring.rb → looking_similar_model.rb} +5 -8
  83. data/lib/algolia/models/recommend/looking_similar_query.rb +328 -0
  84. data/lib/algolia/models/recommend/{params.rb → params_consequence.rb} +26 -28
  85. data/lib/algolia/models/recommend/{promote_object_id.rb → promote_consequence_object.rb} +19 -9
  86. data/lib/algolia/models/recommend/re_ranking_apply_filter.rb +1 -1
  87. data/lib/algolia/models/recommend/{rule_response.rb → recommend_rule.rb} +13 -18
  88. data/lib/algolia/models/recommend/{rule_response_metadata.rb → recommend_rule_metadata.rb} +5 -4
  89. data/lib/algolia/models/recommend/recommendations_hits.rb +4 -24
  90. data/lib/algolia/models/recommend/recommendations_request.rb +3 -1
  91. data/lib/algolia/models/recommend/recommendations_results.rb +4 -24
  92. data/lib/algolia/models/recommend/{base_recommended_for_you_query.rb → recommended_for_you.rb} +5 -14
  93. data/lib/algolia/models/recommend/recommended_for_you_query.rb +36 -16
  94. data/lib/algolia/models/recommend/{recommendation_models.rb → related_model.rb} +4 -5
  95. data/lib/algolia/models/recommend/{edit.rb → related_products.rb} +27 -24
  96. data/lib/algolia/models/recommend/{recommendations_query.rb → related_query.rb} +40 -20
  97. data/lib/algolia/models/recommend/{consequence_params.rb → search_params.rb} +33 -52
  98. data/lib/algolia/models/recommend/search_params_object.rb +15 -14
  99. data/lib/algolia/models/recommend/search_recommend_rules_params.rb +58 -10
  100. data/lib/algolia/models/recommend/search_recommend_rules_response.rb +2 -2
  101. data/lib/algolia/models/recommend/trending_facet_hit.rb +2 -2
  102. data/lib/algolia/models/recommend/trending_facets.rb +243 -0
  103. data/lib/algolia/models/recommend/trending_facets_query.rb +51 -11
  104. data/lib/algolia/models/recommend/{base_trending_items_query.rb → trending_items.rb} +12 -15
  105. data/lib/algolia/models/recommend/trending_items_query.rb +43 -17
  106. data/lib/algolia/models/search/add_api_key_response.rb +1 -1
  107. data/lib/algolia/models/search/base_get_api_key_response.rb +1 -1
  108. data/lib/algolia/models/search/base_index_settings.rb +10 -10
  109. data/lib/algolia/models/search/base_search_params.rb +4 -4
  110. data/lib/algolia/models/search/base_search_params_without_query.rb +4 -4
  111. data/lib/algolia/models/search/browse_params_object.rb +14 -14
  112. data/lib/algolia/models/search/consequence_params.rb +14 -14
  113. data/lib/algolia/models/search/created_at_response.rb +1 -1
  114. data/lib/algolia/models/search/delete_api_key_response.rb +1 -1
  115. data/lib/algolia/models/search/delete_by_params.rb +2 -2
  116. data/lib/algolia/models/search/delete_source_response.rb +1 -1
  117. data/lib/algolia/models/search/deleted_at_response.rb +1 -1
  118. data/lib/algolia/models/search/fetched_index.rb +1 -1
  119. data/lib/algolia/models/search/get_api_key_response.rb +1 -1
  120. data/lib/algolia/models/search/index_settings.rb +20 -20
  121. data/lib/algolia/models/search/index_settings_as_search_params.rb +10 -10
  122. data/lib/algolia/models/search/log.rb +1 -1
  123. data/lib/algolia/models/search/multiple_batch_request.rb +1 -1
  124. data/lib/algolia/models/search/operation_index_params.rb +1 -1
  125. data/lib/algolia/models/search/re_ranking_apply_filter.rb +1 -1
  126. data/lib/algolia/models/search/remove_user_id_response.rb +1 -1
  127. data/lib/algolia/models/search/replace_source_response.rb +1 -1
  128. data/lib/algolia/models/search/save_object_response.rb +1 -1
  129. data/lib/algolia/models/search/save_synonym_response.rb +1 -1
  130. data/lib/algolia/models/search/search_for_facets.rb +15 -15
  131. data/lib/algolia/models/search/search_for_facets_options.rb +1 -1
  132. data/lib/algolia/models/search/search_for_hits.rb +15 -15
  133. data/lib/algolia/models/search/search_for_hits_options.rb +1 -1
  134. data/lib/algolia/models/search/search_params_object.rb +15 -14
  135. data/lib/algolia/models/search/search_user_ids_response.rb +1 -1
  136. data/lib/algolia/models/search/secured_api_key_restrictions.rb +1 -1
  137. data/lib/algolia/models/search/update_api_key_response.rb +1 -1
  138. data/lib/algolia/models/search/updated_at_response.rb +1 -1
  139. data/lib/algolia/models/search/updated_at_with_object_id_response.rb +1 -1
  140. data/lib/algolia/models/search/updated_rule_response.rb +1 -1
  141. data/lib/algolia/models/search/user_hit.rb +1 -1
  142. data/lib/algolia/models/search/user_id.rb +1 -1
  143. data/lib/algolia/models/usage/error_base.rb +205 -0
  144. data/lib/algolia/models/usage/get_usage200_response.rb +198 -0
  145. data/lib/algolia/models/usage/get_usage200_response_statistics_inner.rb +206 -0
  146. data/lib/algolia/models/usage/get_usage400_response.rb +198 -0
  147. data/lib/algolia/models/usage/get_usage400_response_error.rb +216 -0
  148. data/lib/algolia/models/usage/get_usage400_response_error_errors_inner.rb +225 -0
  149. data/lib/algolia/models/usage/granularity.rb +33 -0
  150. data/lib/algolia/models/usage/statistic.rb +116 -0
  151. data/lib/algolia/models/{recommend/promote.rb → usage/statistic_value.rb} +5 -5
  152. data/lib/algolia/version.rb +1 -1
  153. metadata +47 -25
  154. data/lib/algolia/models/recommend/automatic_facet_filter.rb +0 -220
  155. data/lib/algolia/models/recommend/automatic_facet_filters.rb +0 -97
  156. data/lib/algolia/models/recommend/consequence_query.rb +0 -97
  157. data/lib/algolia/models/recommend/promote_object_ids.rb +0 -228
@@ -0,0 +1,243 @@
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 TrendingFacets
9
+ # Facet attribute for which to retrieve trending facet values.
10
+ attr_accessor :facet_name
11
+
12
+ attr_accessor :model
13
+
14
+ attr_accessor :fallback_parameters
15
+
16
+ class EnumAttributeValidator
17
+ attr_reader :datatype
18
+ attr_reader :allowable_values
19
+
20
+ def initialize(datatype, allowable_values)
21
+ @allowable_values = allowable_values.map do |value|
22
+ case datatype.to_s
23
+ when /Integer/i
24
+ value.to_i
25
+ when /Float/i
26
+ value.to_f
27
+ else
28
+ value
29
+ end
30
+ end
31
+ end
32
+
33
+ def valid?(value)
34
+ !value || allowable_values.include?(value)
35
+ end
36
+ end
37
+
38
+ # Attribute mapping from ruby-style variable name to JSON key.
39
+ def self.attribute_map
40
+ {
41
+ :facet_name => :facetName,
42
+ :model => :model,
43
+ :fallback_parameters => :fallbackParameters
44
+ }
45
+ end
46
+
47
+ # Returns all the JSON keys this model knows about
48
+ def self.acceptable_attributes
49
+ attribute_map.values
50
+ end
51
+
52
+ # Attribute type mapping.
53
+ def self.types_mapping
54
+ {
55
+ :facet_name => :Object,
56
+ :model => :TrendingFacetsModel,
57
+ :fallback_parameters => :FallbackParams
58
+ }
59
+ end
60
+
61
+ # List of attributes with nullable: true
62
+ def self.openapi_nullable
63
+ Set.new([
64
+ :facet_name
65
+ ])
66
+ end
67
+
68
+ # Initializes the object
69
+ # @param [Hash] attributes Model attributes in the form of hash
70
+ def initialize(attributes = {})
71
+ unless attributes.is_a?(Hash)
72
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::TrendingFacets` initialize method"
73
+ end
74
+
75
+ # check to see if the attribute exists and convert string to symbol for hash key
76
+ attributes = attributes.each_with_object({}) do |(k, v), h|
77
+ unless self.class.attribute_map.key?(k.to_sym)
78
+ raise ArgumentError,
79
+ "`#{k}` is not a valid attribute in `Algolia::TrendingFacets`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
80
+ end
81
+
82
+ h[k.to_sym] = v
83
+ end
84
+
85
+ if attributes.key?(:facet_name)
86
+ self.facet_name = attributes[:facet_name]
87
+ else
88
+ self.facet_name = nil
89
+ end
90
+
91
+ if attributes.key?(:model)
92
+ self.model = attributes[:model]
93
+ else
94
+ self.model = nil
95
+ end
96
+
97
+ if attributes.key?(:fallback_parameters)
98
+ self.fallback_parameters = attributes[:fallback_parameters]
99
+ end
100
+ end
101
+
102
+ # Checks equality by comparing each attribute.
103
+ # @param [Object] Object to be compared
104
+ def ==(other)
105
+ return true if equal?(other)
106
+
107
+ self.class == other.class &&
108
+ facet_name == other.facet_name &&
109
+ model == other.model &&
110
+ fallback_parameters == other.fallback_parameters
111
+ end
112
+
113
+ # @see the `==` method
114
+ # @param [Object] Object to be compared
115
+ def eql?(other)
116
+ self == other
117
+ end
118
+
119
+ # Calculates hash code according to all attributes.
120
+ # @return [Integer] Hash code
121
+ def hash
122
+ [facet_name, model, fallback_parameters].hash
123
+ end
124
+
125
+ # Builds the object from hash
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ # @return [Object] Returns the model itself
128
+ def self.build_from_hash(attributes)
129
+ return nil unless attributes.is_a?(Hash)
130
+
131
+ attributes = attributes.transform_keys(&:to_sym)
132
+ transformed_hash = {}
133
+ types_mapping.each_pair do |key, type|
134
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
135
+ transformed_hash[key.to_sym] = nil
136
+ elsif type =~ /\AArray<(.*)>/i
137
+ # check to ensure the input is an array given that the attribute
138
+ # is documented as an array but the input is not
139
+ if attributes[attribute_map[key]].is_a?(Array)
140
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
141
+ end
142
+ elsif !attributes[attribute_map[key]].nil?
143
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
144
+ end
145
+ end
146
+ new(transformed_hash)
147
+ end
148
+
149
+ # Deserializes the data based on type
150
+ # @param string type Data type
151
+ # @param string value Value to be deserialized
152
+ # @return [Object] Deserialized data
153
+ def self._deserialize(type, value)
154
+ case type.to_sym
155
+ when :Time
156
+ Time.parse(value)
157
+ when :Date
158
+ Date.parse(value)
159
+ when :String
160
+ value.to_s
161
+ when :Integer
162
+ value.to_i
163
+ when :Float
164
+ value.to_f
165
+ when :Boolean
166
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
167
+ true
168
+ else
169
+ false
170
+ end
171
+ when :Object
172
+ # generic object (usually a Hash), return directly
173
+ value
174
+ when /\AArray<(?<inner_type>.+)>\z/
175
+ inner_type = Regexp.last_match[:inner_type]
176
+ value.map { |v| _deserialize(inner_type, v) }
177
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
178
+ k_type = Regexp.last_match[:k_type]
179
+ v_type = Regexp.last_match[:v_type]
180
+ {}.tap do |hash|
181
+ value.each do |k, v|
182
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
183
+ end
184
+ end
185
+ else # model
186
+ # models (e.g. Pet) or oneOf
187
+ klass = Algolia::Recommend.const_get(type)
188
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
189
+ end
190
+ end
191
+
192
+ # Returns the string representation of the object
193
+ # @return [String] String presentation of the object
194
+ def to_s
195
+ to_hash.to_s
196
+ end
197
+
198
+ # to_body is an alias to to_hash (backward compatibility)
199
+ # @return [Hash] Returns the object in the form of hash
200
+ def to_body
201
+ to_hash
202
+ end
203
+
204
+ def to_json(*_args)
205
+ to_hash.to_json
206
+ end
207
+
208
+ # Returns the object in the form of hash
209
+ # @return [Hash] Returns the object in the form of hash
210
+ def to_hash
211
+ hash = {}
212
+ self.class.attribute_map.each_pair do |attr, param|
213
+ value = send(attr)
214
+ if value.nil?
215
+ is_nullable = self.class.openapi_nullable.include?(attr)
216
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
217
+ end
218
+
219
+ hash[param] = _to_hash(value)
220
+ end
221
+ hash
222
+ end
223
+
224
+ # Outputs non-array value in the form of hash
225
+ # For object, use to_hash. Otherwise, just return the value
226
+ # @param [Object] value Any valid value
227
+ # @return [Hash] Returns the value in the form of hash
228
+ def _to_hash(value)
229
+ if value.is_a?(Array)
230
+ value.compact.map { |v| _to_hash(v) }
231
+ elsif value.is_a?(Hash)
232
+ {}.tap do |hash|
233
+ value.each { |k, v| hash[k] = _to_hash(v) }
234
+ end
235
+ elsif value.respond_to? :to_hash
236
+ value.to_hash
237
+ else
238
+ value
239
+ end
240
+ end
241
+ end
242
+ end
243
+ end
@@ -6,20 +6,24 @@ require 'time'
6
6
  module Algolia
7
7
  module Recommend
8
8
  class TrendingFacetsQuery
9
- # Index name.
9
+ # Index name (case-sensitive).
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
- # Facet name for trending models.
18
+ attr_accessor :query_parameters
19
+
20
+ # Facet attribute for which to retrieve trending facet values.
19
21
  attr_accessor :facet_name
20
22
 
21
23
  attr_accessor :model
22
24
 
25
+ attr_accessor :fallback_parameters
26
+
23
27
  class EnumAttributeValidator
24
28
  attr_reader :datatype
25
29
  attr_reader :allowable_values
@@ -48,8 +52,10 @@ module Algolia
48
52
  :index_name => :indexName,
49
53
  :threshold => :threshold,
50
54
  :max_recommendations => :maxRecommendations,
55
+ :query_parameters => :queryParameters,
51
56
  :facet_name => :facetName,
52
- :model => :model
57
+ :model => :model,
58
+ :fallback_parameters => :fallbackParameters
53
59
  }
54
60
  end
55
61
 
@@ -62,10 +68,12 @@ module Algolia
62
68
  def self.types_mapping
63
69
  {
64
70
  :index_name => :String,
65
- :threshold => :Integer,
71
+ :threshold => :Float,
66
72
  :max_recommendations => :Integer,
67
- :facet_name => :String,
68
- :model => :TrendingFacetsModel
73
+ :query_parameters => :SearchParams,
74
+ :facet_name => :Object,
75
+ :model => :TrendingFacetsModel,
76
+ :fallback_parameters => :FallbackParams
69
77
  }
70
78
  end
71
79
 
@@ -78,7 +86,7 @@ module Algolia
78
86
  def self.openapi_all_of
79
87
  [
80
88
  :BaseRecommendRequest,
81
- :BaseTrendingFacetsQuery
89
+ :TrendingFacets
82
90
  ]
83
91
  end
84
92
 
@@ -107,12 +115,18 @@ module Algolia
107
115
 
108
116
  if attributes.key?(:threshold)
109
117
  self.threshold = attributes[:threshold]
118
+ else
119
+ self.threshold = nil
110
120
  end
111
121
 
112
122
  if attributes.key?(:max_recommendations)
113
123
  self.max_recommendations = attributes[:max_recommendations]
114
124
  end
115
125
 
126
+ if attributes.key?(:query_parameters)
127
+ self.query_parameters = attributes[:query_parameters]
128
+ end
129
+
116
130
  if attributes.key?(:facet_name)
117
131
  self.facet_name = attributes[:facet_name]
118
132
  else
@@ -121,6 +135,12 @@ module Algolia
121
135
 
122
136
  if attributes.key?(:model)
123
137
  self.model = attributes[:model]
138
+ else
139
+ self.model = nil
140
+ end
141
+
142
+ if attributes.key?(:fallback_parameters)
143
+ self.fallback_parameters = attributes[:fallback_parameters]
124
144
  end
125
145
  end
126
146
 
@@ -142,6 +162,24 @@ module Algolia
142
162
  @threshold = threshold
143
163
  end
144
164
 
165
+ # Custom attribute writer method with validation
166
+ # @param [Object] max_recommendations Value to be assigned
167
+ def max_recommendations=(max_recommendations)
168
+ if max_recommendations.nil?
169
+ raise ArgumentError, 'max_recommendations cannot be nil'
170
+ end
171
+
172
+ if max_recommendations > 1000
173
+ raise ArgumentError, 'invalid value for "max_recommendations", must be smaller than or equal to 1000.'
174
+ end
175
+
176
+ if max_recommendations < 1
177
+ raise ArgumentError, 'invalid value for "max_recommendations", must be greater than or equal to 1.'
178
+ end
179
+
180
+ @max_recommendations = max_recommendations
181
+ end
182
+
145
183
  # Checks equality by comparing each attribute.
146
184
  # @param [Object] Object to be compared
147
185
  def ==(other)
@@ -151,8 +189,10 @@ module Algolia
151
189
  index_name == other.index_name &&
152
190
  threshold == other.threshold &&
153
191
  max_recommendations == other.max_recommendations &&
192
+ query_parameters == other.query_parameters &&
154
193
  facet_name == other.facet_name &&
155
- model == other.model
194
+ model == other.model &&
195
+ fallback_parameters == other.fallback_parameters
156
196
  end
157
197
 
158
198
  # @see the `==` method
@@ -164,7 +204,7 @@ module Algolia
164
204
  # Calculates hash code according to all attributes.
165
205
  # @return [Integer] Hash code
166
206
  def hash
167
- [index_name, threshold, max_recommendations, facet_name, model].hash
207
+ [index_name, threshold, max_recommendations, query_parameters, facet_name, model, fallback_parameters].hash
168
208
  end
169
209
 
170
210
  # Builds the object from hash
@@ -5,17 +5,15 @@ require 'time'
5
5
 
6
6
  module Algolia
7
7
  module Recommend
8
- class BaseTrendingItemsQuery
9
- # Facet name for trending models.
8
+ class TrendingItems
9
+ # Facet attribute. To be used in combination with `facetValue`. If specified, only recommendations matching the facet filter will be returned.
10
10
  attr_accessor :facet_name
11
11
 
12
- # Facet value for trending models.
12
+ # Facet value. To be used in combination with `facetName`. If specified, only recommendations matching the facet filter will be returned.
13
13
  attr_accessor :facet_value
14
14
 
15
15
  attr_accessor :model
16
16
 
17
- attr_accessor :query_parameters
18
-
19
17
  attr_accessor :fallback_parameters
20
18
 
21
19
  class EnumAttributeValidator
@@ -46,7 +44,6 @@ module Algolia
46
44
  :facet_name => :facetName,
47
45
  :facet_value => :facetValue,
48
46
  :model => :model,
49
- :query_parameters => :queryParameters,
50
47
  :fallback_parameters => :fallbackParameters
51
48
  }
52
49
  end
@@ -62,7 +59,6 @@ module Algolia
62
59
  :facet_name => :String,
63
60
  :facet_value => :String,
64
61
  :model => :TrendingItemsModel,
65
- :query_parameters => :SearchParamsObject,
66
62
  :fallback_parameters => :SearchParamsObject
67
63
  }
68
64
  end
@@ -76,14 +72,14 @@ module Algolia
76
72
  # @param [Hash] attributes Model attributes in the form of hash
77
73
  def initialize(attributes = {})
78
74
  unless attributes.is_a?(Hash)
79
- raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::BaseTrendingItemsQuery` initialize method"
75
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::TrendingItems` initialize method"
80
76
  end
81
77
 
82
78
  # check to see if the attribute exists and convert string to symbol for hash key
83
79
  attributes = attributes.each_with_object({}) do |(k, v), h|
84
80
  unless self.class.attribute_map.key?(k.to_sym)
85
81
  raise ArgumentError,
86
- "`#{k}` is not a valid attribute in `Algolia::BaseTrendingItemsQuery`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
82
+ "`#{k}` is not a valid attribute in `Algolia::TrendingItems`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
87
83
  end
88
84
 
89
85
  h[k.to_sym] = v
@@ -91,18 +87,20 @@ module Algolia
91
87
 
92
88
  if attributes.key?(:facet_name)
93
89
  self.facet_name = attributes[:facet_name]
90
+ else
91
+ self.facet_name = nil
94
92
  end
95
93
 
96
94
  if attributes.key?(:facet_value)
97
95
  self.facet_value = attributes[:facet_value]
96
+ else
97
+ self.facet_value = nil
98
98
  end
99
99
 
100
100
  if attributes.key?(:model)
101
101
  self.model = attributes[:model]
102
- end
103
-
104
- if attributes.key?(:query_parameters)
105
- self.query_parameters = attributes[:query_parameters]
102
+ else
103
+ self.model = nil
106
104
  end
107
105
 
108
106
  if attributes.key?(:fallback_parameters)
@@ -119,7 +117,6 @@ module Algolia
119
117
  facet_name == other.facet_name &&
120
118
  facet_value == other.facet_value &&
121
119
  model == other.model &&
122
- query_parameters == other.query_parameters &&
123
120
  fallback_parameters == other.fallback_parameters
124
121
  end
125
122
 
@@ -132,7 +129,7 @@ module Algolia
132
129
  # Calculates hash code according to all attributes.
133
130
  # @return [Integer] Hash code
134
131
  def hash
135
- [facet_name, facet_value, model, query_parameters, fallback_parameters].hash
132
+ [facet_name, facet_value, model, fallback_parameters].hash
136
133
  end
137
134
 
138
135
  # Builds the object from hash
@@ -6,25 +6,25 @@ require 'time'
6
6
  module Algolia
7
7
  module Recommend
8
8
  class TrendingItemsQuery
9
- # Index name.
9
+ # Index name (case-sensitive).
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
- # Facet name for trending models.
18
+ attr_accessor :query_parameters
19
+
20
+ # Facet attribute. To be used in combination with `facetValue`. If specified, only recommendations matching the facet filter will be returned.
19
21
  attr_accessor :facet_name
20
22
 
21
- # Facet value for trending models.
23
+ # Facet value. To be used in combination with `facetName`. If specified, only recommendations matching the facet filter will be returned.
22
24
  attr_accessor :facet_value
23
25
 
24
26
  attr_accessor :model
25
27
 
26
- attr_accessor :query_parameters
27
-
28
28
  attr_accessor :fallback_parameters
29
29
 
30
30
  class EnumAttributeValidator
@@ -55,10 +55,10 @@ module Algolia
55
55
  :index_name => :indexName,
56
56
  :threshold => :threshold,
57
57
  :max_recommendations => :maxRecommendations,
58
+ :query_parameters => :queryParameters,
58
59
  :facet_name => :facetName,
59
60
  :facet_value => :facetValue,
60
61
  :model => :model,
61
- :query_parameters => :queryParameters,
62
62
  :fallback_parameters => :fallbackParameters
63
63
  }
64
64
  end
@@ -72,12 +72,12 @@ module Algolia
72
72
  def self.types_mapping
73
73
  {
74
74
  :index_name => :String,
75
- :threshold => :Integer,
75
+ :threshold => :Float,
76
76
  :max_recommendations => :Integer,
77
+ :query_parameters => :SearchParams,
77
78
  :facet_name => :String,
78
79
  :facet_value => :String,
79
80
  :model => :TrendingItemsModel,
80
- :query_parameters => :SearchParamsObject,
81
81
  :fallback_parameters => :SearchParamsObject
82
82
  }
83
83
  end
@@ -91,7 +91,7 @@ module Algolia
91
91
  def self.openapi_all_of
92
92
  [
93
93
  :BaseRecommendRequest,
94
- :BaseTrendingItemsQuery
94
+ :TrendingItems
95
95
  ]
96
96
  end
97
97
 
@@ -120,26 +120,34 @@ module Algolia
120
120
 
121
121
  if attributes.key?(:threshold)
122
122
  self.threshold = attributes[:threshold]
123
+ else
124
+ self.threshold = nil
123
125
  end
124
126
 
125
127
  if attributes.key?(:max_recommendations)
126
128
  self.max_recommendations = attributes[:max_recommendations]
127
129
  end
128
130
 
131
+ if attributes.key?(:query_parameters)
132
+ self.query_parameters = attributes[:query_parameters]
133
+ end
134
+
129
135
  if attributes.key?(:facet_name)
130
136
  self.facet_name = attributes[:facet_name]
137
+ else
138
+ self.facet_name = nil
131
139
  end
132
140
 
133
141
  if attributes.key?(:facet_value)
134
142
  self.facet_value = attributes[:facet_value]
143
+ else
144
+ self.facet_value = nil
135
145
  end
136
146
 
137
147
  if attributes.key?(:model)
138
148
  self.model = attributes[:model]
139
- end
140
-
141
- if attributes.key?(:query_parameters)
142
- self.query_parameters = attributes[:query_parameters]
149
+ else
150
+ self.model = nil
143
151
  end
144
152
 
145
153
  if attributes.key?(:fallback_parameters)
@@ -165,6 +173,24 @@ module Algolia
165
173
  @threshold = threshold
166
174
  end
167
175
 
176
+ # Custom attribute writer method with validation
177
+ # @param [Object] max_recommendations Value to be assigned
178
+ def max_recommendations=(max_recommendations)
179
+ if max_recommendations.nil?
180
+ raise ArgumentError, 'max_recommendations cannot be nil'
181
+ end
182
+
183
+ if max_recommendations > 1000
184
+ raise ArgumentError, 'invalid value for "max_recommendations", must be smaller than or equal to 1000.'
185
+ end
186
+
187
+ if max_recommendations < 1
188
+ raise ArgumentError, 'invalid value for "max_recommendations", must be greater than or equal to 1.'
189
+ end
190
+
191
+ @max_recommendations = max_recommendations
192
+ end
193
+
168
194
  # Checks equality by comparing each attribute.
169
195
  # @param [Object] Object to be compared
170
196
  def ==(other)
@@ -174,10 +200,10 @@ module Algolia
174
200
  index_name == other.index_name &&
175
201
  threshold == other.threshold &&
176
202
  max_recommendations == other.max_recommendations &&
203
+ query_parameters == other.query_parameters &&
177
204
  facet_name == other.facet_name &&
178
205
  facet_value == other.facet_value &&
179
206
  model == other.model &&
180
- query_parameters == other.query_parameters &&
181
207
  fallback_parameters == other.fallback_parameters
182
208
  end
183
209
 
@@ -190,7 +216,7 @@ module Algolia
190
216
  # Calculates hash code according to all attributes.
191
217
  # @return [Integer] Hash code
192
218
  def hash
193
- [index_name, threshold, max_recommendations, facet_name, facet_value, model, query_parameters, fallback_parameters].hash
219
+ [index_name, threshold, max_recommendations, query_parameters, facet_name, facet_value, model, fallback_parameters].hash
194
220
  end
195
221
 
196
222
  # Builds the object from hash
@@ -9,7 +9,7 @@ module Algolia
9
9
  # API key.
10
10
  attr_accessor :key
11
11
 
12
- # Timestamp of creation in [ISO 8601](https://wikipedia.org/wiki/ISO_8601) format.
12
+ # Date and time when the object was created, in RFC 3339 format.
13
13
  attr_accessor :created_at
14
14
 
15
15
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -9,7 +9,7 @@ module Algolia
9
9
  # API key.
10
10
  attr_accessor :value
11
11
 
12
- # Timestamp of creation in milliseconds in [Unix epoch time](https://wikipedia.org/wiki/Unix_time).
12
+ # Timestamp when the object was created, in milliseconds since the Unix epoch.
13
13
  attr_accessor :created_at
14
14
 
15
15
  # Attribute mapping from ruby-style variable name to JSON key.