diff --git a/config/routes/api.yaml b/config/routes/api.yaml index 3c4a5b39..19e3a468 100644 --- a/config/routes/api.yaml +++ b/config/routes/api.yaml @@ -216,6 +216,11 @@ api_latest_job_order: controller: App\Controller\APIController::getLatestJobOrder methods: [GET] +api_customer_hash_get: + path: /api/customer_hash + controller: App\Controller\APIController::getCustomerHash + methods: [GET] + #api_completed_job_orders: # path: /api/job_orders/completed # controller: App\Controller\APIController::getCompletedJobOrders diff --git a/src/Controller/APIController.php b/src/Controller/APIController.php index 8919f4e9..9b9e457d 100644 --- a/src/Controller/APIController.php +++ b/src/Controller/APIController.php @@ -47,6 +47,7 @@ use App\Service\HubSelector; use App\Service\HubDistributor; use App\Service\HubFilterLogger; use App\Service\HubFilteringGeoChecker; +use App\Service\HashGenerator; use App\Entity\MobileSession; use App\Entity\Customer; @@ -3848,6 +3849,35 @@ class APIController extends Controller implements LoggedController return $res->getReturnResponse(); } + public function getCustomerHash(Request $req, EntityManagerInterface $em, HashGenerator $hash) + { + // check required parameters and api key + $res = $this->checkParamsAndKey($req, $em, []); + if ($res->isError()) + return $res->getReturnResponse(); + + // get customer + $cust = $this->session->getCustomer(); + if ($cust == null) + { + $res->setError(true) + ->setErrorMessage('No customer information found'); + return $res->getReturnResponse(); + } + + // hash customer id + $hashed_id = $hash->getHash($cust->getID()); + + $data = [ + 'cust_hash' => $hashed_id, + ]; + + $res->setData($data); + + // response + return $res->getReturnResponse(); + } + // commenting it out. Modify the getJOHistory instead to just get the fulfilled // and cancelled job orders, since ongoing is not yet part of history /*