| 1 |
<?php |
| 2 |
|
| 3 |
/* |
| 4 |
* Copyright 2010 Google Inc. |
| 5 |
* |
| 6 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 |
* you may not use this file except in compliance with the License. |
| 8 |
* You may obtain a copy of the License at |
| 9 |
* |
| 10 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 11 |
* |
| 12 |
* Unless required by applicable law or agreed to in writing, software |
| 13 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 14 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 |
* See the License for the specific language governing permissions and |
| 16 |
* limitations under the License. |
| 17 |
*/ |
| 18 |
|
| 19 |
/** |
| 20 |
* Internal representation of a Google API request, used by the apiServiceResource class to |
| 21 |
* construct API function calls and passing them to the IO layer who knows how to execute |
| 22 |
* the request |
| 23 |
* |
| 24 |
* @author Chris Chabot <chabotc@google.com> |
| 25 |
* @author Chirag Shah <chirags@google.com> |
| 26 |
* |
| 27 |
*/ |
| 28 |
class apiServiceRequest { |
| 29 |
protected $restBasePath; |
| 30 |
protected $restPath; |
| 31 |
protected $rpcPath; |
| 32 |
protected $rpcName; |
| 33 |
protected $httpMethod; |
| 34 |
protected $parameters; |
| 35 |
protected $postBody; |
| 36 |
protected $batchKey; |
| 37 |
|
| 38 |
/** |
| 39 |
* @param string $restBasePath |
| 40 |
* @param string $rpcPath |
| 41 |
* @param string $restPath |
| 42 |
* @param string $rpcName |
| 43 |
* @param string $httpMethod |
| 44 |
* @param $parameters |
| 45 |
* @param $postBody |
| 46 |
*/ |
| 47 |
public function __construct($restBasePath, $rpcPath, $restPath, $rpcName, $httpMethod, $parameters, $postBody = null) { |
| 48 |
|
| 49 |
if (substr($restBasePath, 0, 4) == 'http') { |
| 50 |
$this->restBasePath = $restBasePath; |
| 51 |
} else { |
| 52 |
global $apiConfig; |
| 53 |
$this->restBasePath = $apiConfig['basePath'] . $restBasePath; |
| 54 |
} |
| 55 |
|
| 56 |
$this->restPath = $restPath; |
| 57 |
$this->rpcPath = $rpcPath; |
| 58 |
$this->rpcName = $rpcName; |
| 59 |
$this->httpMethod = $httpMethod; |
| 60 |
$this->parameters = $parameters; |
| 61 |
$this->postBody = $postBody; |
| 62 |
} |
| 63 |
|
| 64 |
/** |
| 65 |
* @return string $postBody |
| 66 |
*/ |
| 67 |
public function getPostBody() { |
| 68 |
return $this->postBody; |
| 69 |
} |
| 70 |
|
| 71 |
/** |
| 72 |
* @param string $postBody The post body. |
| 73 |
*/ |
| 74 |
public function setPostBody($postBody) { |
| 75 |
$this->postBody = $postBody; |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
/** |
| 80 |
* @return the $restBasePath |
| 81 |
*/ |
| 82 |
public function getRestBasePath() { |
| 83 |
return $this->restBasePath; |
| 84 |
} |
| 85 |
|
| 86 |
/** |
| 87 |
* @return the restPath |
| 88 |
*/ |
| 89 |
public function getRestPath() { |
| 90 |
return $this->restPath; |
| 91 |
} |
| 92 |
|
| 93 |
/** |
| 94 |
* @return string $rpcPath |
| 95 |
*/ |
| 96 |
public function getRpcPath() { |
| 97 |
return $this->rpcPath; |
| 98 |
} |
| 99 |
|
| 100 |
/** |
| 101 |
* @return string $rpcName |
| 102 |
*/ |
| 103 |
public function getRpcName() { |
| 104 |
return $this->rpcName; |
| 105 |
} |
| 106 |
|
| 107 |
/** |
| 108 |
* @return string $httpMethod |
| 109 |
*/ |
| 110 |
public function getHttpMethod() { |
| 111 |
return $this->httpMethod; |
| 112 |
} |
| 113 |
|
| 114 |
/** |
| 115 |
* @return array $parameters |
| 116 |
*/ |
| 117 |
public function getParameters() { |
| 118 |
return $this->parameters; |
| 119 |
} |
| 120 |
|
| 121 |
/** |
| 122 |
* @return string $batchKey |
| 123 |
*/ |
| 124 |
public function getBatchKey() { |
| 125 |
return $this->batchKey; |
| 126 |
} |
| 127 |
|
| 128 |
/** |
| 129 |
* @param $batchKey the $batchKey to set |
| 130 |
*/ |
| 131 |
public function setBatchKey($batchKey) { |
| 132 |
$this->batchKey = $batchKey; |
| 133 |
} |
| 134 |
|
| 135 |
} |
| 136 |
|