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();
|
return $res->getReturnResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hubArrive(Request $req)
|
public function hubArrive(Request $req, RiderAPIHandlerInterface $rapi_handler)
|
||||||
{
|
{
|
||||||
$required_params = [];
|
$res = new APIResult();
|
||||||
$em = $this->getDoctrine()->getManager();
|
|
||||||
$res = $this->checkParamsAndKey($req, $em, $required_params);
|
|
||||||
if ($res->isError())
|
|
||||||
return $res->getReturnResponse();
|
|
||||||
|
|
||||||
// are we logged in?
|
$data = $rapi_handler->hubArrive($req);
|
||||||
if (!$this->session->hasRider())
|
|
||||||
|
if (isset($data['error']))
|
||||||
{
|
{
|
||||||
|
$message = $data['error'];
|
||||||
|
|
||||||
$res->setError(true)
|
$res->setError(true)
|
||||||
->setErrorMessage('No logged in rider.');
|
->setErrorMessage($message);
|
||||||
return $res->getReturnResponse();
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$res->setData($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: tag rider as available
|
// response
|
||||||
|
|
||||||
$em->flush();
|
|
||||||
|
|
||||||
|
|
||||||
return $res->getReturnResponse();
|
return $res->getReturnResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -449,6 +449,29 @@ class CMBRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
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 = [])
|
protected function checkMissingParameters(Request $req, $params = [])
|
||||||
{
|
{
|
||||||
$missing = [];
|
$missing = [];
|
||||||
|
|
|
||||||
|
|
@ -446,6 +446,29 @@ class ResqRiderAPIHandler implements RiderAPIHandlerInterface
|
||||||
return $data;
|
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 = [])
|
protected function checkMissingParameters(Request $req, $params = [])
|
||||||
{
|
{
|
||||||
$missing = [];
|
$missing = [];
|
||||||
|
|
|
||||||
|
|
@ -19,4 +19,6 @@ interface RiderAPIHandlerInterface
|
||||||
public function cancelJobOrder(Request $req);
|
public function cancelJobOrder(Request $req);
|
||||||
|
|
||||||
public function arrive(Request $req);
|
public function arrive(Request $req);
|
||||||
|
|
||||||
|
public function hubArrive(Request $req);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue