Add get customer hash to api. #640

This commit is contained in:
Korina Cordero 2021-11-23 05:29:51 +00:00
parent 2e428378c6
commit b0de01ae1b
2 changed files with 35 additions and 0 deletions

View file

@ -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

View file

@ -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
/*