Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
1 / 1 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** @license For full copyright and license information, please see the LICENSE.md file. */ |
| 6 | |
| 7 | namespace App\Core\Api; |
| 8 | |
| 9 | defined('AMMONLY_APP') || exit('Direct script access is forbidden.'); |
| 10 | |
| 11 | use Psr\Http\Message\ResponseInterface; |
| 12 | use Psr\Http\Message\ServerRequestInterface; |
| 13 | |
| 14 | /** |
| 15 | * REST API Client Contract. |
| 16 | * |
| 17 | * Defines standard interface for internal and external REST API consumers. |
| 18 | * |
| 19 | * @package App\Core\Api |
| 20 | */ |
| 21 | interface ApiClientInterface |
| 22 | { |
| 23 | /** |
| 24 | * Executes GET request to REST API endpoint with optional memoization cache. |
| 25 | * |
| 26 | * @param string $path API endpoint path (e.g. '/api/v1/translations/app'). |
| 27 | * @param array<string, mixed> $queryParams Query string parameters. |
| 28 | * @param bool $useCache Whether to cache response payload. |
| 29 | * @return array<string, mixed> Decoded JSON payload array. |
| 30 | */ |
| 31 | public function get(string $path, array $queryParams = [], bool $useCache = true): array; |
| 32 | |
| 33 | /** |
| 34 | * Executes POST request to REST API endpoint. |
| 35 | * |
| 36 | * @param string $path API endpoint path. |
| 37 | * @param array<string, mixed> $body JSON payload data. |
| 38 | * @return array<string, mixed> Decoded JSON response array. |
| 39 | */ |
| 40 | public function post(string $path, array $body = []): array; |
| 41 | |
| 42 | /** |
| 43 | * Executes PUT request to REST API endpoint. |
| 44 | * |
| 45 | * @param string $path API endpoint path. |
| 46 | * @param array<string, mixed> $body JSON payload data. |
| 47 | * @return array<string, mixed> Decoded JSON response array. |
| 48 | */ |
| 49 | public function put(string $path, array $body = []): array; |
| 50 | |
| 51 | /** |
| 52 | * Executes DELETE request to REST API endpoint. |
| 53 | * |
| 54 | * @param string $path API endpoint path. |
| 55 | * @param array<string, mixed> $body Optional JSON payload data. |
| 56 | * @return array<string, mixed> Decoded JSON response array. |
| 57 | */ |
| 58 | public function delete(string $path, array $body = []): array; |
| 59 | |
| 60 | /** |
| 61 | * Sends raw PSR-7 request through client pipeline. |
| 62 | * |
| 63 | * @param ServerRequestInterface $request PSR-7 Server request. |
| 64 | * @return ResponseInterface PSR-7 response. |
| 65 | */ |
| 66 | public function send(ServerRequestInterface $request): ResponseInterface; |
| 67 | } |