|
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 document |
|
16
|
|
|
* |
|
17
|
|
|
* @author VEBER Arnaud <https://github.com/VEBERArnaud> |
|
18
|
|
|
*/ |
|
19
|
|
|
abstract class AbstractDocument implements DocumentInterface |
|
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
|
5 |
|
public function __construct(Client $client) |
|
33
|
|
|
{ |
|
34
|
5 |
|
$this->client = $client; |
|
35
|
5 |
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* get |
|
39
|
|
|
* |
|
40
|
|
|
* @param string $endpoint |
|
41
|
|
|
* |
|
42
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
43
|
|
|
*/ |
|
44
|
12 |
|
protected function get($endpoint) |
|
45
|
|
|
{ |
|
46
|
12 |
|
return $this->client->getHttpClient()->get($endpoint); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* post |
|
51
|
|
|
* |
|
52
|
|
|
* @param string $endpoint |
|
53
|
|
|
* @param array $body |
|
54
|
|
|
* |
|
55
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
56
|
|
|
*/ |
|
57
|
3 |
|
protected function post($endpoint, array $body = []) |
|
58
|
|
|
{ |
|
59
|
3 |
|
return $this->client->getHttpClient()->post( |
|
60
|
|
|
$endpoint, |
|
61
|
3 |
|
['Content-Type' => 'application/json'], |
|
62
|
|
|
json_encode($body) |
|
63
|
|
|
); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* put |
|
68
|
|
|
* |
|
69
|
|
|
* @param string $endpoint |
|
70
|
|
|
* @param array $body |
|
71
|
|
|
* |
|
72
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
73
|
|
|
*/ |
|
74
|
3 |
|
protected function put($endpoint, array $body = []) |
|
75
|
|
|
{ |
|
76
|
3 |
|
return $this->client->getHttpClient()->put( |
|
77
|
|
|
$endpoint, |
|
78
|
3 |
|
['Content-Type' => 'application/json'], |
|
79
|
|
|
json_encode($body) |
|
80
|
|
|
); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* patch |
|
85
|
|
|
* |
|
86
|
|
|
* @param string $endpoint |
|
87
|
|
|
* @param array $body |
|
88
|
|
|
* |
|
89
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
90
|
|
|
*/ |
|
91
|
3 |
|
protected function patch($endpoint, array $body = []) |
|
92
|
|
|
{ |
|
93
|
3 |
|
return $this->client->getHttpClient()->patch( |
|
94
|
|
|
$endpoint, |
|
95
|
3 |
|
['Content-Type' => 'application/json'], |
|
96
|
|
|
json_encode($body) |
|
97
|
|
|
); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
/** |
|
101
|
|
|
* delete |
|
102
|
|
|
* |
|
103
|
|
|
* @param string $endpoint |
|
104
|
|
|
* |
|
105
|
|
|
* @return \Psr\Http\Message\ResponseInterface |
|
106
|
|
|
*/ |
|
107
|
4 |
|
protected function delete($endpoint, array $body = []) |
|
108
|
|
|
{ |
|
109
|
4 |
|
return $this->client->getHttpClient()->delete( |
|
110
|
|
|
$endpoint, |
|
111
|
4 |
|
['Content-Type' => 'application/json'], |
|
112
|
|
|
json_encode($body) |
|
113
|
|
|
); |
|
114
|
|
|
} |
|
115
|
|
|
} |
|
116
|
|
|
|