UNPKG

recombee-api-client

Version:

Node.js client (SDK) for easy use of the Recombee recommendation API

1,674 lines (1,453 loc) 129 kB
declare module "recombee-api-client" { namespace requests { /** * Base class for all the requests */ export class Request { /** * @param method - GET/PUT/POST/DELETE. * @param path - Path to the endpoint. * @param timeout - Timeout in milliseconds. * @param ensureHttps - If true, always use HTTPS. */ constructor( method: "GET" | "PUT" | "POST" | "DELETE", path: string, timeout: number, ensureHttps: boolean ); method: "GET" | "PUT" | "POST" | "DELETE"; path: string; timeout: number; ensureHttps: boolean; protected __response_type: unknown; } export class SetValuesOptions { cascadeCreate?: boolean; } export class SetValues extends requests.Request { /** * @param values - The values for the individual properties. * ```json * { * "product_description": "4K TV with 3D feature", * "categories": ["Electronics", "Televisions"], * "price_usd": 342, * "in_stock_from": "2016-11-16T08:00Z" * } * ``` * @param optional - Optional parameters given as an object. */ constructor( path: string, values: { [key: string]: unknown }, optional?: SetValuesOptions ); protected __response_type: string; /** * Get body parameters * * @returns The values of body parameters (name of parameter: value of the parameter). */ bodyParameters(): { [key: string]: unknown }; queryParameters(): { [key: string]: unknown }; } export class SetUserValues extends SetValues { /** * @param userId - ID of the user which will be modified. * @param values - The values for the individual properties. * ```json * { * "country": "US", * "sex": "F" * } * ``` * @param optional - Optional parameters given as an object. */ constructor( userId: string, values: { [key: string]: unknown }, optional?: SetValuesOptions ); } export class SetItemValues extends SetValues { /** * @param itemId - ID of the item which will be modified. * @param values - The values for the individual properties. * ```json * { * "product_description": "4K TV with 3D feature", * "categories": ["Electronics", "Televisions"], * "price_usd": 342, * "in_stock_from": "2016-11-16T08:00Z" * } * ``` * @param optional - Optional parameters given as an object. */ constructor( itemId: string, values: { [key: string]: unknown }, optional?: SetValuesOptions ); } /** * In many cases, it may be desirable to execute multiple requests at once. For example, when synchronizing the catalog of items in a periodical manner, you would have to execute a sequence of thousands of separate POST requests, which is very ineffective and may take a very long time to complete. Most notably, network latencies can make execution of such sequence very slow and even if executed in multiple parallel threads, there will still be unreasonable overhead caused by the HTTP(s). To avoid the mentioned problems, batch processing may be used, encapsulating a sequence of requests into a single HTTPS request. * Batch processing allows you to submit arbitrary sequence of requests and the batch may combine different types of requests arbitrarily as well. * Note that the status code of the batch request itself is 200 even if the individual requests result in error – you have to inspect the code values in the resulting array. */ export class Batch extends requests.Request { /** * @param requests - Array containing the requests. * @param optional - Optional parameters given as an object (allowed parameters: distinctRecomms). */ constructor( requests: Request[], optional?: { distinctRecomms?: boolean } ); protected __response_type: BatchResponse; /** * Get body parameters * * @returns The values of body parameters (name of parameter: value of the parameter). */ bodyParameters(): { requests: BatchedRequest[]; distinctRecomms?: boolean; } _request_to_batch_object( req: Request ): BatchedRequest /** * Get query parameters * * @returns The values of query parameters (name of parameter: value of the parameter). */ queryParameters(): { [key: string]: unknown }; } } namespace errors { /** * Base class for errors that occur because of errors in requests reported by API or because of a timeout */ export class ApiError extends Error { /** * @param message - Message of the exception. */ constructor( message: string ); } /** * Error thrown when a request did not succeed (did not return 200 or 201) */ export class ResponseError extends errors.ApiError { /** * @param request - Request which caused the exception. * @param statusCode - The returned status code. * @param message - Error message from the API. */ constructor( request: Request, statusCode: number, message: string ); } /** * Error thrown when a request is not processed within the timeout */ export class TimeoutError extends errors.ApiError { /** * @param request - Request which caused the exception. * @param innerException - Exception from underlying HTTP library. */ constructor( request: Request, innerException: object ); } } export type BatchedRequest = { method: string; path: string; params?: { [key: string]: unknown }; } export type ApiClientOptions = { protocol?: string; agent?: object; } & ( | { baseUri?: string; } | { region?: string; } ) export type BatchResponse = { code: number; json: unknown; }[] /** * Mapping of Item/User property types to their corresponding TypeScript types. */ export type EntityProperty = | StringProperty | IntProperty | DoubleProperty | BooleanProperty | TimestampProperty | SetProperty | ImageProperty | ImageListProperty | null; type StringProperty = string; type IntProperty = number; type DoubleProperty = number; type BooleanProperty = boolean; /** Unix timestamp in seconds */ type TimestampProperty = number; /** Unordered set of strings */ type SetProperty = string[]; /** URL of the image */ type ImageProperty = string; /** Array of image URLs */ type ImageListProperty = string[]; /** * Client for sending requests to Recombee and getting replies */ export class ApiClient { /** * @param databaseId - ID of your database. * @param token - Corresponding public token. * @param options - Other custom options. */ constructor( databaseId: string, token: string, options?: ApiClientOptions ); _getRegionalBaseUri( region: string ): string; _buildRequestUrl( request: Request ): string; _getBaseUri(): string; _encodeRequestQueryParams(request: requests.Request): string; _rfc3986EncodeURIComponent(str: string): string; _formatQueryParameterValue(): string; _split_requests( requests: requests.Request[], chunk_size: number ): requests.Request[][]; _concat_multipart_results( responses: Response[][] ): Promise<Response[]> _send_batch_part_rec(requests: requests.Request[], results: Response[]): Promise<Response[]>; _send_multipart_batch(batch: requests.Request, callback?: (error: errors.ResponseError | null, response?: Response) => void): Promise<Response>; /** * Send the request to Recombee * * @param request - Request to be sent. * @param callback - Optional callback. * @returns Promise if callback is omitted, otherwise void. */ send<TRequest extends requests.Request>( request: TRequest, // @ts-expect-error callback?: (error: errors.ResponseError | null, response?: TRequest["__response_type"]) => void // @ts-expect-error ): Promise<TRequest["__response_type"]>; _signUrl( req_part: string ): string } export type Item = { itemId: string; values?: Record<string, EntityProperty>; } export type PropertyInfo = { name: string; type: string; } export type UpdateMoreItemsResponse = { count: number; itemIds: string[]; } export type DeleteMoreItemsResponse = { count: number; itemIds: string[]; } export type Series = { seriesId: string; } export type SeriesItem = { itemType: string; itemId: string; time: number; cascadeCreate?: boolean; } export type User = { userId: string; values?: Record<string, EntityProperty>; } export type DetailView = { userId: string; itemId: string; timestamp?: string | number; duration?: number; cascadeCreate?: boolean; recommId?: string; additionalData?: Record<string, unknown>; autoPresented?: boolean; } export type Purchase = { userId: string; itemId: string; timestamp?: string | number; cascadeCreate?: boolean; amount?: number; price?: number; profit?: number; recommId?: string; additionalData?: Record<string, unknown>; } export type Rating = { userId: string; itemId: string; timestamp?: string | number; rating: number; cascadeCreate?: boolean; recommId?: string; additionalData?: Record<string, unknown>; } export type CartAddition = { userId: string; itemId: string; timestamp?: string | number; cascadeCreate?: boolean; amount?: number; price?: number; recommId?: string; additionalData?: Record<string, unknown>; } export type Bookmark = { userId: string; itemId: string; timestamp?: string | number; cascadeCreate?: boolean; recommId?: string; additionalData?: Record<string, unknown>; } export type ViewPortion = { userId: string; itemId: string; portion: number; sessionId?: string; timestamp?: string | number; cascadeCreate?: boolean; recommId?: string; additionalData?: Record<string, unknown>; autoPresented?: boolean; timeSpent?: number; } export type Recommendation = { id: string; values?: Record<string, EntityProperty>; reqlEvaluations?: Record<string, unknown>; } export type RecommendationResponse = { recommId: string; recomms: Recommendation[]; numberNextRecommsCalls?: number; abGroup?: string; } export type CompositeRecommendationResponse = { recommId: string; source: Recommendation; recomms: Recommendation[]; numberNextRecommsCalls?: number; } export type SearchResponse = { recommId: string; recomms: Recommendation[]; numberNextRecommsCalls?: number; abGroup?: string; } export type SearchSynonym = { id: string; term: string; synonym: string; oneWay: boolean; } export type ListSearchSynonymsResponse = { synonyms: SearchSynonym[]; } export type ListSegmentationsResponse = { segmentations: Segmentation[]; } export type Segmentation = { segmentationId: string; sourceType: string; segmentationType: string; title?: string; description?: string; } export type Scenario = { id: string; endpoint: string; } namespace requests { /** * Adds new item of the given `itemId` to the items catalog. * All the item properties for the newly created items are set to null. */ export class AddItem extends requests.Request { /** * @param itemId - ID of the item to be created. */ constructor( itemId: string, ); itemId: string; protected __response_type: string; bodyParameters(): { }; queryParameters(): { }; } /** * Deletes an item of the given `itemId` from the catalog. * If there are any *purchases*, *ratings*, *bookmarks*, *cart additions*, or *detail views* of the item present in the database, they will be deleted in cascade as well. Also, if the item is present in some *series*, it will be removed from all the *series* where present. * If an item becomes obsolete/no longer available, it is meaningful to keep it in the catalog (along with all the interaction data, which are very useful), and **only exclude the item from recommendations**. In such a case, use [ReQL filter](https://docs.recombee.com/reql) instead of deleting the item completely. */ export class DeleteItem extends requests.Request { /** * @param itemId - ID of the item to be deleted. */ constructor( itemId: string, ); itemId: string; protected __response_type: string; bodyParameters(): { }; queryParameters(): { }; } /** * Gets all the current property values of the given item. */ export class GetItemValues extends requests.Request { /** * @param itemId - ID of the item whose properties are to be obtained. */ constructor( itemId: string, ); itemId: string; protected __response_type: Record<string, EntityProperty>; bodyParameters(): { }; queryParameters(): { }; } /** * Gets a list of IDs of items currently present in the catalog. */ export class ListItems extends requests.Request { /** * @param optional - Optional parameters given as an object. */ constructor( optional?: { /** Boolean-returning [ReQL](https://docs.recombee.com/reql) expression, which allows you to filter items to be listed. Only the items for which the expression is *true* will be returned. */ filter?: string; /** The number of items to be listed. */ count?: number; /** Specifies the number of items to skip (ordered by `itemId`). */ offset?: number; /** With `returnProperties=true`, property values of the listed items are returned along with their IDs in a JSON dictionary. */ returnProperties?: boolean; /** Allows specifying which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list. */ includedProperties?: string[]; } ); filter?: string; count?: number; offset?: number; returnProperties?: boolean; includedProperties?: string[]; protected __response_type: Item[]; bodyParameters(): { }; queryParameters(): { filter?: string; count?: number; offset?: number; returnProperties?: boolean; includedProperties?: string[]; }; } /** * Adding an item property is somewhat equivalent to adding a column to the table of items. The items may be characterized by various properties of different types. */ export class AddItemProperty extends requests.Request { /** * @param propertyName - 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 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). * * `string` - UTF-8 string. * * `boolean` - *true* / *false* * * `timestamp` - Value representing date and time. * * `set` - Set of strings. * * `image` - URL of an image (`jpeg`, `png` or `gif`). * * `imageList` - List of URLs that refer to images. */ constructor( propertyName: string, type: string, ); propertyName: string; type: string; protected __response_type: string; bodyParameters(): { }; queryParameters(): { type: string; }; } /** * Deleting an item property is roughly equivalent to removing a column from the table of items. */ export class DeleteItemProperty extends requests.Request { /** * @param propertyName - Name of the property to be deleted. */ constructor( propertyName: string, ); propertyName: string; protected __response_type: string; bodyParameters(): { }; queryParameters(): { }; } /** * Gets information about specified item property. */ export class GetItemPropertyInfo extends requests.Request { /** * @param propertyName - Name of the property about which the information is to be retrieved. */ constructor( propertyName: string, ); propertyName: string; protected __response_type: PropertyInfo; bodyParameters(): { }; queryParameters(): { }; } /** * Gets the list of all the item properties in your database. */ export class ListItemProperties extends requests.Request { /** */ constructor( ); protected __response_type: PropertyInfo[]; bodyParameters(): { }; queryParameters(): { }; } /** * Updates (some) property values of all the items that pass the filter. * Example: *Setting all the items that are older than a week as unavailable* * ```json * { * "filter": "'releaseDate' < now() - 7*24*3600", * "changes": {"available": false} * } * ``` */ export class UpdateMoreItems extends requests.Request { /** * @param filter - A [ReQL](https://docs.recombee.com/reql) expression, which returns `true` for the items that shall be updated. * @param changes - A dictionary where the keys are properties that shall be updated. */ constructor( filter: string, changes: Record<string, unknown>, ); filter: string; changes: Record<string, unknown>; protected __response_type: UpdateMoreItemsResponse; bodyParameters(): { filter: string; changes: Record<string, unknown>; }; queryParameters(): { }; } /** * Deletes all the items that pass the filter. * If an item becomes obsolete/no longer available, it is meaningful to **keep it in the catalog** (along with all the interaction data, which are very useful) and **only exclude the item from recommendations**. In such a case, use [ReQL filter](https://docs.recombee.com/reql) instead of deleting the item completely. */ export class DeleteMoreItems extends requests.Request { /** * @param filter - A [ReQL](https://docs.recombee.com/reql) expression, which returns `true` for the items that shall be updated. */ constructor( filter: string, ); filter: string; protected __response_type: DeleteMoreItemsResponse; bodyParameters(): { filter: string; }; queryParameters(): { }; } /** * Creates a new series in the database. */ export class AddSeries extends requests.Request { /** * @param seriesId - ID of the series to be created. * @param optional - Optional parameters given as an object. */ constructor( seriesId: string, optional?: { /** If set to `true`, the item will be created with the same ID as the series. Default is `true`. */ cascadeCreate?: boolean; } ); seriesId: string; cascadeCreate?: boolean; protected __response_type: string; bodyParameters(): { cascadeCreate?: boolean; }; queryParameters(): { }; } /** * Deletes the series of the given `seriesId` from the database. * Deleting a series will only delete assignment of items to it, not the items themselves! */ export class DeleteSeries extends requests.Request { /** * @param seriesId - ID of the series to be deleted. * @param optional - Optional parameters given as an object. */ constructor( seriesId: string, optional?: { /** If set to `true`, item with the same ID as seriesId will be also deleted. Default is `false`. */ cascadeDelete?: boolean; } ); seriesId: string; cascadeDelete?: boolean; protected __response_type: string; bodyParameters(): { cascadeDelete?: boolean; }; queryParameters(): { }; } /** * Gets the list of all the series currently present in the database. */ export class ListSeries extends requests.Request { /** */ constructor( ); protected __response_type: Series[]; bodyParameters(): { }; queryParameters(): { }; } /** * Lists all the items present in the given series, sorted according to their time index values. */ export class ListSeriesItems extends requests.Request { /** * @param seriesId - ID of the series whose items are to be listed. */ constructor( seriesId: string, ); seriesId: string; protected __response_type: SeriesItem[]; bodyParameters(): { }; queryParameters(): { }; } /** * Inserts an existing item/series into a series of the given seriesId at a position determined by time. */ export class InsertToSeries extends requests.Request { /** * @param seriesId - ID of the series to be inserted into. * @param itemType - `item` iff the regular item from the catalog is to be inserted, `series` iff series is inserted as the item. * @param itemId - ID of the item iff `itemType` is `item`. ID of the series iff `itemType` is `series`. * @param time - Time index used for sorting items in the series. According to time, items are sorted within series in ascending order. In the example of TV show episodes, the episode number is a natural choice to be passed as time. * @param optional - Optional parameters given as an object. */ constructor( seriesId: string, itemType: string, itemId: string, time: number, optional?: { /** Indicates that any non-existing entity specified within the request should be created (as if corresponding PUT requests were invoked). This concerns both the `seriesId` and the `itemId`. If `cascadeCreate` is set to true, the behavior also depends on the `itemType`. In case of `item`, an item is created, in case of `series` a series + corresponding item with the same ID is created. */ cascadeCreate?: boolean; } ); seriesId: string; itemType: string; itemId: string; time: number; cascadeCreate?: boolean; protected __response_type: string; bodyParameters(): { itemType: string; itemId: string; time: number; cascadeCreate?: boolean; }; queryParameters(): { }; } /** * Removes an existing series item from the series. */ export class RemoveFromSeries extends requests.Request { /** * @param seriesId - ID of the series from which a series item is to be removed. * @param itemType - Type of the item to be removed. * @param itemId - ID of the item iff `itemType` is `item`. ID of the series iff `itemType` is `series`. */ constructor( seriesId: string, itemType: string, itemId: string, ); seriesId: string; itemType: string; itemId: string; protected __response_type: string; bodyParameters(): { itemType: string; itemId: string; }; queryParameters(): { }; } /** * Adds a new user to the database. */ export class AddUser extends requests.Request { /** * @param userId - ID of the user to be added. */ constructor( userId: string, ); userId: string; protected __response_type: string; bodyParameters(): { }; queryParameters(): { }; } /** * Deletes a user of the given *userId* from the database. * If there are any purchases, ratings, bookmarks, cart additions or detail views made by the user present in the database, they will be deleted in cascade as well. */ export class DeleteUser extends requests.Request { /** * @param userId - ID of the user to be deleted. */ constructor( userId: string, ); userId: string; protected __response_type: string; bodyParameters(): { }; queryParameters(): { }; } /** * Gets all the current property values of the given user. */ export class GetUserValues extends requests.Request { /** * @param userId - ID of the user whose properties are to be obtained. */ constructor( userId: string, ); userId: string; protected __response_type: Record<string, EntityProperty>; bodyParameters(): { }; queryParameters(): { }; } /** * Merges interactions (purchases, ratings, bookmarks, detail views ...) of two different users under a single user ID. This is especially useful for online e-commerce applications working with anonymous users identified by unique tokens such as the session ID. In such applications, it may often happen that a user owns a persistent account, yet accesses the system anonymously while, e.g., putting items into a shopping cart. At some point in time, such as when the user wishes to confirm the purchase, (s)he logs into the system using his/her username and password. The interactions made under anonymous session ID then become connected with the persistent account, and merging these two becomes desirable. * Merging happens between two users referred to as the *target* and the *source*. After the merge, all the interactions of the source user are attributed to the target user, and the source user is **deleted**. * By default, the *Merge Users* request is only available from server-side integrations for security reasons, to prevent potential abuse. * If you need to call this request from a client-side environment (such as a web or mobile app), please contact our support and request access to enable this feature for your database. */ export class MergeUsers extends requests.Request { /** * @param targetUserId - ID of the target user. * @param sourceUserId - ID of the source user. * @param optional - Optional parameters given as an object. */ constructor( targetUserId: string, sourceUserId: string, optional?: { /** Sets whether the user *targetUserId* should be created if not present in the database. */ cascadeCreate?: boolean; } ); targetUserId: string; sourceUserId: string; cascadeCreate?: boolean; protected __response_type: string; bodyParameters(): { }; queryParameters(): { cascadeCreate?: boolean; }; } /** * Gets a list of IDs of users currently present in the catalog. */ export class ListUsers extends requests.Request { /** * @param optional - Optional parameters given as an object. */ constructor( optional?: { /** Boolean-returning [ReQL](https://docs.recombee.com/reql) expression, which allows you to filter users to be listed. Only the users for which the expression is *true* will be returned. */ filter?: string; /** The number of users to be listed. */ count?: number; /** Specifies the number of users to skip (ordered by `userId`). */ offset?: number; /** With `returnProperties=true`, property values of the listed users are returned along with their IDs in a JSON dictionary. */ returnProperties?: boolean; /** Allows specifying which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list. */ includedProperties?: string[]; } ); filter?: string; count?: number; offset?: number; returnProperties?: boolean; includedProperties?: string[]; protected __response_type: User[]; bodyParameters(): { }; queryParameters(): { filter?: string; count?: number; offset?: number; returnProperties?: boolean; includedProperties?: string[]; }; } /** * Adding a user property is somewhat equivalent to adding a column to the table of users. The users may be characterized by various properties of different types. */ export class AddUserProperty extends requests.Request { /** * @param propertyName - 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 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). * * `string` - UTF-8 string. * * `boolean` - *true* / *false* * * `timestamp` - Value representing date and time. * * `set` - Set of strings. */ constructor( propertyName: string, type: string, ); propertyName: string; type: string; protected __response_type: string; bodyParameters(): { }; queryParameters(): { type: string; }; } /** * Deleting a user property is roughly equivalent to removing a column from the table of users. */ export class DeleteUserProperty extends requests.Request { /** * @param propertyName - Name of the property to be deleted. */ constructor( propertyName: string, ); propertyName: string; protected __response_type: string; bodyParameters(): { }; queryParameters(): { }; } /** * Gets information about specified user property. */ export class GetUserPropertyInfo extends requests.Request { /** * @param propertyName - Name of the property about which the information is to be retrieved. */ constructor( propertyName: string, ); propertyName: string; protected __response_type: PropertyInfo; bodyParameters(): { }; queryParameters(): { }; } /** * Gets the list of all the user properties in your database. */ export class ListUserProperties extends requests.Request { /** */ constructor( ); protected __response_type: PropertyInfo[]; bodyParameters(): { }; queryParameters(): { }; } /** * Adds a detail view of the given item made by the given user. */ export class AddDetailView extends requests.Request { /** * @param userId - User who viewed the item * @param itemId - Viewed item * @param optional - Optional parameters given as an object. */ constructor( userId: string, itemId: string, optional?: { /** UTC timestamp of the view as ISO8601-1 pattern or UTC epoch time. The default value is the current time. */ timestamp?: string | number; /** Duration of the view */ duration?: number; /** Sets whether the given user/item should be created if not present in the database. */ cascadeCreate?: boolean; /** If this detail view is based on a recommendation request, `recommId` is the id of the clicked recommendation. */ recommId?: string; /** A dictionary of additional data for the interaction. */ additionalData?: Record<string, unknown>; /** Indicates whether the item was automatically presented to the user (e.g., in a swiping feed) or explicitly requested by the user (e.g., by clicking on a link). Defaults to `false`. */ autoPresented?: boolean; } ); userId: string; itemId: string; timestamp?: string | number; duration?: number; cascadeCreate?: boolean; recommId?: string; additionalData?: Record<string, unknown>; autoPresented?: boolean; protected __response_type: string; bodyParameters(): { userId: string; itemId: string; timestamp?: string | number; duration?: number; cascadeCreate?: boolean; recommId?: string; additionalData?: Record<string, unknown>; autoPresented?: boolean; }; queryParameters(): { }; } /** * Deletes an existing detail view uniquely specified by (`userId`, `itemId`, and `timestamp`) or all the detail views with the given `userId` and `itemId` if `timestamp` is omitted. */ export class DeleteDetailView extends requests.Request { /** * @param userId - ID of the user who made the detail view. * @param itemId - ID of the item whose details were viewed. * @param optional - Optional parameters given as an object. */ constructor( userId: string, itemId: string, optional?: { /** Unix timestamp of the detail view. If the `timestamp` is omitted, then all the detail views with the given `userId` and `itemId` are deleted. */ timestamp?: number; } ); userId: string; itemId: string; timestamp?: number; protected __response_type: string; bodyParameters(): { }; queryParameters(): { userId: string; itemId: string; timestamp?: number; }; } /** * Lists all the detail views of the given item ever made by different users. */ export class ListItemDetailViews extends requests.Request { /** * @param itemId - ID of the item whose detail views are to be listed. */ constructor( itemId: string, ); itemId: string; protected __response_type: DetailView[]; bodyParameters(): { }; queryParameters(): { }; } /** * Lists all the detail views of different items ever made by the given user. */ export class ListUserDetailViews extends requests.Request { /** * @param userId - ID of the user whose detail views are to be listed. */ constructor( userId: string, ); userId: string; protected __response_type: DetailView[]; bodyParameters(): { }; queryParameters(): { }; } /** * Adds a purchase of the given item made by the given user. */ export class AddPurchase extends requests.Request { /** * @param userId - User who purchased the item * @param itemId - Purchased item * @param optional - Optional parameters given as an object. */ constructor( userId: string, itemId: string, optional?: { /** UTC timestamp of the purchase as ISO8601-1 pattern or UTC epoch time. The default value is the current time. */ timestamp?: string | number; /** Sets whether the given user/item should be created if not present in the database. */ cascadeCreate?: boolean; /** 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. */ amount?: number; /** 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. */ price?: number; /** 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. */ profit?: number; /** If this purchase is based on a recommendation request, `recommId` is the id of the clicked recommendation. */ recommId?: string; /** A dictionary of additional data for the interaction. */ additionalData?: Record<string, unknown>; } ); userId: string; itemId: string; timestamp?: string | number; cascadeCreate?: boolean; amount?: number; price?: number; profit?: number; recommId?: string; additionalData?: Record<string, unknown>; protected __response_type: string; bodyParameters(): { userId: string; itemId: string; timestamp?: string | number; cascadeCreate?: boolean; amount?: number; price?: number; profit?: number; recommId?: string; additionalData?: Record<string, unknown>; }; queryParameters(): { }; } /** * Deletes an existing purchase uniquely specified by `userId`, `itemId`, and `timestamp` or all the purchases with the given `userId` and `itemId` if `timestamp` is omitted. */ export class DeletePurchase extends requests.Request { /** * @param userId - ID of the user who made the purchase. * @param itemId - ID of the item which was purchased. * @param optional - Optional parameters given as an object. */ constructor( userId: string, itemId: string, optional?: { /** Unix timestamp of the purchase. If the `timestamp` is omitted, then all the purchases with the given `userId` and `itemId` are deleted. */ timestamp?: number; } ); userId: string; itemId: string; timestamp?: number; protected __response_type: string; bodyParameters(): { }; queryParameters(): { userId: string; itemId: string; timestamp?: number; }; } /** * Lists all the ever-made purchases of the given item. */ export class ListItemPurchases extends requests.Request { /** * @param itemId - ID of the item whose purchases are to be listed. */ constructor( itemId: string, ); itemId: string; protected __response_type: Purchase[]; bodyParameters(): { }; queryParameters(): { }; } /** * Lists all the purchases ever made by the given user. */ export class ListUserPurchases extends requests.Request { /** * @param userId - ID of the user whose purchases are to be listed. */ constructor( userId: string, ); userId: string; protected __response_type: Purchase[]; bodyParameters(): { }; queryParameters(): { }; } /** * Adds a rating of the given item made by the given user. */ export class AddRating extends requests.Request { /** * @param userId - User who submitted the rating * @param itemId - Rated item * @param rating - Rating rescaled to interval [-1.0,1.0], where -1.0 means the worst rating possible, 0.0 means neutral, and 1.0 means absolutely positive rating. For example, in the case of 5-star evaluations, rating = (numStars-3)/2 formula may be used for the conversion. * @param optional - Optional parameters given as an object. */ constructor( userId: string, itemId: string, rating: number, optional?: { /** UTC timestamp of the rating as ISO8601-1 pattern or UTC epoch time. The default value is the current time. */ timestamp?: string | number; /** Sets whether the given user/item should be created if not present in the database. */ cascadeCreate?: boolean; /** If this rating is based on a recommendation request, `recommId` is the id of the clicked recommendation. */ recommId?: string; /** A dictionary of additional data for the interaction. */ additionalData?: Record<string, unknown>; } ); userId: string; itemId: string; rating: number; timestamp?: string | number; cascadeCreate?: boolean; recommId?: string; additionalData?: Record<string, unknown>; protected __response_type: string; bodyParameters(): { userId: string; itemId: string; rating: number; timestamp?: string | number; cascadeCreate?: boolean; recommId?: string; additionalData?: Record<string, unknown>; }; queryParameters(): { }; } /** * Deletes an existing rating specified by (`userId`, `itemId`, `timestamp`) from the database or all the ratings with the given `userId` and `itemId` if `timestamp` is omitted. */ export class DeleteRating extends requests.Request { /** * @param userId - ID of the user who rated the item. * @param itemId - ID of the item which was rated. * @param optional - Optional parameters given as an object. */ constructor( userId: string, itemId: string, optional?: { /** Unix timestamp of the rating. If the `timestamp` is omitted, then all the ratings with the given `userId` and `itemId` are deleted. */ timestamp?: number; } ); userId: string; itemId: string; timestamp?: number; protected __response_type: string; bodyParameters(): { }; queryParameters(): { userId: string; itemId: string; timestamp?: number; }; } /** * Lists all the ratings of an item ever submitted by different users. */ export class ListItemRatings extends requests.Request { /** * @param itemId - ID of the item whose ratings are to be listed. */ constructor( itemId: string, ); itemId: string; protected __response_type: Rating[]; bodyParameters(): { }; queryParameters(): { }; } /** * Lists all the ratings ever submitted by the given user. */ export class ListUserRatings extends requests.Request { /** * @param userId - ID of the user whose ratings are to be listed. */ constructor( userId: string, ); userId: string; protected __response_type: Rating[]; bodyParameters(): { }; queryParameters(): { }; } /** * Adds a cart addition of the given item made by the given user. */ export class AddCartAddition extends requests.Request { /** * @param userId - User who added the item to the cart * @param itemId - Item added to the cart * @param optional - Optional parameters given as an object. */ constructor( userId: string, itemId: string, optional?: { /** UTC timestamp of the cart addition as ISO8601-1 pattern or UTC epoch time. The default value is the current time. */ timestamp?: string | number; /** Sets whether the given user/item should be created if not present in the database. */ cascadeCreate?: boolean; /** 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. */ amount?: number; /** Price of the added item. If `amount` is greater than 1, the sum of prices of all the items should be given. */ price?: number; /** If this cart addition is based on a recommendation request, `recommId` is the id of the clicked recommendation. */ recommId?: string; /** A dictionary of additional data for the interaction. */ additionalData?: Record<string, unknown>; } ); userId: string; itemId: string; timestamp?: string | number; cascadeCreate?: boolean; amount?: number; price?: number; recommId?: string; additionalData?: Record<string, unknown>; protected __response_type: string; bodyParameters(): { userId: string; itemId: string; timestamp?: string | number; cascadeCreate?: boolean; amount?: number; price?: number; recommId?: string; additionalData?: Record<string, unknown>; }; queryParameters(): { }; } /** * Deletes an existing cart addition uniquely specified by `userId`, `itemId`, and `timestamp` or all the cart additions with the given `userId` and `itemId` if `timestamp` is omitted. */ export class DeleteCartAddition extends requests.Request { /** * @param userId - ID of the user who made the cart addition. * @param itemId - ID of the item which was added to the cart. * @param optional - Optional parameters given as an object. */ constructor( userId: string, itemId: string, optional?: { /** Unix timestamp of the cart addition. If the `timestamp` is omitted, then all the cart additions with the given `userId` and `itemId` are deleted. */ timestamp?: number; } ); userId: string; itemId: string; timestamp?: number; protected __response_type: string; bodyParameters(): { }; queryParameters(): { userId: string; itemId: string; timestamp?: number; }; } /** * Lists all the ever-made cart additions of the given item. */ export class ListItemCartAdditions extends requests.Request { /** * @param itemId - ID of the item whose cart additions are to be listed. */ constructor( itemId: string, ); itemId: string; protected __response_type: CartAddition[]; bodyParameters(): { }; queryParameters(): { }; } /** * Lists all the cart additions ever made by the given user. */ export class ListUserCartAdditions extends requests.Request { /** * @param userId - ID of the user whose cart additions are to be listed. */ constructor( userId: string, ); userId: string; protected __response_type: CartAddition[]; bodyParameters(): { }; queryParameters(): { }; } /** * Adds a bookmark of the given item made by the given user. */ export class AddBookmark extends requests.Request { /** * @param userId - User who bookmarked the item * @param itemId - Bookmarked item * @param optional - Optional parameters given as an object. */ constructor( userId: string, itemId: string, optional?: { /** UTC timestamp of the bookmark as ISO8601-1 pattern or UTC epoch time. The default value is the current time. */ timestamp?: string | number; /** Sets whether the given user/item should be created if not present in the database. */ cascadeCreate?: boolean; /** If this bookmark is based on a recommendation request, `recommId` is the id of the clicked recommendation. */ recommId?: string; /** A dictionary of additional data for the interaction. */ additionalData?: Record<string, unknown>; } ); userId: string; itemId: string; timestamp?: string | number; cascadeCreate?: boolean; recommId?: string; additionalData?: Record<string, unknown>; protected __response_type: string; bodyParameters(): { userId: string; itemId: string; timestamp?: string | number; cascadeCreate?: boolean; recommId?: string; additionalData?: Record<string, unknown>; }; queryParameters(): { }; } /** * Deletes a bookmark uniquely specified by `userId`, `itemId`, and `timestamp` or all the bookmarks with the given `userId` and `itemId` if `timestamp` is omitted. */ export class DeleteBookmark extends requests.Request { /** * @param userId - ID of the user who made the bookmark. * @param itemId - ID of the item which was bookmarked. * @param optional - Optional parameters given as an object. */ constructor( userId: string, itemId: string, optional?: { /** Unix timestamp of the b