predict method

Makes a recommendation prediction.

If using API Key based authentication, the API Key must be registered using the PredictionApiKeyRegistry service. Learn more.

request - The metadata request object.

Request parameters:

name - Required. Full resource name of the format: {name=projects / * /locations/global/catalogs/default_catalog/eventStores/default_event_store/placements / * } The id of the recommendation engine placement. This id is used to identify the set of models that will be used to make the prediction. We currently support three placements with the following IDs by default: * shopping_cart: Predicts items frequently bought together with one or more catalog items in the same shopping session. Commonly displayed after add-to-cart events, on product detail pages, or on the shopping cart page. * home_page: Predicts the next product that a user will most likely engage with or purchase based on the shopping or viewing history of the specified userId or visitorId. For example - Recommendations for you. * product_detail: Predicts the next product that a user will most likely engage with or purchase. The prediction is based on the shopping or viewing history of the specified userId or visitorId and its relevance to a specified CatalogItem. Typically used on product detail pages. For example - More items like this. * recently_viewed_default: Returns up to 75 items recently viewed by the specified userId or visitorId, most recent ones first. Returns nothing if neither of them has viewed any items yet. For example - Recently viewed. The full list of available placements can be seen at https://console.cloud.google.com/recommendation/datafeeds/default_catalog/dashboard Value must have pattern ^projects/\[^/\]+/locations/\[^/\]+/catalogs/\[^/\]+/eventStores/\[^/\]+/placements/\[^/\]+$.

$fields - Selector specifying which fields to include in a partial response.

Completes with a GoogleCloudRecommendationengineV1beta1PredictResponse.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<GoogleCloudRecommendationengineV1beta1PredictResponse> predict(
  GoogleCloudRecommendationengineV1beta1PredictRequest request,
  core.String name, {
  core.String? $fields,
}) async {
  final _body = convert.json.encode(request);
  final _queryParams = <core.String, core.List<core.String>>{
    if ($fields != null) 'fields': [$fields],
  };

  final _url = 'v1beta1/' + core.Uri.encodeFull('$name') + ':predict';

  final _response = await _requester.request(
    _url,
    'POST',
    body: _body,
    queryParams: _queryParams,
  );
  return GoogleCloudRecommendationengineV1beta1PredictResponse.fromJson(
      _response as core.Map<core.String, core.dynamic>);
}