1 | <?php |
||
10 | class Client |
||
11 | { |
||
12 | private $token; |
||
13 | private $format; |
||
14 | private $cache; |
||
15 | |||
16 | /** |
||
17 | * Yep, it's a constructor. |
||
18 | * |
||
19 | * @param string $token User key (API token) |
||
20 | * @param string $format Raw response text format (JSON or XML) |
||
21 | * |
||
22 | * @throws \InvalidArgumentException When unsupported format is given |
||
23 | */ |
||
24 | 38 | public function __construct($token, $format) |
|
38 | |||
39 | 37 | public function clearCache() |
|
43 | |||
44 | /** |
||
45 | * Execute given API call on specified domain |
||
46 | * |
||
47 | * @param AbstractRequest $request Call name as in URL path, eg. v1/traffic |
||
48 | * |
||
49 | * @return AbstractResponse Value object with interface to fetch results |
||
50 | */ |
||
51 | 36 | public function getResponse(AbstractRequest $request) |
|
66 | |||
67 | /** |
||
68 | * Returns endpoint (API call handler) for given call name |
||
69 | * |
||
70 | * @param AbstractRequest $request Request object |
||
71 | * |
||
72 | * @return ParserInterface |
||
73 | * |
||
74 | * @throws \InvalidArgumentException When given endpoint does not exist |
||
75 | */ |
||
76 | 36 | private function getParser(AbstractRequest $request) |
|
89 | |||
90 | /** |
||
91 | * Utility function to execute API call and get raw response text |
||
92 | * |
||
93 | * @codeCoverageIgnore |
||
94 | * |
||
95 | * @param string $url Call name as in URL path, eg. v1/traffic |
||
96 | * |
||
97 | * @return string Response text and status code |
||
98 | * |
||
99 | * @throws \RuntimeException If request failed (code outside 2xx range) |
||
100 | */ |
||
101 | public function executeCall($url) |
||
121 | } |
||
122 |