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\DataSource;
21use Google\Service\Fitness\ListDataSourcesResponse;
22
23/**
24 * The "dataSources" collection of methods.
25 * Typical usage is:
26 *  <code>
27 *   $fitnessService = new Google\Service\Fitness(...);
28 *   $dataSources = $fitnessService->dataSources;
29 *  </code>
30 */
31class UsersDataSources extends \Google\Service\Resource
32{
33  /**
34   * Creates a new data source that is unique across all data sources belonging to
35   * this user. A data source is a unique source of sensor data. Data sources can
36   * expose raw data coming from hardware sensors on local or companion devices.
37   * They can also expose derived data, created by transforming or merging other
38   * data sources. Multiple data sources can exist for the same data type. Every
39   * data point in every dataset inserted into or read from the Fitness API has an
40   * associated data source. Each data source produces a unique stream of dataset
41   * updates, with a unique data source identifier. Not all changes to data source
42   * affect the data stream ID, so that data collected by updated versions of the
43   * same application/device can still be considered to belong to the same data
44   * source. Data sources are identified using a string generated by the server,
45   * based on the contents of the source being created. The dataStreamId field
46   * should not be set when invoking this method. It will be automatically
47   * generated by the server with the correct format. If a dataStreamId is set, it
48   * must match the format that the server would generate. This format is a
49   * combination of some fields from the data source, and has a specific order. If
50   * it doesn't match, the request will fail with an error. Specifying a DataType
51   * which is not a known type (beginning with "com.google.") will create a
52   * DataSource with a *custom data type*. Custom data types are only readable by
53   * the application that created them. Custom data types are *deprecated*; use
54   * standard data types instead. In addition to the data source fields included
55   * in the data source ID, the developer project number that is authenticated
56   * when creating the data source is included. This developer project number is
57   * obfuscated when read by any other developer reading public data types.
58   * (dataSources.create)
59   *
60   * @param string $userId Create the data source for the person identified. Use
61   * me to indicate the authenticated user. Only me is supported at this time.
62   * @param DataSource $postBody
63   * @param array $optParams Optional parameters.
64   * @return DataSource
65   */
66  public function create($userId, DataSource $postBody, $optParams = [])
67  {
68    $params = ['userId' => $userId, 'postBody' => $postBody];
69    $params = array_merge($params, $optParams);
70    return $this->call('create', [$params], DataSource::class);
71  }
72  /**
73   * Deletes the specified data source. The request will fail if the data source
74   * contains any data points. (dataSources.delete)
75   *
76   * @param string $userId Retrieve a data source for the person identified. Use
77   * me to indicate the authenticated user. Only me is supported at this time.
78   * @param string $dataSourceId The data stream ID of the data source to delete.
79   * @param array $optParams Optional parameters.
80   * @return DataSource
81   */
82  public function delete($userId, $dataSourceId, $optParams = [])
83  {
84    $params = ['userId' => $userId, 'dataSourceId' => $dataSourceId];
85    $params = array_merge($params, $optParams);
86    return $this->call('delete', [$params], DataSource::class);
87  }
88  /**
89   * Returns the specified data source. (dataSources.get)
90   *
91   * @param string $userId Retrieve a data source for the person identified. Use
92   * me to indicate the authenticated user. Only me is supported at this time.
93   * @param string $dataSourceId The data stream ID of the data source to
94   * retrieve.
95   * @param array $optParams Optional parameters.
96   * @return DataSource
97   */
98  public function get($userId, $dataSourceId, $optParams = [])
99  {
100    $params = ['userId' => $userId, 'dataSourceId' => $dataSourceId];
101    $params = array_merge($params, $optParams);
102    return $this->call('get', [$params], DataSource::class);
103  }
104  /**
105   * Lists all data sources that are visible to the developer, using the OAuth
106   * scopes provided. The list is not exhaustive; the user may have private data
107   * sources that are only visible to other developers, or calls using other
108   * scopes. (dataSources.listUsersDataSources)
109   *
110   * @param string $userId List data sources for the person identified. Use me to
111   * indicate the authenticated user. Only me is supported at this time.
112   * @param array $optParams Optional parameters.
113   *
114   * @opt_param string dataTypeName The names of data types to include in the
115   * list. If not specified, all data sources will be returned.
116   * @return ListDataSourcesResponse
117   */
118  public function listUsersDataSources($userId, $optParams = [])
119  {
120    $params = ['userId' => $userId];
121    $params = array_merge($params, $optParams);
122    return $this->call('list', [$params], ListDataSourcesResponse::class);
123  }
124  /**
125   * Updates the specified data source. The dataStreamId, dataType, type,
126   * dataStreamName, and device properties with the exception of version, cannot
127   * be modified. Data sources are identified by their dataStreamId.
128   * (dataSources.update)
129   *
130   * @param string $userId Update the data source for the person identified. Use
131   * me to indicate the authenticated user. Only me is supported at this time.
132   * @param string $dataSourceId The data stream ID of the data source to update.
133   * @param DataSource $postBody
134   * @param array $optParams Optional parameters.
135   * @return DataSource
136   */
137  public function update($userId, $dataSourceId, DataSource $postBody, $optParams = [])
138  {
139    $params = ['userId' => $userId, 'dataSourceId' => $dataSourceId, 'postBody' => $postBody];
140    $params = array_merge($params, $optParams);
141    return $this->call('update', [$params], DataSource::class);
142  }
143}
144
145// Adding a class alias for backwards compatibility with the previous class name.
146class_alias(UsersDataSources::class, 'Google_Service_Fitness_Resource_UsersDataSources');
147