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
@@ -5,14 +5,12 @@ require 'time'
5
5
 
6
6
  module Algolia
7
7
  module Recommend
8
- class BaseRecommendationsQuery
8
+ class LookingSimilar
9
9
  attr_accessor :model
10
10
 
11
11
  # Unique record identifier.
12
12
  attr_accessor :object_id
13
13
 
14
- attr_accessor :query_parameters
15
-
16
14
  attr_accessor :fallback_parameters
17
15
 
18
16
  class EnumAttributeValidator
@@ -42,7 +40,6 @@ module Algolia
42
40
  {
43
41
  :model => :model,
44
42
  :object_id => :objectID,
45
- :query_parameters => :queryParameters,
46
43
  :fallback_parameters => :fallbackParameters
47
44
  }
48
45
  end
@@ -55,10 +52,9 @@ module Algolia
55
52
  # Attribute type mapping.
56
53
  def self.types_mapping
57
54
  {
58
- :model => :RecommendationModels,
55
+ :model => :LookingSimilarModel,
59
56
  :object_id => :String,
60
- :query_parameters => :SearchParamsObject,
61
- :fallback_parameters => :SearchParamsObject
57
+ :fallback_parameters => :FallbackParams
62
58
  }
63
59
  end
64
60
 
@@ -71,14 +67,14 @@ module Algolia
71
67
  # @param [Hash] attributes Model attributes in the form of hash
72
68
  def initialize(attributes = {})
73
69
  unless attributes.is_a?(Hash)
74
- raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::BaseRecommendationsQuery` initialize method"
70
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::LookingSimilar` initialize method"
75
71
  end
76
72
 
77
73
  # check to see if the attribute exists and convert string to symbol for hash key
78
74
  attributes = attributes.each_with_object({}) do |(k, v), h|
79
75
  unless self.class.attribute_map.key?(k.to_sym)
80
76
  raise ArgumentError,
81
- "`#{k}` is not a valid attribute in `Algolia::BaseRecommendationsQuery`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
77
+ "`#{k}` is not a valid attribute in `Algolia::LookingSimilar`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
82
78
  end
83
79
 
84
80
  h[k.to_sym] = v
@@ -96,10 +92,6 @@ module Algolia
96
92
  self.object_id = nil
97
93
  end
98
94
 
99
- if attributes.key?(:query_parameters)
100
- self.query_parameters = attributes[:query_parameters]
101
- end
102
-
103
95
  if attributes.key?(:fallback_parameters)
104
96
  self.fallback_parameters = attributes[:fallback_parameters]
105
97
  end
@@ -113,7 +105,6 @@ module Algolia
113
105
  self.class == other.class &&
114
106
  model == other.model &&
115
107
  object_id == other.object_id &&
116
- query_parameters == other.query_parameters &&
117
108
  fallback_parameters == other.fallback_parameters
118
109
  end
119
110
 
@@ -126,7 +117,7 @@ module Algolia
126
117
  # Calculates hash code according to all attributes.
127
118
  # @return [Integer] Hash code
128
119
  def hash
129
- [model, object_id, query_parameters, fallback_parameters].hash
120
+ [model, object_id, fallback_parameters].hash
130
121
  end
131
122
 
132
123
  # Builds the object from hash
@@ -5,14 +5,11 @@ require 'time'
5
5
 
6
6
  module Algolia
7
7
  module Recommend
8
- class Anchoring
9
- IS = "is".freeze
10
- STARTS_WITH = "startsWith".freeze
11
- ENDS_WITH = "endsWith".freeze
12
- CONTAINS = "contains".freeze
8
+ class LookingSimilarModel
9
+ LOOKING_SIMILAR = "looking-similar".freeze
13
10
 
14
11
  def self.all_vars
15
- @all_vars ||= [IS, STARTS_WITH, ENDS_WITH, CONTAINS].freeze
12
+ @all_vars ||= [LOOKING_SIMILAR].freeze
16
13
  end
17
14
 
18
15
  # Builds the enum from string
@@ -26,9 +23,9 @@ module Algolia
26
23
  # @param [String] The enum value in the form of the string
27
24
  # @return [String] The enum value
28
25
  def build_from_hash(value)
