Merge branch '392-resq-new-api-calls-for-version-check-and-display-order-screen' into 'master'
Resolve "Resq - new API calls for version check and display order screen" Closes #392 See merge request jankstudio/resq!436
This commit is contained in:
commit
6ecc1166e3
5 changed files with 115 additions and 15 deletions
|
|
@ -71,3 +71,6 @@ API_LOGGING=set_to_true_or_false
|
||||||
CUST_DISTANCE_LIMIT=set_to_number
|
CUST_DISTANCE_LIMIT=set_to_number
|
||||||
|
|
||||||
MAPTILER_API_KEY=map_tiler_api_key
|
MAPTILER_API_KEY=map_tiler_api_key
|
||||||
|
|
||||||
|
# API version
|
||||||
|
API_VERSION=insert_api_version_here
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ parameters:
|
||||||
app_access_key: 'access_keys'
|
app_access_key: 'access_keys'
|
||||||
cvu_brand_id: "%env(CVU_BRAND_ID)%"
|
cvu_brand_id: "%env(CVU_BRAND_ID)%"
|
||||||
country_code: "%env(COUNTRY_CODE)%"
|
country_code: "%env(COUNTRY_CODE)%"
|
||||||
|
api_version: "%env(API_VERSION)%"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# default configuration for services in *this* file
|
# default configuration for services in *this* file
|
||||||
|
|
|
||||||
|
|
@ -159,3 +159,13 @@ api_new_jo_request:
|
||||||
path: /api/new_job_order
|
path: /api/new_job_order
|
||||||
controller: App\Controller\APIController::newRequestJobOrder
|
controller: App\Controller\APIController::newRequestJobOrder
|
||||||
methods: [POST]
|
methods: [POST]
|
||||||
|
|
||||||
|
api_version_check:
|
||||||
|
path: /api/version_check
|
||||||
|
controller: App\Controller\APIController::versionCheck
|
||||||
|
methods: [GET]
|
||||||
|
|
||||||
|
api_schedule_option_status:
|
||||||
|
path: /api/schedule_option_status
|
||||||
|
controller: App\Controller\APIController::scheduleOptionStatus
|
||||||
|
methods: [GET]
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ parameters:
|
||||||
app_access_key: 'access_keys'
|
app_access_key: 'access_keys'
|
||||||
cvu_brand_id: "%env(CVU_BRAND_ID)%"
|
cvu_brand_id: "%env(CVU_BRAND_ID)%"
|
||||||
country_code: "%env(COUNTRY_CODE)%"
|
country_code: "%env(COUNTRY_CODE)%"
|
||||||
|
api_version: "%env(API_VERSION)%"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# default configuration for services in *this* file
|
# default configuration for services in *this* file
|
||||||
|
|
|
||||||
|
|
@ -2642,6 +2642,87 @@ class APIController extends Controller implements LoggedController
|
||||||
return $res->getReturnResponse();
|
return $res->getReturnResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function versionCheck(Request $req)
|
||||||
|
{
|
||||||
|
$res = new APIResult();
|
||||||
|
|
||||||
|
$required_params = [
|
||||||
|
'version',
|
||||||
|
];
|
||||||
|
|
||||||
|
$missing = $this->checkMissingParameters($req, $required_params);
|
||||||
|
if (count($missing) > 0)
|
||||||
|
{
|
||||||
|
$params = implode(', ', $missing);
|
||||||
|
$res->setError(true)
|
||||||
|
->setErrorMessage('Missing parameter(s): ' . $params);
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
$need_update = false;
|
||||||
|
|
||||||
|
$api_version = $this->getParameter('api_version');
|
||||||
|
|
||||||
|
$app_version = $req->query->get('version');
|
||||||
|
|
||||||
|
$api_v = explode('.', $api_version);
|
||||||
|
$app_v = explode('.', $app_version);
|
||||||
|
|
||||||
|
if ($api_v[0] < $app_v[0])
|
||||||
|
{
|
||||||
|
$res->setError(true)
|
||||||
|
->setErrorMessage('Invalid application version: ' . $app_version);
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($api_v[0] > $app_v[0])
|
||||||
|
$need_update = true;
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'need_update' => $need_update,
|
||||||
|
];
|
||||||
|
|
||||||
|
$res->setData($data);
|
||||||
|
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scheduleOptionStatus(Request $req)
|
||||||
|
{
|
||||||
|
// check required parameters and api key
|
||||||
|
$required_params = [];
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
$res = $this->checkParamsAndKey($req, $em, $required_params);
|
||||||
|
if ($res->isError())
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
|
||||||
|
// TODO: end of ECQ, have this return true
|
||||||
|
$schedule_choice = true;
|
||||||
|
|
||||||
|
// TODO: remove the time check after ECQ
|
||||||
|
// get current time
|
||||||
|
$current_time = time();
|
||||||
|
$start_advance_order_time = strtotime('17:00');
|
||||||
|
$end_advance_order_time = strtotime('08:00');
|
||||||
|
//$start_advance_order_time = strtotime('08:00');
|
||||||
|
//$end_advance_order_time = strtotime('17:00');
|
||||||
|
|
||||||
|
error_log(date('Y-m-d H:i:s', $current_time));
|
||||||
|
error_log(date('Y-m-d H:i:s', $start_advance_order_time));
|
||||||
|
error_log(date('Y-m-d H:i:s', $end_advance_order_time));
|
||||||
|
|
||||||
|
if (($current_time > $start_advance_order_time) &&
|
||||||
|
($current_time < $end_advance_order_time))
|
||||||
|
$schedule_choice = false;
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'display_schedule_choice' => $schedule_choice,
|
||||||
|
];
|
||||||
|
$res->setData($data);
|
||||||
|
|
||||||
|
return $res->getReturnResponse();
|
||||||
|
}
|
||||||
|
|
||||||
protected function findCustomerByNumber($number)
|
protected function findCustomerByNumber($number)
|
||||||
{
|
{
|
||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
@ -2843,6 +2924,7 @@ class APIController extends Controller implements LoggedController
|
||||||
{
|
{
|
||||||
// get the nearest 10 hubs
|
// get the nearest 10 hubs
|
||||||
$hub_data = [];
|
$hub_data = [];
|
||||||
|
$nearest_hubs_with_distance = [];
|
||||||
$hubs = $map_tools->getClosestOpenHubs($coordinates, 10);
|
$hubs = $map_tools->getClosestOpenHubs($coordinates, 10);
|
||||||
|
|
||||||
foreach ($hubs as $hub)
|
foreach ($hubs as $hub)
|
||||||
|
|
@ -2854,26 +2936,29 @@ class APIController extends Controller implements LoggedController
|
||||||
$nearest = null;
|
$nearest = null;
|
||||||
$slot_found = false;
|
$slot_found = false;
|
||||||
// find the nearest hub
|
// find the nearest hub
|
||||||
foreach ($nearest_hubs_with_distance as $nhd)
|
if (!empty($nearest_hubs_with_distance))
|
||||||
{
|
{
|
||||||
if (empty($nearest))
|
foreach ($nearest_hubs_with_distance as $nhd)
|
||||||
$nearest = $nhd;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if ($nhd['distance'] < $nearest['distance'])
|
if (empty($nearest))
|
||||||
$nearest = $nhd;
|
$nearest = $nhd;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($nhd['distance'] < $nearest['distance'])
|
||||||
|
$nearest = $nhd;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// get slots of nearest hub
|
// get slots of nearest hub
|
||||||
if ($nearest != null)
|
if ($nearest != null)
|
||||||
{
|
{
|
||||||
$hub_slots = $this->getHubRiderSlots($nearest['hub'], $em);
|
$hub_slots = $this->getHubRiderSlots($nearest['hub'], $em);
|
||||||
|
|
||||||
$hub_data = [
|
$hub_data = [
|
||||||
'hub' => $nearest['hub'],
|
'hub' => $nearest['hub'],
|
||||||
'slots' => $hub_slots,
|
'slots' => $hub_slots,
|
||||||
];
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $hub_data;
|
return $hub_data;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue