1 | <?php |
||
11 | class Client |
||
12 | { |
||
13 | /** |
||
14 | * The API key used for making requests |
||
15 | * |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $apiKey; |
||
19 | |||
20 | /** |
||
21 | * The base url used for making requests |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $baseUrl; |
||
26 | |||
27 | /** |
||
28 | * The HTTP client used for making requests |
||
29 | * |
||
30 | * @var ClientInterface |
||
31 | */ |
||
32 | protected $httpClient; |
||
33 | |||
34 | /** |
||
35 | * Contains the last response object |
||
36 | * |
||
37 | * @var HttpResponseInterface|null |
||
38 | */ |
||
39 | protected $lastHttpResponse; |
||
40 | |||
41 | 1 | public function __construct(string $apiKey, string $baseUrl = 'https://api.linkmobility.dk/v2') |
|
48 | |||
49 | /** |
||
50 | * @param RequestInterface $request |
||
51 | * @return ResponseInterface |
||
52 | * @throws \GuzzleHttp\Exception\GuzzleException |
||
53 | */ |
||
54 | public function request(RequestInterface $request) : ResponseInterface |
||
58 | |||
59 | /** |
||
60 | * @param string $method |
||
61 | * @param string $uri |
||
62 | * @param array $options |
||
63 | * @return mixed |
||
64 | * @throws \GuzzleHttp\Exception\GuzzleException |
||
65 | */ |
||
66 | public function rawRequest(string $method, string $uri, array $options = []) |
||
82 | |||
83 | /** |
||
84 | * @return ClientInterface |
||
85 | */ |
||
86 | public function getHttpClient() : ClientInterface |
||
93 | |||
94 | /** |
||
95 | * @param ClientInterface $httpClient |
||
96 | * @return Client |
||
97 | */ |
||
98 | 1 | public function setHttpClient(ClientInterface $httpClient) : Client |
|
103 | |||
104 | /** |
||
105 | * Returns the latest response or null if no request was made yet |
||
106 | * |
||
107 | * @return HttpResponseInterface|null |
||
108 | */ |
||
109 | public function getLastHttpResponse() : ?HttpResponseInterface |
||
113 | } |
||
114 |