From b9da1bc288a2a6ffccfbca6cd19aa195bc6ccfbf Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 27 May 2023 00:27:06 +0200 Subject: [PATCH] refactor: factor out default OCPP request params value MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../ocpp/OCPPRequestService.ts | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index d2122a65..2a6a8c18 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -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 { 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 { params = { - ...{ skipBufferingOnError: false, triggerMessage: false, throwError: false }, + ...defaultRequestParams, ...params, }; if ( -- 2.34.1