Resolve "CAPI call for warranty serial" #1632

Merged
korina.cordero merged 18 commits from 704-capi-call-for-warranty-serial into master 2022-09-23 03:14:28 +00:00
Showing only changes of commit 9efe73e8b2 - Show all commits

View file

@ -23,6 +23,8 @@ use DateTime;
class LoadWarrantySerialCommand extends Command
{
const FIELD_COUNT = 7;
protected $em;
protected $upload_logger;
protected $load_logger;
@ -214,13 +216,11 @@ class LoadWarrantySerialCommand extends Command
// (5) Empty line - ignore
// (6) empty sku - log
// TODO: count the number of fields
// check if the line is a header
if ($row[0] == 'SerialNumber')
// check if empty line
if ($row == array(null))
{
// no need to log, but send back error
$error = 'Invalid information.';
$error = 'Empty line';
$data = [
'serial' => '',
'status' => 'error',
@ -231,11 +231,25 @@ class LoadWarrantySerialCommand extends Command
return $data;
}
// check if empty line
if ($row == array(null))
// check the number of fields
if (count($row) != self::FIELD_COUNT)
{
$error = 'Invalid number of fields.';
$data = [
'serial' => '',
'status' => 'error',
'has_error' => true,
'error_message' => $error,
];
return $data;
}
// check if the line is a header
if ($row[0] == 'SerialNumber')
{
// no need to log, but send back error
$error = 'Empty line';
$error = 'Invalid information.';
$data = [
'serial' => '',
'status' => 'error',
@ -412,7 +426,7 @@ class LoadWarrantySerialCommand extends Command
curl_close($curl);
// check result
// error_log('Result ' . $res);
error_log('Result ' . $res);
}
}