write method

Future<GoogleCloudRetailV2UserEvent> write(
  1. GoogleCloudRetailV2UserEvent request,
  2. String parent, {
  3. bool? writeAsync,
  4. String? $fields,
})

Writes a single user event.

request - The metadata request object.

Request parameters:

parent - Required. The parent catalog resource name, such as projects/1234/locations/global/catalogs/default_catalog. Value must have pattern ^projects/\[^/\]+/locations/\[^/\]+/catalogs/\[^/\]+$.

writeAsync - If set to true, the user event will be written asynchronously after validation, and the API will respond without waiting for the write. Therefore, silent failures can occur even if the API returns success. In case of silent failures, error messages can be found in Stackdriver logs.

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

Completes with a GoogleCloudRetailV2UserEvent.

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<GoogleCloudRetailV2UserEvent> write(
  GoogleCloudRetailV2UserEvent request,
  core.String parent, {
  core.bool? writeAsync,
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    if (writeAsync != null) 'writeAsync': ['${writeAsync}'],
    if ($fields != null) 'fields': [$fields],
  };

  final url_ = 'v2/' + core.Uri.encodeFull('$parent') + '/userEvents:write';

  final response_ = await _requester.request(
    url_,
    'POST',
    body: body_,
    queryParams: queryParams_,
  );
  return GoogleCloudRetailV2UserEvent.fromJson(
      response_ as core.Map<core.String, core.dynamic>);
}