Add plate number warranty API call #166
This commit is contained in:
parent
6771b86d6c
commit
fac78e558d
3 changed files with 31 additions and 1 deletions
|
|
@ -42,9 +42,10 @@ class TestCommand extends Command
|
||||||
// TODO: shift this out of the bundle, since it's project specific
|
// TODO: shift this out of the bundle, since it's project specific
|
||||||
// warranty register
|
// warranty register
|
||||||
$serial = 'AJ34LJADR12134LKJL';
|
$serial = 'AJ34LJADR12134LKJL';
|
||||||
|
$plate_num = 'XEN918';
|
||||||
$params = [
|
$params = [
|
||||||
'serial' => $serial,
|
'serial' => $serial,
|
||||||
'plate_number' => 'XEN918',
|
'plate_number' => $plate_num,
|
||||||
'warranty_class' => 'private',
|
'warranty_class' => 'private',
|
||||||
'battery_model_id' => 438,
|
'battery_model_id' => 438,
|
||||||
'battery_size_id' => 1171,
|
'battery_size_id' => 1171,
|
||||||
|
|
@ -59,6 +60,9 @@ class TestCommand extends Command
|
||||||
// warranty claim
|
// warranty claim
|
||||||
$api->post('/capi/warranties/' . $serial . '/claim');
|
$api->post('/capi/warranties/' . $serial . '/claim');
|
||||||
|
|
||||||
|
// plate warranty
|
||||||
|
$api->get('/capi/plates/' . $plate_num . '/warranties');
|
||||||
|
|
||||||
// battery
|
// battery
|
||||||
// $api->get('/capi/battery_models');
|
// $api->get('/capi/battery_models');
|
||||||
// $api->get('/capi/battery_sizes');
|
// $api->get('/capi/battery_sizes');
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,14 @@ capi_vehicle_list:
|
||||||
methods: [GET]
|
methods: [GET]
|
||||||
|
|
||||||
|
|
||||||
|
# plate api
|
||||||
|
|
||||||
|
capi_plate_warranty:
|
||||||
|
path: /capi/plates/{plate_number}/warranties
|
||||||
|
controller: App\Controller\CAPI\WarrantyController::getPlateWarranties
|
||||||
|
methods: [GET]
|
||||||
|
|
||||||
|
|
||||||
# warranty api
|
# warranty api
|
||||||
|
|
||||||
# check warranty by serial
|
# check warranty by serial
|
||||||
|
|
|
||||||
|
|
@ -178,4 +178,22 @@ class WarrantyController extends APIController
|
||||||
|
|
||||||
return new APIResponse(true, 'Warranty claimed successfully.');
|
return new APIResponse(true, 'Warranty claimed successfully.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPlateWarranties($plate_number, EntityManagerInterface $em)
|
||||||
|
{
|
||||||
|
$warranties = $em->getRepository(Warranty::class)
|
||||||
|
->findBy(['plate_number' => $plate_number], ['date_purchase' => 'DESC']);
|
||||||
|
|
||||||
|
$warr_data = [];
|
||||||
|
foreach ($warranties as $warr)
|
||||||
|
{
|
||||||
|
$warr_data[] = $this->generateWarrantyData($warr);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'warranties' => $warr_data,
|
||||||
|
];
|
||||||
|
|
||||||
|
return new APIResponse(true, 'Warranties loaded.', $data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue