Added transactions schema
MODIFY
src/assets/charging-station-templates
src/assets/charging-station-templates
-Subproject commit 7bb4763ae6e4798d73fa91a07f48a81100a40d26
+Subproject commit ebee47a90f29a317c6f8c4e33cd814c1ace1af38

MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
"$ref": "#/components/parameters/TransactionStatistics"
},
{
- "in": "query",
- "name": "RefundStatus",
- "description": "Pipe separated refund statuses (submitted, notSubmitted, cancelled, approved)",
- "schema": {
- "type": "string"
- }
+ "$ref": "#/components/parameters/RefundStatus"
},
{
"in": "query",
"$ref": "#/components/parameters/SiteAreaIDs"
},
{
- "in": "query",
- "name": "InactivityStatus",
- "required": false,
- "description": "Pipe separated Inactivity Statuses",
- "schema": {
- "type": "string"
- }
+ "$ref": "#/components/parameters/InactivityStatuses"
},
{
- "in": "query",
- "name": "RefundStatus",
- "required": false,
- "description": "Pipe separated Refund Statuses",
- "schema": {
- "type": "string"
- }
+ "$ref": "#/components/parameters/RefundStatus"
},
{
"in": "query",
"type": "boolean"
}
},
+ "RefundStatus": {
+ "in": "query",
+ "name": "RefundStatus",
+ "description": "Pipe separated refund statuses (submitted, notSubmitted, cancelled, approved)",
+ "schema": {
+ "type": "string"
+ }
+ },
"tagID": {
"in": "path",
"name": "id",

ADD
src/assets/server/rest/v1/schemas/transaction/transactions-get.json
+{
+ "title": "Get Transactions",
+ "type": "object",
+ "properties": {
+ "ChargeBoxID": {
+ "$ref": "chargingstation.json#/definitions/id"
+ },
+ "Issuer": {
+ "type": "boolean",
+ "sanitize": "mongo"
+ },
+ "ConnectorID": {
+ "$ref": "chargingstation.json#/definitions/connectorID"
+ },
+ "SiteAreaID": {
+ "$ref": "common.json#/definitions/ids"
+ },
+ "SiteID": {
+ "$ref": "common.json#/definitions/ids"
+ },
+ "UserID": {
+ "$ref": "common.json#/definitions/ids"
+ },
+ "TagID": {
+ "$ref": "tag.json#/definitions/id"
+ },
+ "StartDateTime": {
+ "type": "string",
+ "format":"date-time",
+ "sanitize": "mongo"
+ },
+ "EndDateTime": {
+ "type": "string",
+ "format": "date-time",
+ "sanitize": "mongo"
+ },
+ "ErrorType": {
+ "type": "string",
+ "sanitize": "mongo"
+ },
+ "RefundStatus": {
+ "type": "string",
+ "sanitize": "mongo",
+ "enum": ["submitted", "notSubmitted", "cancelled", "approved"]
+ },
+ "InactivityStatus": {
+ "type": "string",
+ "sanitize": "mongo",
+ "enum": ["I", "W", "E"]
+ },
+ "MinimalPrice": {
+ "type": "number",
+ "sanitize": "mongo"
+ },
+ "Statistics": {
+ "type": "string",
+ "sanitize": "mongo",
+ "enum": ["refund", "history"]
+ },
+ "ReportIDs": {
+ "$ref": "common.json#/definitions/ids"
+ },
+ "Status": {
+ "type": "string",
+ "sanitize": "mongo",
+ "enum": ["completed", "active"]
+ },
+ "Search": {
+ "$ref": "common.json#/definitions/search"
+ },
+ "Limit": {
+ "$ref": "common.json#/definitions/limit"
+ },
+ "SortFields": {
+ "$ref": "common.json#/definitions/sortFields"
+ },
+ "Skip": {
+ "$ref": "common.json#/definitions/skip"
+ },
+ "OnlyRecordCount": {
+ "$ref": "common.json#/definitions/onlyRecordCount"
+ },
+ "ProjectFields": {
+ "$ref": "common.json#/definitions/projectFields"
+ }
+ }
+}

MODIFY
src/integration/pricing/convergent-charging
src/integration/pricing/convergent-charging
-Subproject commit e2682d5ea884a2efe34120997e7f3033517c3e32
+Subproject commit 5212991ce6f8fadeffdfff4011172f55ed310816

MODIFY
src/server/rest/v1/service/TransactionService.ts
src/server/rest/v1/service/TransactionService.ts
@@ -30,6 +30,7 @@ import TenantComponents from '../../../../types/TenantComponents';
import TenantStorage from '../../../../storage/mongodb/TenantStorage';
import TransactionSecurity from './security/TransactionSecurity';
import TransactionStorage from '../../../../storage/mongodb/TransactionStorage';
+import TransactionValidator from '../validator/TransactionValidator';
import User from '../../../../types/User';
import UserStorage from '../../../../storage/mongodb/UserStorage';
import UserToken from '../../../../types/UserToken';
@@ -1050,7 +1051,7 @@ export default class TransactionService {
}
}
// Filter
- const filteredRequest = TransactionSecurity.filterTransactionsRequest(req.query);
+ const filteredRequest = TransactionValidator.getInstance().validateTransactionsGetReq(req.query);
// Build
const extrafilters: any = {};
if (Utils.objectHasProperty(params, 'withTag')) {

MODIFY
src/server/rest/v1/validator/ChargingStationValidator.ts
src/server/rest/v1/validator/ChargingStationValidator.ts
-import { HttpChargingStationCommandRequest, HttpChargingStationConnectorRequest, HttpChargingStationOcppParametersRequest, HttpChargingStationOcppRequest, HttpChargingStationsRequest, HttpDownloadQrCodeRequest } from '../../../../types/requests/HttpChargingStationRequest';
+import { HttpChargingStationCommandRequest, HttpChargingStationConnectorRequest, HttpChargingStationOcppRequest, HttpChargingStationsRequest, HttpDownloadQrCodeRequest } from '../../../../types/requests/HttpChargingStationRequest';
import HttpByIDRequest from '../../../../types/requests/HttpByIDRequest';
import Schema from './Schema';

ADD
src/server/rest/v1/validator/TransactionValidator.ts
+import { HttpChargingStationCommandRequest, HttpChargingStationConnectorRequest, HttpChargingStationOcppParametersRequest, HttpChargingStationOcppRequest, HttpChargingStationsRequest, HttpDownloadQrCodeRequest } from '../../../../types/requests/HttpChargingStationRequest';
+
+import HttpByIDRequest from '../../../../types/requests/HttpByIDRequest';
+import { HttpTransactionsRequest } from '../../../../types/requests/HttpTransactionRequest';
+import Schema from './Schema';
+import SchemaValidator from './SchemaValidator';
+import fs from 'fs';
+import global from '../../../../types/GlobalType';
+
+export default class TransactionValidator extends SchemaValidator {
+ private static instance: TransactionValidator | undefined;
+ private transactionsGet: Schema;
+
+
+ private constructor() {
+ super('TransactionValidator');
+ this.transactionsGet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/transaction/transactions-get.json`, 'utf8'));
+ }
+
+ public static getInstance(): TransactionValidator {
+ if (!TransactionValidator.instance) {
+ TransactionValidator.instance = new TransactionValidator();
+ }
+ return TransactionValidator.instance;
+ }
+
+ public validateTransactionsGetReq(data: any): HttpTransactionsRequest {
+ // Validate schema
+ this.validate(this.transactionsGet, data);
+ return data;
+ }
+}

Added transactions schema