Renamed TransactionConsumption to plural
RENAME
src/assets/server/rest/v1/schemas/transaction/transaction-get-consumption.json
src/assets/server/rest/v1/schemas/transaction/transaction-get-consumptions.json
{
- "title": "Get Transaction Consumption Request",
+ "title": "Get Transaction Consumptions Request",
"type": "object",
"properties": {
"TransactionId": {

MODIFY
src/server/rest/v1/router/api/TransactionRouter.ts
src/server/rest/v1/router/api/TransactionRouter.ts
@@ -107,7 +107,7 @@ export default class TransactionRouter {
}
protected buildRouteTransactionConsumption(): void {
- this.router.get(`/${ServerRoute.REST_TRANSACTION_CONSUMPTION}`, async (req: Request, res: Response, next: NextFunction) => {
+ this.router.get(`/${ServerRoute.REST_TRANSACTION_CONSUMPTIONS}`, async (req: Request, res: Response, next: NextFunction) => {
req.query.TransactionId = req.params.id;
await RouterUtils.handleServerAction(TransactionService.handleGetTransactionConsumption.bind(this), ServerAction.TRANSACTION_CONSUMPTION, req, res, next);
});

MODIFY
src/server/rest/v1/service/TransactionService.ts
src/server/rest/v1/service/TransactionService.ts
@@ -533,7 +533,7 @@ export default class TransactionService {
public static async handleGetTransactionConsumption(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Filter
- const filteredRequest = TransactionValidator.getInstance().validateTransactionGetConsumptionReq(req.query);
+ const filteredRequest = TransactionValidator.getInstance().validateTransactionGetConsumptionsReq(req.query);
// Transaction Id is mandatory
UtilsService.assertIdIsProvided(action, filteredRequest.TransactionId, MODULE_NAME,
'handleGetConsumptionFromTransaction', req.user);

MODIFY
src/server/rest/v1/validator/TransactionValidator.ts
src/server/rest/v1/validator/TransactionValidator.ts
@@ -11,7 +11,7 @@ export default class TransactionValidator extends SchemaValidator {
private transactionGet: Schema;
private transactionsGetByIDs: Schema;
private transactionPushCDR: Schema;
- private transactionGetConsumption: Schema;
+ private transactionGetConsumptions: Schema;
private transactionsAssignUser: Schema;
@@ -21,7 +21,7 @@ export default class TransactionValidator extends SchemaValidator {
this.transactionGet = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/transaction/transaction-get.json`, 'utf8'));
this.transactionsGetByIDs = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/transaction/transactions-get-by-ids.json`, 'utf8'));
this.transactionPushCDR = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/transaction/transaction-push-cdr.json`, 'utf8'));
- this.transactionGetConsumption = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/transaction/transaction-get-consumption.json`, 'utf8'));
+ this.transactionGetConsumptions = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/transaction/transaction-get-consumptions.json`, 'utf8'));
this.transactionsAssignUser = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/transaction/transactions-assign-user.json`, 'utf8'));
}
@@ -56,9 +56,9 @@ export default class TransactionValidator extends SchemaValidator {
return data;
}
- public validateTransactionGetConsumptionReq(data: any): HttpConsumptionFromTransactionRequest {
+ public validateTransactionGetConsumptionsReq(data: any): HttpConsumptionFromTransactionRequest {
// Validate schema
- this.validate(this.transactionGetConsumption, data);
+ this.validate(this.transactionGetConsumptions, data);
return data;
}

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -501,7 +501,7 @@ export enum ServerRoute {
REST_TRANSACTIONS_EXPORT = 'transactions/action/export',
REST_TRANSACTION_CDR = 'transactions/:id/ocpi/cdr',
REST_TRANSACTION_CDR_EXPORT = 'transactions/:id/ocpi/cdr/export',
- REST_TRANSACTION_CONSUMPTION = 'transactions/:id/consumptions',
+ REST_TRANSACTION_CONSUMPTIONS = 'transactions/:id/consumptions',
REST_TRANSACTION_CONSUMPTIONS_REBUILD = 'transactions/:id/consumptions/rebuild',
REST_TRANSACTION_SOFT_STOP = 'transactions/:id/soft-stop',
REST_TRANSACTIONS_REFUND_ACTION = 'transactions/action/refund',

MODIFY
test/api/client/TransactionApi.ts
test/api/client/TransactionApi.ts
@@ -24,7 +24,7 @@ export default class TransactionApi extends CrudApi {
}
public async readAllConsumption(params) {
- return await super.read(params, `${this.buildRestEndpointUrl(ServerRoute.REST_TRANSACTION_CONSUMPTION, { id: params.TransactionId })}?WithUser=true`);
+ return await super.read(params, `${this.buildRestEndpointUrl(ServerRoute.REST_TRANSACTION_CONSUMPTIONS, { id: params.TransactionId })}?WithUser=true`);
}
public async readAllYears(params) {

Renamed TransactionConsumption to plural