1 | <?php |
||
23 | class GenericApi implements ApiInterface |
||
24 | { |
||
25 | /** |
||
26 | * @var ClientInterface $client |
||
27 | */ |
||
28 | private $client; |
||
29 | /** |
||
30 | * @var string $uri |
||
31 | */ |
||
32 | private $uri; |
||
33 | /** |
||
34 | * @var PaginatorFactoryInterface $paginatorFactory |
||
35 | */ |
||
36 | private $paginatorFactory; |
||
37 | |||
38 | /** |
||
39 | * @var AdapterFactoryInterface $apiAdapterFactory |
||
40 | */ |
||
41 | private $apiAdapterFactory; |
||
42 | |||
43 | /** |
||
44 | * @param ClientInterface $client |
||
45 | * @param string $uri |
||
46 | * @param null|AdapterFactoryInterface $apiAdapterFactory |
||
47 | * @param null|PaginatorFactoryInterface $paginatorFactory |
||
48 | * @throws \InvalidArgumentException |
||
49 | */ |
||
50 | public function __construct(ClientInterface $client, $uri, AdapterFactoryInterface $apiAdapterFactory = null, PaginatorFactoryInterface $paginatorFactory = null) |
||
57 | |||
58 | /** |
||
59 | * @param string $uri |
||
60 | * @throws \InvalidArgumentException |
||
61 | */ |
||
62 | private function setUri($uri) |
||
72 | |||
73 | /** |
||
74 | * @param array $uriParameters |
||
75 | * @return string |
||
76 | */ |
||
77 | protected function getUri(array $uriParameters = []) |
||
86 | |||
87 | /** |
||
88 | * {@inheritdoc } |
||
89 | */ |
||
90 | public function get($id, array $uriParameters = []) |
||
96 | |||
97 | /** |
||
98 | * {@inheritdoc } |
||
99 | */ |
||
100 | public function getAll(array $queryParameters = [], array $uriParameters = []) |
||
112 | |||
113 | /** |
||
114 | * {@inheritdoc } |
||
115 | */ |
||
116 | public function getPaginated(array $queryParameters = [], array $uriParameters = []) |
||
125 | |||
126 | /** |
||
127 | * {@inheritdoc } |
||
128 | */ |
||
129 | public function createPaginator(array $queryParameters = [], array $uriParameters = []) |
||
134 | |||
135 | /** |
||
136 | * {@inheritdoc } |
||
137 | */ |
||
138 | public function create(array $body, array $uriParameters = [], array $files = []) |
||
144 | |||
145 | /** |
||
146 | * {@inheritdoc } |
||
147 | */ |
||
148 | public function update($id, array $body, array $uriParameters = [], array $files = []) |
||
159 | |||
160 | /** |
||
161 | * {@inheritdoc } |
||
162 | */ |
||
163 | public function delete($id, array $uriParameters = []) |
||
169 | |||
170 | protected function responseToArray(ResponseInterface $response) |
||
179 | |||
180 | protected function getClient() |
||
184 | } |
||
185 |