Skip to content

Commit 6dfb0b6

Browse files
committed
Add logic parameter to recommendation endpoints. Use HTTPS as default.
1 parent 2d352c5 commit 6dfb0b6

File tree

6 files changed

+73
-17
lines changed

6 files changed

+73
-17
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ or
1717
```
1818
{
1919
"require": {
20-
"recombee/php-api-client": "^2.3.0"
20+
"recombee/php-api-client": "^2.4.0"
2121
}
2222
}
2323
```

src/RecommApi/Client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Client{
4040
* @param string $protocol Default protocol for sending requests. Possible values: 'http', 'https'.
4141
* @param array $options Other custom options
4242
*/
43-
public function __construct($account, $token, $protocol = 'http', $options= array()) {
43+
public function __construct($account, $token, $protocol = 'https', $options= array()) {
4444
$this->account = $account;
4545
$this->token = $token;
4646
$this->protocol = $protocol;
@@ -52,7 +52,7 @@ public function __construct($account, $token, $protocol = 'http', $options= arra
5252
}
5353

5454
protected function getUserAgent() {
55-
$user_agent = 'recombee-php-api-client/2.3.0';
55+
$user_agent = 'recombee-php-api-client/2.4.0';
5656
if (isset($this->options['serviceName']))
5757
$user_agent .= ' '.($this->options['serviceName']);
5858
return $user_agent;

src/RecommApi/Requests/RecommendItemsToItem.php

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ class RecommendItemsToItem extends Request {
4040
* @var int $count Number of items to be recommended (N for the top-N recommendation).
4141
*/
4242
protected $count;
43-
/**
44-
* @var float $user_impact If *targetUserId* parameter is present, the recommendations are biased towards the user given. Using *userImpact*, you may control this bias. For an extreme case of `userImpact=0.0`, the interactions made by the user are not taken into account at all (with the exception of history-based blacklisting), for `userImpact=1.0`, you'll get user-based recommendation. The default value is `0`.
45-
*/
46-
protected $user_impact;
4743
/**
4844
* @var string $filter Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended items based on the values of their attributes.
4945
*/
@@ -60,6 +56,12 @@ class RecommendItemsToItem extends Request {
6056
* @var string $scenario Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". You can see each scenario in the UI separately, so you can check how well each application performs. The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
6157
*/
6258
protected $scenario;
59+
/**
60+
* @var string| $logic Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain (e-commerce, multimedia, fashion ...) and use case.
61+
* See [this section](https://docs.recombee.com/recommendation_logic.html) for list of available logics and other details.
62+
* The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
63+
*/
64+
protected $logic;
6365
/**
6466
* @var bool $return_properties With `returnProperties=true`, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used for easy displaying of the recommended items to the user.
6567
* Example response:
@@ -118,6 +120,10 @@ class RecommendItemsToItem extends Request {
118120
* ```
119121
*/
120122
protected $included_properties;
123+
/**
124+
* @var float $user_impact **Expert option** If *targetUserId* parameter is present, the recommendations are biased towards the given user. Using *userImpact*, you may control this bias. For an extreme case of `userImpact=0.0`, the interactions made by the user are not taken into account at all (with the exception of history-based blacklisting), for `userImpact=1.0`, you'll get user-based recommendation. The default value is `0`.
125+
*/
126+
protected $user_impact;
121127
/**
122128
* @var float $diversity **Expert option** Real number from [0.0, 1.0] which determines how much mutually dissimilar should the recommended items be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification.
123129
*/
@@ -166,9 +172,6 @@ class RecommendItemsToItem extends Request {
166172
* @param int $count Number of items to be recommended (N for the top-N recommendation).
167173
* @param array $optional Optional parameters given as an array containing pairs name of the parameter => value
168174
* - Allowed parameters:
169-
* - *userImpact*
170-
* - Type: float
171-
* - Description: If *targetUserId* parameter is present, the recommendations are biased towards the user given. Using *userImpact*, you may control this bias. For an extreme case of `userImpact=0.0`, the interactions made by the user are not taken into account at all (with the exception of history-based blacklisting), for `userImpact=1.0`, you'll get user-based recommendation. The default value is `0`.
172175
* - *filter*
173176
* - Type: string
174177
* - Description: Boolean-returning [ReQL](https://docs.recombee.com/reql.html) expression which allows you to filter recommended items based on the values of their attributes.
@@ -181,6 +184,11 @@ class RecommendItemsToItem extends Request {
181184
* - *scenario*
182185
* - Type: string
183186
* - Description: Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". You can see each scenario in the UI separately, so you can check how well each application performs. The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
187+
* - *logic*
188+
* - Type: string|
189+
* - Description: Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain (e-commerce, multimedia, fashion ...) and use case.
190+
* See [this section](https://docs.recombee.com/recommendation_logic.html) for list of available logics and other details.
191+
* The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
184192
* - *returnProperties*
185193
* - Type: bool
186194
* - Description: With `returnProperties=true`, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used for easy displaying of the recommended items to the user.
@@ -237,6 +245,9 @@ class RecommendItemsToItem extends Request {
237245
* ]
238246
* }
239247
* ```
248+
* - *userImpact*
249+
* - Type: float
250+
* - Description: **Expert option** If *targetUserId* parameter is present, the recommendations are biased towards the given user. Using *userImpact*, you may control this bias. For an extreme case of `userImpact=0.0`, the interactions made by the user are not taken into account at all (with the exception of history-based blacklisting), for `userImpact=1.0`, you'll get user-based recommendation. The default value is `0`.
240251
* - *diversity*
241252
* - Type: float
242253
* - Description: **Expert option** Real number from [0.0, 1.0] which determines how much mutually dissimilar should the recommended items be. The default value is 0.0, i.e., no diversification. Value 1.0 means maximal diversification.
@@ -261,13 +272,14 @@ public function __construct($item_id, $target_user_id, $count, $optional = array
261272
$this->item_id = $item_id;
262273
$this->target_user_id = $target_user_id;
263274
$this->count = $count;
264-
$this->user_impact = isset($optional['userImpact']) ? $optional['userImpact'] : null;
265275
$this->filter = isset($optional['filter']) ? $optional['filter'] : null;
266276
$this->booster = isset($optional['booster']) ? $optional['booster'] : null;
267277
$this->cascade_create = isset($optional['cascadeCreate']) ? $optional['cascadeCreate'] : null;
268278
$this->scenario = isset($optional['scenario']) ? $optional['scenario'] : null;
279+
$this->logic = isset($optional['logic']) ? $optional['logic'] : null;
269280
$this->return_properties = isset($optional['returnProperties']) ? $optional['returnProperties'] : null;
270281
$this->included_properties = isset($optional['includedProperties']) ? $optional['includedProperties'] : null;
282+
$this->user_impact = isset($optional['userImpact']) ? $optional['userImpact'] : null;
271283
$this->diversity = isset($optional['diversity']) ? $optional['diversity'] : null;
272284
$this->min_relevance = isset($optional['minRelevance']) ? $optional['minRelevance'] : null;
273285
$this->rotation_rate = isset($optional['rotationRate']) ? $optional['rotationRate'] : null;
@@ -276,7 +288,7 @@ public function __construct($item_id, $target_user_id, $count, $optional = array
276288
$this->return_ab_group = isset($optional['returnAbGroup']) ? $optional['returnAbGroup'] : null;
277289
$this->optional = $optional;
278290

279-
$existing_optional = array('userImpact','filter','booster','cascadeCreate','scenario','returnProperties','includedProperties','diversity','minRelevance','rotationRate','rotationTime','expertSettings','returnAbGroup');
291+
$existing_optional = array('filter','booster','cascadeCreate','scenario','logic','returnProperties','includedProperties','userImpact','diversity','minRelevance','rotationRate','rotationTime','expertSettings','returnAbGroup');
280292
foreach ($this->optional as $key => $value) {
281293
if (!in_array($key, $existing_optional))
282294
throw new UnknownOptionalParameterException($key);
@@ -318,8 +330,6 @@ public function getBodyParameters() {
318330
$p = array();
319331
$p['targetUserId'] = $this->target_user_id;
320332
$p['count'] = $this->count;
321-
if (isset($this->optional['userImpact']))
322-
$p['userImpact'] = $this-> optional['userImpact'];
323333
if (isset($this->optional['filter']))
324334
$p['filter'] = $this-> optional['filter'];
325335
if (isset($this->optional['booster']))
@@ -328,10 +338,14 @@ public function getBodyParameters() {
328338
$p['cascadeCreate'] = $this-> optional['cascadeCreate'];
329339
if (isset($this->optional['scenario']))
330340
$p['scenario'] = $this-> optional['scenario'];
341+
if (isset($this->optional['logic']))
342+
$p['logic'] = $this-> optional['logic'];
331343
if (isset($this->optional['returnProperties']))
332344
$p['returnProperties'] = $this-> optional['returnProperties'];
333345
if (isset($this->optional['includedProperties']))
334346
$p['includedProperties'] = $this-> optional['includedProperties'];
347+
if (isset($this->optional['userImpact']))
348+
$p['userImpact'] = $this-> optional['userImpact'];
335349
if (isset($this->optional['diversity']))
336350
$p['diversity'] = $this-> optional['diversity'];
337351
if (isset($this->optional['minRelevance']))

src/RecommApi/Requests/RecommendItemsToUser.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ class RecommendItemsToUser extends Request {
4040
* @var string $scenario Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". You can see each scenario in the UI separately, so you can check how well each application performs. The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
4141
*/
4242
protected $scenario;
43+
/**
44+
* @var string| $logic Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain (e-commerce, multimedia, fashion ...) and use case.
45+
* See [this section](https://docs.recombee.com/recommendation_logic.html) for list of available logics and other details.
46+
* The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
47+
*/
48+
protected $logic;
4349
/**
4450
* @var bool $return_properties With `returnProperties=true`, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used for easy displaying of the recommended items to the user.
4551
* Example response:
@@ -145,6 +151,11 @@ class RecommendItemsToUser extends Request {
145151
* - *scenario*
146152
* - Type: string
147153
* - Description: Scenario defines a particular application of recommendations. It can be for example "homepage", "cart" or "emailing". You can see each scenario in the UI separately, so you can check how well each application performs. The AI which optimizes models in order to get the best results may optimize different scenarios separately, or even use different models in each of the scenarios.
154+
* - *logic*
155+
* - Type: string|
156+
* - Description: Logic specifies particular behavior of the recommendation models. You can pick tailored logic for your domain (e-commerce, multimedia, fashion ...) and use case.
157+
* See [this section](https://docs.recombee.com/recommendation_logic.html) for list of available logics and other details.
158+
* The difference between `logic` and `scenario` is that `logic` specifies mainly behavior, while `scenario` specifies the place where recommendations are shown to the users.
148159
* - *returnProperties*
149160
* - Type: bool
150161
* - Description: With `returnProperties=true`, property values of the recommended items are returned along with their IDs in a JSON dictionary. The acquired property values can be used for easy displaying of the recommended items to the user.
@@ -228,6 +239,7 @@ public function __construct($user_id, $count, $optional = array()) {
228239
$this->booster = isset($optional['booster']) ? $optional['booster'] : null;
229240
$this->cascade_create = isset($optional['cascadeCreate']) ? $optional['cascadeCreate'] : null;
230241
$this->scenario = isset($optional['scenario']) ? $optional['scenario'] : null;
242+
$this->logic = isset($optional['logic']) ? $optional['logic'] : null;
231243
$this->return_properties = isset($optional['returnProperties']) ? $optional['returnProperties'] : null;
232244
$this->included_properties = isset($optional['includedProperties']) ? $optional['includedProperties'] : null;
233245
$this->diversity = isset($optional['diversity']) ? $optional['diversity'] : null;
@@ -238,7 +250,7 @@ public function __construct($user_id, $count, $optional = array()) {
238250
$this->return_ab_group = isset($optional['returnAbGroup']) ? $optional['returnAbGroup'] : null;
239251
$this->optional = $optional;
240252

241-
$existing_optional = array('filter','booster','cascadeCreate','scenario','returnProperties','includedProperties','diversity','minRelevance','rotationRate','rotationTime','expertSettings','returnAbGroup');
253+
$existing_optional = array('filter','booster','cascadeCreate','scenario','logic','returnProperties','includedProperties','diversity','minRelevance','rotationRate','rotationTime','expertSettings','returnAbGroup');
242254
foreach ($this->optional as $key => $value) {
243255
if (!in_array($key, $existing_optional))
244256
throw new UnknownOptionalParameterException($key);
@@ -287,6 +299,8 @@ public function getBodyParameters() {
287299
$p['cascadeCreate'] = $this-> optional['cascadeCreate'];
288300
if (isset($this->optional['scenario']))
289301
$p['scenario'] = $this-> optional['scenario'];
302+
if (isset($this->optional['logic']))
303+
$p['logic'] = $this-> optional['logic'];
290304
if (isset($this->optional['returnProperties']))
291305
$p['returnProperties'] = $this-> optional['returnProperties'];
292306
if (isset($this->optional['includedProperties']))

0 commit comments

Comments
 (0)