+ private async handleAddChargingStations (
+ messageId?: string,
+ procedureName?: ProcedureName,
+ requestPayload?: RequestPayload
+ ): Promise<ResponsePayload> {
+ const { template, numberOfStations } = requestPayload as {
+ template: string
+ numberOfStations: number
+ }
+ if (!this.uiServer.chargingStationTemplates.has(template)) {
+ return {
+ status: ResponseStatus.FAILURE,
+ errorMessage: `Template '${template}' not found`
+ } satisfies ResponsePayload
+ }
+ for (let i = 0; i < numberOfStations; i++) {
+ try {
+ await Bootstrap.getInstance().addChargingStation(
+ Bootstrap.getInstance().getLastIndex(template) + 1,
+ `${template}.json`
+ )
+ } catch (error) {
+ return {
+ status: ResponseStatus.FAILURE,
+ errorMessage: (error as Error).message,
+ errorStack: (error as Error).stack
+ } satisfies ResponsePayload
+ }
+ }
+ return {
+ status: ResponseStatus.SUCCESS
+ }
+ }
+