Skip to content

Commit 9e93727

Browse files
committed
Release: v6.1.0
- Added support for `reqlExpressions` on recommended item segments
1 parent 040f58a commit 9e93727

6 files changed

Lines changed: 302 additions & 6 deletions

File tree

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": "^6.0.0"
20+
"recombee/php-api-client": "^6.1.0"
2121
}
2222
}
2323
```

src/RecommApi/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected function getBaseUri() {
9292
}
9393

9494
protected function getUserAgent() {
95-
$user_agent = 'recombee-php-api-client/6.0.0';
95+
$user_agent = 'recombee-php-api-client/6.1.0';
9696
if (isset($this->options['serviceName']))
9797
$user_agent .= ' '.($this->options['serviceName']);
9898
return $user_agent;

src/RecommApi/Requests/RecommendItemSegmentsToItem.php

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,42 @@ class RecommendItemSegmentsToItem extends Request {
7979
* @var bool $return_ab_group If there is a custom AB-testing running, return the name of the group to which the request belongs.
8080
*/
8181
protected $return_ab_group;
82+
/**
83+
* @var array $reql_expressions A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended Item Segment.
84+
* This can be used to compute additional properties of the recommended Item Segments.
85+
* The keys are the names of the expressions, and the values are the actual ReQL expressions.
86+
* Example request:
87+
* ```json
88+
* {
89+
* "reqlExpressions": {
90+
* "countItems": "size(segment_items(\"categories\", 'segmentId'))"
91+
* }
92+
* }
93+
* ```
94+
* Example response:
95+
* ```json
96+
* {
97+
* "recommId": "a7ac55a4-8d6e-4f19-addc-abac4164d8a8",
98+
* "recomms":
99+
* [
100+
* {
101+
* "id": "category-fantasy-books",
102+
* "reqlEvaluations": {
103+
* "countItems": 486
104+
* }
105+
* },
106+
* {
107+
* "id": "category-sci-fi-costumes",
108+
* "reqlEvaluations": {
109+
* "countItems": 19
110+
* }
111+
* }
112+
* ],
113+
* "numberNextRecommsCalls": 0
114+
* }
115+
* ```
116+
*/
117+
protected $reql_expressions;
82118
/**
83119
* @var array Array containing values of optional parameters
84120
*/
@@ -129,6 +165,41 @@ class RecommendItemSegmentsToItem extends Request {
129165
* - *returnAbGroup*
130166
* - Type: bool
131167
* - Description: If there is a custom AB-testing running, return the name of the group to which the request belongs.
168+
* - *reqlExpressions*
169+
* - Type: array
170+
* - Description: A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended Item Segment.
171+
* This can be used to compute additional properties of the recommended Item Segments.
172+
* The keys are the names of the expressions, and the values are the actual ReQL expressions.
173+
* Example request:
174+
* ```json
175+
* {
176+
* "reqlExpressions": {
177+
* "countItems": "size(segment_items(\"categories\", 'segmentId'))"
178+
* }
179+
* }
180+
* ```
181+
* Example response:
182+
* ```json
183+
* {
184+
* "recommId": "a7ac55a4-8d6e-4f19-addc-abac4164d8a8",
185+
* "recomms":
186+
* [
187+
* {
188+
* "id": "category-fantasy-books",
189+
* "reqlEvaluations": {
190+
* "countItems": 486
191+
* }
192+
* },
193+
* {
194+
* "id": "category-sci-fi-costumes",
195+
* "reqlEvaluations": {
196+
* "countItems": 19
197+
* }
198+
* }
199+
* ],
200+
* "numberNextRecommsCalls": 0
201+
* }
202+
* ```
132203
* @throws Exceptions\UnknownOptionalParameterException UnknownOptionalParameterException if an unknown optional parameter is given in $optional
133204
*/
134205
public function __construct($item_id, $target_user_id, $count, $optional = array()) {
@@ -142,9 +213,10 @@ public function __construct($item_id, $target_user_id, $count, $optional = array
142213
$this->logic = isset($optional['logic']) ? $optional['logic'] : null;
143214
$this->expert_settings = isset($optional['expertSettings']) ? $optional['expertSettings'] : null;
144215
$this->return_ab_group = isset($optional['returnAbGroup']) ? $optional['returnAbGroup'] : null;
216+
$this->reql_expressions = isset($optional['reqlExpressions']) ? $optional['reqlExpressions'] : null;
145217
$this->optional = $optional;
146218

147-
$existing_optional = array('scenario','cascadeCreate','filter','booster','logic','expertSettings','returnAbGroup');
219+
$existing_optional = array('scenario','cascadeCreate','filter','booster','logic','expertSettings','returnAbGroup','reqlExpressions');
148220
foreach ($this->optional as $key => $value) {
149221
if (!in_array($key, $existing_optional))
150222
throw new UnknownOptionalParameterException($key);
@@ -200,6 +272,8 @@ public function getBodyParameters() {
200272
$p['expertSettings'] = $this-> optional['expertSettings'];
201273
if (isset($this->optional['returnAbGroup']))
202274
$p['returnAbGroup'] = $this-> optional['returnAbGroup'];
275+
if (isset($this->optional['reqlExpressions']))
276+
$p['reqlExpressions'] = $this-> optional['reqlExpressions'];
203277
return $p;
204278
}
205279

src/RecommApi/Requests/RecommendItemSegmentsToItemSegment.php

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,42 @@ class RecommendItemSegmentsToItemSegment extends Request {
7878
* @var bool $return_ab_group If there is a custom AB-testing running, return the name of the group to which the request belongs.
7979
*/
8080
protected $return_ab_group;
81+
/**
82+
* @var array $reql_expressions A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended Item Segment.
83+
* This can be used to compute additional properties of the recommended Item Segments.
84+
* The keys are the names of the expressions, and the values are the actual ReQL expressions.
85+
* Example request:
86+
* ```json
87+
* {
88+
* "reqlExpressions": {
89+
* "countItems": "size(segment_items(\"categories\", 'segmentId'))"
90+
* }
91+
* }
92+
* ```
93+
* Example response:
94+
* ```json
95+
* {
96+
* "recommId": "a7ac55a4-8d6e-4f19-addc-abac4164d8a8",
97+
* "recomms":
98+
* [
99+
* {
100+
* "id": "category-fantasy-books",
101+
* "reqlEvaluations": {
102+
* "countItems": 486
103+
* }
104+
* },
105+
* {
106+
* "id": "category-sci-fi-costumes",
107+
* "reqlEvaluations": {
108+
* "countItems": 19
109+
* }
110+
* }
111+
* ],
112+
* "numberNextRecommsCalls": 0
113+
* }
114+
* ```
115+
*/
116+
protected $reql_expressions;
81117
/**
82118
* @var array Array containing values of optional parameters
83119
*/
@@ -128,6 +164,41 @@ class RecommendItemSegmentsToItemSegment extends Request {
128164
* - *returnAbGroup*
129165
* - Type: bool
130166
* - Description: If there is a custom AB-testing running, return the name of the group to which the request belongs.
167+
* - *reqlExpressions*
168+
* - Type: array
169+
* - Description: A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended Item Segment.
170+
* This can be used to compute additional properties of the recommended Item Segments.
171+
* The keys are the names of the expressions, and the values are the actual ReQL expressions.
172+
* Example request:
173+
* ```json
174+
* {
175+
* "reqlExpressions": {
176+
* "countItems": "size(segment_items(\"categories\", 'segmentId'))"
177+
* }
178+
* }
179+
* ```
180+
* Example response:
181+
* ```json
182+
* {
183+
* "recommId": "a7ac55a4-8d6e-4f19-addc-abac4164d8a8",
184+
* "recomms":
185+
* [
186+
* {
187+
* "id": "category-fantasy-books",
188+
* "reqlEvaluations": {
189+
* "countItems": 486
190+
* }
191+
* },
192+
* {
193+
* "id": "category-sci-fi-costumes",
194+
* "reqlEvaluations": {
195+
* "countItems": 19
196+
* }
197+
* }
198+
* ],
199+
* "numberNextRecommsCalls": 0
200+
* }
201+
* ```
131202
* @throws Exceptions\UnknownOptionalParameterException UnknownOptionalParameterException if an unknown optional parameter is given in $optional
132203
*/
133204
public function __construct($context_segment_id, $target_user_id, $count, $optional = array()) {
@@ -141,9 +212,10 @@ public function __construct($context_segment_id, $target_user_id, $count, $optio
141212
$this->logic = isset($optional['logic']) ? $optional['logic'] : null;
142213
$this->expert_settings = isset($optional['expertSettings']) ? $optional['expertSettings'] : null;
143214
$this->return_ab_group = isset($optional['returnAbGroup']) ? $optional['returnAbGroup'] : null;
215+
$this->reql_expressions = isset($optional['reqlExpressions']) ? $optional['reqlExpressions'] : null;
144216
$this->optional = $optional;
145217

146-
$existing_optional = array('scenario','cascadeCreate','filter','booster','logic','expertSettings','returnAbGroup');
218+
$existing_optional = array('scenario','cascadeCreate','filter','booster','logic','expertSettings','returnAbGroup','reqlExpressions');
147219
foreach ($this->optional as $key => $value) {
148220
if (!in_array($key, $existing_optional))
149221
throw new UnknownOptionalParameterException($key);
@@ -200,6 +272,8 @@ public function getBodyParameters() {
200272
$p['expertSettings'] = $this-> optional['expertSettings'];
201273
if (isset($this->optional['returnAbGroup']))
202274
$p['returnAbGroup'] = $this-> optional['returnAbGroup'];
275+
if (isset($this->optional['reqlExpressions']))
276+
$p['reqlExpressions'] = $this-> optional['reqlExpressions'];
203277
return $p;
204278
}
205279

src/RecommApi/Requests/RecommendItemSegmentsToUser.php

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,42 @@ class RecommendItemSegmentsToUser extends Request {
6363
* @var bool $return_ab_group If there is a custom AB-testing running, return the name of the group to which the request belongs.
6464
*/
6565
protected $return_ab_group;
66+
/**
67+
* @var array $reql_expressions A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended Item Segment.
68+
* This can be used to compute additional properties of the recommended Item Segments.
69+
* The keys are the names of the expressions, and the values are the actual ReQL expressions.
70+
* Example request:
71+
* ```json
72+
* {
73+
* "reqlExpressions": {
74+
* "countItems": "size(segment_items(\"categories\", 'segmentId'))"
75+
* }
76+
* }
77+
* ```
78+
* Example response:
79+
* ```json
80+
* {
81+
* "recommId": "a7ac55a4-8d6e-4f19-addc-abac4164d8a8",
82+
* "recomms":
83+
* [
84+
* {
85+
* "id": "category-fantasy-books",
86+
* "reqlEvaluations": {
87+
* "countItems": 486
88+
* }
89+
* },
90+
* {
91+
* "id": "category-sci-fi-costumes",
92+
* "reqlEvaluations": {
93+
* "countItems": 19
94+
* }
95+
* }
96+
* ],
97+
* "numberNextRecommsCalls": 0
98+
* }
99+
* ```
100+
*/
101+
protected $reql_expressions;
66102
/**
67103
* @var array Array containing values of optional parameters
68104
*/
@@ -100,6 +136,41 @@ class RecommendItemSegmentsToUser extends Request {
100136
* - *returnAbGroup*
101137
* - Type: bool
102138
* - Description: If there is a custom AB-testing running, return the name of the group to which the request belongs.
139+
* - *reqlExpressions*
140+
* - Type: array
141+
* - Description: A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended Item Segment.
142+
* This can be used to compute additional properties of the recommended Item Segments.
143+
* The keys are the names of the expressions, and the values are the actual ReQL expressions.
144+
* Example request:
145+
* ```json
146+
* {
147+
* "reqlExpressions": {
148+
* "countItems": "size(segment_items(\"categories\", 'segmentId'))"
149+
* }
150+
* }
151+
* ```
152+
* Example response:
153+
* ```json
154+
* {
155+
* "recommId": "a7ac55a4-8d6e-4f19-addc-abac4164d8a8",
156+
* "recomms":
157+
* [
158+
* {
159+
* "id": "category-fantasy-books",
160+
* "reqlEvaluations": {
161+
* "countItems": 486
162+
* }
163+
* },
164+
* {
165+
* "id": "category-sci-fi-costumes",
166+
* "reqlEvaluations": {
167+
* "countItems": 19
168+
* }
169+
* }
170+
* ],
171+
* "numberNextRecommsCalls": 0
172+
* }
173+
* ```
103174
* @throws Exceptions\UnknownOptionalParameterException UnknownOptionalParameterException if an unknown optional parameter is given in $optional
104175
*/
105176
public function __construct($user_id, $count, $optional = array()) {
@@ -112,9 +183,10 @@ public function __construct($user_id, $count, $optional = array()) {
112183
$this->logic = isset($optional['logic']) ? $optional['logic'] : null;
113184
$this->expert_settings = isset($optional['expertSettings']) ? $optional['expertSettings'] : null;
114185
$this->return_ab_group = isset($optional['returnAbGroup']) ? $optional['returnAbGroup'] : null;
186+
$this->reql_expressions = isset($optional['reqlExpressions']) ? $optional['reqlExpressions'] : null;
115187
$this->optional = $optional;
116188

117-
$existing_optional = array('scenario','cascadeCreate','filter','booster','logic','expertSettings','returnAbGroup');
189+
$existing_optional = array('scenario','cascadeCreate','filter','booster','logic','expertSettings','returnAbGroup','reqlExpressions');
118190
foreach ($this->optional as $key => $value) {
119191
if (!in_array($key, $existing_optional))
120192
throw new UnknownOptionalParameterException($key);
@@ -169,6 +241,8 @@ public function getBodyParameters() {
169241
$p['expertSettings'] = $this-> optional['expertSettings'];
170242
if (isset($this->optional['returnAbGroup']))
171243
$p['returnAbGroup'] = $this-> optional['returnAbGroup'];
244+
if (isset($this->optional['reqlExpressions']))
245+
$p['reqlExpressions'] = $this-> optional['reqlExpressions'];
172246
return $p;
173247
}
174248

0 commit comments

Comments
 (0)