MobileV1.php
54 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AmeliaBooking\Infrastructure\Routes\Mobile; |
| 4 | |
| 5 | use AmeliaBooking\Application\Controller\Mobile\Appointments\GetAppointmentMobileController; |
| 6 | use AmeliaBooking\Application\Controller\Mobile\Appointments\GetAppointmentsMobileController; |
| 7 | use AmeliaBooking\Application\Controller\Mobile\Appointments\UpdateAppointmentStatusMobileController; |
| 8 | use AmeliaBooking\Application\Controller\Mobile\Events\GetEventMobileController; |
| 9 | use AmeliaBooking\Application\Controller\Mobile\Events\GetEventsMobileController; |
| 10 | use AmeliaBooking\Application\Controller\Mobile\Events\ScanEventTicketMobileController; |
| 11 | use AmeliaBooking\Application\Controller\Mobile\GetMobileInfoController; |
| 12 | use Slim\App; |
| 13 | |
| 14 | /** |
| 15 | * Dedicated routes for the Amelia Staff mobile app. |
| 16 | * |
| 17 | * These routes always run in cabinet-provider context — the `source` param is |
| 18 | * never read from the client. A Bearer JWT is required; requests without one |
| 19 | * receive a 409 `{data: {reauthorize: true}}` response, the same shape as an |
| 20 | * expired-session error, so the app drives the user back to login. Both are |
| 21 | * enforced by MobileV1Controller, which every controller below extends. |
| 22 | * |
| 23 | * Versioned under /mobile/v1/ so the contract can evolve independently of the |
| 24 | * shared web-cabinet routes (/appointments, /events) without breaking either. |
| 25 | */ |
| 26 | class MobileV1 |
| 27 | { |
| 28 | /** |
| 29 | * @param App $app |
| 30 | * |
| 31 | * @throws \InvalidArgumentException |
| 32 | */ |
| 33 | public static function routes(App $app) |
| 34 | { |
| 35 | // Version-negotiation handshake. Intentionally UNVERSIONED and |
| 36 | // UNAUTHENTICATED (no Bearer token) — it is the contract the app uses to |
| 37 | // detect version skew, so it must never change shape or require auth. |
| 38 | // Must ship in the same release as the /mobile/v1/* routes below. |
| 39 | $app->get('/mobile/info', GetMobileInfoController::class); |
| 40 | |
| 41 | $app->get('/mobile/v1/appointments', GetAppointmentsMobileController::class); |
| 42 | |
| 43 | $app->get('/mobile/v1/appointments/{id:[0-9]+}', GetAppointmentMobileController::class); |
| 44 | |
| 45 | $app->post('/mobile/v1/appointments/status/{id:[0-9]+}', UpdateAppointmentStatusMobileController::class); |
| 46 | |
| 47 | $app->get('/mobile/v1/events', GetEventsMobileController::class); |
| 48 | |
| 49 | $app->get('/mobile/v1/events/{id:[0-9]+}', GetEventMobileController::class); |
| 50 | |
| 51 | $app->post('/mobile/v1/events/scan', ScanEventTicketMobileController::class); |
| 52 | } |
| 53 | } |
| 54 |