1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the KongAdminApi package. |
5
|
|
|
* |
6
|
|
|
* (c) Unikorp <https://github.com/unikorp> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Unikorp\KongAdminApi; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* abstract api |
16
|
|
|
* |
17
|
|
|
* @author VEBER Arnaud <https://github.com/VEBERArnaud> |
18
|
|
|
*/ |
19
|
|
|
class AbstractApi implements ApiInterface |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* client |
23
|
|
|
* @var \Unikorp\KongAdminApi\Client $client |
24
|
|
|
*/ |
25
|
|
|
private $client = null; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Constructor |
29
|
|
|
* |
30
|
|
|
* @param \Unikorp\KongAdminApi\Client $client |
31
|
|
|
*/ |
32
|
|
|
public function __construct(Client $client) |
33
|
|
|
{ |
34
|
|
|
$this->client = $client; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* get |
39
|
|
|
* |
40
|
|
|
* @param string $uri |
41
|
|
|
* @param array $headers |
42
|
|
|
* |
43
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
44
|
|
|
*/ |
45
|
|
|
protected function get($uri, array $headers = []) |
|
|
|
|
46
|
|
|
{ |
47
|
|
|
return $this->client->getHttpClient()->get($path, $headers); |
|
|
|
|
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* post |
52
|
|
|
* |
53
|
|
|
* @param string $uri |
54
|
|
|
* @param array $headers |
55
|
|
|
* @param string $body |
56
|
|
|
* |
57
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
58
|
|
|
*/ |
59
|
|
|
protected function post($uri, array $headers = [], $body = null) |
60
|
|
|
{ |
61
|
|
|
return $this->client->getHttpClient()->post($uri, $headers, $body); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* put |
66
|
|
|
* |
67
|
|
|
* @param string $uri |
68
|
|
|
* @param array $headers |
69
|
|
|
* @param string $body |
70
|
|
|
* |
71
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
72
|
|
|
*/ |
73
|
|
|
protected function put($uri, array $headers = [], $body = null) |
74
|
|
|
{ |
75
|
|
|
return $this->client->getHttpClient()->put($uri, $headers, $body); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* patch |
80
|
|
|
* |
81
|
|
|
* @param string $uri |
82
|
|
|
* @param array $headers |
83
|
|
|
* @param string $uri |
84
|
|
|
* |
85
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
86
|
|
|
*/ |
87
|
|
|
protected function patch($uri, array $headers = [], $body = null) |
88
|
|
|
{ |
89
|
|
|
return $this->client->getHttpClient()->patch($uri, $headers, $body); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* delete |
94
|
|
|
* |
95
|
|
|
* @param string $uri |
96
|
|
|
* @param array $headers |
97
|
|
|
* @param string $body |
98
|
|
|
* |
99
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
100
|
|
|
*/ |
101
|
|
|
protected function delete($uri, array $headers = [], $body = null) |
102
|
|
|
{ |
103
|
|
|
return $this->client->getHttpClient()->delete($uri, $headers, $body); |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.