Add xlvask module API integration

Introduced xlvask module with request handling, endpoints, and route mappings. Implemented functionalities to fetch usage logs, vehicles, and customers from the API, along with basic authentication support. Includes error handling and configuration setup for seamless integration.
This commit is contained in:
Jepp9350
2025-05-08 14:03:13 +02:00
parent 5550e2e57f
commit 023b6992b6
8 changed files with 428 additions and 1 deletions
@@ -0,0 +1,99 @@
<?php
namespace routes;
use classes\response;
use classes\router;
use classes\xlvask;
use traits\route_t;
class moduleXLVaskRoute
{
use route_t;
public function run(): void
{
global /** @var response $response */
/** @var router $router */
$router, $response;
$this->get('/modules/xlvask/usageLog', function () {
global $response;
self::requirePermission('modules_xlvask_usageLog');
$params = [
'dateFrom' => null,
'regNr' => null,
'vehicleId' => null,
'customerId' => null,
];
// Get the parameters from the request
foreach ( $params as $key => $value ) {
if ($this->isParametersSet([$key])) {
$params[$key] = $this->getParameter($key);
}
}
// Create the xlvask object
$xlvask = new xlvask();
$result = $xlvask->getUsageLog(...$params);
// Response
$response->success($result, 200);
},
[
'modules_xlvask_usageLog' => 'Get the usage log of the xlvask module'
]
);
$this->get('/modules/xlvask/vehicles', function () {
global $response;
self::requirePermission('modules_xlvask_vehicles');
$params = [
'customerId' => null,
'vehicleId' => null,
'registrationNumber' => null,
'changeDate' => null,
];
// Get the parameters from the request
foreach ( $params as $key => $value ) {
if ($this->isParametersSet([$key])) {
$params[$key] = $this->getParameter($key);
}
}
// Create the xlvask object
$xlvask = new xlvask();
$result = $xlvask->getVehicles(...$params);
// Response
$response->success($result, 200);
},
[
'modules_xlvask_vehicles' => 'Get the vehicles of the xlvask module'
]
);
$this->get('/modules/xlvask/customers', function () {
global $response;
self::requirePermission('modules_xlvask_customers');
$params = [
'customerId' => null,
'customerName' => null,
'customerExternalId' => null,
'vatNumber' => null,
'changeDate' => null,
'users' => null,
];
// Get the parameters from the request
foreach ( $params as $key => $value ) {
if ($this->isParametersSet([$key])) {
$params[$key] = $this->getParameter($key);
}
}
// Create the xlvask object
$xlvask = new xlvask();
$result = $xlvask->getCustomers(...$params);
// Response
$response->success($result, 200);
},
[
'modules_xlvask_customers' => 'Get the customers of the xlvask module'
]
);
}
}