Added getImage/assign/unassign-chargingstations endpoints
MODIFY
src/server/rest/v1/router/api/SiteAreaRouter.ts
src/server/rest/v1/router/api/SiteAreaRouter.ts
@@ -19,6 +19,9 @@ export default class SiteAreaRouter {
this.buildRouteGetSiteAreaConsumption();
this.buildRouteUpdateSiteArea();
this.buildRouteDeleteSiteArea();
+ this.buildRouteGetSiteAreaImage();
+ this.buildRouteAssignChargingStationsToSiteArea();
+ this.buildRouteRemoveChargingStationsFromSiteArea();
return this.router;
}
@@ -61,4 +64,25 @@ export default class SiteAreaRouter {
await RouterUtils.handleServerAction(SiteAreaService.handleDeleteSiteArea.bind(this), ServerAction.SITE_AREA_DELETE, req, res, next);
});
}
+
+ private buildRouteGetSiteAreaImage(): void {
+ this.router.get(`/${ServerRoute.REST_SITE_AREA}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.query.ID = req.params.id;
+ await RouterUtils.handleServerAction(SiteAreaService.handleGetSiteAreaImage.bind(this), ServerAction.SITE_AREA_IMAGE, req, res, next);
+ });
+ }
+
+ private buildRouteAssignChargingStationsToSiteArea(): void {
+ this.router.put(`/${ServerRoute.REST_SITE_AREA_ASSIGN_CHARGING_STATIONS}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.body.siteAreaID = req.params.id;
+ await RouterUtils.handleServerAction(SiteAreaService.handleAssignChargingStationsToSiteArea.bind(this), ServerAction.ADD_CHARGING_STATIONS_TO_SITE_AREA, req, res, next);
+ });
+ }
+
+ private buildRouteRemoveChargingStationsFromSiteArea(): void {
+ this.router.put(`/${ServerRoute.REST_SITE_AREA_REMOVE_CHARGING_STATIONS}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.body.siteAreaID = req.params.id;
+ await RouterUtils.handleServerAction(SiteAreaService.handleAssignChargingStationsToSiteArea.bind(this), ServerAction.REMOVE_CHARGING_STATIONS_FROM_SITE_AREA, req, res, next);
+ });
+ }
}

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -604,6 +604,8 @@ export enum ServerRoute {
REST_SITE_AREA = 'site-areas/:id',
REST_SITE_AREA_CONSUMPTION = 'site-areas/:id/consumptions',
REST_SITE_AREA_IMAGE = 'site-areas/:id/image',
+ REST_SITE_AREA_ASSIGN_CHARGING_STATIONS = 'site-areas/:id/charging-stations/assign',
+ REST_SITE_AREA_REMOVE_CHARGING_STATIONS = 'site-areas/:id/charging-stations/unassign',
// BILLING URLs for CRUD operations on PAYMENT METHODS
REST_BILLING_PAYMENT_METHODS = 'users/:userID/payment-methods',

MODIFY
test/api/client/SiteAreaApi.ts
test/api/client/SiteAreaApi.ts
@@ -44,18 +44,16 @@ export default class SiteAreaApi extends CrudApi {
}, this.buildRestEndpointUrl(ServerRoute.REST_SITE_AREA_CONSUMPTION, { id: SiteAreaId }));
}
- public async assignChargingStations(SiteAreaId, ChargingStationIDs) {
- return super.create({
- siteAreaID: SiteAreaId,
+ public async assignChargingStations(siteAreaId: string, ChargingStationIDs: string[]) {
+ return super.update({
chargingStationIDs: ChargingStationIDs
- }, '/client/api/AddChargingStationsToSiteArea');
+ }, this.buildRestEndpointUrl(ServerRoute.REST_SITE_AREA_ASSIGN_CHARGING_STATIONS, { id: siteAreaId }));
}
- public async removeChargingStations(SiteAreaId, ChargingStationIDs) {
- return super.create({
- siteAreaID: SiteAreaId,
+ public async removeChargingStations(siteAreaId: string, ChargingStationIDs: string[]) {
+ return super.update({
chargingStationIDs: ChargingStationIDs
- }, '/client/api/RemoveChargingStationsFromSiteArea');
+ }, this.buildRestEndpointUrl(ServerRoute.REST_SITE_AREA_REMOVE_CHARGING_STATIONS, { id: siteAreaId }));
}
public async assignAssets(SiteAreaId, ChargingStationIDs) {

Added getImage/assign/unassign-chargingstations endpoints