refactor: add type parameter to OCPP stack for request and response
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / OCPPResponseService.ts
index b720c0f136e6c7cf0fac74de9c39b4153ee2a069..7934500ed3ebd7612cfb05ad58b0c68699396dc1 100644 (file)
@@ -31,11 +31,14 @@ export abstract class OCPPResponseService {
       multipleOfPrecision: 2,
     });
     ajvFormats(this.ajv);
-    this.responseHandler = this.responseHandler.bind(this) as (
+    this.responseHandler = this.responseHandler.bind(this) as <
+      ReqType extends JsonType,
+      ResType extends JsonType,
+    >(
       chargingStation: ChargingStation,
       commandName: RequestCommand,
-      payload: JsonType,
-      requestPayload: JsonType,
+      payload: ResType,
+      requestPayload: ReqType,
     ) => Promise<void>;
     this.validateResponsePayload = this.validateResponsePayload.bind(this) as <T extends JsonType>(
       chargingStation: ChargingStation,
@@ -81,10 +84,10 @@ export abstract class OCPPResponseService {
     /* This is intentional */
   }
 
-  public abstract responseHandler(
+  public abstract responseHandler<ReqType extends JsonType, ResType extends JsonType>(
     chargingStation: ChargingStation,
     commandName: RequestCommand,
-    payload: JsonType,
-    requestPayload: JsonType,
+    payload: ResType,
+    requestPayload: ReqType,
   ): Promise<void>;
 }