49 lines
1.4 KiB
PHP
49 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Controller\CustomerAppAPI;
|
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
use Catalyst\ApiBundle\Component\Response as ApiResponse;
|
|
|
|
class AppController extends ApiController
|
|
{
|
|
public function versionCheck(Request $req)
|
|
{
|
|
// validate params
|
|
$missing = $this->hasMissingParams($req, [
|
|
'version',
|
|
]);
|
|
|
|
if ($missing) {
|
|
return new ApiResponse(false, $missing);
|
|
}
|
|
|
|
$need_update = false;
|
|
$msg = 'Version is up to date.';
|
|
|
|
$api_version = $this->getParameter('api_version');
|
|
|
|
$app_version = $req->query->get('version');
|
|
// putting this in for the future, in case we have diverging versions
|
|
$os = $req->query->get('os');
|
|
$platform = $req->query->get('platform');
|
|
|
|
$api_v = explode('.', $api_version);
|
|
$app_v = explode('.', $app_version);
|
|
|
|
if ($api_v[0] < $app_v[0]) {
|
|
return new ApiResponse(false, 'Invalid application version: ' . $app_version);
|
|
}
|
|
|
|
if ($api_v[0] > $app_v[0]) {
|
|
$need_update = true;
|
|
$msg = 'Your version is outdated and needs an update to use the latest features RES-Q has to offer.';
|
|
}
|
|
|
|
// response
|
|
return new ApiResponse(true, '', [
|
|
'need_update' => $need_update,
|
|
'message' => $msg,
|
|
]);
|
|
}
|
|
}
|