1 | <?php |
||
23 | abstract class AbstractResource implements ResourceInterface |
||
24 | { |
||
25 | /** |
||
26 | * @var ClientInterface |
||
27 | */ |
||
28 | protected $client; |
||
29 | |||
30 | /** |
||
31 | * @var ResponseTransformerInterface |
||
32 | */ |
||
33 | protected $responseTransformer; |
||
34 | |||
35 | /** |
||
36 | * @param ClientInterface $client |
||
37 | * @param ResponseTransformerInterface $responseTransformer |
||
38 | */ |
||
39 | 40 | public function __construct( |
|
46 | |||
47 | /** |
||
48 | * @return array |
||
49 | */ |
||
50 | abstract protected function getResourceMethodConfiguration(); |
||
51 | |||
52 | /** |
||
53 | * @param string $requestMethod |
||
54 | * @param string $resourceMethod |
||
55 | * @param array $params |
||
56 | * @param string|array|null $id |
||
57 | * |
||
58 | * @return mixed |
||
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 | 32 | protected function executeRequest($requestMethod, $resourceMethod, array $params, $id) |
|
90 | |||
91 | /** |
||
92 | * @param string $resourceMethod |
||
93 | * @param string|array|null $id |
||
94 | * |
||
95 | * @return string |
||
96 | * @throws \InvalidArgumentException |
||
97 | */ |
||
98 | 32 | private function prepareRequestPathForResourceMethod($resourceMethod, $id) |
|
128 | |||
129 | /** |
||
130 | * @param string $resourceMethod |
||
131 | * |
||
132 | * @return string |
||
133 | * @throws \InvalidArgumentException |
||
134 | */ |
||
135 | 32 | private function calculateRequestPathFormat($resourceMethod) |
|
144 | |||
145 | /** |
||
146 | * @param mixed $value |
||
147 | * |
||
148 | * @throws \InvalidArgumentException |
||
149 | */ |
||
150 | 2 | private function assertIsNull($value) |
|
156 | |||
157 | /** |
||
158 | * @param mixed $value |
||
159 | * |
||
160 | * @throws \InvalidArgumentException |
||
161 | */ |
||
162 | 30 | private function assertIsValidIdString($value) |
|
168 | |||
169 | /** |
||
170 | * @param mixed $value |
||
171 | * |
||
172 | * @throws \InvalidArgumentException |
||
173 | */ |
||
174 | 2 | private function assertIsValidIdArray($value) |
|
185 | } |
||
186 |