Skip to content

Commit 75533d4

Browse files
algolia-botraed667millotpshortcuts
committed
feat(specs): add recommend batch rules endpoint (generated)
algolia/api-clients-automation#3782 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Raed <[email protected]> Co-authored-by: Pierre Millot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent d0fb7d2 commit 75533d4

File tree

4 files changed

+618
-0
lines changed

4 files changed

+618
-0
lines changed

lib/Api/RecommendClient.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,60 @@ public function setClientApiKey($apiKey)
109109
$this->config->setClientApiKey($apiKey);
110110
}
111111

112+
/**
113+
* 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).
114+
*
115+
* Required API Key ACLs:
116+
* - editSettings
117+
*
118+
* @param string $indexName Name of the index on which to perform the operation. (required)
119+
* @param array $model [Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models). (required)
120+
* @param array $recommendRule recommendRule (optional)
121+
* @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions
122+
*
123+
* @return \Algolia\AlgoliaSearch\Model\Recommend\RecommendUpdatedAtResponse|array<string, mixed>
124+
*/
125+
public function batchRecommendRules($indexName, $model, $recommendRule = null, $requestOptions = [])
126+
{
127+
// verify the required parameter 'indexName' is set
128+
if (!isset($indexName)) {
129+
throw new \InvalidArgumentException(
130+
'Parameter `indexName` is required when calling `batchRecommendRules`.'
131+
);
132+
}
133+
// verify the required parameter 'model' is set
134+
if (!isset($model)) {
135+
throw new \InvalidArgumentException(
136+
'Parameter `model` is required when calling `batchRecommendRules`.'
137+
);
138+
}
139+
140+
$resourcePath = '/1/indexes/{indexName}/{model}/recommend/rules/batch';
141+
$queryParameters = [];
142+
$headers = [];
143+
$httpBody = isset($recommendRule) ? $recommendRule : [];
144+
145+
// path params
146+
if (null !== $indexName) {
147+
$resourcePath = str_replace(
148+
'{indexName}',
149+
ObjectSerializer::toPathValue($indexName),
150+
$resourcePath
151+
);
152+
}
153+
154+
// path params
155+
if (null !== $model) {
156+
$resourcePath = str_replace(
157+
'{model}',
158+
ObjectSerializer::toPathValue($model),
159+
$resourcePath
160+
);
161+
}
162+
163+
return $this->sendRequest('POST', $resourcePath, $headers, $queryParameters, $httpBody, $requestOptions);
164+
}
165+
112166
/**
113167
* This method allow you to send requests to the Algolia REST API.
114168
*

lib/Model/Recommend/RecommendRule.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class RecommendRule extends AbstractModel implements ModelInterface, \ArrayAcces
2828
'consequence' => '\Algolia\AlgoliaSearch\Model\Recommend\Consequence',
2929
'description' => 'string',
3030
'enabled' => 'bool',
31+
'validity' => '\Algolia\AlgoliaSearch\Model\Recommend\TimeRange[]',
3132
];
3233

3334
/**
@@ -42,6 +43,7 @@ class RecommendRule extends AbstractModel implements ModelInterface, \ArrayAcces
4243
'consequence' => null,
4344
'description' => null,
4445
'enabled' => null,
46+
'validity' => null,
4547
];
4648

4749
/**
@@ -57,6 +59,7 @@ class RecommendRule extends AbstractModel implements ModelInterface, \ArrayAcces
5759
'consequence' => 'consequence',
5860
'description' => 'description',
5961
'enabled' => 'enabled',
62+
'validity' => 'validity',
6063
];
6164

6265
/**
@@ -71,6 +74,7 @@ class RecommendRule extends AbstractModel implements ModelInterface, \ArrayAcces
7174
'consequence' => 'setConsequence',
7275
'description' => 'setDescription',
7376
'enabled' => 'setEnabled',
77+
'validity' => 'setValidity',
7478
];
7579

7680
/**
@@ -85,6 +89,7 @@ class RecommendRule extends AbstractModel implements ModelInterface, \ArrayAcces
8589
'consequence' => 'getConsequence',
8690
'description' => 'getDescription',
8791
'enabled' => 'getEnabled',
92+
'validity' => 'getValidity',
8893
];
8994

9095
/**
@@ -119,6 +124,9 @@ public function __construct(?array $data = null)
119124
if (isset($data['enabled'])) {
120125
$this->container['enabled'] = $data['enabled'];
121126
}
127+
if (isset($data['validity'])) {
128+
$this->container['validity'] = $data['validity'];
129+
}
122130
}
123131

124132
/**
@@ -337,6 +345,30 @@ public function setEnabled($enabled)
337345
return $this;
338346
}
339347

348+
/**
349+
* Gets validity.
350+
*
351+
* @return null|\Algolia\AlgoliaSearch\Model\Recommend\TimeRange[]
352+
*/
353+
public function getValidity()
354+
{
355+
return $this->container['validity'] ?? null;
356+
}
357+
358+
/**
359+
* Sets validity.
360+
*
361+
* @param null|\Algolia\AlgoliaSearch\Model\Recommend\TimeRange[] $validity time periods when the rule is active
362+
*
363+
* @return self
364+
*/
365+
public function setValidity($validity)
366+
{
367+
$this->container['validity'] = $validity;
368+
369+
return $this;
370+
}
371+
340372
/**
341373
* Returns true if offset exists. False otherwise.
342374
*

0 commit comments

Comments
 (0)