Add permissions for another third party api. Copied the methods from APIController into CAPI third party conrtrollers. #686
This commit is contained in:
parent
54f065d30f
commit
60f401e26e
6 changed files with 1998 additions and 0 deletions
|
|
@ -69,3 +69,53 @@ access_keys:
|
|||
acls:
|
||||
- id: dealer.list
|
||||
label: List
|
||||
|
||||
- id: tapi_vmanufacturer
|
||||
label: Third Party Vehicle Manufacturer Access
|
||||
acls:
|
||||
- id: tapi_vmanufacturer.list
|
||||
label: List Third Party Vehicle Manufacturers
|
||||
- id: tapi_vehicle
|
||||
label: Third Party Vehicle Make Access
|
||||
acls:
|
||||
- id: tapi_vehicle.list
|
||||
label: List Third Party Vehicles
|
||||
- id: tapi_promo
|
||||
labels: Third Party Promo Access
|
||||
acls:
|
||||
- id: tapi_promo.list
|
||||
label: List Third Party Promos
|
||||
- id: tapi_battery
|
||||
labels: Third Party Battery Access
|
||||
acls:
|
||||
- id: tapi_battery_compatible.list
|
||||
label: List Third Party Compatible Batteries
|
||||
- id: tapi_jo
|
||||
labels: Third Party Job Order Access
|
||||
acls:
|
||||
- id: tapi_jo.request
|
||||
label: Third Party Request Job Order
|
||||
- id: tapi_jo.get.estimate
|
||||
label: Third Party Get Estimate
|
||||
- id: tapi_jo.get.ongoing
|
||||
label: Third Party Get Ongoing Job Order
|
||||
- id: tapi_jo.cancel
|
||||
label: Third Party Cancel Job Order
|
||||
- id: tapi_jo.get.history
|
||||
label: Third Party Get Job Order History
|
||||
- id: tapi_jo.get.invoice
|
||||
label: Third Party Get Job Order Invoice
|
||||
- id: tapi_jo.location.support
|
||||
label: Third Party Check Location Support
|
||||
- id: tapi_jo.nearest_hub.get
|
||||
label: Third Party Get Nearest Hub and Slots
|
||||
- id: tapi_jo.schedule_option.status
|
||||
label: Third Party Schedule Option Status
|
||||
- id: tapi_jo.get.info
|
||||
label: Third Party Get Job Order Info
|
||||
- id: tapi_service
|
||||
labels: Third Party Service Access
|
||||
acls:
|
||||
- id: tapi_service.list
|
||||
label: List Third Party Services
|
||||
|
||||
|
|
|
|||
85
src/Controller/CAPI/ResqAPI/BatteryController.php
Normal file
85
src/Controller/CAPI/ResqAPI/BatteryController.php
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\CAPI\ResqAPI;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use Catalyst\APIBundle\Controller\APIController;
|
||||
use Catalyst\APIBundle\Response\APIResponse;
|
||||
use App\Ramcar\APIResult;
|
||||
|
||||
use App\Entity\Vehicle;
|
||||
|
||||
use Catalyst\APIBundle\Access\Generator as ACLGenerator;
|
||||
|
||||
class BatteryController extends APIController
|
||||
{
|
||||
protected $acl_gen;
|
||||
|
||||
public function __construct(ACLGenerator $acl_gen)
|
||||
{
|
||||
$this->acl_gen = $acl_gen;
|
||||
}
|
||||
|
||||
public function getCompatibleBatteries(Request $req, $vid, EntityManagerInterface $em)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('tapi_battery_compatible.list', null, 'No access.');
|
||||
|
||||
// check required parameters and api key
|
||||
$required_params = [];
|
||||
$res = $this->checkParamsAndKey($req, $em, $required_params);
|
||||
if ($res->isError())
|
||||
return $res->getReturnResponse();
|
||||
|
||||
// get vehicle
|
||||
$vehicle = $em->getRepository(Vehicle::class)->find($vid);
|
||||
if ($vehicle == null)
|
||||
{
|
||||
$res->setError(true)
|
||||
->setErrorMessage('Invalid vehicle');
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
// batteries
|
||||
$batt_list = [];
|
||||
$batts = $vehicle->getBatteries();
|
||||
foreach ($batts as $batt)
|
||||
{
|
||||
// TODO: Add warranty_tnv to battery information
|
||||
$batt_list[] = [
|
||||
'id' => $batt->getID(),
|
||||
'mfg_id' => $batt->getManufacturer()->getID(),
|
||||
'mfg_name' => $batt->getManufacturer()->getName(),
|
||||
'model_id' => $batt->getModel()->getID(),
|
||||
'model_name' => $batt->getModel()->getName(),
|
||||
'size_id' => $batt->getSize()->getID(),
|
||||
'size_name' => $batt->getSize()->getName(),
|
||||
'price' => $batt->getSellingPrice(),
|
||||
'wty_private' => $batt->getWarrantyPrivate(),
|
||||
'wty_commercial' => $batt->getWarrantyCommercial(),
|
||||
'image_url' => $this->getBatteryImageURL($req, $batt),
|
||||
];
|
||||
}
|
||||
|
||||
// data
|
||||
$data = [
|
||||
'vehicle' => [
|
||||
'id' => $vehicle->getID(),
|
||||
'mfg_id' => $vehicle->getManufacturer()->getID(),
|
||||
'mfg_name' => $vehicle->getManufacturer()->getName(),
|
||||
'make' => $vehicle->getMake(),
|
||||
'model_year_from' => $vehicle->getModelYearFrom(),
|
||||
'model_year_to' => $vehicle->getModelYearTo(),
|
||||
],
|
||||
'batteries' => $batt_list,
|
||||
];
|
||||
$res->setData($data);
|
||||
|
||||
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
}
|
||||
1637
src/Controller/CAPI/ResqAPI/JobOrderController.php
Normal file
1637
src/Controller/CAPI/ResqAPI/JobOrderController.php
Normal file
File diff suppressed because it is too large
Load diff
40
src/Controller/CAPI/ResqAPI/PromoController.php
Normal file
40
src/Controller/CAPI/ResqAPI/PromoController.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\CAPI\ResqAPI;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use Catalyst\APIBundle\Controller\APIController;
|
||||
use Catalyst\APIBundle\Response\APIResponse;
|
||||
|
||||
use App\Entity\Promo;
|
||||
|
||||
use Catalyst\APIBundle\Access\Generator as ACLGenerator;
|
||||
|
||||
class PromoController extends APIController
|
||||
{
|
||||
protected $acl_gen;
|
||||
|
||||
public function __construct(ACLGenerator $acl_gen)
|
||||
{
|
||||
$this->acl_gen = $acl_gen;
|
||||
}
|
||||
|
||||
public function listPromos(Request $req, EntityManagerInterface $em)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('tapi_promo.list', null, 'No access.');
|
||||
|
||||
// check required parameters and api key
|
||||
$required_params = [];
|
||||
$res = $this->checkParamsAndKey($req, $em, $required_params);
|
||||
if ($res->isError())
|
||||
return $res->getReturnResponse();
|
||||
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
}
|
||||
79
src/Controller/CAPI/ResqAPI/ServiceController.php
Normal file
79
src/Controller/CAPI/ResqAPI/ServiceController.php
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\CAPI\ResqAPI;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use Catalyst\APIBundle\Controller\APIController;
|
||||
use Catalyst\APIBundle\Response\APIResponse;
|
||||
|
||||
use App\Entity\Service;
|
||||
|
||||
use Catalyst\APIBundle\Access\Generator as ACLGenerator;
|
||||
|
||||
class ServiceController extends APIController
|
||||
{
|
||||
protected $acl_gen;
|
||||
|
||||
public function __construct(ACLGenerator $acl_gen)
|
||||
{
|
||||
$this->acl_gen = $acl_gen;
|
||||
}
|
||||
|
||||
public function listServices(Request $req, EntityManagerInterface $em)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('tapi_service.list', null, 'No access.');
|
||||
|
||||
$required_params = [];
|
||||
$res = $this->checkParamsAndKey($req, $em, $required_params);
|
||||
if ($res->isError())
|
||||
return $res->getReturnResponse();
|
||||
|
||||
// services
|
||||
$results = $em->getRepository(Service::class)->findAll();
|
||||
if (empty($results))
|
||||
{
|
||||
$res->setError(true)
|
||||
->setErrorMessage('No services available.');
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
$services = [];
|
||||
foreach ($results as $result)
|
||||
{
|
||||
/*
|
||||
// get partners
|
||||
$partners = [];
|
||||
$service_partners = $result->getPartners();
|
||||
foreach($service_partners as $sp)
|
||||
{
|
||||
$partners[] = [
|
||||
'id' => $sp->getID(),
|
||||
'name' => $sp->getName(),
|
||||
'branch' => $sp->getBranch(),
|
||||
'address' => $sp->getAddress(),
|
||||
'contact_nums' => $sp->getContactNumbers(),
|
||||
'time_open' => $sp->getTimeOpen()->format("g:i A"),
|
||||
'time_close' => $sp->getTimeClose()->format("g:i A"),
|
||||
];
|
||||
}
|
||||
*/
|
||||
|
||||
$services[] = [
|
||||
'id' => $result->getID(),
|
||||
'name' => $result->getName(),
|
||||
// 'partners' => $partners,
|
||||
];
|
||||
}
|
||||
|
||||
$data['services'] = $services;
|
||||
|
||||
$res->setData($data);
|
||||
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
}
|
||||
107
src/Controller/CAPI/ResqAPI/VehicleController.php
Normal file
107
src/Controller/CAPI/ResqAPI/VehicleController.php
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\CAPI\ResqAPI;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use Catalyst\APIBundle\Controller\APIController;
|
||||
use Catalyst\APIBundle\Response\APIResponse;
|
||||
|
||||
use App\Entity\VehicleManufacturer;
|
||||
use App\Entity\Vehicle;
|
||||
|
||||
use Catalyst\APIBundle\Access\Generator as ACLGenerator;
|
||||
|
||||
class VehicleController extends APIController
|
||||
{
|
||||
protected $acl_gen;
|
||||
|
||||
public function __construct(ACLGenerator $acl_gen)
|
||||
{
|
||||
$this->acl_gen = $acl_gen;
|
||||
}
|
||||
|
||||
public function listVehicleManufacturers(Request $req, EntityManagerInterface $em)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('tapi_vmanufacturer.list', null, 'No access.');
|
||||
|
||||
// check required parameters and api key
|
||||
$required_params = [];
|
||||
$res = $this->checkParamsAndKey($req, $em, $required_params);
|
||||
if ($res->isError())
|
||||
return $res->getReturnResponse();
|
||||
|
||||
// get manufacturer list
|
||||
$mfgs = $em->getRepository(VehicleManufacturer::class)->findBy(['flag_mobile' => true], ['name' => 'asc']);
|
||||
$mfg_list = [];
|
||||
foreach ($mfgs as $mfg)
|
||||
{
|
||||
$mfg_list[] = [
|
||||
'id' => $mfg->getID(),
|
||||
'name' => $mfg->getName(),
|
||||
];
|
||||
}
|
||||
|
||||
$data = [
|
||||
'manufacturers' => $mfg_list
|
||||
];
|
||||
$res->setData($data);
|
||||
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
public function listVehicleMakes(Request $req, $mfg_id, EntityManagerInterface $em)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('tapi_vehicle.list', null, 'No access.');
|
||||
|
||||
// check required parameters and api key
|
||||
$required_params = [];
|
||||
$res = $this->checkParamsAndKey($req, $em, $required_params);
|
||||
if ($res->isError())
|
||||
return $res->getReturnResponse();
|
||||
|
||||
// get manufacturer
|
||||
$mfg = $em->getRepository(VehicleManufacturer::class)->find($mfg_id);
|
||||
if ($mfg == null)
|
||||
{
|
||||
$res->setError(true)
|
||||
->setErrorMessage('Invalid vehicle manufacturer id');
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
// get makes
|
||||
$vehicles = $em->getRepository(Vehicle::class)->findBy(
|
||||
[
|
||||
'flag_mobile' => true,
|
||||
'manufacturer' => $mfg_id,
|
||||
],
|
||||
['make' => 'asc']
|
||||
);
|
||||
|
||||
$vlist = [];
|
||||
foreach ($vehicles as $v)
|
||||
{
|
||||
$vlist[] = [
|
||||
'id' => $v->getID(),
|
||||
'make' => trim($v->getMake() . ' ' . $v->getModelYearFormatted(false)),
|
||||
// 'make' => $v->getMake() . ' ' . $v->getModelYearFrom() . '-' . $v->getModelYearTo(),
|
||||
];
|
||||
}
|
||||
|
||||
$data = [
|
||||
'manufacturer' => [
|
||||
'id' => $mfg->getID(),
|
||||
'name' => $mfg->getName(),
|
||||
],
|
||||
'makes' => $vlist,
|
||||
];
|
||||
|
||||
$res->setData($data);
|
||||
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue