Skip to content

Commit

Permalink
Support Item Segmentations
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraFiedler committed Jan 6, 2023
1 parent 66f35c7 commit b983777
Show file tree
Hide file tree
Showing 102 changed files with 2,842 additions and 313 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ or
```
{
"require": {
"recombee/php-api-client": "^4.0.0"
"recombee/php-api-client": "^4.1.0"
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion src/RecommApi/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected function getBaseUri() {
}

protected function getUserAgent() {
$user_agent = 'recombee-php-api-client/4.0.0';
$user_agent = 'recombee-php-api-client/4.1.0';
if (isset($this->options['serviceName']))
$user_agent .= ' '.($this->options['serviceName']);
return $user_agent;
Expand Down
2 changes: 1 addition & 1 deletion src/RecommApi/Requests/AddBookmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Recombee\RecommApi\Exceptions\UnknownOptionalParameterException;

/**
* Adds a bookmark of a given item made by a given user.
* Adds a bookmark of the given item made by the given user.
*/
class AddBookmark extends Request {

Expand Down
10 changes: 5 additions & 5 deletions src/RecommApi/Requests/AddCartAddition.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Recombee\RecommApi\Exceptions\UnknownOptionalParameterException;

/**
* Adds a cart addition of a given item made by a given user.
* Adds a cart addition of the given item made by the given user.
*/
class AddCartAddition extends Request {

Expand All @@ -31,11 +31,11 @@ class AddCartAddition extends Request {
*/
protected $cascade_create;
/**
* @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.
* @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.
*/
protected $amount;
/**
* @var float $price Price of the added item. If `amount` is greater than 1, sum of prices of all the items should be given.
* @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.
*/
protected $price;
/**
Expand Down Expand Up @@ -65,10 +65,10 @@ class AddCartAddition extends Request {
* - Description: Sets whether the given user/item should be created if not present in the database.
* - *amount*
* - Type: float
* - 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.
* - 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.
* - *price*
* - Type: float
* - Description: Price of the added item. If `amount` is greater than 1, sum of prices of all the items should be given.
* - Description: Price of the added item. If `amount` is greater than 1, the sum of prices of all the items should be given.
* - *recommId*
* - Type: string
* - Description: If this cart addition is based on a recommendation request, `recommId` is the id of the clicked recommendation.
Expand Down
2 changes: 1 addition & 1 deletion src/RecommApi/Requests/AddDetailView.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Recombee\RecommApi\Exceptions\UnknownOptionalParameterException;

/**
* Adds a detail view of a given item made by a given user.
* Adds a detail view of the given item made by the given user.
*/
class AddDetailView extends Request {

Expand Down
2 changes: 1 addition & 1 deletion src/RecommApi/Requests/AddGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Recombee\RecommApi\Exceptions\UnknownOptionalParameterException;

/**
* Creates new group in the database.
* Creates a new group in the database.
*/
class AddGroup extends Request {

Expand Down
4 changes: 2 additions & 2 deletions src/RecommApi/Requests/AddItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
use Recombee\RecommApi\Exceptions\UnknownOptionalParameterException;

/**
* Adds new item of given `itemId` to the items catalog.
* All the item properties for the newly created items are set null.
* Adds new item of the given `itemId` to the items catalog.
* All the item properties for the newly created items are set to null.
*/
class AddItem extends Request {

Expand Down
4 changes: 2 additions & 2 deletions src/RecommApi/Requests/AddItemProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class AddItemProperty extends Request {

/**
* @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.
* @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.
*/
protected $property_name;
/**
Expand All @@ -33,7 +33,7 @@ class AddItemProperty extends Request {

/**
* Construct the request
* @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.
* @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.
* @param string $type Value type of the item property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`, `image` or `imageList`.
* * `int`- Signed integer number.
* * `double` - Floating point number. It uses 64-bit base-2 format (IEEE 754 standard).
Expand Down
104 changes: 104 additions & 0 deletions src/RecommApi/Requests/AddManualReqlSegment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php
/*
This file is auto-generated, do not edit
*/

/**
* AddManualReqlSegment request
*/
namespace Recombee\RecommApi\Requests;
use Recombee\RecommApi\Exceptions\UnknownOptionalParameterException;

