mirror of
https://github.com/grocy/grocy.git
synced 2025-08-15 10:14:39 +00:00
Added /system/time API call (#1223)
* Inital structure for /system/time API call * Parse arguments for offset * Correctly parsing parameters * Fixed implimentation, added to openapi.json * Modified DOC * Added Sqlite3 time to output * Fixed error with negative offset * Review Co-authored-by: Bernd Bestel <bernd@berrnd.de>
This commit is contained in:
@@ -43,6 +43,30 @@ class SystemApiController extends BaseApiController
|
||||
return $this->ApiResponse($response, $this->getApplicationService()->GetSystemInfo());
|
||||
}
|
||||
|
||||
public function GetSystemTime(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
try
|
||||
{
|
||||
$offset = 0;
|
||||
$params = $request->getQueryParams();
|
||||
if (isset($params['offset']))
|
||||
{
|
||||
if (!filter_var($params['offset'], FILTER_VALIDATE_INT))
|
||||
{
|
||||
throw new \Exception('Query parameter "offset" is not a valid integer');
|
||||
}
|
||||
|
||||
$offset = $params['offset'];
|
||||
}
|
||||
|
||||
return $this->ApiResponse($response, $this->getApplicationService()->GetSystemTime($offset));
|
||||
}
|
||||
catch (\Exception $ex)
|
||||
{
|
||||
return $this->GenericErrorResponse($response, $ex->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function LogMissingLocalization(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||
{
|
||||
if (GROCY_MODE === 'dev')
|
||||
|
Reference in New Issue
Block a user