29
- return value if Anchoring.all_vars.include?(value)
26
+ return value if LookingSimilarModel.all_vars.include?(value)
30
27
 
31
- raise "Invalid ENUM value #{value} for class #Anchoring"
28
+ raise "Invalid ENUM value #{value} for class #LookingSimilarModel"
32
29
  end
33
30
  end
34
31
  end
@@ -0,0 +1,328 @@
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 LookingSimilarQuery
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
+ attr_accessor :fallback_parameters
26
+
27
+ class EnumAttributeValidator
28
+ attr_reader :datatype
29
+ attr_reader :allowable_values
30
+
31
+ def initialize(datatype, allowable_values)
32
+ @allowable_values = allowable_values.map do |value|
33
+ case datatype.to_s
34
+ when /Integer/i
35
+ value.to_i
36
+ when /Float/i
37
+ value.to_f
38
+ else
39
+ value
40
+ end
41
+ end
42
+ end
43
+
44
+ def valid?(value)
45
+ !value || allowable_values.include?(value)
46
+ end
47
+ end
48
+
49
+ # Attribute mapping from ruby-style variable name to JSON key.
50
+ def self.attribute_map
51
+ {
52
+ :index_name => :indexName,
53
+ :threshold => :threshold,
54
+ :max_recommendations => :maxRecommendations,
55
+ :query_parameters => :queryParameters,
56
+ :model => :model,
57
+ :object_id => :objectID,
58
+ :fallback_parameters => :fallbackParameters
59
+ }
60
+ end
61
+
62
+ # Returns all the JSON keys this model knows about
63
+ def self.acceptable_attributes
64
+ attribute_map.values
65
+ end
66
+
67
+ # Attribute type mapping.
68
+ def self.types_mapping
69
+ {
70
+ :index_name => :String,
71
+ :threshold => :Float,
72
+ :max_recommendations => :Integer,
73
+ :query_parameters => :SearchParams,
74
+ :model => :LookingSimilarModel,
75
+ :object_id => :String,
76
+ :fallback_parameters => :FallbackParams
77
+ }
78
+ end
79
+
80
+ # List of attributes with nullable: true
81
+ def self.openapi_nullable
82
+ Set.new([])
83
+ end
84
+
85
+ # List of class defined in allOf (OpenAPI v3)
86
+ def self.openapi_all_of
87
+ [
88
+ :BaseRecommendRequest,
89
+ :LookingSimilar
90
+ ]
91
+ end
92
+
93
+ # Initializes the object
94
+ # @param [Hash] attributes Model attributes in the form of hash
95
+ def initialize(attributes = {})
96
+ unless attributes.is_a?(Hash)
97
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::LookingSimilarQuery` initialize method"
98
+ end
99
+
100
+ # check to see if the attribute exists and convert string to symbol for hash key
101
+ attributes = attributes.each_with_object({}) do |(k, v), h|
102
+ unless self.class.attribute_map.key?(k.to_sym)
103
+ raise ArgumentError,
104
+ "`#{k}` is not a valid attribute in `Algolia::LookingSimilarQuery`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
105
+ end
106
+
107
+ h[k.to_sym] = v
108
+ end
109
+
110
+ if attributes.key?(:index_name)
111
+ self.index_name = attributes[:index_name]
112
+ else
113
+ self.index_name = nil
114
+ end
115
+
116
+ if attributes.key?(:threshold)
117
+ self.threshold = attributes[:threshold]
118
+ else
119
+ self.threshold = nil
120
+ end
121
+
122
+ if attributes.key?(:max_recommendations)
123
+ self.max_recommendations = attributes[:max_recommendations]
124
+ end
125
+
126
+ if attributes.key?(:query_parameters)
127
+ self.query_parameters = attributes[:query_parameters]
128
+ end
129
+
130
+ if attributes.key?(:model)
131
+ self.model = attributes[:model]
132
+ else
133
+ self.model = nil
134
+ end
135
+
136
+ if attributes.key?(:object_id)
137
+ self.object_id = attributes[:object_id]
138
+ else
139
+ self.object_id = nil
140
+ end
141
+
142
+ if attributes.key?(:fallback_parameters)
143
+ self.fallback_parameters = attributes[:fallback_parameters]
144
+ end
145
+ end
146
+
147
+ # Custom attribute writer method with validation
148
+ # @param [Object] threshold Value to be assigned
149
+ def threshold=(threshold)
150
+ if threshold.nil?
151
+ raise ArgumentError, 'threshold cannot be nil'
152
+ end
153
+
154
+ if threshold > 100
155
+ raise ArgumentError, 'invalid value for "threshold", must be smaller than or equal to 100.'
156
+ end
157
+
158
+ if threshold < 0
159
+ raise ArgumentError, 'invalid value for "threshold", must be greater than or equal to 0.'
160
+ end
161
+
162
+ @threshold = threshold
163
+ end
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
+
183
+ # Checks equality by comparing each attribute.
184
+ # @param [Object] Object to be compared
185
+ def ==(other)
186
+ return true if equal?(other)
187
+
188
+ self.class == other.class &&
189
+ index_name == other.index_name &&
190
+ threshold == other.threshold &&
191
+ max_recommendations == other.max_recommendations &&
192
+ query_parameters == other.query_parameters &&
193
+ model == other.model &&
194
+ object_id == other.object_id &&
195
+ fallback_parameters == other.fallback_parameters
196
+ end
197
+
198
+ # @see the `==` method
199
+ # @param [Object] Object to be compared
200
+ def eql?(other)
201
+ self == other
202
+ end
203
+
204
+ # Calculates hash code according to all attributes.
205
+ # @return [Integer] Hash code
206
+ def hash
207
+ [index_name, threshold, max_recommendations, query_parameters, model, object_id, fallback_parameters].hash
208
+ end
209
+
210
+ # Builds the object from hash
211
+ # @param [Hash] attributes Model attributes in the form of hash
212
+ # @return [Object] Returns the model itself
213
+ def self.build_from_hash(attributes)
214
+ return nil unless attributes.is_a?(Hash)
215
+
216
+ attributes = attributes.transform_keys(&:to_sym)
217
+ transformed_hash = {}
218
+ types_mapping.each_pair do |key, type|
219
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
220
+ transformed_hash[key.to_sym] = nil
221
+ elsif type =~ /\AArray<(.*)>/i
222
+ # check to ensure the input is an array given that the attribute
223
+ # is documented as an array but the input is not
224
+ if attributes[attribute_map[key]].is_a?(Array)
225
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
226
+ end
227
+ elsif !attributes[attribute_map[key]].nil?
228
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
229
+ end
230
+ end
231
+ new(transformed_hash)
232
+ end
233
+
234
+ # Deserializes the data based on type
235
+ # @param string type Data type
236
+ # @param string value Value to be deserialized
237
+ # @return [Object] Deserialized data
238
+ def self._deserialize(type, value)
239
+ case type.to_sym
240
+ when :Time
241
+ Time.parse(value)
242
+ when :Date
243
+ Date.parse(value)
244
+ when :String
245
+ value.to_s
246
+ when :Integer
247
+ value.to_i
248
+ when :Float
249
+ value.to_f
250
+ when :Boolean
251
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
252
+ true
253
+ else
254
+ false
255
+ end
256
+ when :Object
257
+ # generic object (usually a Hash), return directly
258
+ value
259
+ when /\AArray<(?<inner_type>.+)>\z/
260
+ inner_type = Regexp.last_match[:inner_type]
261
+ value.map { |v| _deserialize(inner_type, v) }
262
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
263
+ k_type = Regexp.last_match[:k_type]
264
+ v_type = Regexp.last_match[:v_type]
265
+ {}.tap do |hash|
266
+ value.each do |k, v|
267
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
268
+ end
269
+ end
270
+ else # model
271
+ # models (e.g. Pet) or oneOf
272
+ klass = Algolia::Recommend.const_get(type)
273
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
274
+ end
275
+ end
276
+
277
+ # Returns the string representation of the object
278
+ # @return [String] String presentation of the object
279
+ def to_s
280
+ to_hash.to_s
281
+ end
282
+
283
+ # to_body is an alias to to_hash (backward compatibility)
284
+ # @return [Hash] Returns the object in the form of hash
285
+ def to_body
286
+ to_hash
287
+ end
288
+
289
+ def to_json(*_args)
290
+ to_hash.to_json
291
+ end
292
+
293
+ # Returns the object in the form of hash
294
+ # @return [Hash] Returns the object in the form of hash
295
+ def to_hash
296
+ hash = {}
297
+ self.class.attribute_map.each_pair do |attr, param|
298
+ value = send(attr)
299
+ if value.nil?
300
+ is_nullable = self.class.openapi_nullable.include?(attr)
301
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
302
+ end
303
+
304
+ hash[param] = _to_hash(value)
305
+ end
306
+ hash
307
+ end
308
+
309
+ # Outputs non-array value in the form of hash
310
+ # For object, use to_hash. Otherwise, just return the value
311
+ # @param [Object] value Any valid value
312
+ # @return [Hash] Returns the value in the form of hash
313
+ def _to_hash(value)
314
+ if value.is_a?(Array)
315
+ value.compact.map { |v| _to_hash(v) }
316
+ elsif value.is_a?(Hash)
317
+ {}.tap do |hash|
318
+ value.each { |k, v| hash[k] = _to_hash(v) }
319
+ end
320
+ elsif value.respond_to? :to_hash
321
+ value.to_hash
322
+ else
323
+ value
324
+ end
325
+ end
326
+ end
327
+ end
328
+ end
@@ -5,23 +5,23 @@ require 'time'
5
5
 
