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\Docs\Resource;
19
20use Google\Service\Docs\BatchUpdateDocumentRequest;
21use Google\Service\Docs\BatchUpdateDocumentResponse;
22use Google\Service\Docs\Document;
23
24/**
25 * The "documents" collection of methods.
26 * Typical usage is:
27 *  <code>
28 *   $docsService = new Google\Service\Docs(...);
29 *   $documents = $docsService->documents;
30 *  </code>
31 */
32class Documents extends \Google\Service\Resource
33{
34  /**
35   * Applies one or more updates to the document. Each request is validated before
36   * being applied. If any request is not valid, then the entire request will fail
37   * and nothing will be applied. Some requests have replies to give you some
38   * information about how they are applied. Other requests do not need to return
39   * information; these each return an empty reply. The order of replies matches
40   * that of the requests. For example, suppose you call batchUpdate with four
41   * updates, and only the third one returns information. The response would have
42   * two empty replies, the reply to the third request, and another empty reply,
43   * in that order. Because other users may be editing the document, the document
44   * might not exactly reflect your changes: your changes may be altered with
45   * respect to collaborator changes. If there are no collaborators, the document
46   * should reflect your changes. In any case, the updates in your request are
47   * guaranteed to be applied together atomically. (documents.batchUpdate)
48   *
49   * @param string $documentId The ID of the document to update.
50   * @param BatchUpdateDocumentRequest $postBody
51   * @param array $optParams Optional parameters.
52   * @return BatchUpdateDocumentResponse
53   */
54  public function batchUpdate($documentId, BatchUpdateDocumentRequest $postBody, $optParams = [])
55  {
56    $params = ['documentId' => $documentId, 'postBody' => $postBody];
57    $params = array_merge($params, $optParams);
58    return $this->call('batchUpdate', [$params], BatchUpdateDocumentResponse::class);
59  }
60  /**
61   * Creates a blank document using the title given in the request. Other fields
62   * in the request, including any provided content, are ignored. Returns the
63   * created document. (documents.create)
64   *
65   * @param Document $postBody
66   * @param array $optParams Optional parameters.
67   * @return Document
68   */
69  public function create(Document $postBody, $optParams = [])
70  {
71    $params = ['postBody' => $postBody];
72    $params = array_merge($params, $optParams);
73    return $this->call('create', [$params], Document::class);
74  }
75  /**
76   * Gets the latest version of the specified document. (documents.get)
77   *
78   * @param string $documentId The ID of the document to retrieve.
79   * @param array $optParams Optional parameters.
80   *
81   * @opt_param string suggestionsViewMode The suggestions view mode to apply to
82   * the document. This allows viewing the document with all suggestions inline,
83   * accepted or rejected. If one is not specified, DEFAULT_FOR_CURRENT_ACCESS is
84   * used.
85   * @return Document
86   */
87  public function get($documentId, $optParams = [])
88  {
89    $params = ['documentId' => $documentId];
90    $params = array_merge($params, $optParams);
91    return $this->call('get', [$params], Document::class);
92  }
93}
94
95// Adding a class alias for backwards compatibility with the previous class name.
96class_alias(Documents::class, 'Google_Service_Docs_Resource_Documents');
97