Skip to content

Commit 5f025e0

Browse files
committed
Added cascadeCreate parameter to merge users request
1 parent 1478218 commit 5f025e0

23 files changed

Lines changed: 42 additions & 30 deletions

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ or
1717
```
1818
{
1919
"require": {
20-
"recombee/php-api-client": ">=1.2"
20+
"recombee/php-api-client": ">=1.2.3"
2121
}
2222
}
2323
```
@@ -75,7 +75,7 @@ try
7575
$recommended = $client->send(new Reqs\UserBasedRecommendation('user-25', 5, ['rotationRate' => 0]));
7676
echo 'Recommended items: ' . implode(',',$recommended) . "\n";
7777
}
78-
catch(Ex\ApiTimeoutException $e)
78+
catch(Ex\ApiException $e)
7979
{
8080
//use fallback
8181
}
@@ -192,4 +192,4 @@ catch(Ex\ApiException $e)
192192
{
193193
//ApiException is parent of both ResponseException and ApiTimeoutException
194194
}
195-
```
195+
```

src/RecommApi/Requests/ItemBasedRecommendation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class ItemBasedRecommendation extends Request {
7474
*/
7575
protected $return_properties;
7676
/**
77-
* @var string $included_properties Allows to specify, which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list.
77+
* @var array $included_properties Allows to specify, which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list.
7878
* Example response for `includedProperties=description,price`:
7979
* ```
8080
* [
@@ -163,7 +163,7 @@ class ItemBasedRecommendation extends Request {
163163
* ]
164164
* ```
165165
* - *includedProperties*
166-
* - Type: string
166+
* - Type: array
167167
* - Description: Allows to specify, which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list.
168168
* Example response for `includedProperties=description,price`:
169169
* ```

src/RecommApi/Requests/MergeUsers.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@ class MergeUsers extends Request {
2424
*/
2525
protected $source_user_id;
2626
/**
27-
* @var string $keep_source_user If true, the source user will not be deleted, but also kept in the database..
27+
* @var string $keep_source_user If true, the source user will not be deleted, but also kept in the database.
2828
*/
2929
protected $keep_source_user;
30+
/**
31+
* @var bool $cascade_create Sets whether the user *targetUserId* should be created if not present in the database.
32+
*/
33+
protected $cascade_create;
3034
/**
3135
* @var array Array containing values of optional parameters
3236
*/
@@ -40,16 +44,20 @@ class MergeUsers extends Request {
4044
* - Allowed parameters:
4145
* - *keepSourceUser*
4246
* - Type: string
43-
* - Description: If true, the source user will not be deleted, but also kept in the database..
47+
* - Description: If true, the source user will not be deleted, but also kept in the database.
48+
* - *cascadeCreate*
49+
* - Type: bool
50+
* - Description: Sets whether the user *targetUserId* should be created if not present in the database.
4451
* @throws Exceptions\UnknownOptionalParameterException UnknownOptionalParameterException if an unknown optional parameter is given in $optional
4552
*/
4653
public function __construct($target_user_id, $source_user_id, $optional = array()) {
4754
$this->target_user_id = $target_user_id;
4855
$this->source_user_id = $source_user_id;
4956
$this->keep_source_user = isset($optional['keepSourceUser']) ? $optional['keepSourceUser'] : null;
57+
$this->cascade_create = isset($optional['cascadeCreate']) ? $optional['cascadeCreate'] : null;
5058
$this->optional = $optional;
5159

52-
$existing_optional = array('keepSourceUser');
60+
$existing_optional = array('keepSourceUser','cascadeCreate');
5361
foreach ($this->optional as $key => $value) {
5462
if (!in_array($key, $existing_optional))
5563
throw new UnknownOptionalParameterException($key);
@@ -82,6 +90,8 @@ public function getQueryParameters() {
8290
$params = array();
8391
if (isset($this->optional['keepSourceUser']))
8492
$params['keepSourceUser'] = $this->optional['keepSourceUser'];
93+
if (isset($this->optional['cascadeCreate']))
94+
$params['cascadeCreate'] = $this->optional['cascadeCreate'];
8595
return $params;
8696
}
8797

src/RecommApi/Requests/UserBasedRecommendation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class UserBasedRecommendation extends Request {
6666
*/
6767
protected $return_properties;
6868
/**
69-
* @var string $included_properties Allows to specify, which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list.
69+
* @var array $included_properties Allows to specify, which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list.
7070
* Example response for `includedProperties=description,price`:
7171
* ```
7272
* [
@@ -149,7 +149,7 @@ class UserBasedRecommendation extends Request {
149149
* ]
150150
* ```
151151
* - *includedProperties*
152-
* - Type: string
152+
* - Type: array
153153
* - Description: Allows to specify, which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list.
154154
* Example response for `includedProperties=description,price`:
155155
* ```

tests/AddEntityTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
abstract class AddEntityTestCase extends RecombeeTestCase {
1212

13-
abstract protected function createRequest($entity_id);
13+
abstract protected function createRequest($item_id);
1414

1515
public function testAddEntity() {
1616

tests/AddInteractionTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
abstract class AddInteractionTestCase extends RecombeeTestCase {
1212

13-
abstract protected function createRequest($user_id,$item_id,$optional);
13+
abstract protected function createRequest($user_id,$item_id,$optional=array());
1414

1515
public function testAddInteraction() {
1616

tests/AddPropertyTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
abstract class AddPropertyTestCase extends RecombeeTestCase {
1212

13-
abstract protected function createRequest($name,$type);
13+
abstract protected function createRequest($property_name,$type);
1414

1515
public function testAddProperty() {
1616

tests/AddRatingTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
abstract class AddRatingTestCase extends RecombeeTestCase {
1212

13-
abstract protected function createRequest($user_id,$item_id,$rating,$optional);
13+
abstract protected function createRequest($user_id,$item_id,$rating,$optional=array());
1414

1515
public function testAddRating() {
1616

tests/DeleteEntityTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
abstract class DeleteEntityTestCase extends RecombeeTestCase {
1212

13-
abstract protected function createRequest($entity_id);
13+
abstract protected function createRequest($item_id);
1414

1515
public function testDeleteEntity() {
1616

tests/DeleteInteractionTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
abstract class DeleteInteractionTestCase extends InteractionsTestCase {
1212

13-
abstract protected function createRequest($user_id,$item_id,$optional);
13+
abstract protected function createRequest($user_id,$item_id,$optional=array());
1414

1515
public function testDeleteInteraction() {
1616

0 commit comments

Comments
 (0)