Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 16 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| GetAdminBalanceHistoryAction | |
0.00% |
0 / 16 |
|
0.00% |
0 / 2 |
30 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| __invoke | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
20 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Action\Admin; |
| 6 | |
| 7 | use App\Domain\Admin\Service\AdminBalanceUpdateService; |
| 8 | use App\Renderer\JsonRenderer; |
| 9 | use InvalidArgumentException; |
| 10 | use Psr\Http\Message\ResponseInterface; |
| 11 | use Psr\Http\Message\ServerRequestInterface; |
| 12 | |
| 13 | final readonly class GetAdminBalanceHistoryAction |
| 14 | { |
| 15 | public function __construct( |
| 16 | private JsonRenderer $renderer, |
| 17 | private AdminBalanceUpdateService $balanceUpdateService, |
| 18 | ) {} |
| 19 | |
| 20 | /** |
| 21 | * @param ServerRequestInterface $request |
| 22 | * @param ResponseInterface $response |
| 23 | * @param array<string, string> $args |
| 24 | * @return ResponseInterface |
| 25 | */ |
| 26 | public function __invoke( |
| 27 | ServerRequestInterface $request, |
| 28 | ResponseInterface $response, |
| 29 | array $args, |
| 30 | ): ResponseInterface { |
| 31 | $userId = (int)$args['userId']; |
| 32 | $queryParams = $request->getQueryParams(); |
| 33 | |
| 34 | $fundId = $queryParams['fundId'] ?? null; |
| 35 | $limit = isset($queryParams['limit']) ? (int)$queryParams['limit'] : 50; |
| 36 | |
| 37 | if ($limit < 1 || $limit > 100) { |
| 38 | $limit = 50; |
| 39 | } |
| 40 | |
| 41 | $history = $this->balanceUpdateService->getAdjustmentHistory( |
| 42 | userId: $userId, |
| 43 | fundId: $fundId, |
| 44 | limit: $limit, |
| 45 | ); |
| 46 | |
| 47 | return $this->renderer->json($response, [ |
| 48 | 'success' => true, |
| 49 | 'data' => $history, |
| 50 | ]); |
| 51 | } |
| 52 | } |