Add MotorAPI integration and Economic products support

Implemented MotorAPI lookup functionality with proper validation and logging. Added Economic products endpoint for fetching product details. Enhanced route parameter validation with length constraints and improved response handling for objects.
This commit is contained in:
Jepp9350
2025-02-18 12:34:26 +01:00
parent 5af6fc5aa5
commit 8702b41777
11 changed files with 585 additions and 29 deletions
+30 -12
View File
@@ -43,18 +43,6 @@ trait route_t
return 'integer';
}
/**
* Get the parameter from the request by name
* This is a shorthand for the response class method
* @param string $parameter
* @return mixed|null
*/
public function getParameter(string $parameter): mixed
{
global $response;
return $response->getRequestParameter($parameter);
}
public function requireParameters(array $parameters): void
{
global $response;
@@ -70,6 +58,36 @@ trait route_t
}
}
public function requireMinLength(string $parameter, int $length): void
{
global $response;
$value = self::getParameter($parameter);
if (strlen($value) < $length) {
$response->error('Parameter ' . $parameter . ' must be at least ' . $length . ' characters long', 400);
}
}
/**
* Get the parameter from the request by name
* This is a shorthand for the response class method
* @param string $parameter
* @return mixed|null
*/
public function getParameter(string $parameter): mixed
{
global $response;
return $response->getRequestParameter($parameter);
}
public function requireMaxLength(string $parameter, int $length): void
{
global $response;
$value = self::getParameter($parameter);
if (strlen($value) > $length) {
$response->error('Parameter ' . $parameter . ' must be at most ' . $length . ' characters long', 400);
}
}
public function isParametersSet(array $parameters): bool
{
global $response;