AddPurchase extends Request
Adds a purchase of a given item made by a given user.
Table of Contents
- $additional_data : array<string|int, mixed>
- $amount : float
- $cascade_create : bool
- $ensure_https : bool
- $item_id : string
- $optional : array<string|int, mixed>
- $price : float
- $profit : float
- $recomm_id : string
- $timeout : int
- $timestamp : string|float
- $user_id : string
- __construct() : mixed
- Construct the request
- getBodyParameters() : array<string|int, mixed>
- Get body parameters
- getEnsureHttps() : bool
- Returns true if HTTPS must be chosen over HTTP for this request
- getMethod() : static
- Get used HTTP method
- getPath() : string
- Get URI to the endpoint
- getQueryParameters() : array<string|int, mixed>
- Get query parameters
- getTimeout() : int
- Get request timeout
- setEnsureHttps() : mixed
- Sets if HTTPS must be chosen over HTTP for this request
- setTimeout() : mixed
- Sets request timeout
Properties
$additional_data
protected
array<string|int, mixed>
$additional_data
$amount
protected
float
$amount
$cascade_create
protected
bool
$cascade_create
$ensure_https
protected
bool
$ensure_https
$item_id
protected
string
$item_id
$optional
protected
array<string|int, mixed>
$optional
$price
protected
float
$price
$profit
protected
float
$profit
$recomm_id
protected
string
$recomm_id
$timeout
protected
int
$timeout
$timestamp
protected
string|float
$timestamp
$user_id
protected
string
$user_id
Methods
__construct()
Construct the request
public
__construct(string $user_id, string $item_id[, array<string|int, mixed> $optional = array() ]) : mixed
Parameters
- $user_id : string
-
User who purchased the item
- $item_id : string
-
Purchased item
- $optional : array<string|int, mixed> = array()
-
Optional parameters given as an array containing pairs name of the parameter => value
- Allowed parameters:
-
timestamp
- Type: string|float
- Description: UTC timestamp of the purchase as ISO8601-1 pattern or UTC epoch time. The default value is the current time.
-
cascadeCreate
- Type: bool
- 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 twoitem-y
during a single order (session...), theamount
should equal to 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.
-
profit
- Type: float
- Description: Your profit from the purchased item. The profit is natural in e-commerce domain (for example if
user-x
purchasesitem-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). Ifamount
is greater than 1, 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.
-
additionalData
- Type: array
- Description: A dictionary of additional data for the interaction.
-
timestamp
- Allowed parameters:
Tags
Return values
mixed —getBodyParameters()
Get body parameters
public
getBodyParameters() : array<string|int, mixed>
Return values
array<string|int, mixed> —Values of body parameters (name of parameter => value of the parameter)
getEnsureHttps()
Returns true if HTTPS must be chosen over HTTP for this request
public
getEnsureHttps() : bool
Return values
bool —true if HTTPS must be chosen
getMethod()
Get used HTTP method
public
getMethod() : static
Return values
static —Used HTTP method
getPath()
Get URI to the endpoint
public
getPath() : string
Return values
string —URI to the endpoint
getQueryParameters()
Get query parameters
public
getQueryParameters() : array<string|int, mixed>
Return values
array<string|int, mixed> —Values of query parameters (name of parameter => value of the parameter)
getTimeout()
Get request timeout
public
getTimeout() : int
Return values
int —Request timeout in milliseconds
setEnsureHttps()
Sets if HTTPS must be chosen over HTTP for this request
public
setEnsureHttps(mixed $ensure_https) : mixed
Parameters
- $ensure_https : mixed
Return values
mixed —setTimeout()
Sets request timeout
public
setTimeout(mixed $timeout) : mixed
Parameters
- $timeout : mixed