Added getConsumption/update/delete
MODIFY
src/server/rest/v1/router/api/SiteAreaRouter.ts
src/server/rest/v1/router/api/SiteAreaRouter.ts
@@ -16,6 +16,9 @@ export default class SiteAreaRouter {
this.buildRouteSiteAreas();
this.buildRouteSiteArea();
this.buildRouteCreateSiteArea();
+ this.buildRouteGetSiteAreaConsumption();
+ this.buildRouteUpdateSiteArea();
+ this.buildRouteDeleteSiteArea();
return this.router;
}
@@ -37,4 +40,25 @@ export default class SiteAreaRouter {
await RouterUtils.handleServerAction(SiteAreaService.handleCreateSiteArea.bind(this), ServerAction.SITE_AREA_CREATE, req, res, next);
});
}
+
+ private buildRouteGetSiteAreaConsumption(): void {
+ this.router.get(`/${ServerRoute.REST_SITE_AREA_CONSUMPTION}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.query.ID = req.params.id;
+ await RouterUtils.handleServerAction(SiteAreaService.handleGetSiteAreaConsumption.bind(this), ServerAction.SITE_AREA_CONSUMPTION, req, res, next);
+ });
+ }
+
+ private buildRouteUpdateSiteArea(): void {
+ this.router.put(`/${ServerRoute.REST_SITE_AREA}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.body.id = req.params.id;
+ await RouterUtils.handleServerAction(SiteAreaService.handleUpdateSiteArea.bind(this), ServerAction.SITE_AREA_UPDATE, req, res, next);
+ });
+ }
+
+ private buildRouteDeleteSiteArea(): void {
+ this.router.delete(`/${ServerRoute.REST_SITE_AREA}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.query.ID = req.params.id;
+ await RouterUtils.handleServerAction(SiteAreaService.handleDeleteSiteArea.bind(this), ServerAction.SITE_AREA_DELETE, req, res, next);
+ });
+ }
}

MODIFY
test/api/client/SiteAreaApi.ts
test/api/client/SiteAreaApi.ts
@@ -8,7 +8,7 @@ export default class SiteAreaApi extends CrudApi {
super(authenticatedApi);
}
- public async readById(id) {
+ public async readById(id: string) {
return super.readById(id, this.buildRestEndpointUrl(ServerRoute.REST_SITE_AREA, { id }));
}
@@ -30,19 +30,18 @@ export default class SiteAreaApi extends CrudApi {
}
public async update(data) {
- return super.update(data, '/client/api/SiteAreaUpdate');
+ return super.update(data, this.buildRestEndpointUrl(ServerRoute.REST_SITE_AREA, { id: data.id }));
}
public async delete(id) {
- return super.delete(id, '/client/api/SiteAreaDelete');
+ return super.delete(id, this.buildRestEndpointUrl(ServerRoute.REST_SITE_AREA, { id }));
}
- public async readConsumption(SiteAreaId, StartDate, EndDate) {
+ public async readConsumption(SiteAreaId: string, StartDate: Date, EndDate: Date) {
return super.read({
- SiteAreaID: SiteAreaId,
StartDate: StartDate,
EndDate: EndDate
- }, '/client/api/SiteAreaConsumption');
+ }, this.buildRestEndpointUrl(ServerRoute.REST_SITE_AREA_CONSUMPTION, { id: SiteAreaId }));
}
public async assignChargingStations(SiteAreaId, ChargingStationIDs) {

Added getConsumption/update/delete