Merge branch '644-fix-app-warranty-api' into 'master'
Add QR prefix removal to app api for warranty #644 Closes #644 See merge request jankstudio/resq!756
This commit is contained in:
commit
e986d07f70
2 changed files with 19 additions and 1 deletions
|
|
@ -3347,6 +3347,21 @@ class APIController extends Controller implements LoggedController
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: put this in a service
|
||||||
|
protected function cleanSerial($serial)
|
||||||
|
{
|
||||||
|
// trim and make everything upper case
|
||||||
|
$clean_serial = trim(strtoupper($serial));
|
||||||
|
|
||||||
|
|
||||||
|
// remove QR prefix if it exists
|
||||||
|
$prefix = substr($clean_serial, 0, 2);
|
||||||
|
if ($prefix == 'QR')
|
||||||
|
$clean_serial = substr($clean_serial, 2);
|
||||||
|
|
||||||
|
return $clean_serial;
|
||||||
|
}
|
||||||
|
|
||||||
public function warrantyCheck($serial, EntityManagerInterface $em, Request $req)
|
public function warrantyCheck($serial, EntityManagerInterface $em, Request $req)
|
||||||
{
|
{
|
||||||
// check required parameters and api key
|
// check required parameters and api key
|
||||||
|
|
@ -3356,6 +3371,7 @@ class APIController extends Controller implements LoggedController
|
||||||
return $res->getReturnResponse();
|
return $res->getReturnResponse();
|
||||||
|
|
||||||
// check if warranty serial is there
|
// check if warranty serial is there
|
||||||
|
$serial = $this->cleanSerial($serial);
|
||||||
$warr_serial = $em->getRepository(WarrantySerial::class)->find($serial);
|
$warr_serial = $em->getRepository(WarrantySerial::class)->find($serial);
|
||||||
$warr = $em->getRepository(Warranty::class)->findOneBy(['serial' => $serial]);
|
$warr = $em->getRepository(Warranty::class)->findOneBy(['serial' => $serial]);
|
||||||
$batt = null;
|
$batt = null;
|
||||||
|
|
@ -3577,7 +3593,8 @@ class APIController extends Controller implements LoggedController
|
||||||
$warr_card = $req->files->get('warr_card');
|
$warr_card = $req->files->get('warr_card');
|
||||||
|
|
||||||
// normalize serial
|
// normalize serial
|
||||||
$serial = trim(strtoupper($serial));
|
$serial = $this->cleanSerial($serial);
|
||||||
|
// $serial = trim(strtoupper($serial));
|
||||||
|
|
||||||
// process picture uploads
|
// process picture uploads
|
||||||
$upload_dir = $kernel->getProjectDir() . '/public/warranty_uploads';
|
$upload_dir = $kernel->getProjectDir() . '/public/warranty_uploads';
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,7 @@ class CustomerWarrantyController extends APIController
|
||||||
return preg_replace('/\s+/', '', strtoupper($plate_num));
|
return preg_replace('/\s+/', '', strtoupper($plate_num));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: put this in a service
|
||||||
protected function cleanSerial($serial)
|
protected function cleanSerial($serial)
|
||||||
{
|
{
|
||||||
// trim and make everything upper case
|
// trim and make everything upper case
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue