Skip to content

Commit b983777

Browse files
committed
Support Item Segmentations
1 parent 66f35c7 commit b983777

File tree

102 files changed

+2842
-313
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+2842
-313
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": "^4.0.0"
20+
"recombee/php-api-client": "^4.1.0"
2121
}
2222
}
2323
```

src/RecommApi/Client.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ protected function getBaseUri() {
8585
}
8686

8787
protected function getUserAgent() {
88-
$user_agent = 'recombee-php-api-client/4.0.0';
88+
$user_agent = 'recombee-php-api-client/4.1.0';
8989
if (isset($this->options['serviceName']))
9090
$user_agent .= ' '.($this->options['serviceName']);
9191
return $user_agent;

src/RecommApi/Requests/AddBookmark.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Recombee\RecommApi\Exceptions\UnknownOptionalParameterException;
1111

1212
/**
13-
* Adds a bookmark of a given item made by a given user.
13+
* Adds a bookmark of the given item made by the given user.
1414
*/
1515
class AddBookmark extends Request {
1616

src/RecommApi/Requests/AddCartAddition.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Recombee\RecommApi\Exceptions\UnknownOptionalParameterException;
1111

1212
/**
13-
* Adds a cart addition of a given item made by a given user.
13+
* Adds a cart addition of the given item made by the given user.
1414
*/
1515
class AddCartAddition extends Request {
1616

@@ -31,11 +31,11 @@ class AddCartAddition extends Request {
3131
*/
3232
protected $cascade_create;
3333
/**
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.
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 2.
3535
*/
3636
protected $amount;
3737
/**
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.
38+
* @var float $price Price of the added item. If `amount` is greater than 1, the sum of prices of all the items should be given.
3939
*/
4040
protected $price;
4141
/**
@@ -65,10 +65,10 @@ class AddCartAddition extends Request {
6565
* - Description: Sets whether the given user/item should be created if not present in the database.
6666
* - *amount*
6767
* - Type: float
68-
* - 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.
68+
* - 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 2.
6969
* - *price*
7070
* - Type: float
71-
* - Description: Price of the added item. If `amount` is greater than 1, sum of prices of all the items should be given.
71+
* - Description: Price of the added item. If `amount` is greater than 1, the sum of prices of all the items should be given.
7272
* - *recommId*
7373
* - Type: string
7474
* - Description: If this cart addition is based on a recommendation request, `recommId` is the id of the clicked recommendation.

src/RecommApi/Requests/AddDetailView.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Recombee\RecommApi\Exceptions\UnknownOptionalParameterException;
1111

1212
/**
13-
* Adds a detail view of a given item made by a given user.
13+
* Adds a detail view of the given item made by the given user.
1414
*/
1515
class AddDetailView extends Request {
1616

src/RecommApi/Requests/AddGroup.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Recombee\RecommApi\Exceptions\UnknownOptionalParameterException;
1111

1212
/**
13-
* Creates new group in the database.
13+
* Creates a new group in the database.
1414
*/
1515
class AddGroup extends Request {
1616

src/RecommApi/Requests/AddItem.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
use Recombee\RecommApi\Exceptions\UnknownOptionalParameterException;
1111

1212
/**
13-
* Adds new item of given `itemId` to the items catalog.
14-
* All the item properties for the newly created items are set null.
13+
* Adds new item of the given `itemId` to the items catalog.
14+
* All the item properties for the newly created items are set to null.
1515
*/
1616
class AddItem extends Request {
1717

src/RecommApi/Requests/AddItemProperty.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
class AddItemProperty extends Request {
1616

1717
/**
18-
* @var 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.
18+
* @var 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.
1919
*/
2020
protected $property_name;
2121
/**
@@ -33,7 +33,7 @@ class AddItemProperty extends Request {
3333

3434
/**
3535
* Construct the request
36-
* @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.
36+
* @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.
3737
* @param string $type Value type of the item property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`, `image` or `imageList`.
3838
* * `int`- Signed integer number.
3939
* * `double` - Floating point number. It uses 64-bit base-2 format (IEEE 754 standard).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
/*
3+
This file is auto-generated, do not edit
4+
*/
5+
6+
/**
7+
* AddManualReqlSegment request
8+
*/
9+
namespace Recombee\RecommApi\Requests;
10+
use Recombee\RecommApi\Exceptions\UnknownOptionalParameterException;
11+
12+
/**
13+
* Adds a new Segment into a Manual ReQL Segmentation.
14+
* The new Segment is defined by a [ReQL](https://docs.recombee.com/reql.html) filter that returns `true` for an item in case that this item belongs to the segment.
15+
*/
16+
class AddManualReqlSegment extends Request {
17+
18+
/**
19+
* @var string $segmentation_id ID of the Segmentation to which the new Segment should be added
20+
*/
21+
protected $segmentation_id;
22+
/**
23+
* @var string $segment_id ID of the newly created Segment
24+
*/
25+
protected $segment_id;
26+
/**
27+
* @var string $filter ReQL filter that returns `true` for items that belong to this Segment. Otherwise returns `false`.
28+
*/
29+
protected $filter;
30+
/**
31+
* @var string $title Human-readable name of the Segment that is shown in the Recombee Admin UI.
32+
*/
33+
protected $title;
34+
/**
35+
* @var array Array containing values of optional parameters
36+
*/
37+
protected $optional;
38+
39+
/**
40+
* Construct the request
41+
* @param string $segmentation_id ID of the Segmentation to which the new Segment should be added
42+
* @param string $segment_id ID of the newly created Segment
43+
* @param string $filter ReQL filter that returns `true` for items that belong to this Segment. Otherwise returns `false`.
44+
* @param array $optional Optional parameters given as an array containing pairs name of the parameter => value
45+
* - Allowed parameters:
46+
* - *title*
47+
* - Type: string
48+
* - Description: Human-readable name of the Segment that is shown in the Recombee Admin UI.
49+
* @throws Exceptions\UnknownOptionalParameterException UnknownOptionalParameterException if an unknown optional parameter is given in $optional
50+
*/
51+
public function __construct($segmentation_id, $segment_id, $filter, $optional = array()) {
52+
$this->segmentation_id = $segmentation_id;
53+
$this->segment_id = $segment_id;
54+
$this->filter = $filter;
55+
$this->title = isset($optional['title']) ? $optional['title'] : null;
56+
$this->optional = $optional;
57+
58+
$existing_optional = array('title');
59+
foreach ($this->optional as $key => $value) {
60+
if (!in_array($key, $existing_optional))
61+
throw new UnknownOptionalParameterException($key);
62+
}
63+
$this->timeout = 10000;
64+
$this->ensure_https = false;
65+
}
66+
67+
/**
68+
* Get used HTTP method
69+
* @return static Used HTTP method
70+
*/
71+
public function getMethod() {
72+
return Request::HTTP_PUT;
73+
}
74+
75+
/**
76+
* Get URI to the endpoint
77+
* @return string URI to the endpoint
78+
*/
79+
public function getPath() {
80+
return "/{databaseId}/segmentations/manual-reql/{$this->segmentation_id}/segments/{$this->segment_id}";
81+
}
82+
83+
/**
84+
* Get query parameters
85+
* @return array Values of query parameters (name of parameter => value of the parameter)
86+
*/
87+
public function getQueryParameters() {
88+
$params = array();
89+
return $params;
90+
}
91+
92+
/**
93+
* Get body parameters
94+
* @return array Values of body parameters (name of parameter => value of the parameter)
95+
*/
96+
public function getBodyParameters() {
97+
$p = array();
98+
$p['filter'] = $this->filter;
99+
if (isset($this->optional['title']))
100+
$p['title'] = $this-> optional['title'];
101+
return $p;
102+
}
103+
104+
}

