Skip to content

Commit 077e21f

Browse files
committed
Added parameters amount,price,profit to AddPurchase and amount,price to AddCartAddition
1 parent 857d619 commit 077e21f

33 files changed

Lines changed: 1378 additions & 28 deletions

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

src/RecommApi/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ protected function getOptionalHttpHeaders() {
112112
}
113113

114114
protected function getHttpHeaders() {
115-
return array_merge(array('User-Agent' => 'recombee-php-api-client/1.5.0'), $this->getOptionalHttpHeaders());
115+
return array_merge(array('User-Agent' => 'recombee-php-api-client/1.6.0'), $this->getOptionalHttpHeaders());
116116
}
117117

118118
protected function getOptionalRequestOptions() {

src/RecommApi/Requests/AddCartAddition.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ class AddCartAddition 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 float $amount Amount (number) added to cart. The default is 1. For example if `user-x` adds two `item-y` during a single order (session...), the `amount` should equal to 2.
35+
*/
36+
protected $amount;
37+
/**
38+
* @var float $price Price of the added item. If `amount` is greater than 1, sum of prices of all the items should be given.
39+
*/
40+
protected $price;
3341
/**
3442
* @var array Array containing values of optional parameters
3543
*/
@@ -47,16 +55,24 @@ class AddCartAddition extends Request {
4755
* - *cascadeCreate*
4856
* - Type: bool
4957
* - Description: Sets whether the given user/item should be created if not present in the database.
58+
* - *amount*
59+
* - Type: float
60+
* - Description: Amount (number) added to cart. The default is 1. For example if `user-x` adds two `item-y` during a single order (session...), the `amount` should equal to 2.
61+
* - *price*
62+
* - Type: float
63+
* - Description: Price of the added item. If `amount` is greater than 1, sum of prices of all the items should be given.
5064
* @throws Exceptions\UnknownOptionalParameterException UnknownOptionalParameterException if an unknown optional parameter is given in $optional
5165
*/
5266
public function __construct($user_id, $item_id, $optional = array()) {
5367
$this->user_id = $user_id;
5468
$this->item_id = $item_id;
5569
$this->timestamp = isset($optional['timestamp']) ? $optional['timestamp'] : null;
5670
$this->cascade_create = isset($optional['cascadeCreate']) ? $optional['cascadeCreate'] : null;
71+
$this->amount = isset($optional['amount']) ? $optional['amount'] : null;
72+
$this->price = isset($optional['price']) ? $optional['price'] : null;
5773
$this->optional = $optional;
5874

59-
$existing_optional = array('timestamp','cascadeCreate');
75+
$existing_optional = array('timestamp','cascadeCreate','amount','price');
6076
foreach ($this->optional as $key => $value) {
6177
if (!in_array($key, $existing_optional))
6278
throw new UnknownOptionalParameterException($key);
@@ -102,6 +118,10 @@ public function getBodyParameters() {
102118
$p['timestamp'] = $this-> optional['timestamp'];
103119
if (isset($this->optional['cascadeCreate']))
104120
$p['cascadeCreate'] = $this-> optional['cascadeCreate'];
121+
if (isset($this->optional['amount']))
122+
$p['amount'] = $this-> optional['amount'];
123+
if (isset($this->optional['price']))
124+
$p['price'] = $this-> optional['price'];
105125
return $p;
106126
}
107127

src/RecommApi/Requests/AddItemProperty.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class AddItemProperty extends Request {
3131
public function __construct($property_name, $type) {
3232
$this->property_name = $property_name;
3333
$this->type = $type;
34-
$this->timeout = 1000;
34+
$this->timeout = 100000;
3535
$this->ensure_https = false;
3636
}
3737

src/RecommApi/Requests/AddPurchase.php

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ class AddPurchase 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 float $amount Amount (number) of purchased items. The default is 1. For example if `user-x` purchases two `item-y` during a single order (session...), the `amount` should equal to 2.
35+
*/
36+
protected $amount;
37+
/**
38+
* @var float $price Price paid by the user for the item. If `amount` is greater than 1, sum of prices of all the items should be given.
39+
*/
40+
protected $price;
41+
/**
42+
* @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.
43+
*/
44+
protected $profit;
3345
/**
3446
* @var array Array containing values of optional parameters
3547
*/
@@ -47,16 +59,28 @@ class AddPurchase extends Request {
4759
* - *cascadeCreate*
4860
* - Type: bool
4961
* - Description: Sets whether the given user/item should be created if not present in the database.
62+
* - *amount*
63+
* - Type: float
64+
* - Description: Amount (number) of purchased items. The default is 1. For example if `user-x` purchases two `item-y` during a single order (session...), the `amount` should equal to 2.
65+
* - *price*
66+
* - Type: float
67+
* - Description: Price paid by the user for the item. If `amount` is greater than 1, sum of prices of all the items should be given.
68+
* - *profit*
69+
* - Type: float
70+
* - 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.
5071
* @throws Exceptions\UnknownOptionalParameterException UnknownOptionalParameterException if an unknown optional parameter is given in $optional
5172
*/
5273
public function __construct($user_id, $item_id, $optional = array()) {
5374
$this->user_id = $user_id;
5475
$this->item_id = $item_id;
5576
$this->timestamp = isset($optional['timestamp']) ? $optional['timestamp'] : null;
5677
$this->cascade_create = isset($optional['cascadeCreate']) ? $optional['cascadeCreate'] : null;
78+
$this->amount = isset($optional['amount']) ? $optional['amount'] : null;
79+
$this->price = isset($optional['price']) ? $optional['price'] : null;
80+
$this->profit = isset($optional['profit']) ? $optional['profit'] : null;
5781
$this->optional = $optional;
5882

59-
$existing_optional = array('timestamp','cascadeCreate');
83+
$existing_optional = array('timestamp','cascadeCreate','amount','price','profit');
6084
foreach ($this->optional as $key => $value) {
6185
if (!in_array($key, $existing_optional))
6286
throw new UnknownOptionalParameterException($key);
@@ -102,6 +126,12 @@ public function getBodyParameters() {
102126
$p['timestamp'] = $this-> optional['timestamp'];
103127
if (isset($this->optional['cascadeCreate']))
104128
$p['cascadeCreate'] = $this-> optional['cascadeCreate'];
129+
if (isset($this->optional['amount']))
130+
$p['amount'] = $this-> optional['amount'];
131+
if (isset($this->optional['price']))
132+
$p['price'] = $this-> optional['price'];
133+
if (isset($this->optional['profit']))
134+
$p['profit'] = $this-> optional['profit'];
105135
return $p;
106136
}
107137

src/RecommApi/Requests/AddUserProperty.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class AddUserProperty extends Request {
3131
public function __construct($property_name, $type) {
3232
$this->property_name = $property_name;
3333
$this->type = $type;
34-
$this->timeout = 1000;
34+
$this->timeout = 100000;
3535
$this->ensure_https = false;
3636
}
3737

src/RecommApi/Requests/DeleteItemProperty.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class DeleteItemProperty extends Request {
2525
*/
2626
public function __construct($property_name) {
2727
$this->property_name = $property_name;
28-
$this->timeout = 1000;
28+
$this->timeout = 100000;
2929
$this->ensure_https = false;
3030
}
3131

src/RecommApi/Requests/DeleteUserProperty.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class DeleteUserProperty extends Request {
2525
*/
2626
public function __construct($property_name) {
2727
$this->property_name = $property_name;
28-
$this->timeout = 1000;
28+
$this->timeout = 100000;
2929
$this->ensure_https = false;
3030
}
3131

src/RecommApi/Requests/GetUserPropertyInfo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class GetUserPropertyInfo extends Request {
2525
*/
2626
public function __construct($property_name) {
2727
$this->property_name = $property_name;
28-
$this->timeout = 1000;
28+
$this->timeout = 100000;
2929
$this->ensure_https = false;
3030
}
3131

src/RecommApi/Requests/ListGroupItems.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ListGroupItems extends Request {
2525
*/
2626
public function __construct($group_id) {
2727
$this->group_id = $group_id;
28-
$this->timeout = 1000;
28+
$this->timeout = 100000;
2929
$this->ensure_https = false;
3030
}
3131

0 commit comments

Comments
 (0)