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\Fitness\Resource;
19
20use Google\Service\Fitness\Dataset;
21
22/**
23 * The "datasets" collection of methods.
24 * Typical usage is:
25 *  <code>
26 *   $fitnessService = new Google\Service\Fitness(...);
27 *   $datasets = $fitnessService->datasets;
28 *  </code>
29 */
30class UsersDataSourcesDatasets extends \Google\Service\Resource
31{
32  /**
33   * Performs an inclusive delete of all data points whose start and end times
34   * have any overlap with the time range specified by the dataset ID. For most
35   * data types, the entire data point will be deleted. For data types where the
36   * time span represents a consistent value (such as
37   * com.google.activity.segment), and a data point straddles either end point of
38   * the dataset, only the overlapping portion of the data point will be deleted.
39   * (datasets.delete)
40   *
41   * @param string $userId Delete a dataset for the person identified. Use me to
42   * indicate the authenticated user. Only me is supported at this time.
43   * @param string $dataSourceId The data stream ID of the data source that
44   * created the dataset.
45   * @param string $datasetId Dataset identifier that is a composite of the
46   * minimum data point start time and maximum data point end time represented as
47   * nanoseconds from the epoch. The ID is formatted like: "startTime-endTime"
48   * where startTime and endTime are 64 bit integers.
49   * @param array $optParams Optional parameters.
50   */
51  public function delete($userId, $dataSourceId, $datasetId, $optParams = [])
52  {
53    $params = ['userId' => $userId, 'dataSourceId' => $dataSourceId, 'datasetId' => $datasetId];
54    $params = array_merge($params, $optParams);
55    return $this->call('delete', [$params]);
56  }
57  /**
58   * Returns a dataset containing all data points whose start and end times
59   * overlap with the specified range of the dataset minimum start time and
60   * maximum end time. Specifically, any data point whose start time is less than
61   * or equal to the dataset end time and whose end time is greater than or equal
62   * to the dataset start time. (datasets.get)
63   *
64   * @param string $userId Retrieve a dataset for the person identified. Use me to
65   * indicate the authenticated user. Only me is supported at this time.
66   * @param string $dataSourceId The data stream ID of the data source that
67   * created the dataset.
68   * @param string $datasetId Dataset identifier that is a composite of the
69   * minimum data point start time and maximum data point end time represented as
70   * nanoseconds from the epoch. The ID is formatted like: "startTime-endTime"
71   * where startTime and endTime are 64 bit integers.
72   * @param array $optParams Optional parameters.
73   *
74   * @opt_param int limit If specified, no more than this many data points will be
75   * included in the dataset. If there are more data points in the dataset,
76   * nextPageToken will be set in the dataset response. The limit is applied from
77   * the end of the time range. That is, if pageToken is absent, the limit most
78   * recent data points will be returned.
79   * @opt_param string pageToken The continuation token, which is used to page
80   * through large datasets. To get the next page of a dataset, set this parameter
81   * to the value of nextPageToken from the previous response. Each subsequent
82   * call will yield a partial dataset with data point end timestamps that are
83   * strictly smaller than those in the previous partial response.
84   * @return Dataset
85   */
86  public function get($userId, $dataSourceId, $datasetId, $optParams = [])
87  {
88    $params = ['userId' => $userId, 'dataSourceId' => $dataSourceId, 'datasetId' => $datasetId];
89    $params = array_merge($params, $optParams);
90    return $this->call('get', [$params], Dataset::class);
91  }
92  /**
93   * Adds data points to a dataset. The dataset need not be previously created.
94   * All points within the given dataset will be returned with subsquent calls to
95   * retrieve this dataset. Data points can belong to more than one dataset. This
96   * method does not use patch semantics: the data points provided are merely
97   * inserted, with no existing data replaced. (datasets.patch)
98   *
99   * @param string $userId Patch a dataset for the person identified. Use me to
100   * indicate the authenticated user. Only me is supported at this time.
101   * @param string $dataSourceId The data stream ID of the data source that
102   * created the dataset.
103   * @param string $datasetId This field is not used, and can be safely omitted.
104   * @param Dataset $postBody
105   * @param array $optParams Optional parameters.
106   * @return Dataset
107   */
108  public function patch($userId, $dataSourceId, $datasetId, Dataset $postBody, $optParams = [])
109  {
110    $params = ['userId' => $userId, 'dataSourceId' => $dataSourceId, 'datasetId' => $datasetId, 'postBody' => $postBody];
111    $params = array_merge($params, $optParams);
112    return $this->call('patch', [$params], Dataset::class);
113  }
114}
115
116// Adding a class alias for backwards compatibility with the previous class name.
117class_alias(UsersDataSourcesDatasets::class, 'Google_Service_Fitness_Resource_UsersDataSourcesDatasets');
118