Add API call to get warranties when given a list of serial numbers. #372

This commit is contained in:
Korina Cordero 2020-04-02 03:33:02 +00:00
parent c38eb147c8
commit 719cccf778
4 changed files with 63 additions and 3 deletions

View file

@ -64,7 +64,7 @@ class TestAPICommand extends Command
'start' => '1', 'start' => '1',
]; ];
$api->get('/capi/warranties', $params); //$api->get('/capi/warranties', $params);
// warranty find // warranty find
@ -123,7 +123,7 @@ class TestAPICommand extends Command
// privacy policy // privacy policy
$privacy_policy_id = 2; $privacy_policy_id = 2;
$api->get('/capi/privacy_policy/' . $privacy_policy_id ); //$api->get('/capi/privacy_policy/' . $privacy_policy_id );
// register new customer // register new customer
$params = [ $params = [
@ -137,6 +137,18 @@ class TestAPICommand extends Command
'v_condition' => 'new', 'v_condition' => 'new',
'v_fuel_type' => 'gas', 'v_fuel_type' => 'gas',
]; ];
$api->post('/capi/quick_registration', $params); //$api->post('/capi/quick_registration', $params);
// get warranties given list of serial numbers
$serial_list = [
'AJ34LJADR12134LKJM4',
'AJ34LJADR12134LKJL5',
];
$params = [
'serial_list' => $serial_list,
];
$api->post('/capi/warranties_list', $params);
} }
} }

View file

@ -20,6 +20,8 @@ access_keys:
label: Delete label: Delete
- id: warranty.set.privacypolicy - id: warranty.set.privacypolicy
label: Set Privacy Policy label: Set Privacy Policy
- id: warranty.list.serial
label: List by Serial
- id: batterybrand - id: batterybrand
label: Battery Brand Access label: Battery Brand Access
acls: acls:

View file

@ -108,6 +108,12 @@ capi_warranty_privacy_policy:
controller: App\Controller\CAPI\WarrantyController::setPrivacyPolicy controller: App\Controller\CAPI\WarrantyController::setPrivacyPolicy
methods: [POST] methods: [POST]
# get list of warranties given list of serials
capi_warranty_get_warranties_from_serials:
path: /capi/warranties_list
controller: App\Controller\CAPI\WarrantyController::getWarrantiesBySerialList
methods: [POST]
# customer vehicle api # customer vehicle api
# find customer vehicle by id # find customer vehicle by id

View file

@ -502,6 +502,46 @@ class WarrantyController extends APIController
} }
public function getWarrantiesBySerialList(Request $req, EntityManagerInterface $em)
{
$this->denyAccessUnlessGranted('warranty.list.serial', null, 'No access.');
error_log('getWarrantiesBySerialList');
// required parameters
$params = [
'serial_list',
];
$msg = $this->checkRequiredParameters($req, $params);
error_log('msg - ' . $msg);
if ($msg)
return new APIResponse(false, $msg);
$serial_list = $req->request->get('serial_list');
if (empty($serial_list))
return new APIResponse(false, 'Empty serial numbers list.');
$warranty_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);
}
$data = [
'warranties' => $warranty_list,
];
return new APIResponse(true, 'Warranties found.', $data);
}
protected function getCustomerFromMobile($em, $warranty) protected function getCustomerFromMobile($em, $warranty)
{ {
$w_mobile = $warranty->getMobileNumber(); $w_mobile = $warranty->getMobileNumber();