Added getImage/assign/unassign-CS/assets doc
MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
}
}
},
+ "/api/site-areas/{id}/image": {
+ "get": {
+ "description": "Retrieve Site Area's image",
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/siteAreaID"
+ },
+ {
+ "in": "query",
+ "name": "TenantID",
+ "description": "Tenant ID",
+ "required": true,
+ "schema": {
+ "type": "boolean"
+ }
+ }
+ ],
+ "tags": [
+ "Site Area"
+ ],
+ "responses": {
+ "200": {
+ "description": "Return the image"
+ },
+ "401": {
+ "$ref": "#/components/responses/UnauthorizedError"
+ },
+ "403": {
+ "$ref": "#/components/responses/ForbiddenError"
+ },
+ "500": {
+ "$ref": "#/components/responses/BackendError"
+ },
+ "550": {
+ "$ref": "#/components/responses/ResourceDoesNotExists"
+ }
+ }
+ }
+ },
"/api/site-areas/{id}/consumptions": {
"get": {
"description": "Retrieve Site Area consumptions",
}
}
},
+ "/api/site-areas/{id}/charging-stations/assign": {
+ "put": {
+ "description": "Assign charging stations to a Site Area",
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/siteAreaID"
+ }
+ ],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "chargingStationIDs": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "tags": [
+ "Site Area"
+ ],
+ "responses": {
+ "200": {
+ "description": "Charging stations assigned successfully",
+ "content": {
+ "application/json": {
+ "example": {
+ "status": "Success"
+ }
+ }
+ }
+ },
+ "401": {
+ "$ref": "#/components/responses/UnauthorizedError"
+ },
+ "403": {
+ "$ref": "#/components/responses/ForbiddenError"
+ },
+ "500": {
+ "$ref": "#/components/responses/BackendError"
+ },
+ "550": {
+ "$ref": "#/components/responses/ResourceDoesNotExists"
+ }
+ }
+ }
+ },
+ "/api/site-areas/{id}/charging-stations/unassign": {
+ "put": {
+ "description": "Unassign charging stations from a Site Area",
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/siteAreaID"
+ }
+ ],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "chargingStationIDs": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "tags": [
+ "Site Area"
+ ],
+ "responses": {
+ "200": {
+ "description": "Charging stations unassigned successfully",
+ "content": {
+ "application/json": {
+ "example": {
+ "status": "Success"
+ }
+ }
+ }
+ },
+ "401": {
+ "$ref": "#/components/responses/UnauthorizedError"
+ },
+ "403": {
+ "$ref": "#/components/responses/ForbiddenError"
+ },
+ "500": {
+ "$ref": "#/components/responses/BackendError"
+ },
+ "550": {
+ "$ref": "#/components/responses/ResourceDoesNotExists"
+ }
+ }
+ }
+ },
+ "/api/site-areas/{id}/assets/assign": {
+ "put": {
+ "description": "Assign assets to a Site Area",
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/siteAreaID"
+ }
+ ],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "assetIDs": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "tags": [
+ "Site Area"
+ ],
+ "responses": {
+ "200": {
+ "description": "Assets assigned successfully",
+ "content": {
+ "application/json": {
+ "example": {
+ "status": "Success"
+ }
+ }
+ }
+ },
+ "401": {
+ "$ref": "#/components/responses/UnauthorizedError"
+ },
+ "403": {
+ "$ref": "#/components/responses/ForbiddenError"
+ },
+ "500": {
+ "$ref": "#/components/responses/BackendError"
+ },
+ "550": {
+ "$ref": "#/components/responses/ResourceDoesNotExists"
+ }
+ }
+ }
+ },
+ "/api/site-areas/{id}/assets/unassign": {
+ "put": {
+ "description": "Unassign assets from a Site Area",
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/siteAreaID"
+ }
+ ],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "assetIDs": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "tags": [
+ "Site Area"
+ ],
+ "responses": {
+ "200": {
+ "description": "Charging stations unassigned successfully",
+ "content": {
+ "application/json": {
+ "example": {
+ "status": "Success"
+ }
+ }
+ }
+ },
+ "401": {
+ "$ref": "#/components/responses/UnauthorizedError"
+ },
+ "403": {
+ "$ref": "#/components/responses/ForbiddenError"
+ },
+ "500": {
+ "$ref": "#/components/responses/BackendError"
+ },
+ "550": {
+ "$ref": "#/components/responses/ResourceDoesNotExists"
+ }
+ }
+ }
+ },
"/auth/signin": {
"post": {
"description": "Sign in",

MODIFY
src/server/rest/v1/router/api/SiteAreaRouter.ts
src/server/rest/v1/router/api/SiteAreaRouter.ts
@@ -22,6 +22,8 @@ export default class SiteAreaRouter {
this.buildRouteGetSiteAreaImage();
this.buildRouteAssignChargingStationsToSiteArea();
this.buildRouteRemoveChargingStationsFromSiteArea();
+ this.buildRouteAssignAssetsToSiteArea();
+ this.buildRouteRemoveAssetsToSiteArea();
return this.router;
}
@@ -66,7 +68,7 @@ export default class SiteAreaRouter {
}
private buildRouteGetSiteAreaImage(): void {
- this.router.get(`/${ServerRoute.REST_SITE_AREA}`, async (req: Request, res: Response, next: NextFunction) => {
+ this.router.get(`/${ServerRoute.REST_SITE_AREA_IMAGE}`, 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);
});
@@ -85,4 +87,18 @@ export default class SiteAreaRouter {
await RouterUtils.handleServerAction(SiteAreaService.handleAssignChargingStationsToSiteArea.bind(this), ServerAction.REMOVE_CHARGING_STATIONS_FROM_SITE_AREA, req, res, next);
});
}
+
+ private buildRouteAssignAssetsToSiteArea(): void {
+ this.router.put(`/${ServerRoute.REST_SITE_AREA_ASSIGN_ASSETS}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.body.siteAreaID = req.params.id;
+ await RouterUtils.handleServerAction(SiteAreaService.handleAssignAssetsToSiteArea.bind(this), ServerAction.ADD_ASSET_TO_SITE_AREA, req, res, next);
+ });
+ }
+
+ private buildRouteRemoveAssetsToSiteArea(): void {
+ this.router.put(`/${ServerRoute.REST_SITE_AREA_REMOVE_ASSETS}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.body.siteAreaID = req.params.id;
+ await RouterUtils.handleServerAction(SiteAreaService.handleAssignAssetsToSiteArea.bind(this), ServerAction.REMOVE_ASSET_TO_SITE_AREA, req, res, next);
+ });
+ }
}

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -606,6 +606,8 @@ export enum ServerRoute {
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',
+ REST_SITE_AREA_ASSIGN_ASSETS = 'site-areas/:id/assets/assign',
+ REST_SITE_AREA_REMOVE_ASSETS = 'site-areas/:id/assets/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
import AuthenticatedBaseApi from './utils/AuthenticatedBaseApi';
import CrudApi from './utils/CrudApi';
+import { Server } from 'http';
import { ServerRoute } from '../../../src/types/Server';
import TestConstants from './utils/TestConstants';
@@ -22,9 +23,8 @@ export default class SiteAreaApi extends CrudApi {
if (data.chargeBoxIDs) {
// Assign Chargers to Site
await super.create({
- siteAreaID: siteArea.data.id,
chargingStationIDs: data.chargeBoxIDs
- }, '/client/api/AddChargingStationsToSiteArea');
+ }, this.buildRestEndpointUrl(ServerRoute.REST_SITE_AREA_ASSIGN_CHARGING_STATIONS, { id: siteArea.data.id }));
}
return siteArea;
}
@@ -37,36 +37,26 @@ export default class SiteAreaApi extends CrudApi {
return super.delete(id, this.buildRestEndpointUrl(ServerRoute.REST_SITE_AREA, { id }));
}
- public async readConsumption(SiteAreaId: string, StartDate: Date, EndDate: Date) {
+ public async readConsumption(SiteAreaID: string, StartDate: Date, EndDate: Date) {
return super.read({
StartDate: StartDate,
EndDate: EndDate
- }, this.buildRestEndpointUrl(ServerRoute.REST_SITE_AREA_CONSUMPTION, { id: SiteAreaId }));
+ }, this.buildRestEndpointUrl(ServerRoute.REST_SITE_AREA_CONSUMPTION, { id: SiteAreaID }));
}
- public async assignChargingStations(siteAreaId: string, ChargingStationIDs: string[]) {
- return super.update({
- chargingStationIDs: ChargingStationIDs
- }, this.buildRestEndpointUrl(ServerRoute.REST_SITE_AREA_ASSIGN_CHARGING_STATIONS, { id: siteAreaId }));
+ public async assignChargingStations(siteAreaID: string, chargingStationIDs: string[]) {
+ return super.update({ chargingStationIDs }, this.buildRestEndpointUrl(ServerRoute.REST_SITE_AREA_ASSIGN_CHARGING_STATIONS, { id: siteAreaID }));
}
- public async removeChargingStations(siteAreaId: string, ChargingStationIDs: string[]) {
- return super.update({
- chargingStationIDs: ChargingStationIDs
- }, this.buildRestEndpointUrl(ServerRoute.REST_SITE_AREA_REMOVE_CHARGING_STATIONS, { id: siteAreaId }));
+ public async removeChargingStations(siteAreaID: string, chargingStationIDs: string[]) {
+ return super.update({ chargingStationIDs }, this.buildRestEndpointUrl(ServerRoute.REST_SITE_AREA_REMOVE_CHARGING_STATIONS, { id: siteAreaID }));
}
- public async assignAssets(SiteAreaId, ChargingStationIDs) {
- return super.create({
- siteAreaID: SiteAreaId,
- assetIDs: ChargingStationIDs
- }, '/client/api/AddAssetsToSiteArea');
+ public async assignAssets(siteAreaID: string, assetIDs: string[]) {
+ return super.update({ assetIDs }, this.buildRestEndpointUrl(ServerRoute.REST_SITE_AREA_ASSIGN_ASSETS, { id: siteAreaID }));
}
- public async removeAssets(SiteAreaId, ChargingStationIDs) {
- return super.create({
- siteAreaID: SiteAreaId,
- assetIDs: ChargingStationIDs
- }, '/client/api/RemoveAssetsFromSiteArea');
+ public async removeAssets(siteAreaID: string, assetIDs) {
+ return super.update({ assetIDs }, this.buildRestEndpointUrl(ServerRoute.REST_SITE_AREA_REMOVE_ASSETS, { id: siteAreaID }));
}
}

Added getImage/assign/unassign-CS/assets doc