/**
* Adds a new Segment into a Manual ReQL Segmentation.
* 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.
*/
class AddManualReqlSegment extends Request {

/**
* @var string $segmentation_id ID of the Segmentation to which the new Segment should be added
*/
protected $segmentation_id;
/**
* @var string $segment_id ID of the newly created Segment
*/
protected $segment_id;
/**
* @var string $filter ReQL filter that returns `true` for items that belong to this Segment. Otherwise returns `false`.
*/
protected $filter;
/**
* @var string $title Human-readable name of the Segment that is shown in the Recombee Admin UI.
*/
protected $title;
/**
* @var array Array containing values of optional parameters
*/
protected $optional;

/**
* Construct the request
* @param string $segmentation_id ID of the Segmentation to which the new Segment should be added
* @param string $segment_id ID of the newly created Segment
* @param string $filter ReQL filter that returns `true` for items that belong to this Segment. Otherwise returns `false`.
* @param array $optional Optional parameters given as an array containing pairs name of the parameter => value
* - Allowed parameters:
* - *title*
* - Type: string
* - Description: Human-readable name of the Segment that is shown in the Recombee Admin UI.
* @throws Exceptions\UnknownOptionalParameterException UnknownOptionalParameterException if an unknown optional parameter is given in $optional
*/
public function __construct($segmentation_id, $segment_id, $filter, $optional = array()) {
$this->segmentation_id = $segmentation_id;
$this->segment_id = $segment_id;
$this->filter = $filter;
$this->title = isset($optional['title']) ? $optional['title'] : null;
$this->optional = $optional;

$existing_optional = array('title');
foreach ($this->optional as $key => $value) {
if (!in_array($key, $existing_optional))
throw new UnknownOptionalParameterException($key);
}
$this->timeout = 10000;
$this->ensure_https = false;
}

/**
* Get used HTTP method
* @return static Used HTTP method
*/
public function getMethod() {
return Request::HTTP_PUT;
}

/**
* Get URI to the endpoint
* @return string URI to the endpoint
*/
public function getPath() {
return "/{databaseId}/segmentations/manual-reql/{$this->segmentation_id}/segments/{$this->segment_id}";
}

/**
* Get query parameters
* @return array Values of query parameters (name of parameter => value of the parameter)
*/
public function getQueryParameters() {
$params = array();
return $params;
}

/**
* Get body parameters
* @return array Values of body parameters (name of parameter => value of the parameter)
*/
public function getBodyParameters() {
$p = array();
$p['filter'] = $this->filter;
if (isset($this->optional['title']))
$p['title'] = $this-> optional['title'];
return $p;
}

}
14 changes: 7 additions & 7 deletions src/RecommApi/Requests/AddPurchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Recombee\RecommApi\Exceptions\UnknownOptionalParameterException;

/**
* Adds a purchase of a given item made by a given user.
* Adds a purchase of the given item made by the given user.
*/
class AddPurchase extends Request {

Expand All @@ -31,15 +31,15 @@ class AddPurchase extends Request {
*/
protected $cascade_create;
/**
* @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.
* @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.
*/
protected $amount;
/**
* @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.
* @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.
*/
protected $price;
/**
* @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.
* @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.
*/
protected $profit;
/**
Expand Down Expand Up @@ -69,13 +69,13 @@ class AddPurchase extends Request {
* - Description: Sets whether the given user/item should be created if not present in the database.
* - *amount*
* - Type: float
* - 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.
* - 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.
* - *price*
* - Type: float
* - 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.
* - 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.
* - *profit*
* - Type: float
* - 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.
* - 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.
* - *recommId*
* - Type: string
* - Description: If this purchase is based on a recommendation request, `recommId` is the id of the clicked recommendation.
Expand Down
2 changes: 1 addition & 1 deletion src/RecommApi/Requests/AddRating.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Recombee\RecommApi\Exceptions\UnknownOptionalParameterException;

/**
* Adds a rating of given item made by a given user.
* Adds a rating of the given item made by the given user.
*/
class AddRating extends Request {

Expand Down
2 changes: 1 addition & 1 deletion src/RecommApi/Requests/AddSeries.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Recombee\RecommApi\Exceptions\UnknownOptionalParameterException;

/**
* Creates new series in the database.
* Creates a new series in the database.
*/
class AddSeries extends Request {

Expand Down
6 changes: 3 additions & 3 deletions src/RecommApi/Requests/AddUserProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
use Recombee\RecommApi\Exceptions\UnknownOptionalParameterException;

/**
* 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.
* 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.
*/
class AddUserProperty extends Request {

/**
* @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.
* @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.
*/
protected $property_name;
/**
Expand All @@ -31,7 +31,7 @@ class AddUserProperty extends Request {

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

0 comments on commit b983777

Please sign in to comment.