Add rider details in API rider status call
This commit is contained in:
parent
21b7727278
commit
93b62a37a2
2 changed files with 34 additions and 3 deletions
|
|
@ -957,29 +957,55 @@ class APIController extends Controller
|
|||
|
||||
// get first jo that's pending
|
||||
$jo = $ongoing_jos[0];
|
||||
$dest = $jo->getCoordinates();
|
||||
|
||||
switch ($jo->getStatus())
|
||||
{
|
||||
case JOStatus::PENDING:
|
||||
$res->setData([
|
||||
'status' => APIRiderStatus::OUTLET_ASSIGN,
|
||||
'jo_id' => $jo->getID(),
|
||||
'destination' => [
|
||||
'long' => $dest->getLongitude(),
|
||||
'lat' => $dest->getLatitude(),
|
||||
],
|
||||
]);
|
||||
return $res->getReturnResponse();
|
||||
case JOStatus::RIDER_ASSIGN:
|
||||
$res->setData([
|
||||
'status' => APIRiderStatus::RIDER_ASSIGN,
|
||||
'jo_id' => $jo->getID(),
|
||||
'destination' => [
|
||||
'long' => $dest->getLongitude(),
|
||||
'lat' => $dest->getLatitude(),
|
||||
],
|
||||
]);
|
||||
return $res->getReturnResponse();
|
||||
case JOStatus::ASSIGNED:
|
||||
$coord = $jo->getOutlet()->getCoordinates();
|
||||
$rider = $jo->getRider();
|
||||
// TODO: figure out cleaner way to generate urls
|
||||
$image_url = 'http://resq.jankstudio.com/assets/images/user.gif';
|
||||
if ($rider->getImageFile() != null)
|
||||
$image_url = 'http://resq.jankstudio.com/uploads/' . $rider->getImageFile();
|
||||
$res->setData([
|
||||
'status' => APIRiderStatus::RIDER_PICK_UP,
|
||||
'jo_id' => $jo->getID(),
|
||||
'destination' => [
|
||||
'long' => $dest->getLongitude(),
|
||||
'lat' => $dest->getLatitude(),
|
||||
],
|
||||
// TODO: fix this to actual location of rider
|
||||
'lcoation' => [
|
||||
'long' => $coord->getLongitude(),
|
||||
'lat' => $coord->getLatitude()
|
||||
'rider' => [
|
||||
'id' => $rider->getID(),
|
||||
'name' => $rider->getFullName(),
|
||||
'plate_num' => $rider->getPlateNumber(),
|
||||
'contact_num' => $rider->getContactNumber(),
|
||||
'image_url' => $image_url,
|
||||
'location' => [
|
||||
'long' => $coord->getLongitude(),
|
||||
'lat' => $coord->getLatitude()
|
||||
]
|
||||
]
|
||||
]);
|
||||
return $res->getReturnResponse();
|
||||
|
|
|
|||
|
|
@ -94,6 +94,11 @@ class Rider
|
|||
return $this->last_name;
|
||||
}
|
||||
|
||||
public function getFullName()
|
||||
{
|
||||
return $this->first_name . ' ' . $this->last_name;
|
||||
}
|
||||
|
||||
public function setPlateNumber($plate_number)
|
||||
{
|
||||
$this->plate_number = $plate_number;
|
||||
|
|
|
|||
Loading…
Reference in a new issue