remarks from reviewer
MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
}
}
},
- "/api/charging-stations/{id}/cancel/reservation": {
+ "/api/charging-stations/{id}/reservation/cancel": {
"put": {
"security": [
{

RENAME
src/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-cancel-reservation.json
src/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-reservation-cancel.json
MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -1114,19 +1114,10 @@ export default class ChargingStationService {
}
public static async handleCancelReservation(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
- // Check auth
- if (!await Authorizations.canListChargingStations(req.user)) {
- throw new AppAuthError({
- errorCode: HTTPAuthError.FORBIDDEN,
- user: req.user,
- action: Action.LIST, entity: Entity.CHARGING_STATIONS,
- module: MODULE_NAME, method: 'handleCancelReservation'
- });
- }
// Request assembly
req.body.chargingStationID = req.params.id;
// Filter
- const filteredRequest = ChargingStationValidator.getInstance().validateChargingStationActionCancelReservationReq(req.body);
+ const filteredRequest = ChargingStationValidator.getInstance().validateChargingStationActionReservationCancelReq(req.body);
// Get the Charging station
const chargingStation = await UtilsService.checkAndGetChargingStationAuthorization(
req.tenant, req.user, filteredRequest.chargingStationID, action, null, { withSite: true, withSiteArea: true });

MODIFY
src/server/rest/v1/validator/ChargingStationValidator.ts
src/server/rest/v1/validator/ChargingStationValidator.ts
-import { HttpChargingProfilesRequest, HttpChargingStationCancelReservationRequest, HttpChargingStationChangeAvailabilityRequest, HttpChargingStationChangeConfigurationRequest, HttpChargingStationClearCacheRequest, HttpChargingStationCommandDataTransferRequest, HttpChargingStationCommandGetConfigurationRequest, HttpChargingStationCommandRequest, HttpChargingStationCommandUnlockConnectorRequest, HttpChargingStationConnectorRequest, HttpChargingStationGetCompositeScheduleRequest, HttpChargingStationGetDiagnosticsRequest, HttpChargingStationGetFirmwareRequest, HttpChargingStationLimitPowerRequest, HttpChargingStationOcppParametersRequest, HttpChargingStationOcppRequest, HttpChargingStationParamsUpdateRequest, HttpChargingStationRequest, HttpChargingStationReserveNowRequest, HttpChargingStationResetRequest, HttpChargingStationStartTransactionRequest, HttpChargingStationStopTransactionRequest, HttpChargingStationUpdateFirmwareRequest, HttpChargingStationsInErrorRequest, HttpChargingStationsRequest, HttpDownloadQrCodeRequest, HttpTriggerSmartChargingRequest } from '../../../../types/requests/HttpChargingStationRequest';
+import { HttpChargingProfilesRequest, HttpChargingStationChangeAvailabilityRequest, HttpChargingStationChangeConfigurationRequest, HttpChargingStationClearCacheRequest, HttpChargingStationCommandDataTransferRequest, HttpChargingStationCommandGetConfigurationRequest, HttpChargingStationCommandRequest, HttpChargingStationCommandUnlockConnectorRequest, HttpChargingStationConnectorRequest, HttpChargingStationGetCompositeScheduleRequest, HttpChargingStationGetDiagnosticsRequest, HttpChargingStationGetFirmwareRequest, HttpChargingStationLimitPowerRequest, HttpChargingStationOcppParametersRequest, HttpChargingStationOcppRequest, HttpChargingStationParamsUpdateRequest, HttpChargingStationRequest, HttpChargingStationReservationCancelRequest, HttpChargingStationReserveNowRequest, HttpChargingStationResetRequest, HttpChargingStationStartTransactionRequest, HttpChargingStationStopTransactionRequest, HttpChargingStationUpdateFirmwareRequest, HttpChargingStationsInErrorRequest, HttpChargingStationsRequest, HttpDownloadQrCodeRequest, HttpTriggerSmartChargingRequest } from '../../../../types/requests/HttpChargingStationRequest';
import { ChargingProfile } from '../../../../types/ChargingProfile';
import { ChargingStationTemplate } from '../../../../types/ChargingStation';
@@ -17,7 +17,7 @@ export default class ChargingStationValidator extends SchemaValidator {
private chargingStationActionAvailabilityChange: Schema;
private chargingStationActionChangeConfiguration: Schema;
private chargingStationActionCacheClear: Schema;
- private chargingStationActionCancelReservation: Schema;
+ private chargingStationActionReservationCancel: Schema;
private chargingStationActionDataTransfer: Schema;
private chargingStationActionTransactionStart: Schema;
private chargingStationActionTransactionStop: Schema;
@@ -54,7 +54,7 @@ export default class ChargingStationValidator extends SchemaValidator {
this.chargingStationActionAvailabilityChange = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-availability-change.json`, 'utf8'));
this.chargingStationActionChangeConfiguration = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-configuration-change.json`, 'utf8'));
this.chargingStationActionCacheClear = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-cache-clear.json`, 'utf8'));
- this.chargingStationActionCancelReservation = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-cancel-reservation.json`, 'utf8'));
+ this.chargingStationActionReservationCancel = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-reservation-cancel.json`, 'utf8'));
this.chargingStationActionDataTransfer = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-data-transfer.json`, 'utf8'));
this.chargingStationActionTransactionStart = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-transaction-start.json`, 'utf8'));
this.chargingStationActionTransactionStop = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/chargingstation/chargingstation-action-transaction-stop.json`, 'utf8'));
@@ -124,8 +124,8 @@ export default class ChargingStationValidator extends SchemaValidator {
return this.validate('validateChargingStationActionCacheClearReq', this.chargingStationActionCacheClear, data);
}
- public validateChargingStationActionCancelReservationReq(data: unknown): HttpChargingStationCancelReservationRequest {
- return this.validate('validateChargingStationActionCancelReservationReq', this.chargingStationActionCancelReservation, data);
+ public validateChargingStationActionReservationCancelReq(data: unknown): HttpChargingStationReservationCancelRequest {
+ return this.validate('validateChargingStationActionReservationCancelReq', this.chargingStationActionReservationCancel, data);
}
public validateChargingStationActionTransactionStartReq(data: unknown): HttpChargingStationStartTransactionRequest {

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -36,8 +36,8 @@ export enum ServerAction {
CHARGING_STATION_UPDATE_PARAMS = 'RestChargingStationUpdateParams',
CHARGING_STATION_LIMIT_POWER = 'RestChargingStationLimitPower',
CHARGING_STATION_DELETE = 'RestChargingStationDelete',
- CHARGING_STATION_RESERVE_NOW = 'RestChargingStationReserveNpw',
- CHARGING_STATION_CANCEL_RESERVATION = 'RestChargingStationCancelReservation',
+ CHARGING_STATION_RESERVE_NOW = 'RestChargingStationReserveNow',
+ CHARGING_STATION_CANCEL_RESERVATION = 'RestChargingStationReservationCancel',
CHECK_SMART_CHARGING_CONNECTION = 'RestCheckSmartChargingConnection',
TRIGGER_SMART_CHARGING = 'RestTriggerSmartCharging',

MODIFY
src/types/requests/HttpChargingStationRequest.ts
src/types/requests/HttpChargingStationRequest.ts
@@ -133,7 +133,7 @@ export interface HttpChargingStationClearCacheRequest {
chargingStationID: string
}
-export interface HttpChargingStationCancelReservationRequest {
+export interface HttpChargingStationReservationCancelRequest {
chargingStationID: string,
args: {
reservationId: number;

remarks from reviewer