6
6
  module Algolia
7
7
  module Recommend
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
-
8
+ # Filter or boost recommendations matching a facet filter.
9
+ class ParamsConsequence
10
+ # Filter recommendations that match or don't match the same `facet:facet_value` combination as the viewed item.
12
11
  attr_accessor :automatic_facet_filters
13
12
 
14
- attr_accessor :automatic_optional_facet_filters
13
+ # 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/).
14
+ attr_accessor :filters
15
15
 
16
- attr_accessor :rendering_content
16
+ # Filters to promote or demote records in the search results. Optional filters work like facet filters, but they don't exclude records from the search results. Records that match the optional filter rank before records that don't match. Matches with higher weights (`<score=N>`) rank before matches with lower weights. If you're using a negative filter `facet:-value`, matching records rank after records that don't match.
17
+ attr_accessor :optional_filters
17
18
 
18
19
  # Attribute mapping from ruby-style variable name to JSON key.
19
20
  def self.attribute_map
20
21
  {
21
- :query => :query,
22
22
  :automatic_facet_filters => :automaticFacetFilters,
23
- :automatic_optional_facet_filters => :automaticOptionalFacetFilters,
24
- :rendering_content => :renderingContent
23
+ :filters => :filters,
24
+ :optional_filters => :optionalFilters
25
25
  }
