Changed QR-Code generate / download
MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
}
}
},
- "/api/chargingstations/connectors/qrcode": {
- "post": {
+ "/api/chargingstations/{id}/connectors/{connectorId}/qrcode/generate": {
+ "get": {
"security": [
{
"bearerAuth": []
}
],
"description": "Generate connector's QRCode",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "type": "object",
- "properties": {
- "chargeBoxID": {
- "type": "string"
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/chargingStationID"
},
- "connectorID": {
- "type": "integer",
- "minimum": 1,
- "example": 1
- }
- }
- }
- }
+ {
+ "$ref": "#/components/parameters/connectorID"
}
- },
+ ],
"tags": [
"Charging Stations"
],
}
}
},
- "/api/chargingstations/{id}/connectors/{connectorId}/qrcode": {
+ "/api/chargingstations/{id}/connectors/{connectorId}/qrcode/download": {
"get": {
"security": [
{
},
{
"$ref": "#/components/parameters/connectorID"
- },
- {
- "$ref": "#/components/parameters/SiteAreaID"
- },
- {
- "$ref": "#/components/parameters/SiteID"
}
],
"tags": [

MODIFY
src/server/rest/v1/router/api/ChargingStationRouter.ts
src/server/rest/v1/router/api/ChargingStationRouter.ts
@@ -101,11 +101,21 @@ export default class ChargingStationRouter {
}
protected buildRouteChargingStationGenerateQRCode(): void {
- this.router.post(`/${ServerRoute.REST_CHARGING_STATIONS_QRCODE_GENERATE}`, async (req: Request, res: Response, next: NextFunction) => {
+ this.router.get(`/${ServerRoute.REST_CHARGING_STATIONS_QRCODE_GENERATE}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.query.ChargingStationID = req.params.id;
+ req.query.ConnectorID = req.params.connectorId;
await RouterUtils.handleServerAction(ChargingStationService.handleGenerateQrCodeForConnector.bind(this), ServerAction.GENERATE_QR_CODE_FOR_CONNECTOR, req, res, next);
});
}
+ protected buildRouteChargingStationDownloadQRCode(): void {
+ this.router.get(`/${ServerRoute.REST_CHARGING_STATIONS_QRCODE_DOWNLOAD}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.query.ChargingStationID = req.params.id;
+ req.query.ConnectorID = req.params.connectorId;
+ await RouterUtils.handleServerAction(ChargingStationService.handleDownloadQrCodesPdf.bind(this), ServerAction.CHARGING_STATION_DOWNLOAD_QR_CODE_PDF, req, res, next);
+ });
+ }
+
protected buildRouteChargingStationCompositeSchedule(): void {
this.router.get(`/${ServerRoute.REST_CHARGING_STATIONS_COMPOSITE_SCHEDULE}`, async (req: Request, res: Response, next: NextFunction) => {
req.query.chargeBoxID = req.params.id;
@@ -132,14 +142,6 @@ export default class ChargingStationRouter {
});
}
- protected buildRouteChargingStationDownloadQRCode(): void {
- this.router.get(`/${ServerRoute.REST_CHARGING_STATIONS_QRCODE_DOWNLOAD}`, async (req: Request, res: Response, next: NextFunction) => {
- req.query.ChargeBoxID = req.params.id;
- req.query.ConnectorID = req.params.connectorId;
- await RouterUtils.handleServerAction(ChargingStationService.handleDownloadQrCodesPdf.bind(this), ServerAction.CHARGING_STATION_DOWNLOAD_QR_CODE_PDF, req, res, next);
- });
- }
-
protected buildRouteChargingStationRequestOCPPParameters(): void {
this.router.post(`/${ServerRoute.REST_CHARGING_STATIONS_OCPP_PARAMETERS}`, async (req: Request, res: Response, next: NextFunction) => {
await RouterUtils.handleServerAction(ChargingStationService.handleRequestChargingStationOcppParameters.bind(this), ServerAction.CHARGING_STATION_REQUEST_OCPP_PARAMETERS, req, res, next);

MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -443,7 +443,7 @@ export default class ChargingStationService {
public static async handleGenerateQrCodeForConnector(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Filter
- const filteredRequest = ChargingStationSecurity.filterChargingStationConnectorRequest(req.body);
+ const filteredRequest = ChargingStationSecurity.filterChargingStationConnectorRequest(req.query);
// Check auth
if (!Authorizations.canReadChargingStation(req.user)) {
throw new AppAuthError({
@@ -451,25 +451,25 @@ export default class ChargingStationService {
user: req.user,
action: Action.READ, entity: Entity.CHARGING_STATION,
module: MODULE_NAME, method: 'handleGenerateQrCodeForConnector',
- value: filteredRequest.chargeBoxID
+ value: filteredRequest.ChargingStationID
});
}
// Check ChargeBoxID
- UtilsService.assertIdIsProvided(action, filteredRequest.chargeBoxID, MODULE_NAME, 'handleGenerateQrCodeForConnector', req.user);
+ UtilsService.assertIdIsProvided(action, filteredRequest.ChargingStationID, MODULE_NAME, 'handleGenerateQrCodeForConnector', req.user);
// Check ConnectorID
- UtilsService.assertIdIsProvided(action, filteredRequest.connectorID, MODULE_NAME, 'handleGenerateQrCodeForConnector', req.user);
+ UtilsService.assertIdIsProvided(action, filteredRequest.ConnectorID, MODULE_NAME, 'handleGenerateQrCodeForConnector', req.user);
// Get the Charging Station`
- const chargingStation: ChargingStation = await ChargingStationStorage.getChargingStation(req.user.tenantID, filteredRequest.chargeBoxID);
+ const chargingStation: ChargingStation = await ChargingStationStorage.getChargingStation(req.user.tenantID, filteredRequest.ChargingStationID);
// Found ChargingStation ?
- UtilsService.assertObjectExists(action, chargingStation, `ChargingStation '${filteredRequest.chargeBoxID}' does not exist`,
+ UtilsService.assertObjectExists(action, chargingStation, `ChargingStation '${filteredRequest.ChargingStationID}' does not exist`,
MODULE_NAME, 'handleGetChargingStationOcppParameters', req.user);
// Found Connector ?
- UtilsService.assertObjectExists(action, Utils.getConnectorFromID(chargingStation, filteredRequest.connectorID),
- `Connector ID '${filteredRequest.connectorID}' does not exist`,
+ UtilsService.assertObjectExists(action, Utils.getConnectorFromID(chargingStation, filteredRequest.ConnectorID),
+ `Connector ID '${filteredRequest.ConnectorID}' does not exist`,
MODULE_NAME, 'handleGetChargingStationOcppParameters', req.user);
const chargingStationQRCode: ChargingStationQRCode = {
- chargingStationID: filteredRequest.chargeBoxID,
- connectorID: filteredRequest.connectorID,
+ chargingStationID: filteredRequest.ChargingStationID,
+ connectorID: filteredRequest.ConnectorID,
endpoint: Utils.getChargingStationEndpoint(),
tenantName: req.user.tenantName,
tenantSubDomain: req.user.tenantSubdomain
@@ -840,7 +840,7 @@ export default class ChargingStationService {
// Filter
const filteredRequest = ChargingStationSecurity.filterDownloadQrCodesPdfRequest(req.query);
// Check
- if (!filteredRequest.SiteID && !filteredRequest.SiteAreaID && !filteredRequest.ChargeBoxID) {
+ if (!filteredRequest.SiteID && !filteredRequest.SiteAreaID && !filteredRequest.ChargingStationID) {
throw new AppError({
source: Constants.CENTRAL_SERVER,
errorCode: HTTPError.GENERAL_ERROR,
@@ -1384,8 +1384,7 @@ export default class ChargingStationService {
}
private static async getChargingStationsForQrCode(req: Request): Promise<DataResult<ChargingStation>> {
- return ChargingStationService.getChargingStations(req,
- ['id', 'connectors.connectorId', 'siteArea.name']);
+ return ChargingStationService.getChargingStations(req, ['id', 'connectors.connectorId', 'siteArea.name']);
}
private static async convertQrCodeToPDF(req: Request, pdfDocument: PDFKit.PDFDocument, chargingStations: ChargingStation[]): Promise<void> {

MODIFY
src/server/rest/v1/service/security/ChargingStationSecurity.ts
src/server/rest/v1/service/security/ChargingStationSecurity.ts
@@ -25,8 +25,8 @@ export default class ChargingStationSecurity {
public static filterChargingStationConnectorRequest(request: any): HttpChargingStationConnectorRequest {
return {
- chargeBoxID: sanitize(request.chargeBoxID),
- connectorID: Utils.convertToInt(sanitize(request.connectorID)),
+ ChargingStationID: sanitize(request.ChargingStationID),
+ ConnectorID: Utils.convertToInt(sanitize(request.ConnectorID)),
};
}
@@ -62,7 +62,7 @@ export default class ChargingStationSecurity {
public static filterDownloadQrCodesPdfRequest(request: any): HttpDownloadQrCodeRequest {
return {
- ChargeBoxID: request.ChargeBoxID ? sanitize(request.ChargeBoxID) : null,
+ ChargingStationID: request.ChargingStationID ? sanitize(request.ChargingStationID) : null,
ConnectorID: request.ConnectorID ? Utils.convertToInt(sanitize(request.ConnectorID)) : null,
SiteAreaID: request.SiteAreaID ? sanitize(request.SiteAreaID) : null,
SiteID: request.SiteID ? sanitize(request.SiteID) : null,

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -387,8 +387,8 @@ export enum ServerAction {
HTTP_ERROR = 'HttpError'
}
-export enum ServerRoute {
// RESTful API
+export enum ServerRoute {
REST_SIGNIN = 'signin',
REST_SIGNON = 'signon',
REST_SIGNOUT = 'signout',
@@ -406,8 +406,8 @@ export enum ServerRoute {
REST_CHARGING_STATIONS_REMOTE_START = 'chargingstations/remote/start',
REST_CHARGING_STATIONS_REMOTE_STOP = 'chargingstations/remote/stop',
REST_CHARGING_STATIONS_UNLOCK_CONNECTOR = 'chargingstations/connectors/unlock',
- REST_CHARGING_STATIONS_QRCODE_GENERATE = 'chargingstations/connectors/qrcode',
- REST_CHARGING_STATIONS_QRCODE_DOWNLOAD = 'chargingstations/:id/connectors/:connectorId/qrcode',
+ REST_CHARGING_STATIONS_QRCODE_GENERATE = 'chargingstations/:id/connectors/:connectorId/qrcode/generate',
+ REST_CHARGING_STATIONS_QRCODE_DOWNLOAD = 'chargingstations/:id/connectors/:connectorId/qrcode/download',
REST_CHARGING_STATION_CHECK_SMART_CHARGING_CONNECTION = 'chargingstations/smartcharging/checkconnection',
REST_CHARGING_STATIONS_COMPOSITE_SCHEDULE = 'chargingstations/:id/compositeschedule',
REST_CHARGING_STATIONS_DIAGNOSTICS = 'chargingstations/:id/diagnostics',

MODIFY
src/types/requests/HttpChargingStationRequest.ts
src/types/requests/HttpChargingStationRequest.ts
@@ -23,7 +23,7 @@ export interface HttpChargingProfilesRequest extends HttpDatabaseRequest {
}
export interface HttpDownloadQrCodeRequest {
- ChargeBoxID?: string;
+ ChargingStationID?: string;
ConnectorID?: number;
SiteID?: string;
SiteAreaID?: string;
@@ -71,8 +71,8 @@ export interface HttpChargingStationRequest {
}
export interface HttpChargingStationConnectorRequest {
- chargeBoxID: string;
- connectorID: number;
+ ChargingStationID: string;
+ ConnectorID: number;
}
export interface HttpChargingStationOcppParametersRequest {

Changed QR-Code generate / download