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\HomeGraphService\Resource;
19
20use Google\Service\HomeGraphService\QueryRequest;
21use Google\Service\HomeGraphService\QueryResponse;
22use Google\Service\HomeGraphService\ReportStateAndNotificationRequest;
23use Google\Service\HomeGraphService\ReportStateAndNotificationResponse;
24use Google\Service\HomeGraphService\RequestSyncDevicesRequest;
25use Google\Service\HomeGraphService\RequestSyncDevicesResponse;
26use Google\Service\HomeGraphService\SyncRequest;
27use Google\Service\HomeGraphService\SyncResponse;
28
29/**
30 * The "devices" collection of methods.
31 * Typical usage is:
32 *  <code>
33 *   $homegraphService = new Google\Service\HomeGraphService(...);
34 *   $devices = $homegraphService->devices;
35 *  </code>
36 */
37class Devices extends \Google\Service\Resource
38{
39  /**
40   * Gets the current states in Home Graph for the given set of the third-party
41   * user's devices. The third-party user's identity is passed in via the
42   * `agent_user_id` (see QueryRequest). This request must be authorized using
43   * service account credentials from your Actions console project.
44   * (devices.query)
45   *
46   * @param QueryRequest $postBody
47   * @param array $optParams Optional parameters.
48   * @return QueryResponse
49   */
50  public function query(QueryRequest $postBody, $optParams = [])
51  {
52    $params = ['postBody' => $postBody];
53    $params = array_merge($params, $optParams);
54    return $this->call('query', [$params], QueryResponse::class);
55  }
56  /**
57   * Reports device state and optionally sends device notifications. Called by
58   * your smart home Action when the state of a third-party device changes or you
59   * need to send a notification about the device. See [Implement Report
60   * State](https://developers.google.com/assistant/smarthome/develop/report-
61   * state) for more information. This method updates the device state according
62   * to its declared
63   * [traits](https://developers.google.com/assistant/smarthome/concepts/devices-
64   * traits). Publishing a new state value outside of these traits will result in
65   * an `INVALID_ARGUMENT` error response. The third-party user's identity is
66   * passed in via the `agent_user_id` (see ReportStateAndNotificationRequest).
67   * This request must be authorized using service account credentials from your
68   * Actions console project. (devices.reportStateAndNotification)
69   *
70   * @param ReportStateAndNotificationRequest $postBody
71   * @param array $optParams Optional parameters.
72   * @return ReportStateAndNotificationResponse
73   */
74  public function reportStateAndNotification(ReportStateAndNotificationRequest $postBody, $optParams = [])
75  {
76    $params = ['postBody' => $postBody];
77    $params = array_merge($params, $optParams);
78    return $this->call('reportStateAndNotification', [$params], ReportStateAndNotificationResponse::class);
79  }
80  /**
81   * Requests Google to send an `action.devices.SYNC` [intent](https://developers.
82   * google.com/assistant/smarthome/reference/intent/sync) to your smart home
83   * Action to update device metadata for the given user. The third-party user's
84   * identity is passed via the `agent_user_id` (see RequestSyncDevicesRequest).
85   * This request must be authorized using service account credentials from your
86   * Actions console project. (devices.requestSync)
87   *
88   * @param RequestSyncDevicesRequest $postBody
89   * @param array $optParams Optional parameters.
90   * @return RequestSyncDevicesResponse
91   */
92  public function requestSync(RequestSyncDevicesRequest $postBody, $optParams = [])
93  {
94    $params = ['postBody' => $postBody];
95    $params = array_merge($params, $optParams);
96    return $this->call('requestSync', [$params], RequestSyncDevicesResponse::class);
97  }
98  /**
99   * Gets all the devices associated with the given third-party user. The third-
100   * party user's identity is passed in via the `agent_user_id` (see SyncRequest).
101   * This request must be authorized using service account credentials from your
102   * Actions console project. (devices.sync)
103   *
104   * @param SyncRequest $postBody
105   * @param array $optParams Optional parameters.
106   * @return SyncResponse
107   */
108  public function sync(SyncRequest $postBody, $optParams = [])
109  {
110    $params = ['postBody' => $postBody];
111    $params = array_merge($params, $optParams);
112    return $this->call('sync', [$params], SyncResponse::class);
113  }
114}
115
116// Adding a class alias for backwards compatibility with the previous class name.
117class_alias(Devices::class, 'Google_Service_HomeGraphService_Resource_Devices');
118