Added setting OICP/SapAnalytics/Billing schemas
ADD
src/assets/server/rest/v1/schemas/setting/setting-billing-set.json
+{
+ "$id": "setting-billing-set",
+ "title": "Set Billing Settings",
+ "type": "object",
+ "properties": {
+ "content": {
+ "type": "object",
+ "properties": {
+ "billing": {
+ "type": "object",
+ "properties": {
+ "isTransactionBillingActivated": {
+ "type": "boolean",
+ "sanitize": "mongo"
+ },
+ "immediateBillingAllowed": {
+ "type": "boolean",
+ "sanitize": "mongo"
+ },
+ "periodicBillingAllowed": {
+ "type": "boolean",
+ "sanitize": "mongo"
+ },
+ "taxID": {
+ "type": "string",
+ "sanitize": "mongo"
+ }
+ }
+ },
+ "type": {
+ "type": "string",
+ "sanitize": "mongo",
+ "enum": ["billing"]
+ }
+ },
+ "required": [
+ "type"
+ ]
+ },
+ "id": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "identifier": {
+ "type": "string",
+ "sanitize": "mongo",
+ "enum": ["billing"]
+ },
+ "sensitiveData": {
+ "type": "array",
+ "nullable": true,
+ "items": {
+ "type": "string",
+ "sanitize": "mongo"
+ }
+ }
+ },
+ "required": [
+ "id",
+ "identifier",
+ "content"
+ ]
+}

ADD
src/assets/server/rest/v1/schemas/setting/setting-oicp-set.json
+{
+ "$id": "setting-sac-set",
+ "title": "Set SAP Analytics Settings",
+ "type": "object",
+ "properties": {
+ "content": {
+ "type": "object",
+ "properties": {
+ "oicp": {
+ "type": "object",
+ "properties": {
+ "businessDetails": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "website": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "logo": {
+ "type": "object",
+ "properties": {
+ "url": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "thumbnail": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "category": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "type": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "width": {
+ "type": "number",
+ "sanitize": "mongo"
+ },
+ "height": {
+ "type": "number",
+ "sanitize": "mongo"
+ }
+ }
+ }
+ }
+ },
+ "cpo": {
+ "type": "object",
+ "properties": {
+ "countryCode": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "partyID": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "key": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "cert": {
+ "type": "string",
+ "sanitize": "mongo"
+ }
+ }
+ },
+ "emsp": {
+ "type": "object",
+ "properties": {
+ "countryCode": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "partyID": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "key": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "cert": {
+ "type": "string",
+ "sanitize": "mongo"
+ }
+ }
+ },
+ "currency": {
+ "type": "string",
+ "sanitize": "mongo"
+ }
+ }
+ },
+ "type": {
+ "type": "string",
+ "sanitize": "mongo",
+ "enum": ["oicp"]
+ }
+ },
+ "required": [
+ "type"
+ ]
+ },
+ "id": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "identifier": {
+ "type": "string",
+ "sanitize": "mongo",
+ "enum": ["oicp"]
+ },
+ "sensitiveData": {
+ "type": "array",
+ "nullable": true,
+ "items": {
+ "type": "string",
+ "sanitize": "mongo"
+ }
+ }
+ },
+ "required": [
+ "id",
+ "identifier",
+ "content"
+ ]
+}

ADD
src/assets/server/rest/v1/schemas/setting/setting-sac-set.json
+{
+ "$id": "setting-sac-set",
+ "title": "Set SAP Analytics Settings",
+ "type": "object",
+ "properties": {
+ "content": {
+ "type": "object",
+ "properties": {
+ "sac": {
+ "type": "object",
+ "properties": {
+ "mainUrl": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "timezone": {
+ "type": "string",
+ "sanitize": "mongo"
+ }
+ }
+ },
+ "type": {
+ "type": "string",
+ "sanitize": "mongo",
+ "enum": ["sac"]
+ }
+ },
+ "required": [
+ "type"
+ ]
+ },
+ "id": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "identifier": {
+ "type": "string",
+ "sanitize": "mongo",
+ "enum": ["sac"]
+ },
+ "sensitiveData": {
+ "type": "array",
+ "nullable": true,
+ "items": {
+ "type": "string",
+ "sanitize": "mongo"
+ }
+ }
+ },
+ "required": [
+ "id",
+ "identifier",
+ "content"
+ ]
+}

