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:
Marc Ole Bulling
2020-12-28 19:39:24 +01:00
committed by GitHub
parent 6fcc0636e8
commit 7e8f460dad
4 changed files with 135 additions and 0 deletions

View File

@@ -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')