From: Jérôme Benoit Date: Fri, 26 May 2023 22:27:06 +0000 (+0200) Subject: refactor: factor out default OCPP request params value X-Git-Tag: v1.2.15~38 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=b9da1bc288a2a6ffccfbca6cd19aa195bc6ccfbf;p=e-mobility-charging-stations-simulator.git refactor: factor out default OCPP request params value Signed-off-by: Jérôme Benoit --- 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 (