26
26
  end
27
27
 
@@ -33,10 +33,9 @@ module Algolia
33
33
  # Attribute type mapping.
34
34
  def self.types_mapping
35
35
  {
36
- :query => :ConsequenceQuery,
37
- :automatic_facet_filters => :AutomaticFacetFilters,
38
- :automatic_optional_facet_filters => :AutomaticFacetFilters,
39
- :rendering_content => :RenderingContent
36
+ :automatic_facet_filters => :'Array<AutoFacetFilter>',
37
+ :filters => :String,
38
+ :optional_filters => :'Array<String>'
40
39
  }
41
40
  end
42
41
 
@@ -49,33 +48,33 @@ module Algolia
49
48
  # @param [Hash] attributes Model attributes in the form of hash
50
49
  def initialize(attributes = {})
51
50
  unless attributes.is_a?(Hash)
52
- raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::Params` initialize method"
51
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::ParamsConsequence` initialize method"
53
52
  end
54
53
 
55
54
  # check to see if the attribute exists and convert string to symbol for hash key
56
55
  attributes = attributes.each_with_object({}) do |(k, v), h|
57
56
  unless self.class.attribute_map.key?(k.to_sym)
58
57
  raise ArgumentError,
59
- "`#{k}` is not a valid attribute in `Algolia::Params`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
58
+ "`#{k}` is not a valid attribute in `Algolia::ParamsConsequence`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
60
59
  end
61
60
 
62
61
  h[k.to_sym] = v
63
62
  end
64
63
 
65
- if attributes.key?(:query)
66
- self.query = attributes[:query]
67
- end
68
-
69
64
  if attributes.key?(:automatic_facet_filters)
