continue to Migrate Settings
ADD
src/assets/server/rest/v1/schemas/setting/setting-crypto-set.json
+{
+ "$id": "setting-crypto-set",
+ "title": "Set Crypto Settings",
+ "type": "object",
+ "properties": {
+ "content": {
+ "type": "object",
+ "properties": {
+ "crypto": {
+ "type": "object",
+ "properties": {
+ "key": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "keyProperties": {
+ "type": "object",
+ "properties": {
+ "blockCypher": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "blockSize": {
+ "type": "number",
+ "sanitize": "mongo"
+ },
+ "operationMode": {
+ "type": "string",
+ "sanitize": "mongo"
+ }
+ }
+ }
+ }
+ },
+ "type": {
+ "type": "string",
+ "sanitize": "mongo",
+ "enum": ["crypto"]
+ }
+ },
+ "required": [
+ "type"
+ ]
+ },
+ "id": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "identifier": {
+ "type": "string",
+ "sanitize": "mongo",
+ "enum": ["crypto"]
+ },
+ "sensitiveData": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "sanitize": "mongo"
+ }
+ }
+ },
+ "required": [
+ "id",
+ "identifier",
+ "content"
+ ]
+}

ADD
src/assets/server/rest/v1/schemas/setting/setting-pricing-set.json
+{
+ "$id": "setting-pricing-set",
+ "title": "Set Pricing Settings",
+ "type": "object",
+ "properties": {
+ "content": {
+ "type": "object",
+ "properties": {
+ "simple": {
+ "type": "object",
+ "properties": {
+ "price": {
+ "type": "number",
+ "sanitize": "mongo"
+ },
+ "currency": {
+ "type": "string",
+ "sanitize": "mongo"
+ }
+ }
+ },
+ "type": {
+ "type": "string",
+ "sanitize": "mongo",
+ "enum": ["simple"]
+ }
+ },
+ "required": [
+ "type"
+ ]
+ },
+ "id": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "identifier": {
+ "type": "string",
+ "sanitize": "mongo",
+ "enum": ["pricing"]
+ },
+ "sensitiveData": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "sanitize": "mongo"
+ }
+ }
+ },
+ "required": [
+ "id",
+ "identifier",
+ "content"
+ ]
+}

ADD
src/assets/server/rest/v1/schemas/setting/setting-refund-set.json
+{
+ "$id": "setting-refund-set",
+ "title": "Set Refund Settings",
+ "type": "object",
+ "properties": {
+ "content": {
+ "type": "object",
+ "properties": {
+ "concur": {
+ "type": "object",
+ "properties": {
+ "apiUrl": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "appUrl": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "authenticationUrl": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "clientId": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "clientSecret": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "expenseTypeCode": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "paymentTypeId": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "policyId": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "reportName": {
+ "type": "string",
+ "sanitize": "mongo"
+ }
+ }
+ },
+ "type": {
+ "type": "string",
+ "sanitize": "mongo",
+ "enum": ["concur"]
+ }
+ },
+ "required": [
+ "type",
+ "concur"
+ ]
+ },
+ "id": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "identifier": {
+ "type": "string",
+ "sanitize": "mongo",
+ "enum": ["refund"]
+ },
+ "sensitiveData": {
+ "type": "array",
+ "items": {
+ "type": "string",
+ "sanitize": "mongo"
+ }
+ }
+ },
+ "required": [
+ "id",
+ "identifier",
+ "content"
+ ]
+}

