Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| ProjectInterestAction | |
0.00% |
0 / 10 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| __invoke | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Action\SuperAdmin; |
| 6 | |
| 7 | use App\Domain\Exception\BadRequestException; |
| 8 | use App\Domain\SuperAdmin\Service\SuperAdminService; |
| 9 | use App\Renderer\JsonRenderer; |
| 10 | use App\Support\Row; |
| 11 | use Psr\Http\Message\ResponseInterface; |
| 12 | use Psr\Http\Message\ServerRequestInterface; |
| 13 | |
| 14 | /** |
| 15 | * GET /api/super-admin/interest-projection |
| 16 | * |
| 17 | * Returns a daily interest projection for all active accounts |
| 18 | * from today to the requested end date. |
| 19 | */ |
| 20 | final readonly class ProjectInterestAction |
| 21 | { |
| 22 | public function __construct( |
| 23 | private SuperAdminService $superAdminService, |
| 24 | private JsonRenderer $renderer, |
| 25 | ) {} |
| 26 | |
| 27 | public function __invoke( |
| 28 | ServerRequestInterface $request, |
| 29 | ResponseInterface $response, |
| 30 | ): ResponseInterface { |
| 31 | $params = $request->getQueryParams(); |
| 32 | $endDate = Row::nullableString($params, 'endDate'); |
| 33 | |
| 34 | if ($endDate === null) { |
| 35 | throw new BadRequestException('endDate query parameter is required'); |
| 36 | } |
| 37 | |
| 38 | $rows = $this->superAdminService->projectInterest($endDate); |
| 39 | |
| 40 | return $this->renderer->json($response, [ |
| 41 | 'success' => true, |
| 42 | 'data' => $rows, |
| 43 | ]); |
| 44 | } |
| 45 | } |