1 | <?php |
||
26 | abstract class AbstractReportingCloud |
||
27 | { |
||
28 | /** |
||
29 | * Default date/time format of backend is 'ISO 8601' |
||
30 | * |
||
31 | * Note, last letter is 'P' and not 'O': |
||
32 | * |
||
33 | * O - Difference to Greenwich time (GMT) in hours (e.g. +0200) |
||
34 | * P - Difference to Greenwich time (GMT) with colon between hours and minutes (e.g. +02:00) |
||
35 | * |
||
36 | * Backend uses the 'P' variant |
||
37 | * |
||
38 | * @const DEFAULT_DATE_FORMAT |
||
39 | */ |
||
40 | const DEFAULT_DATE_FORMAT = 'Y-m-d\TH:i:sP'; |
||
41 | |||
42 | /** |
||
43 | * Default time zone of backend |
||
44 | * |
||
45 | * @const DEFAULT_TIME_ZONE |
||
46 | */ |
||
47 | const DEFAULT_TIME_ZONE = 'UTC'; |
||
48 | |||
49 | /** |
||
50 | * Default base URI of backend |
||
51 | * |
||
52 | * @const DEFAULT_BASE_URI |
||
53 | */ |
||
54 | const DEFAULT_BASE_URI = 'https://api.reporting.cloud'; |
||
55 | |||
56 | /** |
||
57 | * Default version string of backend |
||
58 | * |
||
59 | * @const DEFAULT_VERSION |
||
60 | */ |
||
61 | const DEFAULT_VERSION = 'v1'; |
||
62 | |||
63 | /** |
||
64 | * Default timeout of backend in seconds |
||
65 | * |
||
66 | * @const DEFAULT_TIMEOUT |
||
67 | */ |
||
68 | const DEFAULT_TIMEOUT = 120; // seconds |
||
69 | |||
70 | /** |
||
71 | * Default debug flag of REST client |
||
72 | * |
||
73 | * @const DEFAULT_DEBUG |
||
74 | */ |
||
75 | const DEFAULT_DEBUG = false; |
||
76 | |||
77 | /** |
||
78 | * Backend username |
||
79 | * |
||
80 | * @var string |
||
81 | */ |
||
82 | protected $username; |
||
83 | |||
84 | /** |
||
85 | * Backend password |
||
86 | * |
||
87 | * @var string |
||
88 | */ |
||
89 | protected $password; |
||
90 | |||
91 | /** |
||
92 | * Backend base URI |
||
93 | * |
||
94 | * @var string |
||
95 | */ |
||
96 | protected $baseUri; |
||
97 | |||
98 | /** |
||
99 | * Backend version string |
||
100 | * |
||
101 | * @var string |
||
102 | */ |
||
103 | protected $version; |
||
104 | |||
105 | /** |
||
106 | * Backend timeout in seconds |
||
107 | * |
||
108 | * @var integer |
||
109 | */ |
||
110 | protected $timeout; |
||
111 | |||
112 | /** |
||
113 | * REST client to backend |
||
114 | * |
||
115 | * @var Client |
||
116 | */ |
||
117 | protected $client; |
||
118 | |||
119 | /** |
||
120 | * Debug flag of REST client |
||
121 | * |
||
122 | * @var boolean |
||
123 | */ |
||
124 | protected $debug; |
||
125 | |||
126 | /** |
||
127 | * AbstractReportingCloud constructor |
||
128 | * |
||
129 | * @param array $options |
||
130 | */ |
||
131 | 46 | public function __construct($options = []) |
|
157 | |||
158 | /** |
||
159 | * Return the REST client of the backend web service |
||
160 | * |
||
161 | * @return \GuzzleHttp\Client |
||
162 | */ |
||
163 | 14 | public function getClient() |
|
184 | |||
185 | /** |
||
186 | * Set the REST client of the backend web service |
||
187 | * |
||
188 | * @param Client $client REST client |
||
189 | * |
||
190 | * @return ReportingCloud |
||
191 | */ |
||
192 | 14 | public function setClient(Client $client) |
|
198 | |||
199 | /** |
||
200 | * Return the base URI of the backend web service |
||
201 | * |
||
202 | * @return string |
||
203 | */ |
||
204 | 18 | public function getBaseUri() |
|
212 | |||
213 | /** |
||
214 | * Set the base URI of the backend web service |
||
215 | * |
||
216 | * @param string $baseUri Base URI |
||
217 | * |
||
218 | * @return ReportingCloud |
||
219 | */ |
||
220 | 18 | public function setBaseUri($baseUri) |
|
226 | |||
227 | /** |
||
228 | * Get the timeout (in seconds) of the backend web service |
||
229 | * |
||
230 | * @return integer |
||
231 | */ |
||
232 | 17 | public function getTimeout() |
|
240 | |||
241 | /** |
||
242 | * Set the timeout (in seconds) of the backend web service |
||
243 | * |
||
244 | * @param integer $timeout Timeout |
||
245 | * |
||
246 | * @return ReportingCloud |
||
247 | */ |
||
248 | 17 | public function setTimeout($timeout) |
|
254 | |||
255 | /** |
||
256 | * Return the username |
||
257 | * |
||
258 | * @return string |
||
259 | */ |
||
260 | 17 | public function getUsername() |
|
264 | |||
265 | /** |
||
266 | * Set the username |
||
267 | * |
||
268 | * @param string $username Username |
||
269 | * |
||
270 | * @return ReportingCloud |
||
271 | */ |
||
272 | 43 | public function setUsername($username) |
|
278 | |||
279 | /** |
||
280 | * Return the password |
||
281 | * |
||
282 | * @return string |
||
283 | */ |
||
284 | 17 | public function getPassword() |
|
288 | |||
289 | /** |
||
290 | * Set the password |
||
291 | * |
||
292 | * @param string $password Password |
||
293 | * |
||
294 | * @return ReportingCloud |
||
295 | */ |
||
296 | 43 | public function setPassword($password) |
|
302 | |||
303 | /** |
||
304 | * Return the debug flag |
||
305 | * |
||
306 | * @return mixed |
||
307 | */ |
||
308 | 17 | public function getDebug() |
|
316 | |||
317 | /** |
||
318 | * Set the debug flag |
||
319 | * |
||
320 | * @param boolean $debug Debug flag |
||
321 | * |
||
322 | * @return ReportingCloud |
||
323 | */ |
||
324 | 17 | public function setDebug($debug) |
|
330 | |||
331 | /** |
||
332 | * Construct URI with version number |
||
333 | * |
||
334 | * @param string $uri URI |
||
335 | * |
||
336 | * @return string |
||
337 | */ |
||
338 | 13 | protected function uri($uri) |
|
342 | |||
343 | /** |
||
344 | * Get the version string of the backend web service |
||
345 | * |
||
346 | * @return string |
||
347 | */ |
||
348 | 16 | public function getVersion() |
|
356 | |||
357 | /** |
||
358 | * Set the version string of the backend web service |
||
359 | * |
||
360 | * @param string $version Version string |
||
361 | * |
||
362 | * @return ReportingCloud |
||
363 | */ |
||
364 | 2 | public function setVersion($version) |
|
370 | |||
371 | /** |
||
372 | * Request the URI with options |
||
373 | * |
||
374 | * @param string $method HTTP method |
||
375 | * @param string $uri URI |
||
376 | * @param array $options Options |
||
377 | * |
||
378 | * @return mixed|null|\Psr\Http\Message\ResponseInterface |
||
379 | * |
||
380 | * @throws RuntimeException |
||
381 | */ |
||
382 | 13 | protected function request($method, $uri, $options) |
|
409 | |||
410 | /** |
||
411 | * Using the passed propertyMap, recursively normalizes the keys of the passed array |
||
412 | * |
||
413 | * @param array $array Array |
||
414 | * @param PropertyMap $propertyMap PropertyMap |
||
415 | * |
||
416 | * @return array |
||
417 | */ |
||
418 | 3 | protected function normalizeArrayKeys($array, PropertyMap $propertyMap) |
|
435 | |||
436 | } |