1 | <?php |
||
13 | class AbstractApi implements ApiInterface |
||
14 | { |
||
15 | /** |
||
16 | * @var Client |
||
17 | */ |
||
18 | protected $client; |
||
19 | |||
20 | /** |
||
21 | * AbstractApi constructor. |
||
22 | * @param Client $client |
||
23 | */ |
||
24 | public function __construct(Client $client) |
||
28 | |||
29 | /** |
||
30 | * @param string $path |
||
31 | * @param array $parameters |
||
32 | * @return ResponseInterface |
||
33 | * @throws \Http\Client\Exception |
||
34 | */ |
||
35 | protected function get(string $path, array $parameters = []): ResponseInterface |
||
39 | |||
40 | /** |
||
41 | * @param string $path |
||
42 | * @param array $parameters |
||
43 | * @return ResponseInterface |
||
44 | */ |
||
45 | protected function post(string $path, array $parameters = []): ResponseInterface |
||
49 | |||
50 | /** |
||
51 | * @param string $path |
||
52 | * @param array $parameters |
||
53 | * @return ResponseInterface |
||
54 | */ |
||
55 | protected function path(string $path, array $parameters = []): ResponseInterface |
||
59 | |||
60 | /** |
||
61 | * @param string $path |
||
62 | * @param array $parameters |
||
63 | * @return ResponseInterface |
||
64 | */ |
||
65 | protected function put(string $path, array $parameters = []): ResponseInterface |
||
69 | |||
70 | /** |
||
71 | * @param string $path |
||
72 | * @param array $parameters |
||
73 | * @return ResponseInterface |
||
74 | */ |
||
75 | protected function delete(string $path, array $parameters = []): ResponseInterface |
||
79 | |||
80 | /** |
||
81 | * @param ResponseInterface $response |
||
82 | * @param DataTransformerInterface $dataTransformer |
||
83 | * @return mixed |
||
84 | */ |
||
85 | protected function getResult(ResponseInterface $response, DataTransformerInterface $dataTransformer) |
||
91 | |||
92 | /** |
||
93 | * @param ResponseInterface $response |
||
94 | * @param DataTransformerInterface $dataTransformer |
||
95 | * @return array |
||
96 | */ |
||
97 | protected function getArrayResult(ResponseInterface $response, DataTransformerInterface $dataTransformer): array |
||
105 | |||
106 | /** |
||
107 | * @param ResponseInterface $response |
||
108 | * @param string $field |
||
109 | * @return string |
||
110 | */ |
||
111 | protected function getSingleResult(ResponseInterface $response, string $field): string |
||
117 | } |
||
118 |