Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| SwinvoiceController | |
100.00% |
5 / 5 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| respond | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| async | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | use Psr\Http\Message\ResponseInterface as Response; |
| 6 | use Psr\Http\Message\ServerRequestInterface as Request; |
| 7 | use UppServices\SwinvoiceService; |
| 8 | |
| 9 | /** |
| 10 | * Slim entry for Gekkotech soft-invoice async processing. |
| 11 | * Internal server self-call target (parity with TicketbaiController::async); not a POS API. |
| 12 | */ |
| 13 | class SwinvoiceController |
| 14 | { |
| 15 | public function __construct( |
| 16 | private readonly SwinvoiceService $swinvoiceService, |
| 17 | ) { |
| 18 | } |
| 19 | |
| 20 | private function respond(Response $response, array $result): Response |
| 21 | { |
| 22 | $response->getBody()->write($result['output']); |
| 23 | return $response->withHeader('Content-Type', $result['contentType']); |
| 24 | } |
| 25 | |
| 26 | /** POST /swinvoice/async — LocalUrl fire-and-forget from LicenseConfirm (not POS). */ |
| 27 | public function async(Request $request, Response $response): Response |
| 28 | { |
| 29 | $rawBody = (string) $request->getBody(); |
| 30 | return $this->respond($response, $this->swinvoiceService->async($rawBody)); |
| 31 | } |
| 32 | } |