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\Script\Resource;
19
20use Google\Service\Script\ExecutionRequest;
21use Google\Service\Script\Operation;
22
23/**
24 * The "scripts" collection of methods.
25 * Typical usage is:
26 *  <code>
27 *   $scriptService = new Google\Service\Script(...);
28 *   $scripts = $scriptService->scripts;
29 *  </code>
30 */
31class Scripts extends \Google\Service\Resource
32{
33  /**
34   * Runs a function in an Apps Script project. The script project must be
35   * deployed for use with the Apps Script API and the calling application must
36   * share the same Cloud Platform project. This method requires authorization
37   * with an OAuth 2.0 token that includes at least one of the scopes listed in
38   * the [Authorization](#authorization-scopes) section; script projects that do
39   * not require authorization cannot be executed through this API. To find the
40   * correct scopes to include in the authentication token, open the script
41   * project **Overview** page and scroll down to "Project OAuth Scopes." The
42   * error `403, PERMISSION_DENIED: The caller does not have permission` indicates
43   * that the Cloud Platform project used to authorize the request is not the same
44   * as the one used by the script. (scripts.run)
45   *
46   * @param string $scriptId The script ID of the script to be executed. Find the
47   * script ID on the **Project settings** page under "IDs."
48   * @param ExecutionRequest $postBody
49   * @param array $optParams Optional parameters.
50   * @return Operation
51   */
52  public function run($scriptId, ExecutionRequest $postBody, $optParams = [])
53  {
54    $params = ['scriptId' => $scriptId, 'postBody' => $postBody];
55    $params = array_merge($params, $optParams);
56    return $this->call('run', [$params], Operation::class);
57  }
58}
59
60// Adding a class alias for backwards compatibility with the previous class name.
61class_alias(Scripts::class, 'Google_Service_Script_Resource_Scripts');
62