MODIFY
src/server/rest/v1/service/SettingService.ts
src/server/rest/v1/service/SettingService.ts
@@ -185,7 +185,7 @@ export default class SettingService {
filteredRequest = SettingValidator.getInstance().validateSettingOCPISetReq(req.body);
break;
case TechnicalSettings.CRYPTO:
- // filteredRequest = SettingValidator.getInstance().validateSettingCryptoSetReq(req.body);
+ filteredRequest = SettingValidator.getInstance().validateSettingCryptoSetReq(req.body);
break;
case TechnicalSettings.USER:
filteredRequest = SettingValidator.getInstance().validateSettingUserSetReq(req.body);
@@ -193,6 +193,12 @@ export default class SettingService {
case TechnicalSettings.SMART_CHARGING:
filteredRequest = SettingValidator.getInstance().validateSettingSmartChargingSetReq(req.body);
break;
+ case TechnicalSettings.REFUND:
+ filteredRequest = SettingValidator.getInstance().validateSettingRefundSetReq(req.body);
+ break;
+ case TechnicalSettings.PRICING:
+ filteredRequest = SettingValidator.getInstance().validateSettingPricingSetReq(req.body);
+ break;
default:
throw new AppError({
source: Constants.CENTRAL_SERVER,

MODIFY
src/server/rest/v1/validator/SettingValidator.ts
src/server/rest/v1/validator/SettingValidator.ts
-import { HttpSettingOCPISetRequest, HttpSettingSmartChargingSetRequest, HttpSettingUserSetRequest } from '../../../../types/requests/HttpSettingRequest';
+import { HttpSettingCryptoSetRequest, HttpSettingOCPISetRequest, HttpSettingPricingSetRequest, HttpSettingRefundSetRequest, HttpSettingSmartChargingSetRequest, HttpSettingUserSetRequest } from '../../../../types/requests/HttpSettingRequest';
import Schema from '../../../../types/validator/Schema';
import SchemaValidator from '../../../../validator/SchemaValidator';
@@ -10,12 +10,18 @@ export default class SettingValidator extends SchemaValidator {
private settingOCPISet: Schema;
private settingUserSet: Schema;
private settingSmartChargingSet: Schema;
+ private settingRefundSet: Schema;
+ private settingPricingSet: Schema;
+ private settingCryptoSet: Schema;
private constructor() {
super('SettingValidator');
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'));
}
public static getInstance(): SettingValidator {
@@ -36,4 +42,16 @@ export default class SettingValidator extends SchemaValidator {
public validateSettingSmartChargingSetReq(data: Record<string, unknown>): HttpSettingSmartChargingSetRequest {
return this.validate(this.settingUserSet, data);
}
+
+ public validateSettingRefundSetReq(data: Record<string, unknown>): HttpSettingRefundSetRequest {
+ return this.validate(this.settingRefundSet, data);
+ }
+
+ public validateSettingPricingSetReq(data: Record<string, unknown>): HttpSettingPricingSetRequest {
+ return this.validate(this.settingPricingSet, data);
+ }
+
+ public validateSettingCryptoSetReq(data: Record<string, unknown>): HttpSettingCryptoSetRequest {
+ return this.validate(this.settingCryptoSet, data);
+ }
}

MODIFY
src/types/Setting.ts
src/types/Setting.ts
@@ -5,7 +5,9 @@ export enum TechnicalSettings {
USER = 'user',
CRYPTO = 'crypto',
OCPI = 'ocpi',
- SMART_CHARGING = 'smartCharging'
+ SMART_CHARGING = 'smartCharging',
+ REFUND = 'refund',
+ PRICING = 'pricing',
}
export interface Setting extends CreatedUpdatedProps {

MODIFY
src/types/requests/HttpSettingRequest.ts
src/types/requests/HttpSettingRequest.ts
import HttpByIDRequest from './HttpByIDRequest';
import HttpDatabaseRequest from './HttpDatabaseRequest';
+import { NumberFormatPartTypes } from 'intl';
export interface HttpSettingRequest extends HttpByIDRequest {
ContentFilter: boolean;
@@ -68,3 +69,43 @@ export interface HttpSettingSmartChargingSetRequest extends HttpSettingSetReques
}
}
}
+
+export interface HttpSettingRefundSetRequest extends HttpSettingSetRequest {
+ content: {
+ type: string,
+ concur: {
+ apiUrl: string,
+ appUrl: string,
+ authentificationUrl: string,
+ clientId: string,
+ clientSecret: string,
+ expenseTypeId: string,
+ policyId: string,
+ reportName: string
+ }
+ }
+}
+
+export interface HttpSettingPricingSetRequest extends HttpSettingSetRequest {
+ content: {
+ type: string,
+ simple?: {
+ price: number,
+ currency: string
+ }
+ }
+}
+
+export interface HttpSettingCryptoSetRequest extends HttpSettingSetRequest {
+ content: {
+ type: string,
+ crypto: {
+ key: string,
+ keyProperties: {
+ blockCypher: string,
+ blockSize: number,
+ operationMode: string
+ }
+ }
+ }
+}

continue to Migrate Settings