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\Sheets\Resource;
19
20use Google\Service\Sheets\AppendValuesResponse;
21use Google\Service\Sheets\BatchClearValuesByDataFilterRequest;
22use Google\Service\Sheets\BatchClearValuesByDataFilterResponse;
23use Google\Service\Sheets\BatchClearValuesRequest;
24use Google\Service\Sheets\BatchClearValuesResponse;
25use Google\Service\Sheets\BatchGetValuesByDataFilterRequest;
26use Google\Service\Sheets\BatchGetValuesByDataFilterResponse;
27use Google\Service\Sheets\BatchGetValuesResponse;
28use Google\Service\Sheets\BatchUpdateValuesByDataFilterRequest;
29use Google\Service\Sheets\BatchUpdateValuesByDataFilterResponse;
30use Google\Service\Sheets\BatchUpdateValuesRequest;
31use Google\Service\Sheets\BatchUpdateValuesResponse;
32use Google\Service\Sheets\ClearValuesRequest;
33use Google\Service\Sheets\ClearValuesResponse;
34use Google\Service\Sheets\UpdateValuesResponse;
35use Google\Service\Sheets\ValueRange;
36
37/**
38 * The "values" collection of methods.
39 * Typical usage is:
40 *  <code>
41 *   $sheetsService = new Google\Service\Sheets(...);
42 *   $values = $sheetsService->values;
43 *  </code>
44 */
45class SpreadsheetsValues extends \Google\Service\Resource
46{
47  /**
48   * Appends values to a spreadsheet. The input range is used to search for
49   * existing data and find a "table" within that range. Values will be appended
50   * to the next row of the table, starting with the first column of the table.
51   * See the [guide](/sheets/api/guides/values#appending_values) and [sample
52   * code](/sheets/api/samples/writing#append_values) for specific details of how
53   * tables are detected and data is appended. The caller must specify the
54   * spreadsheet ID, range, and a valueInputOption. The `valueInputOption` only
55   * controls how the input data will be added to the sheet (column-wise or row-
56   * wise), it does not influence what cell the data starts being written to.
57   * (values.append)
58   *
59   * @param string $spreadsheetId The ID of the spreadsheet to update.
60   * @param string $range The [A1 notation](/sheets/api/guides/concepts#cell) of a
61   * range to search for a logical table of data. Values are appended after the
62   * last row of the table.
63   * @param ValueRange $postBody
64   * @param array $optParams Optional parameters.
65   *
66   * @opt_param bool includeValuesInResponse Determines if the update response
67   * should include the values of the cells that were appended. By default,
68   * responses do not include the updated values.
69   * @opt_param string insertDataOption How the input data should be inserted.
70   * @opt_param string responseDateTimeRenderOption Determines how dates, times,
71   * and durations in the response should be rendered. This is ignored if
72   * response_value_render_option is FORMATTED_VALUE. The default dateTime render
73   * option is SERIAL_NUMBER.
74   * @opt_param string responseValueRenderOption Determines how values in the
75   * response should be rendered. The default render option is FORMATTED_VALUE.
76   * @opt_param string valueInputOption How the input data should be interpreted.
77   * @return AppendValuesResponse
78   */
79  public function append($spreadsheetId, $range, ValueRange $postBody, $optParams = [])
80  {
81    $params = ['spreadsheetId' => $spreadsheetId, 'range' => $range, 'postBody' => $postBody];
82    $params = array_merge($params, $optParams);
83    return $this->call('append', [$params], AppendValuesResponse::class);
84  }
85  /**
86   * Clears one or more ranges of values from a spreadsheet. The caller must
87   * specify the spreadsheet ID and one or more ranges. Only values are cleared --
88   * all other properties of the cell (such as formatting and data validation) are
89   * kept. (values.batchClear)
90   *
91   * @param string $spreadsheetId The ID of the spreadsheet to update.
92   * @param BatchClearValuesRequest $postBody
93   * @param array $optParams Optional parameters.
94   * @return BatchClearValuesResponse
95   */
96  public function batchClear($spreadsheetId, BatchClearValuesRequest $postBody, $optParams = [])
97  {
98    $params = ['spreadsheetId' => $spreadsheetId, 'postBody' => $postBody];
99    $params = array_merge($params, $optParams);
100    return $this->call('batchClear', [$params], BatchClearValuesResponse::class);
101  }
102  /**
103   * Clears one or more ranges of values from a spreadsheet. The caller must
104   * specify the spreadsheet ID and one or more DataFilters. Ranges matching any
105   * of the specified data filters will be cleared. Only values are cleared -- all
106   * other properties of the cell (such as formatting, data validation, etc..) are
107   * kept. (values.batchClearByDataFilter)
108   *
109   * @param string $spreadsheetId The ID of the spreadsheet to update.
110   * @param BatchClearValuesByDataFilterRequest $postBody
111   * @param array $optParams Optional parameters.
112   * @return BatchClearValuesByDataFilterResponse
113   */
114  public function batchClearByDataFilter($spreadsheetId, BatchClearValuesByDataFilterRequest $postBody, $optParams = [])
115  {
116    $params = ['spreadsheetId' => $spreadsheetId, 'postBody' => $postBody];
117    $params = array_merge($params, $optParams);
118    return $this->call('batchClearByDataFilter', [$params], BatchClearValuesByDataFilterResponse::class);
119  }
120  /**
121   * Returns one or more ranges of values from a spreadsheet. The caller must
122   * specify the spreadsheet ID and one or more ranges. (values.batchGet)
123   *
124   * @param string $spreadsheetId The ID of the spreadsheet to retrieve data from.
125   * @param array $optParams Optional parameters.
126   *
127   * @opt_param string dateTimeRenderOption How dates, times, and durations should
128   * be represented in the output. This is ignored if value_render_option is
129   * FORMATTED_VALUE. The default dateTime render option is SERIAL_NUMBER.
130   * @opt_param string majorDimension The major dimension that results should use.
131   * For example, if the spreadsheet data is: `A1=1,B1=2,A2=3,B2=4`, then
132   * requesting `ranges=["A1:B2"],majorDimension=ROWS` returns `[[1,2],[3,4]]`,
133   * whereas requesting `ranges=["A1:B2"],majorDimension=COLUMNS` returns
134   * `[[1,3],[2,4]]`.
135   * @opt_param string ranges The [A1 notation or R1C1
136   * notation](/sheets/api/guides/concepts#cell) of the range to retrieve values
137   * from.
138   * @opt_param string valueRenderOption How values should be represented in the
139   * output. The default render option is ValueRenderOption.FORMATTED_VALUE.
140   * @return BatchGetValuesResponse
141   */
142  public function batchGet($spreadsheetId, $optParams = [])
143  {
144    $params = ['spreadsheetId' => $spreadsheetId];
145    $params = array_merge($params, $optParams);
146    return $this->call('batchGet', [$params], BatchGetValuesResponse::class);
147  }
148  /**
149   * Returns one or more ranges of values that match the specified data filters.
150   * The caller must specify the spreadsheet ID and one or more DataFilters.
151   * Ranges that match any of the data filters in the request will be returned.
152   * (values.batchGetByDataFilter)
153   *
154   * @param string $spreadsheetId The ID of the spreadsheet to retrieve data from.
155   * @param BatchGetValuesByDataFilterRequest $postBody
156   * @param array $optParams Optional parameters.
157   * @return BatchGetValuesByDataFilterResponse
158   */
159  public function batchGetByDataFilter($spreadsheetId, BatchGetValuesByDataFilterRequest $postBody, $optParams = [])
160  {
161    $params = ['spreadsheetId' => $spreadsheetId, 'postBody' => $postBody];
162    $params = array_merge($params, $optParams);
163    return $this->call('batchGetByDataFilter', [$params], BatchGetValuesByDataFilterResponse::class);
164  }
165  /**
166   * Sets values in one or more ranges of a spreadsheet. The caller must specify
167   * the spreadsheet ID, a valueInputOption, and one or more ValueRanges.
168   * (values.batchUpdate)
169   *
170   * @param string $spreadsheetId The ID of the spreadsheet to update.
171   * @param BatchUpdateValuesRequest $postBody
172   * @param array $optParams Optional parameters.
173   * @return BatchUpdateValuesResponse
174   */
175  public function batchUpdate($spreadsheetId, BatchUpdateValuesRequest $postBody, $optParams = [])
176  {
177    $params = ['spreadsheetId' => $spreadsheetId, 'postBody' => $postBody];
178    $params = array_merge($params, $optParams);
179    return $this->call('batchUpdate', [$params], BatchUpdateValuesResponse::class);
180  }
181  /**
182   * Sets values in one or more ranges of a spreadsheet. The caller must specify
183   * the spreadsheet ID, a valueInputOption, and one or more
184   * DataFilterValueRanges. (values.batchUpdateByDataFilter)
185   *
186   * @param string $spreadsheetId The ID of the spreadsheet to update.
187   * @param BatchUpdateValuesByDataFilterRequest $postBody
188   * @param array $optParams Optional parameters.
189   * @return BatchUpdateValuesByDataFilterResponse
190   */
191  public function batchUpdateByDataFilter($spreadsheetId, BatchUpdateValuesByDataFilterRequest $postBody, $optParams = [])
192  {
193    $params = ['spreadsheetId' => $spreadsheetId, 'postBody' => $postBody];
194    $params = array_merge($params, $optParams);
195    return $this->call('batchUpdateByDataFilter', [$params], BatchUpdateValuesByDataFilterResponse::class);
196  }
197  /**
198   * Clears values from a spreadsheet. The caller must specify the spreadsheet ID
199   * and range. Only values are cleared -- all other properties of the cell (such
200   * as formatting, data validation, etc..) are kept. (values.clear)
201   *
202   * @param string $spreadsheetId The ID of the spreadsheet to update.
203   * @param string $range The [A1 notation or R1C1
204   * notation](/sheets/api/guides/concepts#cell) of the values to clear.
205   * @param ClearValuesRequest $postBody
206   * @param array $optParams Optional parameters.
207   * @return ClearValuesResponse
208   */
209  public function clear($spreadsheetId, $range, ClearValuesRequest $postBody, $optParams = [])
210  {
211    $params = ['spreadsheetId' => $spreadsheetId, 'range' => $range, 'postBody' => $postBody];
212    $params = array_merge($params, $optParams);
213    return $this->call('clear', [$params], ClearValuesResponse::class);
214  }
215  /**
216   * Returns a range of values from a spreadsheet. The caller must specify the
217   * spreadsheet ID and a range. (values.get)
218   *
219   * @param string $spreadsheetId The ID of the spreadsheet to retrieve data from.
220   * @param string $range The [A1 notation or R1C1
221   * notation](/sheets/api/guides/concepts#cell) of the range to retrieve values
222   * from.
223   * @param array $optParams Optional parameters.
224   *
225   * @opt_param string dateTimeRenderOption How dates, times, and durations should
226   * be represented in the output. This is ignored if value_render_option is
227   * FORMATTED_VALUE. The default dateTime render option is SERIAL_NUMBER.
228   * @opt_param string majorDimension The major dimension that results should use.
229   * For example, if the spreadsheet data is: `A1=1,B1=2,A2=3,B2=4`, then
230   * requesting `range=A1:B2,majorDimension=ROWS` returns `[[1,2],[3,4]]`, whereas
231   * requesting `range=A1:B2,majorDimension=COLUMNS` returns `[[1,3],[2,4]]`.
232   * @opt_param string valueRenderOption How values should be represented in the
233   * output. The default render option is FORMATTED_VALUE.
234   * @return ValueRange
235   */
236  public function get($spreadsheetId, $range, $optParams = [])
237  {
238    $params = ['spreadsheetId' => $spreadsheetId, 'range' => $range];
239    $params = array_merge($params, $optParams);
240    return $this->call('get', [$params], ValueRange::class);
241  }
242  /**
243   * Sets values in a range of a spreadsheet. The caller must specify the
244   * spreadsheet ID, range, and a valueInputOption. (values.update)
245   *
246   * @param string $spreadsheetId The ID of the spreadsheet to update.
247   * @param string $range The [A1 notation](/sheets/api/guides/concepts#cell) of
248   * the values to update.
249   * @param ValueRange $postBody
250   * @param array $optParams Optional parameters.
251   *
252   * @opt_param bool includeValuesInResponse Determines if the update response
253   * should include the values of the cells that were updated. By default,
254   * responses do not include the updated values. If the range to write was larger
255   * than the range actually written, the response includes all values in the
256   * requested range (excluding trailing empty rows and columns).
257   * @opt_param string responseDateTimeRenderOption Determines how dates, times,
258   * and durations in the response should be rendered. This is ignored if
259   * response_value_render_option is FORMATTED_VALUE. The default dateTime render
260   * option is SERIAL_NUMBER.
261   * @opt_param string responseValueRenderOption Determines how values in the
262   * response should be rendered. The default render option is FORMATTED_VALUE.
263   * @opt_param string valueInputOption How the input data should be interpreted.
264   * @return UpdateValuesResponse
265   */
266  public function update($spreadsheetId, $range, ValueRange $postBody, $optParams = [])
267  {
268    $params = ['spreadsheetId' => $spreadsheetId, 'range' => $range, 'postBody' => $postBody];
269    $params = array_merge($params, $optParams);
270    return $this->call('update', [$params], UpdateValuesResponse::class);
271  }
272}
273
274// Adding a class alias for backwards compatibility with the previous class name.
275class_alias(SpreadsheetsValues::class, 'Google_Service_Sheets_Resource_SpreadsheetsValues');
276