Skip to content

Commit 1843fec

Browse files
committed
Add recommId parameter to add interaction requests
1 parent 55a9b28 commit 1843fec

11 files changed

+99
-11
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ or
1717
```
1818
{
1919
"require": {
20-
"recombee/php-api-client": "^2.1.1"
20+
"recombee/php-api-client": "^2.2.0"
2121
}
2222
}
2323
```

src/RecommApi/Client.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -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.1.1';
55+
$user_agent = 'recombee-php-api-client/2.2.0';
5656
if (isset($this->options['serviceName']))
5757
$user_agent .= ' '.($this->options['serviceName']);
5858
return $user_agent;

src/RecommApi/Requests/AddBookmark.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ class AddBookmark extends Request {
3030
* @var bool $cascade_create Sets whether the given user/item should be created if not present in the database.
3131
*/
3232
protected $cascade_create;
33+
/**
34+
* @var string $recomm_id If this bookmark is based on a recommendation request, `recommId` is the id of the clicked recommendation.
35+
*/
36+
protected $recomm_id;
3337
/**
3438
* @var array Array containing values of optional parameters
3539
*/
@@ -47,16 +51,20 @@ class AddBookmark extends Request {
4751
* - *cascadeCreate*
4852
* - Type: bool
4953
* - Description: Sets whether the given user/item should be created if not present in the database.
54+
* - *recommId*
55+
* - Type: string
56+
* - Description: If this bookmark is based on a recommendation request, `recommId` is the id of the clicked recommendation.
5057
* @throws Exceptions\UnknownOptionalParameterException UnknownOptionalParameterException if an unknown optional parameter is given in $optional
5158
*/
5259
public function __construct($user_id, $item_id, $optional = array()) {
5360
$this->user_id = $user_id;
5461
$this->item_id = $item_id;
5562
$this->timestamp = isset($optional['timestamp']) ? $optional['timestamp'] : null;
5663
$this->cascade_create = isset($optional['cascadeCreate']) ? $optional['cascadeCreate'] : null;
64+
$this->recomm_id = isset($optional['recommId']) ? $optional['recommId'] : null;
5765
$this->optional = $optional;
5866

59-
$existing_optional = array('timestamp','cascadeCreate');
67+
$existing_optional = array('timestamp','cascadeCreate','recommId');
6068
foreach ($this->optional as $key => $value) {
6169
if (!in_array($key, $existing_optional))
6270
throw new UnknownOptionalParameterException($key);
@@ -102,6 +110,8 @@ public function getBodyParameters() {
102110
$p['timestamp'] = $this-> optional['timestamp'];
103111
if (isset($this->optional['cascadeCreate']))
104112
$p['cascadeCreate'] = $this-> optional['cascadeCreate'];
113+
if (isset($this->optional['recommId']))
114+
$p['recommId'] = $this-> optional['recommId'];
105115
return $p;
106116
}
107117

src/RecommApi/Requests/AddCartAddition.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ class AddCartAddition extends Request {
3838
* @var float $price Price of the added item. If `amount` is greater than 1, sum of prices of all the items should be given.
3939
*/
4040
protected $price;
41+
/**
42+
* @var string $recomm_id If this cart addition is based on a recommendation request, `recommId` is the id of the clicked recommendation.
43+
*/
44+
protected $recomm_id;
4145
/**
4246
* @var array Array containing values of optional parameters
4347
*/
@@ -61,6 +65,9 @@ class AddCartAddition extends Request {
6165
* - *price*
6266
* - Type: float
6367
* - Description: Price of the added item. If `amount` is greater than 1, sum of prices of all the items should be given.
68+
* - *recommId*
69+
* - Type: string
70+
* - Description: If this cart addition is based on a recommendation request, `recommId` is the id of the clicked recommendation.
6471
* @throws Exceptions\UnknownOptionalParameterException UnknownOptionalParameterException if an unknown optional parameter is given in $optional
6572
*/
6673
public function __construct($user_id, $item_id, $optional = array()) {
@@ -70,9 +77,10 @@ public function __construct($user_id, $item_id, $optional = array()) {
7077
$this->cascade_create = isset($optional['cascadeCreate']) ? $optional['cascadeCreate'] : null;
7178
$this->amount = isset($optional['amount']) ? $optional['amount'] : null;
7279
$this->price = isset($optional['price']) ? $optional['price'] : null;
80+
$this->recomm_id = isset($optional['recommId']) ? $optional['recommId'] : null;
7381
$this->optional = $optional;
7482

75-
$existing_optional = array('timestamp','cascadeCreate','amount','price');
83+
$existing_optional = array('timestamp','cascadeCreate','amount','price','recommId');
7684
foreach ($this->optional as $key => $value) {
7785
if (!in_array($key, $existing_optional))
7886
throw new UnknownOptionalParameterException($key);
@@ -122,6 +130,8 @@ public function getBodyParameters() {
122130
$p['amount'] = $this-> optional['amount'];
123131
if (isset($this->optional['price']))
124132
$p['price'] = $this-> optional['price'];
133+
if (isset($this->optional['recommId']))
134+
$p['recommId'] = $this-> optional['recommId'];
125135
return $p;
126136
}
127137

src/RecommApi/Requests/AddDetailView.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ class AddDetailView extends Request {
3434
* @var bool $cascade_create Sets whether the given user/item should be created if not present in the database.
3535
*/
3636
protected $cascade_create;
37+
/**
38+
* @var string $recomm_id If this detail view is based on a recommendation request, `recommId` is the id of the clicked recommendation.
39+
*/
40+
protected $recomm_id;
3741
/**
3842
* @var array Array containing values of optional parameters
3943
*/
@@ -54,6 +58,9 @@ class AddDetailView extends Request {
5458
* - *cascadeCreate*
5559
* - Type: bool
5660
* - Description: Sets whether the given user/item should be created if not present in the database.
61+
* - *recommId*
62+
* - Type: string
63+
* - Description: If this detail view is based on a recommendation request, `recommId` is the id of the clicked recommendation.
5764
* @throws Exceptions\UnknownOptionalParameterException UnknownOptionalParameterException if an unknown optional parameter is given in $optional
5865
*/
5966
public function __construct($user_id, $item_id, $optional = array()) {
@@ -62,9 +69,10 @@ public function __construct($user_id, $item_id, $optional = array()) {
6269
$this->timestamp = isset($optional['timestamp']) ? $optional['timestamp'] : null;
6370
$this->duration = isset($optional['duration']) ? $optional['duration'] : null;
6471
$this->cascade_create = isset($optional['cascadeCreate']) ? $optional['cascadeCreate'] : null;
72+
$this->recomm_id = isset($optional['recommId']) ? $optional['recommId'] : null;
6573
$this->optional = $optional;
6674

67-
$existing_optional = array('timestamp','duration','cascadeCreate');
75+
$existing_optional = array('timestamp','duration','cascadeCreate','recommId');
6876
foreach ($this->optional as $key => $value) {
6977
if (!in_array($key, $existing_optional))
7078
throw new UnknownOptionalParameterException($key);
@@ -112,6 +120,8 @@ public function getBodyParameters() {
112120
$p['duration'] = $this-> optional['duration'];
113121
if (isset($this->optional['cascadeCreate']))
114122
$p['cascadeCreate'] = $this-> optional['cascadeCreate'];
123+
if (isset($this->optional['recommId']))
124+
$p['recommId'] = $this-> optional['recommId'];
115125
return $p;
116126
}
117127

src/RecommApi/Requests/AddItemProperty.php

+16
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,29 @@ class AddItemProperty extends Request {
2020
protected $property_name;
2121
/**
2222
* @var string $type Value type of the item property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`, `image` or `imageList`.
23+
* * `int`- Signed integer number.
24+
* * `double` - Floating point number. It uses 64-bit base-2 format (IEEE 754 standard).
25+
* * `string` - UTF-8 string.
26+
* * `boolean` - *true* / *false*
27+
* * `timestamp` - Value representing date and time.
28+
* * `set` - Set of strings.
29+
* * `image` - URL of an image (`jpeg`, `png` or `gif`).
30+
* * `imageList` - List of URLs that refer to images.
2331
*/
2432
protected $type;
2533

2634
/**
2735
* Construct the request
2836
* @param string $property_name Name of the item property to be created. Currently, the following names are reserved:`id`, `itemid`, case insensitively. Also, the length of the property name must not exceed 63 characters.
2937
* @param string $type Value type of the item property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`, `image` or `imageList`.
38+
* * `int`- Signed integer number.
39+
* * `double` - Floating point number. It uses 64-bit base-2 format (IEEE 754 standard).
40+
* * `string` - UTF-8 string.
41+
* * `boolean` - *true* / *false*
42+
* * `timestamp` - Value representing date and time.
43+
* * `set` - Set of strings.
44+
* * `image` - URL of an image (`jpeg`, `png` or `gif`).
45+
* * `imageList` - List of URLs that refer to images.
3046
*/
3147
public function __construct($property_name, $type) {
3248
$this->property_name = $property_name;

src/RecommApi/Requests/AddPurchase.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ class AddPurchase extends Request {
4242
* @var float $profit Your profit from the purchased item. The profit is natural in e-commerce domain (for example if `user-x` purchases `item-y` for $100 and the gross margin is 30 %, then the profit is $30), but is applicable also in other domains (for example at a news company it may be income from displayed advertisement on article page). If `amount` is greater than 1, sum of profit of all the items should be given.
4343
*/
4444
protected $profit;
45+
/**
46+
* @var string $recomm_id If this purchase is based on a recommendation request, `recommId` is the id of the clicked recommendation.
47+
*/
48+
protected $recomm_id;
4549
/**
4650
* @var array Array containing values of optional parameters
4751
*/
@@ -68,6 +72,9 @@ class AddPurchase extends Request {
6872
* - *profit*
6973
* - Type: float
7074
* - Description: Your profit from the purchased item. The profit is natural in e-commerce domain (for example if `user-x` purchases `item-y` for $100 and the gross margin is 30 %, then the profit is $30), but is applicable also in other domains (for example at a news company it may be income from displayed advertisement on article page). If `amount` is greater than 1, sum of profit of all the items should be given.
75+
* - *recommId*
76+
* - Type: string
77+
* - Description: If this purchase is based on a recommendation request, `recommId` is the id of the clicked recommendation.
7178
* @throws Exceptions\UnknownOptionalParameterException UnknownOptionalParameterException if an unknown optional parameter is given in $optional
7279
*/
7380
public function __construct($user_id, $item_id, $optional = array()) {
@@ -78,9 +85,10 @@ public function __construct($user_id, $item_id, $optional = array()) {
7885
$this->amount = isset($optional['amount']) ? $optional['amount'] : null;
7986
$this->price = isset($optional['price']) ? $optional['price'] : null;
8087
$this->profit = isset($optional['profit']) ? $optional['profit'] : null;
88+
$this->recomm_id = isset($optional['recommId']) ? $optional['recommId'] : null;
8189
$this->optional = $optional;
8290

83-
$existing_optional = array('timestamp','cascadeCreate','amount','price','profit');
91+
$existing_optional = array('timestamp','cascadeCreate','amount','price','profit','recommId');
8492
foreach ($this->optional as $key => $value) {
8593
if (!in_array($key, $existing_optional))
8694
throw new UnknownOptionalParameterException($key);
@@ -132,6 +140,8 @@ public function getBodyParameters() {
132140
$p['price'] = $this-> optional['price'];
133141
if (isset($this->optional['profit']))
134142
$p['profit'] = $this-> optional['profit'];
143+
if (isset($this->optional['recommId']))
144+
$p['recommId'] = $this-> optional['recommId'];
135145
return $p;
136146
}
137147

src/RecommApi/Requests/AddRating.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ class AddRating extends Request {
3434
* @var bool $cascade_create Sets whether the given user/item should be created if not present in the database.
3535
*/
3636
protected $cascade_create;
37+
/**
38+
* @var string $recomm_id If this rating is based on a recommendation request, `recommId` is the id of the clicked recommendation.
39+
*/
40+
protected $recomm_id;
3741
/**
3842
* @var array Array containing values of optional parameters
3943
*/
@@ -52,6 +56,9 @@ class AddRating extends Request {
5256
* - *cascadeCreate*
5357
* - Type: bool
5458
* - Description: Sets whether the given user/item should be created if not present in the database.
59+
* - *recommId*
60+
* - Type: string
61+
* - Description: If this rating is based on a recommendation request, `recommId` is the id of the clicked recommendation.
5562
* @throws Exceptions\UnknownOptionalParameterException UnknownOptionalParameterException if an unknown optional parameter is given in $optional
5663
*/
5764
public function __construct($user_id, $item_id, $rating, $optional = array()) {
@@ -60,9 +67,10 @@ public function __construct($user_id, $item_id, $rating, $optional = array()) {
6067
$this->rating = $rating;
6168
$this->timestamp = isset($optional['timestamp']) ? $optional['timestamp'] : null;
6269
$this->cascade_create = isset($optional['cascadeCreate']) ? $optional['cascadeCreate'] : null;
70+
$this->recomm_id = isset($optional['recommId']) ? $optional['recommId'] : null;
6371
$this->optional = $optional;
6472

65-
$existing_optional = array('timestamp','cascadeCreate');
73+
$existing_optional = array('timestamp','cascadeCreate','recommId');
6674
foreach ($this->optional as $key => $value) {
6775
if (!in_array($key, $existing_optional))
6876
throw new UnknownOptionalParameterException($key);
@@ -109,6 +117,8 @@ public function getBodyParameters() {
109117
$p['timestamp'] = $this-> optional['timestamp'];
110118
if (isset($this->optional['cascadeCreate']))
111119
$p['cascadeCreate'] = $this-> optional['cascadeCreate'];
120+
if (isset($this->optional['recommId']))
121+
$p['recommId'] = $this-> optional['recommId'];
112122
return $p;
113123
}
114124

src/RecommApi/Requests/AddUserProperty.php

+14-2
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,26 @@ class AddUserProperty extends Request {
1919
*/
2020
protected $property_name;
2121
/**
22-
* @var string $type Value type of the user property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`
22+
* @var string $type Value type of the user property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`.
23+
* * `int` - Signed integer number.
24+
* * `double` - Floating point number. It uses 64-bit base-2 format (IEEE 754 standard).
25+
* * `string` - UTF-8 string.
26+
* * `boolean` - *true* / *false*
27+
* * `timestamp` - Value representing date and time.
28+
* * `set` - Set of strings.
2329
*/
2430
protected $type;
2531

2632
/**
2733
* Construct the request
2834
* @param string $property_name Name of the user property to be created. Currently, the following names are reserved:`id`, `userid`, case insensitively. Also, the length of the property name must not exceed 63 characters.
29-
* @param string $type Value type of the user property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`
35+
* @param string $type Value type of the user property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`.
36+
* * `int` - Signed integer number.
37+
* * `double` - Floating point number. It uses 64-bit base-2 format (IEEE 754 standard).
38+
* * `string` - UTF-8 string.
39+
* * `boolean` - *true* / *false*
40+
* * `timestamp` - Value representing date and time.
41+
* * `set` - Set of strings.
3042
*/
3143
public function __construct($property_name, $type) {
3244
$this->property_name = $property_name;

src/RecommApi/Requests/MergeUsers.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
/**
1313
* Merges interactions (purchases, ratings, bookmarks, detail views ...) of two different users under a single user ID. This is especially useful for online e-commerce applications working with anonymous users identified by unique tokens such as the session ID. In such applications, it may often happen that a user owns a persistent account, yet accesses the system anonymously while, e.g., putting items into a shopping cart. At some point in time, such as when the user wishes to confirm the purchase, (s)he logs into the system using his/her username and password. The interactions made under anonymous session ID then become connected with the persistent account, and merging these two together becomes desirable.
14-
* Merging happens between two users referred to as the *target* and the *source*. After the merge, all the interactions of the source user are attributed to the target user, and the source user is **deleted** unless special parameter `keepSourceUser` is set `true`.
14+
* Merging happens between two users referred to as the *target* and the *source*. After the merge, all the interactions of the source user are attributed to the target user, and the source user is **deleted**.
1515
*/
1616
class MergeUsers extends Request {
1717

src/RecommApi/Requests/SetViewPortion.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ class SetViewPortion extends Request {
3939
* @var bool $cascade_create Sets whether the given user/item should be created if not present in the database.
4040
*/
4141
protected $cascade_create;
42+
/**
43+
* @var string $recomm_id If this view portion is based on a recommendation request, `recommId` is the id of the clicked recommendation.
44+
*/
45+
protected $recomm_id;
4246
/**
4347
* @var array Array containing values of optional parameters
4448
*/
@@ -60,6 +64,9 @@ class SetViewPortion extends Request {
6064
* - *cascadeCreate*
6165
* - Type: bool
6266
* - Description: Sets whether the given user/item should be created if not present in the database.
67+
* - *recommId*
68+
* - Type: string
69+
* - Description: If this view portion is based on a recommendation request, `recommId` is the id of the clicked recommendation.
6370
* @throws Exceptions\UnknownOptionalParameterException UnknownOptionalParameterException if an unknown optional parameter is given in $optional
6471
*/
6572
public function __construct($user_id, $item_id, $portion, $optional = array()) {
@@ -69,9 +76,10 @@ public function __construct($user_id, $item_id, $portion, $optional = array()) {
6976
$this->session_id = isset($optional['sessionId']) ? $optional['sessionId'] : null;
7077
$this->timestamp = isset($optional['timestamp']) ? $optional['timestamp'] : null;
7178
$this->cascade_create = isset($optional['cascadeCreate']) ? $optional['cascadeCreate'] : null;
79+
$this->recomm_id = isset($optional['recommId']) ? $optional['recommId'] : null;
7280
$this->optional = $optional;
7381

74-
$existing_optional = array('sessionId','timestamp','cascadeCreate');
82+
$existing_optional = array('sessionId','timestamp','cascadeCreate','recommId');
7583
foreach ($this->optional as $key => $value) {
7684
if (!in_array($key, $existing_optional))
7785
throw new UnknownOptionalParameterException($key);
@@ -120,6 +128,8 @@ public function getBodyParameters() {
120128
$p['timestamp'] = $this-> optional['timestamp'];
121129
if (isset($this->optional['cascadeCreate']))
122130
$p['cascadeCreate'] = $this-> optional['cascadeCreate'];
131+
if (isset($this->optional['recommId']))
132+
$p['recommId'] = $this-> optional['recommId'];
123133
return $p;
124134
}
125135

0 commit comments

Comments
 (0)