Fix responses. Add routes for promo. #686
This commit is contained in:
parent
5b32349437
commit
ce6b1f8049
4 changed files with 26 additions and 4 deletions
|
|
@ -22,3 +22,9 @@ tapi_battery_list:
|
|||
path: /tapi/vehicles/{vid}/compatible_batteries
|
||||
controller: App\Controller\TAPI\BatteryController::getCompatibleBatteries
|
||||
methods: [GET]
|
||||
|
||||
# promos
|
||||
tapi_promo_list:
|
||||
path: /tapi/promos
|
||||
controller: App\Controller\TAPI\PromoController::listPromos
|
||||
methods: [GET]
|
||||
|
|
|
|||
|
|
@ -80,4 +80,14 @@ class BatteryController extends APIController
|
|||
$message = 'Compatible batteries found.';
|
||||
return new APIResponse(true, $message, $data);
|
||||
}
|
||||
|
||||
// TODO: might have to put this in a common service since JobOrderController also calls this
|
||||
protected function getBatteryImageURL($req, $batt)
|
||||
{
|
||||
// TODO: workaround for now, we get static image of battery based on model name
|
||||
$filename = trim(strtolower($batt->getModel()->getName())) . '_mobile.jpg';
|
||||
$file_path = $req->getSchemeAndHttpHost() . $this->generateUrl('static_battery_image') . '/' . $filename;
|
||||
|
||||
return $file_path;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1471,6 +1471,7 @@ class JobOrderController extends APIController
|
|||
return $selected_rider;
|
||||
}
|
||||
|
||||
// TODO: might have to put this in a common service since BatteryController also calls this
|
||||
protected function getBatteryImageURL($req, $batt)
|
||||
{
|
||||
// TODO: workaround for now, we get static image of battery based on model name
|
||||
|
|
|
|||
|
|
@ -30,11 +30,16 @@ class PromoController extends APIController
|
|||
|
||||
// check required parameters and api key
|
||||
$required_params = [];
|
||||
$res = $this->checkParamsAndKey($req, $em, $required_params);
|
||||
if ($res->isError())
|
||||
return $res->getReturnResponse();
|
||||
$msg = $this->checkRequiredParameters($req, $required_params);
|
||||
if ($msg)
|
||||
return new APIResponse(false, $msg);
|
||||
|
||||
return $res->getReturnResponse();
|
||||
$data = [];
|
||||
// TODO: add call to get promos here
|
||||
|
||||
$message = 'Promos found.';
|
||||
|
||||
return new APIResponse(true, $message, $data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue