Fix issues encountered during v2 app creation #730
This commit is contained in:
parent
c7fc06ef50
commit
6d416ee5f1
6 changed files with 70 additions and 29 deletions
|
|
@ -89,6 +89,30 @@ class CustomerController extends ApiController
|
||||||
return new ApiResponse(true, '', $data);
|
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)
|
protected function updateCustomerInfo(Request $req)
|
||||||
{
|
{
|
||||||
// create new customer if it's not there
|
// create new customer if it's not there
|
||||||
|
|
@ -118,28 +142,4 @@ class CustomerController extends ApiController
|
||||||
|
|
||||||
return $cust;
|
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,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,11 @@ use Catalyst\ApiBundle\Component\Response as ApiResponse;
|
||||||
use App\Service\InvoiceGeneratorInterface;
|
use App\Service\InvoiceGeneratorInterface;
|
||||||
use App\Ramcar\InvoiceCriteria;
|
use App\Ramcar\InvoiceCriteria;
|
||||||
use App\Ramcar\TradeInType;
|
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)
|
public function getEstimate(Request $req, InvoiceGeneratorInterface $ic)
|
||||||
{
|
{
|
||||||
|
|
@ -30,9 +30,13 @@ use App\Ramcar\AutoAssignStatus;
|
||||||
use App\Ramcar\WarrantyClass;
|
use App\Ramcar\WarrantyClass;
|
||||||
use App\Ramcar\HubCriteria;
|
use App\Ramcar\HubCriteria;
|
||||||
use App\Ramcar\DeliveryStatus;
|
use App\Ramcar\DeliveryStatus;
|
||||||
|
use App\Entity\Battery;
|
||||||
|
use App\Entity\Hub;
|
||||||
|
use App\Entity\Promo;
|
||||||
use App\Entity\JOEvent;
|
use App\Entity\JOEvent;
|
||||||
use App\Entity\Warranty;
|
use App\Entity\Warranty;
|
||||||
use App\Entity\JobOrder;
|
use App\Entity\JobOrder;
|
||||||
|
use App\Entity\CustomerVehicle;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
||||||
|
|
@ -502,7 +506,7 @@ class JobOrderController extends ApiController
|
||||||
$instructions = $req->request->get('delivery_instructions', '');
|
$instructions = $req->request->get('delivery_instructions', '');
|
||||||
|
|
||||||
// landmark
|
// landmark
|
||||||
$landmark = $req->request->get('landmark', ' ');
|
$landmark = $req->request->get('landmark', '');
|
||||||
|
|
||||||
// longitude and latitude
|
// longitude and latitude
|
||||||
$long = $req->request->get('long');
|
$long = $req->request->get('long');
|
||||||
|
|
@ -1305,6 +1309,7 @@ class JobOrderController extends ApiController
|
||||||
],
|
],
|
||||||
'delivery_address' => $jo->getDeliveryAddress(),
|
'delivery_address' => $jo->getDeliveryAddress(),
|
||||||
'delivery_instructions' => $jo->getDeliveryInstructions(),
|
'delivery_instructions' => $jo->getDeliveryInstructions(),
|
||||||
|
'landmark' => $jo->getLandmark(),
|
||||||
'jo_status' => $status,
|
'jo_status' => $status,
|
||||||
'status' => $this->generateAPIRiderStatus($status),
|
'status' => $this->generateAPIRiderStatus($status),
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -185,6 +185,33 @@ class LocationController extends ApiController
|
||||||
return new ApiResponse();
|
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)
|
public function getLocations(Request $req)
|
||||||
{
|
{
|
||||||
// validate params
|
// validate params
|
||||||
|
|
@ -204,7 +231,7 @@ class LocationController extends ApiController
|
||||||
$locations = [];
|
$locations = [];
|
||||||
$cust_meta = $this->em->getRepository(CustomerMetadata::class)->findOneBy(['customer' => $cust]);
|
$cust_meta = $this->em->getRepository(CustomerMetadata::class)->findOneBy(['customer' => $cust]);
|
||||||
if ($cust_meta != null) {
|
if ($cust_meta != null) {
|
||||||
$locations[] = $cust_meta->getAllMetaInfo();
|
$locations = $cust_meta->getAllMetaInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
|
|
@ -212,7 +239,7 @@ class LocationController extends ApiController
|
||||||
];
|
];
|
||||||
|
|
||||||
// response
|
// response
|
||||||
return new ApiResponse();
|
return new ApiResponse(true, '', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function findAdvanceNearestHubAndSlots(Point $coordinates, MapTools $map_tools, $hub = null)
|
protected function findAdvanceNearestHubAndSlots(Point $coordinates, MapTools $map_tools, $hub = null)
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,7 @@ class PartnerController extends ApiController
|
||||||
$rev->setRating($rating)
|
$rev->setRating($rating)
|
||||||
->setMessage($msg)
|
->setMessage($msg)
|
||||||
->setPartner($partner)
|
->setPartner($partner)
|
||||||
->setMobileSession($this->session);
|
->setMobileSession($this->session); // TODO: add support new customer user entity
|
||||||
|
|
||||||
// save to db
|
// save to db
|
||||||
$this->em->persist($rev);
|
$this->em->persist($rev);
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,12 @@ class CustomerMetadata
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deleteMetadataInfo($id)
|
||||||
|
{
|
||||||
|
unset($this->meta_info[$id]);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function getMetaInfo($id)
|
public function getMetaInfo($id)
|
||||||
{
|
{
|
||||||
// return null if we don't have it
|
// return null if we don't have it
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue