Move the hubArrive function to the service. #311
This commit is contained in:
parent
bf3136da62
commit
aa1a2b3bcb
4 changed files with 61 additions and 15 deletions
|
|
@ -336,27 +336,25 @@ class RAPIController extends Controller
|
|||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function hubArrive(Request $req)
|
||||
public function hubArrive(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||
{
|
||||
$required_params = [];
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$res = $this->checkParamsAndKey($req, $em, $required_params);
|
||||
if ($res->isError())
|
||||
return $res->getReturnResponse();
|
||||
$res = new APIResult();
|
||||
|
||||
// are we logged in?
|
||||
if (!$this->session->hasRider())
|
||||
$data = $rapi_handler->hubArrive($req);
|
||||
|
||||
if (isset($data['error']))
|
||||
{
|
||||
$message = $data['error'];
|
||||
|
||||
$res->setError(true)
|
||||
->setErrorMessage('No logged in rider.');
|
||||
return $res->getReturnResponse();
|
||||
->setErrorMessage($message);
|
||||
}
|
||||
else
|
||||
{
|
||||
$res->setData($data);
|
||||
}
|
||||
|
||||
// TODO: tag rider as available
|
||||
|
||||
$em->flush();
|
||||
|
||||
|
||||
// response
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -449,6 +449,29 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
|||
return $data;
|
||||
}
|
||||
|
||||
public function hubArrive(Request $req)
|
||||
{
|
||||
$required_params = [];
|
||||
$data = $this->checkParamsAndKey($req, $required_params);
|
||||
if (isset($data['error']))
|
||||
return $data;
|
||||
|
||||
// are we logged in?
|
||||
if (!$this->session->hasRider())
|
||||
{
|
||||
$data = [
|
||||
'error' => 'No logged in rider.'
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
// TODO: tag rider as available
|
||||
|
||||
$this->em->flush();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function checkMissingParameters(Request $req, $params = [])
|
||||
{
|
||||
$missing = [];
|
||||
|
|
|
|||
|
|
@ -446,6 +446,29 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface
|
|||
return $data;
|
||||
}
|
||||
|
||||
public function hubArrive(Request $req)
|
||||
{
|
||||
$required_params = [];
|
||||
$data = $this->checkParamsAndKey($req, $required_params);
|
||||
if (isset($data['error']))
|
||||
return $data;
|
||||
|
||||
// are we logged in?
|
||||
if (!$this->session->hasRider())
|
||||
{
|
||||
$data = [
|
||||
'error' => 'No logged in rider.'
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
// TODO: tag rider as available
|
||||
|
||||
$this->em->flush();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function checkMissingParameters(Request $req, $params = [])
|
||||
{
|
||||
$missing = [];
|
||||
|
|
|
|||
|
|
@ -19,4 +19,6 @@ interface RiderAPIHandlerInterface
|
|||
public function cancelJobOrder(Request $req);
|
||||
|
||||
public function arrive(Request $req);
|
||||
|
||||
public function hubArrive(Request $req);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue