1<?php
2/*
3 * Copyright 2014 Google Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6 * use this file except in compliance with the License. You may obtain a copy of
7 * the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 */
17
18namespace Google\Service\CloudRetail\Resource;
19
20use Google\Service\CloudRetail\GoogleApiHttpBody;
21use Google\Service\CloudRetail\GoogleCloudRetailV2ImportUserEventsRequest;
22use Google\Service\CloudRetail\GoogleCloudRetailV2PurgeUserEventsRequest;
23use Google\Service\CloudRetail\GoogleCloudRetailV2RejoinUserEventsRequest;
24use Google\Service\CloudRetail\GoogleCloudRetailV2UserEvent;
25use Google\Service\CloudRetail\GoogleLongrunningOperation;
26
27/**
28 * The "userEvents" collection of methods.
29 * Typical usage is:
30 *  <code>
31 *   $retailService = new Google\Service\CloudRetail(...);
32 *   $userEvents = $retailService->userEvents;
33 *  </code>
34 */
35class ProjectsLocationsCatalogsUserEvents extends \Google\Service\Resource
36{
37  /**
38   * Writes a single user event from the browser. This uses a GET request to due
39   * to browser restriction of POST-ing to a 3rd party domain. This method is used
40   * only by the Retail API JavaScript pixel and Google Tag Manager. Users should
41   * not call this method directly. (userEvents.collect)
42   *
43   * @param string $parent Required. The parent catalog name, such as
44   * `projects/1234/locations/global/catalogs/default_catalog`.
45   * @param array $optParams Optional parameters.
46   *
47   * @opt_param string ets The event timestamp in milliseconds. This prevents
48   * browser caching of otherwise identical get requests. The name is abbreviated
49   * to reduce the payload bytes.
50   * @opt_param string uri The URL including cgi-parameters but excluding the hash
51   * fragment with a length limit of 5,000 characters. This is often more useful
52   * than the referer URL, because many browsers only send the domain for 3rd
53   * party requests.
54   * @opt_param string userEvent Required. URL encoded UserEvent proto with a
55   * length limit of 2,000,000 characters.
56   * @return GoogleApiHttpBody
57   */
58  public function collect($parent, $optParams = [])
59  {
60    $params = ['parent' => $parent];
61    $params = array_merge($params, $optParams);
62    return $this->call('collect', [$params], GoogleApiHttpBody::class);
63  }
64  /**
65   * Bulk import of User events. Request processing might be synchronous. Events
66   * that already exist are skipped. Use this method for backfilling historical
67   * user events. Operation.response is of type ImportResponse. Note that it is
68   * possible for a subset of the items to be successfully inserted.
69   * Operation.metadata is of type ImportMetadata. (userEvents.import)
70   *
71   * @param string $parent Required.
72   * `projects/1234/locations/global/catalogs/default_catalog`
73   * @param GoogleCloudRetailV2ImportUserEventsRequest $postBody
74   * @param array $optParams Optional parameters.
75   * @return GoogleLongrunningOperation
76   */
77  public function import($parent, GoogleCloudRetailV2ImportUserEventsRequest $postBody, $optParams = [])
78  {
79    $params = ['parent' => $parent, 'postBody' => $postBody];
80    $params = array_merge($params, $optParams);
81    return $this->call('import', [$params], GoogleLongrunningOperation::class);
82  }
83  /**
84   * Deletes permanently all user events specified by the filter provided.
85   * Depending on the number of events specified by the filter, this operation
86   * could take hours or days to complete. To test a filter, use the list command
87   * first. (userEvents.purge)
88   *
89   * @param string $parent Required. The resource name of the catalog under which
90   * the events are created. The format is
91   * `projects/${projectId}/locations/global/catalogs/${catalogId}`
92   * @param GoogleCloudRetailV2PurgeUserEventsRequest $postBody
93   * @param array $optParams Optional parameters.
94   * @return GoogleLongrunningOperation
95   */
96  public function purge($parent, GoogleCloudRetailV2PurgeUserEventsRequest $postBody, $optParams = [])
97  {
98    $params = ['parent' => $parent, 'postBody' => $postBody];
99    $params = array_merge($params, $optParams);
100    return $this->call('purge', [$params], GoogleLongrunningOperation::class);
101  }
102  /**
103   * Starts a user event rejoin operation with latest product catalog. Events will
104   * not be annotated with detailed product information if product is missing from
105   * the catalog at the time the user event is ingested, and these events are
106   * stored as unjoined events with a limited usage on training and serving. This
107   * method can be used to start a join operation on specified events with latest
108   * version of product catalog. It can also be used to correct events joined with
109   * the wrong product catalog. A rejoin operation can take hours or days to
110   * complete. (userEvents.rejoin)
111   *
112   * @param string $parent Required. The parent catalog resource name, such as
113   * `projects/1234/locations/global/catalogs/default_catalog`.
114   * @param GoogleCloudRetailV2RejoinUserEventsRequest $postBody
115   * @param array $optParams Optional parameters.
116   * @return GoogleLongrunningOperation
117   */
118  public function rejoin($parent, GoogleCloudRetailV2RejoinUserEventsRequest $postBody, $optParams = [])
119  {
120    $params = ['parent' => $parent, 'postBody' => $postBody];
121    $params = array_merge($params, $optParams);
122    return $this->call('rejoin', [$params], GoogleLongrunningOperation::class);
123  }
124  /**
125   * Writes a single user event. (userEvents.write)
126   *
127   * @param string $parent Required. The parent catalog resource name, such as
128   * `projects/1234/locations/global/catalogs/default_catalog`.
129   * @param GoogleCloudRetailV2UserEvent $postBody
130   * @param array $optParams Optional parameters.
131   * @return GoogleCloudRetailV2UserEvent
132   */
133  public function write($parent, GoogleCloudRetailV2UserEvent $postBody, $optParams = [])
134  {
135    $params = ['parent' => $parent, 'postBody' => $postBody];
136    $params = array_merge($params, $optParams);
137    return $this->call('write', [$params], GoogleCloudRetailV2UserEvent::class);
138  }
139}
140
141// Adding a class alias for backwards compatibility with the previous class name.
142class_alias(ProjectsLocationsCatalogsUserEvents::class, 'Google_Service_CloudRetail_Resource_ProjectsLocationsCatalogsUserEvents');
143