refactor: factor out default OCPP request params value
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 26 May 2023 22:27:06 +0000 (00:27 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 26 May 2023 22:27:06 +0000 (00:27 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ocpp/OCPPRequestService.ts

index d2122a65ad2f281c7a9de9cd6b9afcbbeeb87a9d..2a6a8c1884898d9d3c123cd071cda6f88c9befe0 100644 (file)
@@ -27,6 +27,12 @@ import { Constants, ErrorUtils, Utils, logger } from '../../utils';
 
 const moduleName = 'OCPPRequestService';
 
+const defaultRequestParams: RequestParams = {
+  skipBufferingOnError: false,
+  triggerMessage: false,
+  throwError: false,
+};
+
 export abstract class OCPPRequestService {
   private static instance: OCPPRequestService | null = null;
   private readonly version: OCPPVersion;
@@ -158,14 +164,10 @@ export abstract class OCPPRequestService {
     messageId: string,
     messagePayload: JsonType,
     commandName: RequestCommand,
-    params: RequestParams = {
-      skipBufferingOnError: false,
-      triggerMessage: false,
-      throwError: false,
-    }
+    params: RequestParams = defaultRequestParams
   ): Promise<ResponseType> {
     params = {
-      ...{ skipBufferingOnError: false, triggerMessage: false, throwError: false },
+      ...defaultRequestParams,
       ...params,
     };
     try {
@@ -264,14 +266,10 @@ export abstract class OCPPRequestService {
     messagePayload: JsonType | OCPPError,
     messageType: MessageType,
     commandName: RequestCommand | IncomingRequestCommand,
-    params: RequestParams = {
-      skipBufferingOnError: false,
-      triggerMessage: false,
-      throwError: false,
-    }
+    params: RequestParams = defaultRequestParams
   ): Promise<ResponseType> {
     params = {
-      ...{ skipBufferingOnError: false, triggerMessage: false, throwError: false },
+      ...defaultRequestParams,
       ...params,
     };
     if (