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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user