Merge branch '372-api-call-get-list-of-warranties-given-list-of-serial-numbers' into 'master'
Resolve "API call - get list of warranties given list of serial numbers" Closes #372 See merge request jankstudio/resq!417
This commit is contained in:
commit
8f72cc4486
4 changed files with 66 additions and 3 deletions
|
|
@ -64,7 +64,7 @@ class TestAPICommand extends Command
|
|||
'start' => '1',
|
||||
];
|
||||
|
||||
$api->get('/capi/warranties', $params);
|
||||
//$api->get('/capi/warranties', $params);
|
||||
|
||||
|
||||
// warranty find
|
||||
|
|
@ -123,7 +123,7 @@ class TestAPICommand extends Command
|
|||
|
||||
// privacy policy
|
||||
$privacy_policy_id = 2;
|
||||
$api->get('/capi/privacy_policy/' . $privacy_policy_id );
|
||||
//$api->get('/capi/privacy_policy/' . $privacy_policy_id );
|
||||
|
||||
// register new customer
|
||||
$params = [
|
||||
|
|
@ -137,6 +137,19 @@ class TestAPICommand extends Command
|
|||
'v_condition' => 'new',
|
||||
'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',
|
||||
'test',
|
||||
];
|
||||
|
||||
$params = [
|
||||
'serial_list' => $serial_list,
|
||||
];
|
||||
|
||||
$api->post('/capi/warranties_list', $params);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ access_keys:
|
|||
label: Delete
|
||||
- id: warranty.set.privacypolicy
|
||||
label: Set Privacy Policy
|
||||
- id: warranty.list.serial
|
||||
label: List by Serial
|
||||
- id: batterybrand
|
||||
label: Battery Brand Access
|
||||
acls:
|
||||
|
|
|
|||
|
|
@ -108,6 +108,12 @@ capi_warranty_privacy_policy:
|
|||
controller: App\Controller\CAPI\WarrantyController::setPrivacyPolicy
|
||||
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
|
||||
|
||||
# find customer vehicle by id
|
||||
|
|
|
|||
|
|
@ -502,6 +502,48 @@ 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 = [];
|
||||
$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)
|
||||
$warr_not_found_list[] = $clean_serial;
|
||||
else
|
||||
$warranty_list[] = $this->generateWarrantyData($warr);
|
||||
}
|
||||
|
||||
|
||||
$data = [
|
||||
'warranties_found' => $warranty_list,
|
||||
'warranties_not_found' => $warr_not_found_list,
|
||||
];
|
||||
|
||||
return new APIResponse(true, 'Warranties found.', $data);
|
||||
}
|
||||
|
||||
protected function getCustomerFromMobile($em, $warranty)
|
||||
{
|
||||
$w_mobile = $warranty->getMobileNumber();
|
||||
|
|
|
|||
Loading…
Reference in a new issue