Add /guest/departments endpoint for paginated department retrieval

- Introduced `GET /guest/departments` in `guestRoute` to fetch departments with pagination.
- Limited response to include only `id` and `name` fields for streamlined output.
This commit is contained in:
Jeppe Bundgaard
2025-11-20 13:13:16 +01:00
parent b4f208d30d
commit 6d49befd22
+13
View File
@@ -5,6 +5,7 @@ namespace routes;
use classes\authentication;
use classes\recaptcha;
use classes\virkdata;
use objects\departments_o;
use objects\logs_o;
use objects\tokens_o;
use objects\users_o;
@@ -47,5 +48,17 @@ class guestRoute
}, [
'cvr_search' => 'Search CVR numbers'
]);
$this->get('/guest/departments', function () {
global $response;
$departments = (new departments_o());
$response->success($departments->listObjectsWithPaginationIfSet(function ($department_array) {
// Only return id and name
return [
'id' => $department_array['id'],
'name' => $department_array['name']
];
}), 200);
});
}
}