Renamed class' file + Small changes
MODIFY
src/integration/car-connector/CarConnectorFactory.ts
src/integration/car-connector/CarConnectorFactory.ts
import { CarConnectorConnectionType, CarConnectorSetting } from '../../types/Setting';
-import CarConnectorIntegration from './carConnectorIntegration';
-import Logging from '../../utils/Logging';
-import MercedesCarConnectorIntegration from './mercedes-connector/mercedesCarConnectorIntegration';
-import { ServerAction } from '../../types/Server';
+import CarConnectorIntegration from './CarConnectorIntegration';
+import MercedesCarConnectorIntegration from './mercedes-connector/MMercedesCarConnectorIntegration';
import SettingStorage from '../../storage/mongodb/SettingStorage';
import Tenant from '../../types/Tenant';
import TenantComponents from '../../types/TenantComponents';
import Utils from '../../utils/Utils';
-const MODULE_NAME = 'CarConnectorFactory';
-
export default class CarConnectorFactory {
static async getCarConnectorImpl(tenant: Tenant, connectorId: string): Promise<CarConnectorIntegration<CarConnectorSetting>> {
// Check if car connector component is active
@@ -29,12 +25,6 @@ export default class CarConnectorFactory {
return carConnectorIntegrationImpl;
}
}
- await Logging.logDebug({
- tenantID: tenant.id,
- action: ServerAction.CAR_CONNECTOR,
- module: MODULE_NAME, method: 'getCarConnectorImpl',
- message: 'Car connector settings are not configured'
- });
}
return null;
}

MODIFY
src/integration/car-connector/CarConnectorIntegration.ts
src/integration/car-connector/CarConnectorIntegration.ts
@@ -16,5 +16,5 @@ export default abstract class CarConnectorIntegration<T extends CarConnectorSett
public abstract createConnection(userID: string, data: unknown): Promise<Connection>;
- public abstract getCurrentSOC(userID: string): Promise<number>;
+ public abstract getCurrentSoC(userID: string): Promise<number>;
}

RENAME
src/integration/car-connector/mercedes-connector/mercedesCarConnectorIntegration.ts
src/integration/car-connector/mercedes-connector/MMercedesCarConnectorIntegration.ts
@@ -4,7 +4,7 @@ import axiosRetry, { IAxiosRetryConfig } from 'axios-retry';
import AxiosFactory from '../../../utils/AxiosFactory';
import BackendError from '../../../exception/BackendError';
-import CarConnectorIntegration from '../carConnectorIntegration';
+import CarConnectorIntegration from '../CarConnectorIntegration';
import Connection from '../../../types/Connection';
import ConnectionStorage from '../../../storage/mongodb/ConnectionStorage';
import Constants from '../../../utils/Constants';
@@ -17,8 +17,6 @@ import moment from 'moment-timezone';
import querystring from 'querystring';
const MODULE_NAME = 'MercedesCarConnectorIntegration';
-const CONNECTOR_ID = CarConnectorConnectionType.MERCEDES;
-
export default class MercedesCarConnectorIntegration extends CarConnectorIntegration<CarConnectorSetting> {
private axiosInstance: AxiosInstance;
private readonly axiosRetryConfiguration: IAxiosRetryConfig = {
@@ -106,7 +104,7 @@ export default class MercedesCarConnectorIntegration extends CarConnectorIntegra
action: ServerAction.CAR_CONNECTOR, message: 'Mercedes access token granted'
});
// Check first
- let connection = await ConnectionStorage.getConnectionByConnectorIdAndUserId(this.tenant, CONNECTOR_ID, userID);
+ let connection = await ConnectionStorage.getConnectionByConnectorIdAndUserId(this.tenant, CarConnectorConnectionType.MERCEDES, userID);
if (connection) {
// Update
connection.data = response.data;
@@ -117,7 +115,7 @@ export default class MercedesCarConnectorIntegration extends CarConnectorIntegra
connection = {
data: response.data,
userId: userID,
- connectorId: CONNECTOR_ID,
+ connectorId: CarConnectorConnectionType.MERCEDES,
createdAt: new Date(),
validUntil: this.computeValidUntilAt(response)
};
@@ -138,7 +136,7 @@ export default class MercedesCarConnectorIntegration extends CarConnectorIntegra
}
}
- public async getCurrentSOC(userID: string): Promise<number> {
+ public async getCurrentSoC(userID: string): Promise<number> {
// To be implemented
const connection = await this.getRefreshedConnection(userID);
return 0;
@@ -206,11 +204,11 @@ export default class MercedesCarConnectorIntegration extends CarConnectorIntegra
}
private async getRefreshedConnection(userID: string): Promise<Connection> {
- let connection = await ConnectionStorage.getConnectionByConnectorIdAndUserId(this.tenant, CONNECTOR_ID, userID);
+ let connection = await ConnectionStorage.getConnectionByConnectorIdAndUserId(this.tenant, CarConnectorConnectionType.MERCEDES, userID);
if (!connection) {
throw new BackendError({
source: Constants.CENTRAL_SERVER,
- message: `The user does not have a connection to connector '${CONNECTOR_ID}'`,
+ message: `The user does not have a connection to connector '${CarConnectorConnectionType.MERCEDES}'`,
module: MODULE_NAME,
method: 'getRefreshedConnection',
action: ServerAction.CAR_CONNECTOR,

Renamed class' file + Small changes