70
- self.automatic_facet_filters = attributes[:automatic_facet_filters]
65
+ if (value = attributes[:automatic_facet_filters]).is_a?(Array)
66
+ self.automatic_facet_filters = value
67
+ end
71
68
  end
72
69
 
73
- if attributes.key?(:automatic_optional_facet_filters)
74
- self.automatic_optional_facet_filters = attributes[:automatic_optional_facet_filters]
70
+ if attributes.key?(:filters)
71
+ self.filters = attributes[:filters]
75
72
  end
76
73
 
77
- if attributes.key?(:rendering_content)
78
- self.rendering_content = attributes[:rendering_content]
74
+ if attributes.key?(:optional_filters)
75
+ if (value = attributes[:optional_filters]).is_a?(Array)
76
+ self.optional_filters = value
77
+ end
79
78
  end
80
79
  end
81
80
 
@@ -85,10 +84,9 @@ module Algolia
85
84
  return true if equal?(other)
86
85
 
87
86
  self.class == other.class &&
88
- query == other.query &&
89
87
  automatic_facet_filters == other.automatic_facet_filters &&
90
- automatic_optional_facet_filters == other.automatic_optional_facet_filters &&
91
- rendering_content == other.rendering_content
88
+ filters == other.filters &&
89
+ optional_filters == other.optional_filters
92
90
  end
93
91
 
94
92
  # @see the `==` method
@@ -100,7 +98,7 @@ module Algolia
100
98
  # Calculates hash code according to all attributes.
101
99
  # @return [Integer] Hash code
102
100
  def hash
103
- [query, automatic_facet_filters, automatic_optional_facet_filters, rendering_content].hash
101
+ [automatic_facet_filters, filters, optional_filters].hash
104
102
  end
105
103
 
106
104
  # Builds the object from hash
@@ -5,12 +5,12 @@ require 'time'
5
5
 
6
6
  module Algolia
7
7
  module Recommend
8
- # Record to promote.
9
- class PromoteObjectID
8
+ # Object ID and position of the recommendation you want to pin.
9
+ class PromoteConsequenceObject
10
10
  # Unique record identifier.
11
11
  attr_accessor :object_id
12
12
 
13
- # Position in the search results where you want to show the promoted records.
13
+ # Index in the list of recommendations where to place this item.
14
14
  attr_accessor :position
15
15
 
16
16
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -43,14 +43,14 @@ module Algolia
43
43
  # @param [Hash] attributes Model attributes in the form of hash
44
44
  def initialize(attributes = {})
45
45
  unless attributes.is_a?(Hash)
46
- raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::PromoteObjectID` initialize method"
46
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::PromoteConsequenceObject` initialize method"
47
47
  end
48
48
 
49
49
  # check to see if the attribute exists and convert string to symbol for hash key
50
50
  attributes = attributes.each_with_object({}) do |(k, v), h|
51
51
  unless self.class.attribute_map.key?(k.to_sym)
52
52
  raise ArgumentError,
53
- "`#{k}` is not a valid attribute in `Algolia::PromoteObjectID`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
53
+ "`#{k}` is not a valid attribute in `Algolia::PromoteConsequenceObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
54
54
  end
55
55
 
56
56
  h[k.to_sym] = v
@@ -58,17 +58,27 @@ module Algolia
58
58
 
59
59
  if attributes.key?(:object_id)
60
60
  self.object_id = attributes[:object_id]
61
- else
62
- self.object_id = nil
63
61
  end
64
62
 
65
63
  if attributes.key?(:position)
66
64
  self.position = attributes[:position]
67
- else
68
- self.position = nil
69
65
  end
70
66
  end
71
67
 
68
+ # Custom attribute writer method with validation
69
+ # @param [Object] position Value to be assigned
70
+ def position=(position)
71
+ if position.nil?
72
+ raise ArgumentError, 'position cannot be nil'
73
+ end
74
+
75
+ if position < 0
76
+ raise ArgumentError, 'invalid value for "position", must be greater than or equal to 0.'
77
+ end
78
+
79
+ @position = position
80
+ end
81
+
72
82
  # Checks equality by comparing each attribute.
73
83
  # @param [Object] Object to be compared
74
84
  def ==(other)