Add geofence check for job order request api call #141
This commit is contained in:
parent
2ffc856b10
commit
27372264e9
1 changed files with 16 additions and 4 deletions
|
|
@ -25,6 +25,7 @@ use App\Ramcar\JOEventType;
|
|||
use App\Service\InvoiceCreator;
|
||||
use App\Service\RisingTideGateway;
|
||||
use App\Service\MQTTClient;
|
||||
use App\Service\GeofenceTracker;
|
||||
|
||||
use App\Entity\MobileSession;
|
||||
use App\Entity\Customer;
|
||||
|
|
@ -766,7 +767,7 @@ class APIController extends Controller
|
|||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function requestJobOrder(Request $req, InvoiceCreator $ic)
|
||||
public function requestJobOrder(Request $req, InvoiceCreator $ic, GeofenceTracker $geo)
|
||||
{
|
||||
// check required parameters and api key
|
||||
$required_params = [
|
||||
|
|
@ -793,6 +794,19 @@ class APIController extends Controller
|
|||
// instructions
|
||||
$instructions = $req->request->get('delivery_instructions', '');
|
||||
|
||||
// longitude and latitude
|
||||
$long = $req->request->get('long');
|
||||
$lat = $req->request->get('lat');
|
||||
|
||||
// geofence
|
||||
$is_covered = $geo->isCovered($long, $lat);
|
||||
if (!$is_covered)
|
||||
{
|
||||
$res->setError(true)
|
||||
->setErrorMessage('Location is not covered by our service.');
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
|
||||
$jo = new JobOrder();
|
||||
$jo->setSource(TransactionOrigin::MOBILE_APP)
|
||||
|
|
@ -836,9 +850,7 @@ class APIController extends Controller
|
|||
}
|
||||
$jo->setWarrantyClass($warr);
|
||||
|
||||
// longitude and latitude
|
||||
$long = $req->request->get('long');
|
||||
$lat = $req->request->get('lat');
|
||||
// set coordinates
|
||||
$point = new Point($long, $lat);
|
||||
$jo->setCoordinates($point);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue