1 | <?php |
||
26 | class ComradeReader |
||
27 | { |
||
28 | /** @var Client $client */ |
||
29 | protected $client; |
||
30 | |||
31 | /** @var string $url */ |
||
32 | protected $url; |
||
33 | |||
34 | /** @var string $secretToken */ |
||
35 | protected $secretToken; |
||
36 | |||
37 | /** @var string $tokenFieldName */ |
||
38 | protected $tokenFieldName = 'token'; |
||
39 | |||
40 | /** @var Serializer $serializer */ |
||
41 | protected $serializer; |
||
42 | |||
43 | /** @var CacheProvider $cache */ |
||
44 | protected $cache; |
||
45 | |||
46 | /** |
||
47 | * @param string $apiUrl |
||
48 | * @param string $apiKey |
||
49 | * @param Serializer $serializer |
||
50 | * @param CacheProvider $cache |
||
51 | */ |
||
52 | public function __construct( |
||
68 | |||
69 | /** |
||
70 | * @param string $tokenFieldName |
||
71 | * @return ComradeReader |
||
72 | */ |
||
73 | public function setTokenFieldName($tokenFieldName) |
||
78 | |||
79 | /** |
||
80 | * @return string |
||
81 | */ |
||
82 | public function getTokenFieldName() |
||
86 | |||
87 | /** |
||
88 | * @return array |
||
89 | */ |
||
90 | protected function getConnectionOptions() |
||
98 | |||
99 | /** |
||
100 | * Make a request to the server |
||
101 | * and return a decoded response |
||
102 | * |
||
103 | * @param string $method |
||
104 | * @param string $url |
||
105 | * @param array $parameters |
||
106 | * @param int $cacheLifeTime |
||
107 | * |
||
108 | * @throws InvalidArgumentException |
||
109 | * @throws ResourceNotFoundException |
||
110 | * |
||
111 | * @return ComradeDeserializer |
||
112 | */ |
||
113 | public function request( |
||
159 | |||
160 | /** |
||
161 | * Alias to request() |
||
162 | * |
||
163 | * @param string $url |
||
164 | * @param array $parameters |
||
165 | * @param int $cacheLifeTime |
||
166 | * |
||
167 | * @throws ResourceNotFoundException |
||
168 | * @return ComradeDeserializer |
||
169 | */ |
||
170 | public function get( |
||
178 | |||
179 | /** |
||
180 | * Alias to request(), with "POST" preselected as a HTTP method |
||
181 | * |
||
182 | * @param string $url |
||
183 | * @param array $parameters |
||
184 | * @param int $cacheLifeTime |
||
185 | * |
||
186 | * @throws ResourceNotFoundException |
||
187 | * @return ComradeDeserializer |
||
188 | */ |
||
189 | public function post( |
||
197 | |||
198 | /** |
||
199 | * Alias to request(), with "PUT" preselected as a HTTP method |
||
200 | * |
||
201 | * @param string $url |
||
202 | * @param array $parameters |
||
203 | * @param int $cacheLifeTime |
||
204 | * |
||
205 | * @throws ResourceNotFoundException |
||
206 | * @return ComradeDeserializer |
||
207 | */ |
||
208 | public function put( |
||
216 | |||
217 | /** |
||
218 | * Alias to request(), with "DELETE" preselected as a HTTP method |
||
219 | * |
||
220 | * @param string $url |
||
221 | * @param array $parameters |
||
222 | * @param int $cacheLifeTime |
||
223 | * |
||
224 | * @throws ResourceNotFoundException |
||
225 | * @return ComradeDeserializer |
||
226 | */ |
||
227 | public function delete( |
||
235 | |||
236 | /** |
||
237 | * @param string $path |
||
238 | * @return string |
||
239 | */ |
||
240 | protected function getPreparedRequestUrl($path) |
||
244 | |||
245 | /** |
||
246 | * @param string $method |
||
247 | * @param string $url |
||
248 | * @param array $parameters |
||
249 | * @return string |
||
250 | */ |
||
251 | protected function getCacheId($method, $url, $parameters) |
||
255 | |||
256 | /** |
||
257 | * @param string $url |
||
258 | * @param string $method |
||
259 | * @param array $parameters |
||
260 | * |
||
261 | * @throws \InvalidArgumentException |
||
262 | * @return string |
||
263 | */ |
||
264 | protected function buildParameters($url, $method, $parameters) |
||
294 | } |