Add status notification support to trigger message OCPP command
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / 1.6 / OCPP16RequestService.ts
index 3d91576bb5b85b41e667e5354174ae2d815ac119..75e113d21162efaecb375b069ab60e124552242c 100644 (file)
@@ -9,7 +9,7 @@ import { OCPP16ServiceUtils } from './OCPP16ServiceUtils';
 import OCPPError from '../../../exception/OCPPError';
 import OCPPRequestService from '../OCPPRequestService';
 import type OCPPResponseService from '../OCPPResponseService';
-import { SendParams } from '../../../types/ocpp/Requests';
+import { RequestParams } from '../../../types/ocpp/Requests';
 import Utils from '../../../utils/Utils';
 
 const moduleName = 'OCPP16RequestService';
@@ -22,28 +22,28 @@ export default class OCPP16RequestService extends OCPPRequestService {
     super(chargingStation, ocppResponseService);
   }
 
-  public async sendMessageHandler<Response extends JsonType>(
+  public async requestHandler<Request extends JsonType, Response extends JsonType>(
     commandName: OCPP16RequestCommand,
     commandParams?: JsonType,
-    params?: SendParams
+    params?: RequestParams
   ): Promise<Response> {
     if (Object.values(OCPP16RequestCommand).includes(commandName)) {
       return (await this.sendMessage(
         Utils.generateUUID(),
-        this.buildCommandPayload(commandName, commandParams),
+        this.buildRequestPayload<Request>(commandName, commandParams),
         commandName,
         params
       )) as unknown as Response;
     }
     throw new OCPPError(
       ErrorType.NOT_SUPPORTED,
-      `${moduleName}.sendMessageHandler: Unsupported OCPP command ${commandName}`,
+      `${moduleName}.requestHandler: Unsupported OCPP command ${commandName}`,
       commandName,
       { commandName }
     );
   }
 
-  private buildCommandPayload<Request extends JsonType>(
+  private buildRequestPayload<Request extends JsonType>(
     commandName: OCPP16RequestCommand,
     commandParams?: JsonType
   ): Request {
@@ -133,7 +133,7 @@ export default class OCPP16RequestService extends OCPPRequestService {
         throw new OCPPError(
           ErrorType.NOT_SUPPORTED,
           // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
-          `${moduleName}.buildCommandPayload: Unsupported OCPP command: ${commandName}`,
+          `${moduleName}.buildRequestPayload: Unsupported OCPP command: ${commandName}`,
           commandName,
           { commandName }
         );