Add method to cancel warranty in WarrantyController. Add route and acl for cancel warranty. Add test command to test cancel warranty. #250
This commit is contained in:
parent
74e1e329a7
commit
e634f2ee32
4 changed files with 33 additions and 0 deletions
|
|
@ -73,6 +73,10 @@ class TestAPICommand extends Command
|
||||||
];
|
];
|
||||||
$api->post('/capi/warranties/' . $id . '/claim', $params);
|
$api->post('/capi/warranties/' . $id . '/claim', $params);
|
||||||
|
|
||||||
|
// warranty cancel
|
||||||
|
$id = 86811;
|
||||||
|
$api->get('/capi/warranties/' . $id . '/cancel');
|
||||||
|
|
||||||
// plate warranty
|
// plate warranty
|
||||||
$api->get('/capi/plates/' . $plate_num . '/warranties');
|
$api->get('/capi/plates/' . $plate_num . '/warranties');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@ access_keys:
|
||||||
label: Register Battery
|
label: Register Battery
|
||||||
- id: warranty.claim
|
- id: warranty.claim
|
||||||
label: Claim
|
label: Claim
|
||||||
|
- id: warranty.cancel
|
||||||
|
label: Cancel
|
||||||
- id: batterybrand
|
- id: batterybrand
|
||||||
label: Battery Brand Access
|
label: Battery Brand Access
|
||||||
acls:
|
acls:
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,12 @@ capi_warranty_get_all:
|
||||||
controller: App\Controller\CAPI\WarrantyController::getAll
|
controller: App\Controller\CAPI\WarrantyController::getAll
|
||||||
methods: [GET]
|
methods: [GET]
|
||||||
|
|
||||||
|
# cancel warranty
|
||||||
|
capi_warranty_cancel:
|
||||||
|
path: /capi/warranties/{id}/cancel
|
||||||
|
controller: App\Controller\CAPI\WarrantyController::cancel
|
||||||
|
methods: [GET]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# customer vehicle api
|
# customer vehicle api
|
||||||
|
|
|
||||||
|
|
@ -310,4 +310,25 @@ class WarrantyController extends APIController
|
||||||
|
|
||||||
return new APIResponse(true, 'Warranties loaded.', $data);
|
return new APIResponse(true, 'Warranties loaded.', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function cancel(Request $req, EntityManagerInterface $em, $id)
|
||||||
|
{
|
||||||
|
$this->denyAccessUnlessGranted('warranty.cancel', null, 'No access.');
|
||||||
|
|
||||||
|
// find warranty
|
||||||
|
$warr = $em->getRepository(Warranty::class)->find($id);
|
||||||
|
if ($warr == null)
|
||||||
|
{
|
||||||
|
return new APIResponse(false, 'No warranty found with that id.', null, 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set status to cancelled
|
||||||
|
$warr->setStatus(WarrantyStatus::CANCELLED);
|
||||||
|
|
||||||
|
$em->persist($warr);
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
|
return new APIResponse(true, 'Warranty cancelled successfully.');
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue