AccessToken
3 years ago
AuthHandler
3 years ago
Http
3 years ago
Service
3 years ago
Task
3 years ago
Utils
3 years ago
Client.php
3 years ago
Collection.php
3 years ago
Exception.php
3 years ago
Model.php
3 years ago
Service.php
3 years ago
aliases.php
3 years ago
Service.php
73 lines
| 1 | <?php |
| 2 | /* |
| 3 | * Copyright 2010 Google Inc. |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of 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, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | namespace Google; |
| 19 | |
| 20 | use Google\Http\Batch; |
| 21 | use TypeError; |
| 22 | |
| 23 | class Service |
| 24 | { |
| 25 | public $batchPath; |
| 26 | public $rootUrl; |
| 27 | public $version; |
| 28 | public $servicePath; |
| 29 | public $serviceName; |
| 30 | public $availableScopes; |
| 31 | public $resource; |
| 32 | private $client; |
| 33 | |
| 34 | public function __construct($clientOrConfig = []) |
| 35 | { |
| 36 | if ($clientOrConfig instanceof Client) { |
| 37 | $this->client = $clientOrConfig; |
| 38 | } elseif (is_array($clientOrConfig)) { |
| 39 | $this->client = new Client($clientOrConfig ?: []); |
| 40 | } else { |
| 41 | $errorMessage = 'constructor must be array or instance of Google\Client'; |
| 42 | if (class_exists('TypeError')) { |
| 43 | throw new TypeError($errorMessage); |
| 44 | } |
| 45 | trigger_error($errorMessage, E_USER_ERROR); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Return the associated Google\Client class. |
| 51 | * @return \Google\Client |
| 52 | */ |
| 53 | public function getClient() |
| 54 | { |
| 55 | return $this->client; |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Create a new HTTP Batch handler for this service |
| 60 | * |
| 61 | * @return Batch |
| 62 | */ |
| 63 | public function createBatch() |
| 64 | { |
| 65 | return new Batch( |
| 66 | $this->client, |
| 67 | false, |
| 68 | $this->rootUrl, |
| 69 | $this->batchPath |
| 70 | ); |
| 71 | } |
| 72 | } |
| 73 |