Add verifyJobOrder API call. #424
This commit is contained in:
parent
cbaf1ed6a6
commit
3abb6f0efb
3 changed files with 48 additions and 0 deletions
|
|
@ -154,3 +154,8 @@ cmb_rapi_cancel_reasons:
|
|||
path: /cmbrapi/cancelreasons
|
||||
controller: App\Controller\CMBRAPIController::getCancelReasons
|
||||
methods: [GET]
|
||||
|
||||
cmb_rapi_jo_verify:
|
||||
path: /cmbrapi/joverify
|
||||
controller: App\Controller\CMBRAPIController::verifyJobOrder
|
||||
methods: [GET]
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ use App\Ramcar\NewAPIResult;
|
|||
use App\Service\RiderAPIHandlerInterface;
|
||||
|
||||
// Rider API controller for CMB
|
||||
// TODO: refactor the other functions to use generateResultFromHandler
|
||||
|
||||
class CMBRAPIController extends Controller
|
||||
{
|
||||
public function register(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
|
|
@ -732,6 +734,15 @@ class CMBRAPIController extends Controller
|
|||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function verifyJobOrder(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$data = $rapi_handler->verifyJobOrder($req);
|
||||
|
||||
$res = $this->generateResultFromHandler($data);
|
||||
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
protected function generateResultFromHandler($data)
|
||||
{
|
||||
$res = new NewAPIResult();
|
||||
|
|
|
|||
|
|
@ -2075,6 +2075,38 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
|||
|
||||
}
|
||||
|
||||
public function verifyJobOrder(Request $req)
|
||||
{
|
||||
$required_params = [
|
||||
'jo_id'
|
||||
];
|
||||
$data = $this->checkJO($req, $required_params, $jo);
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$data['title'] = 'Failed Verify Job Order';
|
||||
return $data;
|
||||
}
|
||||
|
||||
// check if JO status is not fulfilled and not cancelled
|
||||
if (($jo->getStatus() == JOStatus::FULFILLED) ||
|
||||
($jo->getStatus() == JOStatus::CANCELLED))
|
||||
{
|
||||
$data = [
|
||||
'title' => 'Failed Verify Job Order',
|
||||
'error' => 'Job order has been fulfilled or cancelled.'
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
$jo_data = $this->formatJobOrderData($req, $jo);
|
||||
|
||||
$data = [
|
||||
'job_order' => $jo_data
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function checkMissingParameters(Request $req, $params = [])
|
||||
{
|
||||
$missing = [];
|
||||
|
|
|
|||
Loading…
Reference in a new issue