Resolve "Have CAPI call for warranty get remove 'QR' prefix from serial" #1566
1 changed files with 19 additions and 5 deletions
|
|
@ -89,18 +89,29 @@ class CustomerWarrantyController extends APIController
|
|||
return true;
|
||||
}
|
||||
|
||||
protected function cleanSerial($serial)
|
||||
{
|
||||
return trim(strtoupper($serial));
|
||||
}
|
||||
|
||||
protected function cleanPlateNumber($plate_num)
|
||||
{
|
||||
return preg_replace('/\s+/', '', strtoupper($plate_num));
|
||||
}
|
||||
|
||||
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 check($serial, EntityManagerInterface $em, Request $req, WarrantyAPILogger $logger)
|
||||
{
|
||||
$serial = $this->cleanSerial($serial);
|
||||
|
||||
$user_id = $_SERVER['HTTP_X_CATA_API_KEY'];
|
||||
$log_data = [
|
||||
'serial' => $serial,
|
||||
|
|
@ -303,6 +314,7 @@ class CustomerWarrantyController extends APIController
|
|||
public function register($serial, EntityManagerInterface $em, Request $req, KernelInterface $kernel, RisingTideGateway $rt, TranslatorInterface $trans,
|
||||
WarrantyAPILogger $logger)
|
||||
{
|
||||
$serial = $this->cleanSerial($serial);
|
||||
error_log('HERE - register');
|
||||
|
||||
// set up information for logging
|
||||
|
|
@ -366,6 +378,8 @@ class CustomerWarrantyController extends APIController
|
|||
// TODO: move this to a service, since it's shared by all warranty updaters
|
||||
protected function handlePictureUpload($file, $target_dir, $serial, $name)
|
||||
{
|
||||
$serial = $this->cleanSerial($serial);
|
||||
|
||||
error_log("handling $name upload");
|
||||
// no file sent
|
||||
if ($file == null)
|
||||
|
|
|
|||
Loading…
Reference in a new issue