1 | <?php namespace Atog\Api; |
||
10 | abstract class Client |
||
11 | { |
||
12 | /** |
||
13 | * Endpoints |
||
14 | * @var string |
||
15 | */ |
||
16 | protected $endpoints = []; |
||
17 | |||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $domain; |
||
22 | |||
23 | /** |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $config; |
||
27 | |||
28 | /** |
||
29 | * A array containing the cached endpoints |
||
30 | * @var array |
||
31 | */ |
||
32 | private $cachedEndpoints = []; |
||
33 | |||
34 | /** |
||
35 | * Create a new client instance. |
||
36 | * @param array $endpoints |
||
37 | * @param array $config |
||
38 | */ |
||
39 | 11 | public function __construct(array $endpoints, array $config = []) |
|
44 | |||
45 | /** |
||
46 | * @param array $endpoints |
||
47 | * @throws \Atog\Api\Exceptions\InvalidEndpointException |
||
48 | */ |
||
49 | 11 | protected function setEndpoints(array $endpoints) |
|
67 | |||
68 | /** |
||
69 | * @return array |
||
70 | */ |
||
71 | 1 | public function getConfig() |
|
75 | |||
76 | /** |
||
77 | * Make a GET Request to an endpoint |
||
78 | * @param $endpoint |
||
79 | * @return \Jyggen\Curl\Response |
||
80 | * @throws \Jyggen\Curl\Exception\CurlErrorException |
||
81 | * @throws \Jyggen\Curl\Exception\ProtectedOptionException |
||
82 | */ |
||
83 | 1 | public function get($endpoint) |
|
103 | |||
104 | /** |
||
105 | * Get an API endpoint |
||
106 | * @param string $endpoint |
||
107 | * @return \Atog\Api\Endpoint |
||
108 | * @throws \Atog\Api\Exceptions\InvalidEndpointException |
||
109 | */ |
||
110 | 4 | public function __get($endpoint) |
|
114 | |||
115 | /** |
||
116 | * Get an API endpoint. |
||
117 | * @param string $endpoint |
||
118 | * @return \Atog\Api\Endpoint |
||
119 | * @throws \Atog\Api\Exceptions\InvalidEndpointException |
||
120 | */ |
||
121 | 8 | public function getEndpoint($endpoint) |
|
153 | } |
||
154 |