1 | <?php |
||
24 | abstract class AbstractResource implements ResourceInterface |
||
25 | { |
||
26 | /** |
||
27 | * @var ClientInterface |
||
28 | */ |
||
29 | protected $client; |
||
30 | |||
31 | /** |
||
32 | * @var ResponseTransformerInterface |
||
33 | */ |
||
34 | protected $responseTransformer; |
||
35 | |||
36 | /** |
||
37 | * @param ClientInterface $client |
||
38 | * @param ResponseTransformerInterface $responseTransformer |
||
39 | */ |
||
40 | 40 | public function __construct( |
|
47 | |||
48 | /** |
||
49 | * @return array |
||
50 | */ |
||
51 | abstract protected function getResourceMethodConfiguration(); |
||
52 | |||
53 | /** |
||
54 | * @param string $requestMethod |
||
55 | * @param string $resourceMethod |
||
56 | * @param array $params |
||
57 | * @param string|array|null $id |
||
58 | * |
||
59 | * @throws \RuntimeException |
||
60 | * @throws \LogicException |
||
61 | * @throws \Exception |
||
62 | * @throws \InvalidArgumentException |
||
63 | * @throws \Zibios\WrikePhpLibrary\Exception\Api\ApiException |
||
64 | * @throws \Zibios\WrikePhpLibrary\Exception\Api\AccessForbiddenException |
||
65 | * @throws \Zibios\WrikePhpLibrary\Exception\Api\InvalidParameterException |
||
66 | * @throws \Zibios\WrikePhpLibrary\Exception\Api\InvalidRequestException |
||
67 | * @throws \Zibios\WrikePhpLibrary\Exception\Api\NotAllowedException |
||
68 | * @throws \Zibios\WrikePhpLibrary\Exception\Api\NotAuthorizedException |
||
69 | * @throws \Zibios\WrikePhpLibrary\Exception\Api\ParameterRequiredException |
||
70 | * @throws \Zibios\WrikePhpLibrary\Exception\Api\ResourceNotFoundException |
||
71 | * @throws \Zibios\WrikePhpLibrary\Exception\Api\ServerErrorException |
||
72 | * |
||
73 | * @return mixed |
||
74 | */ |
||
75 | 32 | protected function executeRequest($requestMethod, $resourceMethod, array $params, $id) |
|
92 | |||
93 | /** |
||
94 | * @param string $resourceMethod |
||
95 | * @param string|array|null $id |
||
96 | * |
||
97 | * @throws \InvalidArgumentException |
||
98 | * |
||
99 | * @return string |
||
100 | */ |
||
101 | 32 | private function prepareRequestPathForResourceMethod($resourceMethod, $id) |
|
131 | |||
132 | /** |
||
133 | * @param string $resourceMethod |
||
134 | * |
||
135 | * @throws \InvalidArgumentException |
||
136 | * |
||
137 | * @return string |
||
138 | */ |
||
139 | 32 | private function calculateRequestPathFormat($resourceMethod) |
|
148 | |||
149 | /** |
||
150 | * @param mixed $value |
||
151 | * |
||
152 | * @throws \InvalidArgumentException |
||
153 | */ |
||
154 | 2 | private function assertIsNull($value) |
|
160 | |||
161 | /** |
||
162 | * @param mixed $value |
||
163 | * |
||
164 | * @throws \InvalidArgumentException |
||
165 | */ |
||
166 | 30 | private function assertIsValidIdString($value) |
|
172 | |||
173 | /** |
||
174 | * @param mixed $value |
||
175 | * |
||
176 | * @throws \InvalidArgumentException |
||
177 | */ |
||
178 | 2 | private function assertIsValidIdArray($value) |
|
189 | } |
||
190 |