1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* IClient.php |
4
|
|
|
* |
5
|
|
|
* @copyright More in license.md |
6
|
|
|
* @license https://www.ipublikuj.eu |
7
|
|
|
* @author Adam Kadlec <[email protected]> |
8
|
|
|
* @package iPublikuj:JsonAPIClient! |
9
|
|
|
* @subpackage Clients |
10
|
|
|
* @since 1.0.0 |
11
|
|
|
* |
12
|
|
|
* @date 05.05.18 |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
declare(strict_types = 1); |
16
|
|
|
|
17
|
|
|
namespace IPub\JsonAPIClient\Clients; |
18
|
|
|
|
19
|
|
|
use Neomerx\JsonApi\Contracts\Encoder\Parameters\EncodingParametersInterface; |
20
|
|
|
use Neomerx\JsonApi\Exceptions\JsonApiException; |
21
|
|
|
|
22
|
|
|
use IPub\JsonAPIClient\Http; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* HTTP client interface |
26
|
|
|
* |
27
|
|
|
* @package iPublikuj:JsonAPIClient! |
28
|
|
|
* @subpackage Clients |
29
|
|
|
* |
30
|
|
|
* @author Adam Kadlec <[email protected]> |
31
|
|
|
*/ |
32
|
1 |
|
interface IClient |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* @param string $endpoint |
36
|
|
|
* @param EncodingParametersInterface|NULL $parameters the parameters to send to the remote server |
37
|
|
|
* @param array $options |
38
|
|
|
* |
39
|
|
|
* @return Http\IResponse |
40
|
|
|
* |
41
|
|
|
* @throws JsonApiException if the remote server replies with an error |
42
|
|
|
*/ |
43
|
|
|
public function index(string $endpoint, EncodingParametersInterface $parameters = NULL, array $options = []) : Http\IResponse; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Read the domain record from the remote JSON API. |
47
|
|
|
* |
48
|
|
|
* @param string $endpoint |
49
|
|
|
* @param EncodingParametersInterface|NULL $parameters the parameters to send to the remote server |
50
|
|
|
* @param array $options |
51
|
|
|
* |
52
|
|
|
* @return Http\IResponse |
53
|
|
|
* |
54
|
|
|
* @throws JsonApiException if the remote server replies with an error |
55
|
|
|
*/ |
56
|
|
|
public function read(string $endpoint, EncodingParametersInterface $parameters = NULL, array $options = []) : Http\IResponse; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param string $endpoint |
60
|
|
|
* @param mixed $record |
61
|
|
|
* @param EncodingParametersInterface|NULL $parameters the parameters to send to the remote server |
62
|
|
|
* @param array $options |
63
|
|
|
* |
64
|
|
|
* @return Http\IResponse |
65
|
|
|
* |
66
|
|
|
* @throws JsonApiException if the remote server replies with an error |
67
|
|
|
*/ |
68
|
|
|
public function create(string $endpoint, $record, EncodingParametersInterface $parameters = NULL, array $options = []) : Http\IResponse; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @param string $endpoint |
72
|
|
|
* @param mixed $record |
73
|
|
|
* @param string[]|NULL $fields the resource fields to send, if sending sparse field-sets |
74
|
|
|
* @param EncodingParametersInterface|NULL $parameters the parameters to send to the remote server |
75
|
|
|
* @param array $options |
76
|
|
|
* |
77
|
|
|
* @return Http\IResponse |
78
|
|
|
* |
79
|
|
|
* @throws JsonApiException if the remote server replies with an error |
80
|
|
|
*/ |
81
|
|
|
public function update(string $endpoint, $record, array $fields = NULL, EncodingParametersInterface $parameters = NULL, array $options = []) : Http\IResponse; |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @param string $endpoint |
85
|
|
|
* @param array $options |
86
|
|
|
* |
87
|
|
|
* @return Http\IResponse |
88
|
|
|
* |
89
|
|
|
* @throws JsonApiException if the remote server replies with an error |
90
|
|
|
*/ |
91
|
|
|
public function delete(string $endpoint, array $options = []) : Http\IResponse; |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @param string $key |
95
|
|
|
* |
96
|
|
|
* @return void |
97
|
|
|
*/ |
98
|
|
|
public function addApiKey(string $key) : void; |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @param string $token |
102
|
|
|
* |
103
|
|
|
* @return void |
104
|
|
|
*/ |
105
|
|
|
public function addAuthorization(string $token) : void; |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @return void |
109
|
|
|
*/ |
110
|
|
|
public function removeAuthorization() : void; |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @param string $header |
114
|
|
|
* @param string $value |
115
|
|
|
* |
116
|
|
|
* @return void |
117
|
|
|
*/ |
118
|
|
|
public function addHeader(string $header, string $value) : void; |
119
|
|
|
} |
120
|
|
|
|