diff --git a/src/Controller/CustomerAppAPI/CustomerController.php b/src/Controller/CustomerAppAPI/CustomerController.php index 82675b90..88401054 100644 --- a/src/Controller/CustomerAppAPI/CustomerController.php +++ b/src/Controller/CustomerAppAPI/CustomerController.php @@ -89,6 +89,30 @@ class CustomerController extends ApiController return new ApiResponse(true, '', $data); } + public function getCustomerHash(Request $req, HashGenerator $hash) + { + // validate params + $validity = $this->validateRequest($req); + + if (!$validity['is_valid']) { + return new ApiResponse(false, $validity['error']); + } + + // get customer + $cust = $this->session->getCustomer(); + if ($cust == null) { + return new ApiResponse(false, 'No customer information found.'); + } + + // hash customer id + $hashed_id = $hash->getHash($cust->getID()); + + // response + return new ApiResponse(true, '', [ + 'cust_hash' => $hashed_id, + ]); + } + protected function updateCustomerInfo(Request $req) { // create new customer if it's not there @@ -118,28 +142,4 @@ class CustomerController extends ApiController return $cust; } - - public function getCustomerHash(Request $req, HashGenerator $hash) - { - // validate params - $validity = $this->validateRequest($req); - - if (!$validity['is_valid']) { - return new ApiResponse(false, $validity['error']); - } - - // get customer - $cust = $this->session->getCustomer(); - if ($cust == null) { - return new ApiResponse(false, 'No customer information found.'); - } - - // hash customer id - $hashed_id = $hash->getHash($cust->getID()); - - // response - return new ApiResponse(true, '', [ - 'cust_hash' => $hashed_id, - ]); - } } diff --git a/src/Controller/CustomerAppAPI/EstimateController.php b/src/Controller/CustomerAppAPI/InvoiceController.php similarity index 96% rename from src/Controller/CustomerAppAPI/EstimateController.php rename to src/Controller/CustomerAppAPI/InvoiceController.php index d6a61cc9..1c8ab6c6 100644 --- a/src/Controller/CustomerAppAPI/EstimateController.php +++ b/src/Controller/CustomerAppAPI/InvoiceController.php @@ -8,8 +8,11 @@ use Catalyst\ApiBundle\Component\Response as ApiResponse; use App\Service\InvoiceGeneratorInterface; use App\Ramcar\InvoiceCriteria; use App\Ramcar\TradeInType; +use App\Entity\CustomerVehicle; +use App\Entity\Promo; +use App\Entity\Battery; -class EstimateController extends ApiController +class InvoiceController extends ApiController { public function getEstimate(Request $req, InvoiceGeneratorInterface $ic) { diff --git a/src/Controller/CustomerAppAPI/JobOrderController.php b/src/Controller/CustomerAppAPI/JobOrderController.php index 676cbbeb..cfa33fbf 100644 --- a/src/Controller/CustomerAppAPI/JobOrderController.php +++ b/src/Controller/CustomerAppAPI/JobOrderController.php @@ -30,9 +30,13 @@ use App\Ramcar\AutoAssignStatus; use App\Ramcar\WarrantyClass; use App\Ramcar\HubCriteria; use App\Ramcar\DeliveryStatus; +use App\Entity\Battery; +use App\Entity\Hub; +use App\Entity\Promo; use App\Entity\JOEvent; use App\Entity\Warranty; use App\Entity\JobOrder; +use App\Entity\CustomerVehicle; use DateTime; @@ -502,7 +506,7 @@ class JobOrderController extends ApiController $instructions = $req->request->get('delivery_instructions', ''); // landmark - $landmark = $req->request->get('landmark', ' '); + $landmark = $req->request->get('landmark', ''); // longitude and latitude $long = $req->request->get('long'); @@ -1305,6 +1309,7 @@ class JobOrderController extends ApiController ], 'delivery_address' => $jo->getDeliveryAddress(), 'delivery_instructions' => $jo->getDeliveryInstructions(), + 'landmark' => $jo->getLandmark(), 'jo_status' => $status, 'status' => $this->generateAPIRiderStatus($status), ]; diff --git a/src/Controller/CustomerAppAPI/LocationController.php b/src/Controller/CustomerAppAPI/LocationController.php index a0832df5..b3d3ecb3 100644 --- a/src/Controller/CustomerAppAPI/LocationController.php +++ b/src/Controller/CustomerAppAPI/LocationController.php @@ -185,6 +185,33 @@ class LocationController extends ApiController return new ApiResponse(); } + public function removeLocation($id, Request $req) + { + // validate params + $validity = $this->validateRequest($req); + + if (!$validity['is_valid']) { + return new ApiResponse(false, $validity['error']); + } + + // get customer + $cust = $this->session->getCustomer(); + if ($cust == null) { + return new ApiResponse(false, 'No customer information found.'); + } + + // find customer metadata and delete entry if present + $cv = $this->em->getRepository(CustomerMetadata::class)->findOneBy(['customer' => $cust]); + if ($cv != null) { + $cv->deleteMetadataInfo(base64_decode($id)); + } + + $this->em->flush(); + + // response + return new ApiResponse(); + } + public function getLocations(Request $req) { // validate params @@ -204,7 +231,7 @@ class LocationController extends ApiController $locations = []; $cust_meta = $this->em->getRepository(CustomerMetadata::class)->findOneBy(['customer' => $cust]); if ($cust_meta != null) { - $locations[] = $cust_meta->getAllMetaInfo(); + $locations = $cust_meta->getAllMetaInfo(); } $data = [ @@ -212,7 +239,7 @@ class LocationController extends ApiController ]; // response - return new ApiResponse(); + return new ApiResponse(true, '', $data); } protected function findAdvanceNearestHubAndSlots(Point $coordinates, MapTools $map_tools, $hub = null) diff --git a/src/Controller/CustomerAppAPI/PartnerController.php b/src/Controller/CustomerAppAPI/PartnerController.php index 7ae0e284..e08b86f0 100644 --- a/src/Controller/CustomerAppAPI/PartnerController.php +++ b/src/Controller/CustomerAppAPI/PartnerController.php @@ -152,7 +152,7 @@ class PartnerController extends ApiController $rev->setRating($rating) ->setMessage($msg) ->setPartner($partner) - ->setMobileSession($this->session); + ->setMobileSession($this->session); // TODO: add support new customer user entity // save to db $this->em->persist($rev); diff --git a/src/Entity/CustomerMetadata.php b/src/Entity/CustomerMetadata.php index 5ef9d518..af0fc6a7 100644 --- a/src/Entity/CustomerMetadata.php +++ b/src/Entity/CustomerMetadata.php @@ -63,6 +63,12 @@ class CustomerMetadata return $this; } + public function deleteMetadataInfo($id) + { + unset($this->meta_info[$id]); + return $this; + } + public function getMetaInfo($id) { // return null if we don't have it