Add Advenir User ID if it exist
ADD
src/assets/server/rest/v1/schemas/transaction/transaction-for-advenir-consumptions-get.json
+{
+ "$id": "transaction-for-advenir-consumptions-get",
+ "title": "Get Transaction Consumptions For Advenir Request",
+ "type": "object",
+ "properties": {
+ "TransactionId": {
+ "$ref": "transaction#/definitions/id"
+ },
+ "AdvenirUserId": {
+ "type": "string",
+ "sanitize": "mongo"
+ }
+ },
+ "required": [
+ "TransactionId"
+ ]
+}

MODIFY
src/server/rest/v1/service/TransactionService.ts
src/server/rest/v1/service/TransactionService.ts
@@ -548,7 +548,7 @@ export default class TransactionService {
UtilsService.assertComponentIsActiveFromToken(req.user, TenantComponents.OCPI,
Action.READ, Entity.TRANSACTION, MODULE_NAME, 'handleGetTransactionConsumptionForAdvenir');
// Filter
- const filteredRequest = TransactionValidator.getInstance().validateTransactionConsumptionsGetReq(req.query);
+ const filteredRequest = TransactionValidator.getInstance().validateTransactionConsumptionsAdvenirGetReq(req.query);
// Transaction Id is mandatory
UtilsService.assertIdIsProvided(action, filteredRequest.TransactionId, MODULE_NAME,
'handleGetConsumptionFromTransaction', req.user);
@@ -600,8 +600,8 @@ export default class TransactionService {
};
}
);
- // Value is not known on our side
- const userID = '<put-here-the-advenir-cpo-id>';
+ // Add Advenir user Id if exists
+ const userID = filteredRequest.AdvenirUserId ?? '<put-here-the-advenir-cpo-id>';
// Prepare ADVENIR payload
const transactionID = `${transaction.id}`;
const transactionData: AdvenirTransactionData = {

MODIFY
src/server/rest/v1/validator/TransactionValidator.ts
src/server/rest/v1/validator/TransactionValidator.ts
-import { HttpAssignTransactionsToUserRequest, HttpConsumptionFromTransactionRequest, HttpExportTransactionCdrRequest, HttpPushTransactionCdrRequest, HttpTransactionRequest, HttpTransactionsRequest, HttpUnassignTransactionsToUserRequest } from '../../../../types/requests/HttpTransactionRequest';
+import { HttpAssignTransactionsToUserRequest, HttpConsumptionFromTransactionAdvenirRequest, HttpConsumptionFromTransactionRequest, HttpExportTransactionCdrRequest, HttpPushTransactionCdrRequest, HttpTransactionRequest, HttpTransactionsRequest, HttpUnassignTransactionsToUserRequest } from '../../../../types/requests/HttpTransactionRequest';
import Schema from '../../../../types/validator/Schema';
import SchemaValidator from '../../../../validator/SchemaValidator';
@@ -13,6 +13,7 @@ export default class TransactionValidator extends SchemaValidator {
private transactionCdrPush: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/transaction/transaction-cdr-push.json`, 'utf8'));
private transactionCdrExport: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/transaction/transaction-cdr-export.json`, 'utf8'));
private transactionConsumptionsGet: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/transaction/transaction-consumptions-get.json`, 'utf8'));
+ private transactionConsumptionsAdvenirGet: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/transaction/transaction-for-advenir-consumptions-get.json`, 'utf8'));
private transactionsUserAssign: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/transaction/transactions-user-assign.json`, 'utf8'));
private transactionsUnassignedCountGet: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/transaction/transactions-unassigned-count-get.json`, 'utf8'));
private transactionsInErrorGet: Schema = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/transaction/transactions-inerror-get.json`, 'utf8'));
@@ -53,6 +54,10 @@ export default class TransactionValidator extends SchemaValidator {
return this.validate(this.transactionConsumptionsGet, data);
}
+ public validateTransactionConsumptionsAdvenirGetReq(data: Record<string, unknown>): HttpConsumptionFromTransactionAdvenirRequest {
+ return this.validate(this.transactionConsumptionsAdvenirGet, data);
+ }
+
public validateTransactionsUserAssignReq(data: Record<string, unknown>): HttpAssignTransactionsToUserRequest {
return this.validate(this.transactionsUserAssign, data);
}

MODIFY
src/types/requests/HttpTransactionRequest.ts
src/types/requests/HttpTransactionRequest.ts
@@ -66,3 +66,8 @@ export interface HttpConsumptionFromTransactionRequest {
StartDateTime: Date;
EndDateTime: Date;
}
+
+export interface HttpConsumptionFromTransactionAdvenirRequest {
+ TransactionId: number;
+ AdvenirUserId?: string;
+}

Add Advenir User ID if it exist