From 135ab10cd38c52d18a27765b6455de2f558b6e42 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Thu, 2 Apr 2020 03:58:21 +0000 Subject: [PATCH] Add to response the list of serials with no warranties. #372 --- catalyst/api-bundle/Command/TestAPICommand.php | 3 ++- src/Controller/CAPI/WarrantyController.php | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/catalyst/api-bundle/Command/TestAPICommand.php b/catalyst/api-bundle/Command/TestAPICommand.php index a8a2be2a..952b98b6 100644 --- a/catalyst/api-bundle/Command/TestAPICommand.php +++ b/catalyst/api-bundle/Command/TestAPICommand.php @@ -142,7 +142,8 @@ class TestAPICommand extends Command // get warranties given list of serial numbers $serial_list = [ 'AJ34LJADR12134LKJM4', - 'AJ34LJADR12134LKJL5', + 'AJ34LJADR12134LKJL5', + 'test', ]; $params = [ diff --git a/src/Controller/CAPI/WarrantyController.php b/src/Controller/CAPI/WarrantyController.php index 114f3c8c..affdb892 100644 --- a/src/Controller/CAPI/WarrantyController.php +++ b/src/Controller/CAPI/WarrantyController.php @@ -523,20 +523,22 @@ class WarrantyController extends APIController return new APIResponse(false, 'Empty serial numbers list.'); $warranty_list = []; + $warr_not_found_list = []; foreach ($serial_list as $serial) { $clean_serial = $this->cleanSerial($serial); $warr = $em->getRepository(Warranty::class)->findOneBy(['serial' => $clean_serial]); if ($warr == null) - return new APIResponse(false, 'No warranty found with that serial number.', null, 404); - - $warranty_list[] = $this->generateWarrantyData($warr); + $warr_not_found_list[] = 'Warranty not found for ' . $clean_serial; + else + $warranty_list[] = $this->generateWarrantyData($warr); } $data = [ - 'warranties' => $warranty_list, + 'warranties_found' => $warranty_list, + 'warranties_not_found' => $warr_not_found_list, ]; return new APIResponse(true, 'Warranties found.', $data);