Class: Algolia::RecommendClient

Inherits:
Object
  • Object
show all
Defined in:
lib/algolia/api/recommend_client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = nil) ⇒ RecommendClient

Returns a new instance of RecommendClient.



7
8
9
10
11
12
13
# File 'lib/algolia/api/recommend_client.rb', line 7

def initialize(config = nil)
  raise "`config` is missing." if config.nil?
  raise "`app_id` is missing." if config.app_id.nil? || config.app_id == ""
  raise "`api_key` is missing." if config.api_key.nil? || config.api_key == ""

  @api_client = Algolia::ApiClient.new(config)
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



5
6
7
# File 'lib/algolia/api/recommend_client.rb', line 5

def api_client
  @api_client
end

Class Method Details

.create(app_id, api_key, opts = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/algolia/api/recommend_client.rb', line 15

def self.create(app_id, api_key, opts = {})
  hosts = []
  hosts << Transport::StatefulHost.new("#{app_id}-dsn.algolia.net", accept: CallType::READ)
  hosts << Transport::StatefulHost.new("#{app_id}.algolia.net", accept: CallType::WRITE)

  hosts += 1
    .upto(3)
    .map do |i|
      Transport::StatefulHost.new("#{app_id}-#{i}.algolianet.com", accept: CallType::READ | CallType::WRITE)
    end
    .shuffle

  config = Algolia::Configuration.new(app_id, api_key, hosts, "Recommend", opts)
  create_with_config(config)
end

.create_with_config(config) ⇒ Object



31
32
33
# File 'lib/algolia/api/recommend_client.rb', line 31

def self.create_with_config(config)
  new(config)
end

Instance Method Details

#add_user_agent_segment(segment, version = nil) ⇒ Object



45
46
47
48
49
# File 'lib/algolia/api/recommend_client.rb', line 45

def add_user_agent_segment(segment, version = nil)
  @api_client.config.add_user_agent_segment(segment, version)

  self
end

#batch_recommend_rules(index_name, model, recommend_rule = nil, request_options = {}) ⇒ RecommendUpdatedAtResponse

Create or update a batch of Recommend Rules Each Recommend Rule is created or updated, depending on whether a Recommend Rule with the same ‘objectID` already exists. You may also specify `true` for `clearExistingRules`, in which case the batch will atomically replace all the existing Recommend Rules. Recommend Rules are similar to Search Rules, except that the conditions and consequences apply to a [source item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main differences are the following: - Conditions `pattern` and `anchoring` are unavailable. - Condition `filters` triggers if the source item matches the specified filters. - Condition `filters` accepts numeric filters. - Consequence `params` only covers filtering parameters. - Consequence `automaticFacetFilters` doesn’t require a facet value placeholder (it tries to match the data source item’s attributes instead).

Required API Key ACLs:

- editSettings

Parameters:

  • index_name (String)

    Name of the index on which to perform the operation. (required)

  • model (RecommendModels)
  • recommend_rule (Array<RecommendRule>) (defaults to: nil)
  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:

  • (RecommendUpdatedAtResponse)


100
101
102
103
104
105
106
# File 'lib/algolia/api/recommend_client.rb', line 100

def batch_recommend_rules(index_name, model, recommend_rule = nil, request_options = {})
  response = batch_recommend_rules_with_http_info(index_name, model, recommend_rule, request_options)
  @api_client.deserialize(
    response.body,
    request_options[:debug_return_type] || "Recommend::RecommendUpdatedAtResponse"
  )
end

#batch_recommend_rules_with_http_info(index_name, model, recommend_rule = nil, request_options = {}) ⇒ Http::Response

Create or update a batch of Recommend Rules Each Recommend Rule is created or updated, depending on whether a Recommend Rule with the same ‘objectID` already exists. You may also specify `true` for `clearExistingRules`, in which case the batch will atomically replace all the existing Recommend Rules. Recommend Rules are similar to Search Rules, except that the conditions and consequences apply to a [source item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main differences are the following: - Conditions `pattern` and `anchoring` are unavailable. - Condition `filters` triggers if the source item matches the specified filters. - Condition `filters` accepts numeric filters. - Consequence `params` only covers filtering parameters. - Consequence `automaticFacetFilters` doesn’t require a facet value placeholder (it tries to match the data source item’s attributes instead).

Required API Key ACLs:

- editSettings

Parameters:

  • index_name (String)

    Name of the index on which to perform the operation. (required)

  • model (RecommendModels)
  • recommend_rule (Array<RecommendRule>) (defaults to: nil)
  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/algolia/api/recommend_client.rb', line 60

def batch_recommend_rules_with_http_info(index_name, model, recommend_rule = nil, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `batch_recommend_rules`."
  end
  # verify the required parameter 'model' is set
  if @api_client.config.client_side_validation && model.nil?
    raise ArgumentError, "Parameter `model` is required when calling `batch_recommend_rules`."
  end

  path = "/1/indexes/{indexName}/{model}/recommend/rules/batch"
    .sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
    .sub("{" + "model" + "}", Transport.encode_uri(model.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(recommend_rule)

  new_options = request_options.merge(
    :operation => :"RecommendClient.batch_recommend_rules",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end

#custom_delete(path, parameters = nil, request_options = {}) ⇒ Object

Parameters:

  • path (String)

    Path of the endpoint, anything after "/1" must be specified. (required)

  • parameters (Hash<String, Object>) (defaults to: nil)

    Query parameters to apply to the current query.

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:

  • (Object)


146
147
148
149
# File 'lib/algolia/api/recommend_client.rb', line 146

def custom_delete(path, parameters = nil, request_options = {})
  response = custom_delete_with_http_info(path, parameters, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Object")
end

#custom_delete_with_http_info(path, parameters = nil, request_options = {}) ⇒ Http::Response

Returns the response.

Parameters:

  • path (String)

    Path of the endpoint, anything after "/1" must be specified. (required)

  • parameters (Hash<String, Object>) (defaults to: nil)

    Query parameters to apply to the current query.

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/algolia/api/recommend_client.rb', line 114

def custom_delete_with_http_info(path, parameters = nil, request_options = {})
  # verify the required parameter 'path' is set
  if @api_client.config.client_side_validation && path.nil?
    raise ArgumentError, "Parameter `path` is required when calling `custom_delete`."
  end

  path = "/{path}".sub("{" + "path" + "}", path.to_s)
  query_params = {}
  query_params = query_params.merge(parameters) unless parameters.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"RecommendClient.custom_delete",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:DELETE, path, new_options)
end

#custom_get(path, parameters = nil, request_options = {}) ⇒ Object

Parameters:

  • path (String)

    Path of the endpoint, anything after "/1" must be specified. (required)

  • parameters (Hash<String, Object>) (defaults to: nil)

    Query parameters to apply to the current query.

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:

  • (Object)


189
190
191
192
# File 'lib/algolia/api/recommend_client.rb', line 189

def custom_get(path, parameters = nil, request_options = {})
  response = custom_get_with_http_info(path, parameters, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Object")
end

#custom_get_with_http_info(path, parameters = nil, request_options = {}) ⇒ Http::Response

Returns the response.

Parameters:

  • path (String)

    Path of the endpoint, anything after "/1" must be specified. (required)

  • parameters (Hash<String, Object>) (defaults to: nil)

    Query parameters to apply to the current query.

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/algolia/api/recommend_client.rb', line 157

def custom_get_with_http_info(path, parameters = nil, request_options = {})
  # verify the required parameter 'path' is set
  if @api_client.config.client_side_validation && path.nil?
    raise ArgumentError, "Parameter `path` is required when calling `custom_get`."
  end

  path = "/{path}".sub("{" + "path" + "}", path.to_s)
  query_params = {}
  query_params = query_params.merge(parameters) unless parameters.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"RecommendClient.custom_get",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#custom_post(path, parameters = nil, body = nil, request_options = {}) ⇒ Object

Parameters:

  • path (String)

    Path of the endpoint, anything after "/1" must be specified. (required)

  • parameters (Hash<String, Object>) (defaults to: nil)

    Query parameters to apply to the current query.

  • body (Object) (defaults to: nil)

    Parameters to send with the custom request.

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:

  • (Object)


234
235
236
237
# File 'lib/algolia/api/recommend_client.rb', line 234

def custom_post(path, parameters = nil, body = nil, request_options = {})
  response = custom_post_with_http_info(path, parameters, body, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Object")
end

#custom_post_with_http_info(path, parameters = nil, body = nil, request_options = {}) ⇒ Http::Response

Returns the response.

Parameters:

  • path (String)

    Path of the endpoint, anything after "/1" must be specified. (required)

  • parameters (Hash<String, Object>) (defaults to: nil)

    Query parameters to apply to the current query.

  • body (Object) (defaults to: nil)

    Parameters to send with the custom request.

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/algolia/api/recommend_client.rb', line 201

def custom_post_with_http_info(path, parameters = nil, body = nil, request_options = {})
  # verify the required parameter 'path' is set
  if @api_client.config.client_side_validation && path.nil?
    raise ArgumentError, "Parameter `path` is required when calling `custom_post`."
  end

  path = "/{path}".sub("{" + "path" + "}", path.to_s)
  query_params = {}
  query_params = query_params.merge(parameters) unless parameters.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(body)

  new_options = request_options.merge(
    :operation => :"RecommendClient.custom_post",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end

#custom_put(path, parameters = nil, body = nil, request_options = {}) ⇒ Object

Parameters:

  • path (String)

    Path of the endpoint, anything after "/1" must be specified. (required)

  • parameters (Hash<String, Object>) (defaults to: nil)

    Query parameters to apply to the current query.

  • body (Object) (defaults to: nil)

    Parameters to send with the custom request.

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:

  • (Object)


279
280
281
282
# File 'lib/algolia/api/recommend_client.rb', line 279

def custom_put(path, parameters = nil, body = nil, request_options = {})
  response = custom_put_with_http_info(path, parameters, body, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Object")
end

#custom_put_with_http_info(path, parameters = nil, body = nil, request_options = {}) ⇒ Http::Response

Returns the response.

Parameters:

  • path (String)

    Path of the endpoint, anything after "/1" must be specified. (required)

  • parameters (Hash<String, Object>) (defaults to: nil)

    Query parameters to apply to the current query.

  • body (Object) (defaults to: nil)

    Parameters to send with the custom request.

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# File 'lib/algolia/api/recommend_client.rb', line 246

def custom_put_with_http_info(path, parameters = nil, body = nil, request_options = {})
  # verify the required parameter 'path' is set
  if @api_client.config.client_side_validation && path.nil?
    raise ArgumentError, "Parameter `path` is required when calling `custom_put`."
  end

  path = "/{path}".sub("{" + "path" + "}", path.to_s)
  query_params = {}
  query_params = query_params.merge(parameters) unless parameters.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(body)

  new_options = request_options.merge(
    :operation => :"RecommendClient.custom_put",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:PUT, path, new_options)
end

#delete_recommend_rule(index_name, model, object_id, request_options = {}) ⇒ DeletedAtResponse

Deletes a Recommend rule from a recommendation scenario.

Required API Key ACLs:

- editSettings

Parameters:

  • index_name (String)

    Name of the index on which to perform the operation. (required)

  • model (RecommendModels)
  • object_id (String)

    Unique record identifier. (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:

  • (DeletedAtResponse)


338
339
340
341
# File 'lib/algolia/api/recommend_client.rb', line 338

def delete_recommend_rule(index_name, model, object_id, request_options = {})
  response = delete_recommend_rule_with_http_info(index_name, model, object_id, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Recommend::DeletedAtResponse")
end

#delete_recommend_rule_with_http_info(index_name, model, object_id, request_options = {}) ⇒ Http::Response

Deletes a Recommend rule from a recommendation scenario.

Required API Key ACLs:

- editSettings

Parameters:

  • index_name (String)

    Name of the index on which to perform the operation. (required)

  • model (RecommendModels)
  • object_id (String)

    Unique record identifier. (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/algolia/api/recommend_client.rb', line 293

def delete_recommend_rule_with_http_info(index_name, model, object_id, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `delete_recommend_rule`."
  end
  # verify the required parameter 'model' is set
  if @api_client.config.client_side_validation && model.nil?
    raise ArgumentError, "Parameter `model` is required when calling `delete_recommend_rule`."
  end
  # verify the required parameter 'object_id' is set
  if @api_client.config.client_side_validation && object_id.nil?
    raise ArgumentError, "Parameter `object_id` is required when calling `delete_recommend_rule`."
  end

  path = "/1/indexes/{indexName}/{model}/recommend/rules/{objectID}"
    .sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
    .sub("{" + "model" + "}", Transport.encode_uri(model.to_s))
    .sub("{" + "objectID" + "}", Transport.encode_uri(object_id.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"RecommendClient.delete_recommend_rule",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:DELETE, path, new_options)
end

#get_recommend_rule(index_name, model, object_id, request_options = {}) ⇒ RecommendRule

Retrieves a Recommend rule that you previously created in the Algolia dashboard.

Required API Key ACLs:

- settings

Parameters:

  • index_name (String)

    Name of the index on which to perform the operation. (required)

  • model (RecommendModels)
  • object_id (String)

    Unique record identifier. (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:

  • (RecommendRule)


397
398
399
400
# File 'lib/algolia/api/recommend_client.rb', line 397

def get_recommend_rule(index_name, model, object_id, request_options = {})
  response = get_recommend_rule_with_http_info(index_name, model, object_id, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || "Recommend::RecommendRule")
end

#get_recommend_rule_with_http_info(index_name, model, object_id, request_options = {}) ⇒ Http::Response

Retrieves a Recommend rule that you previously created in the Algolia dashboard.

Required API Key ACLs:

- settings

Parameters:

  • index_name (String)

    Name of the index on which to perform the operation. (required)

  • model (RecommendModels)
  • object_id (String)

    Unique record identifier. (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
# File 'lib/algolia/api/recommend_client.rb', line 352

def get_recommend_rule_with_http_info(index_name, model, object_id, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `get_recommend_rule`."
  end
  # verify the required parameter 'model' is set
  if @api_client.config.client_side_validation && model.nil?
    raise ArgumentError, "Parameter `model` is required when calling `get_recommend_rule`."
  end
  # verify the required parameter 'object_id' is set
  if @api_client.config.client_side_validation && object_id.nil?
    raise ArgumentError, "Parameter `object_id` is required when calling `get_recommend_rule`."
  end

  path = "/1/indexes/{indexName}/{model}/recommend/rules/{objectID}"
    .sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
    .sub("{" + "model" + "}", Transport.encode_uri(model.to_s))
    .sub("{" + "objectID" + "}", Transport.encode_uri(object_id.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"RecommendClient.get_recommend_rule",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#get_recommend_status(index_name, model, task_id, request_options = {}) ⇒ GetRecommendTaskResponse

Checks the status of a given task. Deleting a Recommend rule is asynchronous. When you delete a rule, a task is created on a queue and completed depending on the load on the server. The API response includes a task ID that you can use to check the status.

Required API Key ACLs:

- editSettings

Parameters:

  • index_name (String)

    Name of the index on which to perform the operation. (required)

  • model (RecommendModels)
  • task_id (Integer)

    Unique task identifier. (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:

  • (GetRecommendTaskResponse)


456
457
458
459
460
461
462
# File 'lib/algolia/api/recommend_client.rb', line 456

def get_recommend_status(index_name, model, task_id, request_options = {})
  response = get_recommend_status_with_http_info(index_name, model, task_id, request_options)
  @api_client.deserialize(
    response.body,
    request_options[:debug_return_type] || "Recommend::GetRecommendTaskResponse"
  )
end

#get_recommend_status_with_http_info(index_name, model, task_id, request_options = {}) ⇒ Http::Response

Checks the status of a given task. Deleting a Recommend rule is asynchronous. When you delete a rule, a task is created on a queue and completed depending on the load on the server. The API response includes a task ID that you can use to check the status.

Required API Key ACLs:

- editSettings

Parameters:

  • index_name (String)

    Name of the index on which to perform the operation. (required)

  • model (RecommendModels)
  • task_id (Integer)

    Unique task identifier. (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
# File 'lib/algolia/api/recommend_client.rb', line 411

def get_recommend_status_with_http_info(index_name, model, task_id, request_options = {})
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `get_recommend_status`."
  end
  # verify the required parameter 'model' is set
  if @api_client.config.client_side_validation && model.nil?
    raise ArgumentError, "Parameter `model` is required when calling `get_recommend_status`."
  end
  # verify the required parameter 'task_id' is set
  if @api_client.config.client_side_validation && task_id.nil?
    raise ArgumentError, "Parameter `task_id` is required when calling `get_recommend_status`."
  end

  path = "/1/indexes/{indexName}/{model}/task/{taskID}"
    .sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
    .sub("{" + "model" + "}", Transport.encode_uri(model.to_s))
    .sub("{" + "taskID" + "}", Transport.encode_uri(task_id.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :"RecommendClient.get_recommend_status",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#get_recommendations(get_recommendations_params, request_options = {}) ⇒ GetRecommendationsResponse

Retrieves recommendations from selected AI models.

Required API Key ACLs:

- search

Parameters:

  • get_recommendations_params (GetRecommendationsParams)

    (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:

  • (GetRecommendationsResponse)


503
504
505
506
507
508
509
# File 'lib/algolia/api/recommend_client.rb', line 503

def get_recommendations(get_recommendations_params, request_options = {})
  response = get_recommendations_with_http_info(get_recommendations_params, request_options)
  @api_client.deserialize(
    response.body,
    request_options[:debug_return_type] || "Recommend::GetRecommendationsResponse"
  )
end

#get_recommendations_with_http_info(get_recommendations_params, request_options = {}) ⇒ Http::Response

Retrieves recommendations from selected AI models.

Required API Key ACLs:

- search

Parameters:

  • get_recommendations_params (GetRecommendationsParams)

    (required)

  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
# File 'lib/algolia/api/recommend_client.rb', line 471

def get_recommendations_with_http_info(get_recommendations_params, request_options = {})
  # verify the required parameter 'get_recommendations_params' is set
  if @api_client.config.client_side_validation && get_recommendations_params.nil?
    raise ArgumentError, "Parameter `get_recommendations_params` is required when calling `get_recommendations`."
  end

  path = "/1/indexes/*/recommendations"
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(get_recommendations_params)

  new_options = request_options.merge(
    :operation => :"RecommendClient.get_recommendations",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => true
  )

  @api_client.call_api(:POST, path, new_options)
end

#search_recommend_rules(index_name, model, search_recommend_rules_params = nil, request_options = {}) ⇒ SearchRecommendRulesResponse

Searches for Recommend rules. Use an empty query to list all rules for this recommendation scenario.

Required API Key ACLs:

- settings

Parameters:

  • index_name (String)

    Name of the index on which to perform the operation. (required)

  • model (RecommendModels)
  • search_recommend_rules_params (SearchRecommendRulesParams) (defaults to: nil)
  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:

  • (SearchRecommendRulesResponse)


565
566
567
568
569
570
571
572
573
574
575
576
# File 'lib/algolia/api/recommend_client.rb', line 565

def search_recommend_rules(index_name, model, search_recommend_rules_params = nil, request_options = {})
  response = search_recommend_rules_with_http_info(
    index_name,
    model,
    search_recommend_rules_params,
    request_options
  )
  @api_client.deserialize(
    response.body,
    request_options[:debug_return_type] || "Recommend::SearchRecommendRulesResponse"
  )
end

#search_recommend_rules_with_http_info(index_name, model, search_recommend_rules_params = nil, request_options = {}) ⇒ Http::Response

Searches for Recommend rules. Use an empty query to list all rules for this recommendation scenario.

Required API Key ACLs:

- settings

Parameters:

  • index_name (String)

    Name of the index on which to perform the operation. (required)

  • model (RecommendModels)
  • search_recommend_rules_params (SearchRecommendRulesParams) (defaults to: nil)
  • request_options:

    The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)

Returns:



520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
# File 'lib/algolia/api/recommend_client.rb', line 520

def search_recommend_rules_with_http_info(
  index_name,
  model,
  search_recommend_rules_params = nil,
  request_options = {}
)
  # verify the required parameter 'index_name' is set
  if @api_client.config.client_side_validation && index_name.nil?
    raise ArgumentError, "Parameter `index_name` is required when calling `search_recommend_rules`."
  end
  # verify the required parameter 'model' is set
  if @api_client.config.client_side_validation && model.nil?
    raise ArgumentError, "Parameter `model` is required when calling `search_recommend_rules`."
  end

  path = "/1/indexes/{indexName}/{model}/recommend/rules/search"
    .sub("{" + "indexName" + "}", Transport.encode_uri(index_name.to_s))
    .sub("{" + "model" + "}", Transport.encode_uri(model.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(search_recommend_rules_params)

  new_options = request_options.merge(
    :operation => :"RecommendClient.search_recommend_rules",
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => true
  )

  @api_client.call_api(:POST, path, new_options)
end

#set_client_api_key(api_key) ⇒ void

This method returns an undefined value.

Helper method to switch the API key used to authenticate the requests.

Parameters:

  • api_key (String)

    the new API key to use.



39
40
41
42
43
# File 'lib/algolia/api/recommend_client.rb', line 39

def set_client_api_key(api_key)
  @api_client.set_client_api_key(api_key)

  self
end