src/RecommApi/Requests/AddPurchase.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Recombee\RecommApi\Exceptions\UnknownOptionalParameterException;
1111

1212
/**
13-
* Adds a purchase of a given item made by a given user.
13+
* Adds a purchase of the given item made by the given user.
1414
*/
1515
class AddPurchase extends Request {
1616

@@ -31,15 +31,15 @@ class AddPurchase extends Request {
3131
*/
3232
protected $cascade_create;
3333
/**
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.
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 2.
3535
*/
3636
protected $amount;
3737
/**
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.
38+
* @var float $price Price paid by the user for the item. If `amount` is greater than 1, the sum of prices of all the items should be given.
3939
*/
4040
protected $price;
4141
/**
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.
42+
* @var float $profit Your profit from the purchased item. The profit is natural in the 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 also applicable in other domains (for example, at a news company it may be income from a displayed advertisement on article page). If `amount` is greater than 1, the sum of profit of all the items should be given.
4343
*/
4444
protected $profit;
4545
/**
@@ -69,13 +69,13 @@ class AddPurchase extends Request {
6969
* - Description: Sets whether the given user/item should be created if not present in the database.
7070
* - *amount*
7171
* - Type: float
72-
* - 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.
72+
* - 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 2.
7373
* - *price*
7474
* - Type: float
75-
* - 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.
75+
* - Description: Price paid by the user for the item. If `amount` is greater than 1, the sum of prices of all the items should be given.
7676
* - *profit*
7777
* - Type: float
78-
* - 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.
78+
* - Description: Your profit from the purchased item. The profit is natural in the 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 also applicable in other domains (for example, at a news company it may be income from a displayed advertisement on article page). If `amount` is greater than 1, the sum of profit of all the items should be given.
7979
* - *recommId*
8080
* - Type: string
8181
* - Description: If this purchase is based on a recommendation request, `recommId` is the id of the clicked recommendation.

src/RecommApi/Requests/AddRating.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Recombee\RecommApi\Exceptions\UnknownOptionalParameterException;
1111

1212
/**
13-
* Adds a rating of given item made by a given user.
13+
* Adds a rating of the given item made by the given user.
1414
*/
1515
class AddRating extends Request {
1616

src/RecommApi/Requests/AddSeries.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Recombee\RecommApi\Exceptions\UnknownOptionalParameterException;
1111

1212
/**
13-
* Creates new series in the database.
13+
* Creates a new series in the database.
1414
*/
1515
class AddSeries extends Request {
1616

src/RecommApi/Requests/AddUserProperty.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
use Recombee\RecommApi\Exceptions\UnknownOptionalParameterException;
1111

1212
/**
13-
* Adding an user property is somehow equivalent to adding a column to the table of users. The users may be characterized by various properties of different types.
13+
* Adding a user property is somehow equivalent to adding a column to the table of users. The users may be characterized by various properties of different types.
1414
*/
1515
class AddUserProperty extends Request {
1616

1717
/**
18-
* @var 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.
18+
* @var 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.
1919
*/
2020
protected $property_name;
2121
/**
@@ -31,7 +31,7 @@ class AddUserProperty extends Request {
3131

3232
/**
3333
* Construct the request
34-
* @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.
34+
* @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.
3535
* @param string $type Value type of the user property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`.
3636
* * `int` - Signed integer number.
3737
* * `double` - Floating point number. It uses 64-bit base-2 format (IEEE 754 standard).

0 commit comments

Comments
 (0)