MODIFY
src/server/rest/v1/service/SettingService.ts
src/server/rest/v1/service/SettingService.ts
@@ -155,7 +155,7 @@ export default class SettingService {
});
}
// Filter
- const filteredRequest = SettingValidator.getInstance().validateSettingCreateReq(req.body);
+ const filteredRequest = SettingSecurity.filterSettingCreateRequest(req.body);
// Process the sensitive data if any
await Cypher.encryptSensitiveDataInJSON(req.tenant, filteredRequest);
// Update timestamp
@@ -177,13 +177,16 @@ export default class SettingService {
}
public static async handleUpdateSetting(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
- let filteredRequest: any;
+ let filteredRequest;
UtilsService.assertIdIsProvided(action, req.body.id, MODULE_NAME, 'handleUpdateSetting', req.user);
switch (req.body.identifier) {
// Filter
case IntegrationSettings.OCPI:
filteredRequest = SettingValidator.getInstance().validateSettingOCPISetReq(req.body);
break;
+ case IntegrationSettings.OICP:
+ filteredRequest = SettingValidator.getInstance().validateSettingOICPSetReq(req.body);
+ break;
case TechnicalSettings.CRYPTO:
filteredRequest = SettingValidator.getInstance().validateSettingCryptoSetReq(req.body);
break;
@@ -199,6 +202,9 @@ export default class SettingService {
case IntegrationSettings.PRICING:
filteredRequest = SettingValidator.getInstance().validateSettingPricingSetReq(req.body);
break;
+ case IntegrationSettings.SAC:
+ filteredRequest = SettingValidator.getInstance().validateSettingSacSetReq(req.body);
+ break;
default:
filteredRequest = SettingSecurity.filterSettingUpdateRequest(req.body);
await Logging.logDebug({

MODIFY
src/server/rest/v1/validator/SettingValidator.ts
src/server/rest/v1/validator/SettingValidator.ts
-import { HttpSettingCryptoSetRequest, HttpSettingOCPISetRequest, HttpSettingPricingSetRequest, HttpSettingRefundSetRequest, HttpSettingSmartChargingSetRequest, HttpSettingUserSetRequest } from '../../../../types/requests/HttpSettingRequest';
+import { HttpSettingBillingSetRequest, HttpSettingCryptoSetRequest, HttpSettingOCPISetRequest, HttpSettingOICPSetRequest, HttpSettingPricingSetRequest, HttpSettingRefundSetRequest, HttpSettingSacSetRequest, HttpSettingSmartChargingSetRequest, HttpSettingUserSetRequest } from '../../../../types/requests/HttpSettingRequest';
import Schema from '../../../../types/validator/Schema';
import SchemaValidator from '../../../../validator/SchemaValidator';
-import { Setting } from '../../../../types/Setting';
import fs from 'fs';
import global from '../../../../types/GlobalType';
export default class SettingValidator extends SchemaValidator {
private static instance: SettingValidator|null = null;
- private settingCreate: Schema;
private settingOCPISet: Schema;
private settingUserSet: Schema;
private settingSmartChargingSet: Schema;
private settingRefundSet: Schema;
private settingPricingSet: Schema;
private settingCryptoSet: Schema;
+ private settingSacSet: Schema;
+ private settingOICPSet: Schema;
+ private settingBillingSet: Schema;
private constructor() {
super('SettingValidator');
- this.settingCreate = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/setting/setting-create.json`, 'utf8'));
this.settingOCPISet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/setting/setting-ocpi-set.json`, 'utf8'));
this.settingSmartChargingSet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/setting/setting-smart-charging-set.json`, 'utf8'));
this.settingUserSet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/setting/setting-user-set.json`, 'utf8'));
this.settingRefundSet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/setting/setting-refund-set.json`, 'utf8'));
this.settingPricingSet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/setting/setting-pricing-set.json`, 'utf8'));
this.settingCryptoSet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/setting/setting-crypto-set.json`, 'utf8'));
+ this.settingSacSet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/setting/setting-sac-set.json`, 'utf8'));
+ this.settingOICPSet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/setting/setting-oicp-set.json`, 'utf8'));
+ this.settingBillingSet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/setting/setting-billing-set.json`, 'utf8'));
}
public static getInstance(): SettingValidator {
@@ -34,10 +37,6 @@ export default class SettingValidator extends SchemaValidator {
return SettingValidator.instance;
}
- public validateSettingCreateReq(data: Record<string, unknown>): Setting {
- return this.validate(this.settingCreate, data);
- }
-
public validateSettingOCPISetReq(data: Record<string, unknown>): HttpSettingOCPISetRequest {
return this.validate(this.settingOCPISet, data);
}
@@ -61,4 +60,16 @@ export default class SettingValidator extends SchemaValidator {
public validateSettingCryptoSetReq(data: Record<string, unknown>): HttpSettingCryptoSetRequest {
return this.validate(this.settingCryptoSet, data);
}
+
+ public validateSettingSacSetReq(data: Record<string, unknown>): HttpSettingSacSetRequest {
+ return this.validate(this.settingSacSet, data);
+ }
+
+ public validateSettingOICPSetReq(data: Record<string, unknown>): HttpSettingOICPSetRequest {
+ return this.validate(this.settingOICPSet, data);
+ }
+
+ public validateSettingBillingSetReq(data: Record<string, unknown>): HttpSettingBillingSetRequest {
+ return this.validate(this.settingBillingSet, data);
+ }
}

MODIFY
src/types/Setting.ts
src/types/Setting.ts
@@ -8,6 +8,8 @@ export enum TechnicalSettings {
export enum IntegrationSettings {
OCPI = 'ocpi',
+ OICP = 'oicp',
+ SAC = 'sapAnalytics',
SMART_CHARGING = 'smartCharging',
REFUND = 'refund',
PRICING = 'pricing',

MODIFY
src/types/requests/HttpSettingRequest.ts
src/types/requests/HttpSettingRequest.ts
@@ -46,6 +46,39 @@ export interface HttpSettingOCPISetRequest extends HttpSettingSetRequest {
}
}
+export interface HttpSettingOICPSetRequest extends HttpSettingSetRequest {
+ content: {
+ type: string,
+ ocpi: {
+ businessDetails: {
+ logo: {
+ category?: string,
+ height?: number,
+ thumbnail?: string,
+ type?: string,
+ url?: string,
+ width?: number
+ },
+ name: string,
+ website: string
+ },
+ cpo: {
+ countryCode: string,
+ partyID: string,
+ key: string,
+ cert: string
+ },
+ currency: string,
+ emsp: {
+ countryCode: string,
+ partyID: string,
+ key: string,
+ cert: string
+ }
+ }
+ }
+}
+
export interface HttpSettingUserSetRequest extends HttpSettingSetRequest {
content: {
type: string,
@@ -114,3 +147,25 @@ export interface HttpSettingCryptoSetRequest extends HttpSettingSetRequest {
}
}
}
+
+export interface HttpSettingSacSetRequest extends HttpSettingSetRequest {
+ content: {
+ type: string,
+ sac: {
+ mainUrl: string,
+ timezone: string
+ }
+ }
+}
+
+export interface HttpSettingBillingSetRequest extends HttpSettingSetRequest {
+ content: {
+ type: string,
+ billing: {
+ isTransactionBillingActivated: boolean,
+ immediateBillingAllowed: boolean,
+ periodicBillingAllowed: boolean,
+ taxID: string
+ }
+ }
+}

Added setting OICP/SapAnalytics/Billing schemas