Added transaction refund/assign/export rest endpoints + doc
MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
}
}
},
+ "/api/transactions/action/refund": {
+ "post": {
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "description": "Refund Transactions",
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "transactionIds": {
+ "type": "array",
+ "items": {
+ "type": "number"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "tags": [
+ "Transactions"
+ ],
+ "responses": {
+ "200": {
+ "description": "Transaction stop successfully",
+ "content": {
+ "application/json": {
+ "example": {
+ "status": "Success",
+ "inSuccess": 42,
+ "inError": 1
+ }
+ }
+ }
+ },
+ "401": {
+ "$ref": "#/components/responses/UnauthorizedError"
+ },
+ "403": {
+ "$ref": "#/components/responses/ForbiddenError"
+ },
+ "500": {
+ "$ref": "#/components/responses/BackendError"
+ },
+ "552": {
+ "description": "No Refund valid connection found"
+ }
+ }
+ }
+ },
+ "/api/transactions/action/assign": {
+ "post": {
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "description": "Assign Transactions to a user",
+ "parameters": [
+ {
+ "in": "query",
+ "name": "TagID",
+ "description": "Tag ID",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "in": "query",
+ "name": "UserID",
+ "description": "User ID",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
+ ],
+ "tags": [
+ "Transactions"
+ ],
+ "responses": {
+ "200": {
+ "description": "Transactions successfully assigned",
+ "content": {
+ "application/json": {
+ "example": {
+ "status": "Success"
+ }
+ }
+ }
+ },
+ "401": {
+ "$ref": "#/components/responses/UnauthorizedError"
+ },
+ "403": {
+ "$ref": "#/components/responses/ForbiddenError"
+ },
+ "500": {
+ "$ref": "#/components/responses/BackendError"
+ }
+ }
+ }
+ },
+ "/api/transactions/action/export": {
+ "get": {
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "description": "Export Transactions",
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/Issuer"
+ },
+ {
+ "$ref": "#/components/parameters/Search"
+ },
+ {
+ "$ref": "#/components/parameters/StartDateTime"
+ },
+ {
+ "$ref": "#/components/parameters/EndDateTime"
+ },
+ {
+ "$ref": "#/components/parameters/WithChargingStation"
+ },
+ {
+ "$ref": "#/components/parameters/ChargingStationIDs"
+ },
+ {
+ "$ref": "#/components/parameters/ConnectorIDs"
+ },
+ {
+ "$ref": "#/components/parameters/WithCar"
+ },
+ {
+ "$ref": "#/components/parameters/WithUser"
+ },
+ {
+ "$ref": "#/components/parameters/UserIDs"
+ },
+ {
+ "$ref": "#/components/parameters/TagIDs"
+ },
+ {
+ "$ref": "#/components/parameters/VisualTagIDs"
+ },
+ {
+ "$ref": "#/components/parameters/SiteIDs"
+ },
+ {
+ "$ref": "#/components/parameters/WithSite"
+ },
+ {
+ "$ref": "#/components/parameters/SiteAreaIDs"
+ },
+ {
+ "$ref": "#/components/parameters/WithSiteArea"
+ },
+ {
+ "$ref": "#/components/parameters/WithCompany"
+ },
+ {
+ "$ref": "#/components/parameters/InactivityStatuses"
+ },
+ {
+ "$ref": "#/components/parameters/TransactionStatistics"
+ },
+ {
+ "$ref": "#/components/parameters/RefundStatus"
+ },
+ {
+ "in": "query",
+ "name": "MinimalPrice",
+ "description": "Transactions minimal price",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "in": "query",
+ "name": "ReportIDs",
+ "description": "Pipe separated report IDs",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "$ref": "#/components/parameters/Limit"
+ },
+ {
+ "$ref": "#/components/parameters/Skip"
+ },
+ {
+ "$ref": "#/components/parameters/SortFields"
+ },
+ {
+ "$ref": "#/components/parameters/OnlyRecordCount"
+ },
+ {
+ "$ref": "#/components/parameters/ProjectFields"
+ }
+ ],
+ "tags": [
+ "Transactions"
+ ],
+ "responses": {
+ "200": {
+ "description": "Transactions successfully exported",
+ "content": {
+ "text/csv": {
+ "example": "id,chargingStationID,connectorID,companyName,siteName,siteAreaName,userID,user,tagID,visualTagID,tagDescription,timezone,startDate,startTime,endDate,endTime,totalConsumptionkWh,totalDurationMins,totalInactivityMins,price,priceUnit\n1155141205,\"###\",1,,,,\"\",\"\",\"###\",\"###\",\"###\",\"Europe/Paris\",\"2021-07-07\",\"16:21:59\",\"2021-07-07\",\"16:22:27\",0,0.46,0.46,0,\"EUR\""
+ }
+ }
+ },
+ "401": {
+ "$ref": "#/components/responses/UnauthorizedError"
+ },
+ "403": {
+ "$ref": "#/components/responses/ForbiddenError"
+ },
+ "500": {
+ "$ref": "#/components/responses/BackendError"
+ }
+ }
+ }
+ },
"/api/charging-stations": {
"get": {
"security": [

MODIFY
src/server/rest/v1/router/api/TransactionRouter.ts
src/server/rest/v1/router/api/TransactionRouter.ts
@@ -19,6 +19,9 @@ export default class TransactionRouter {
this.buildRouteDeleteTransaction();
this.buildRouteDeleteTransactions();
this.buildRoutePushTransactionCDR();
+ this.buildRouteTransactionsRefund();
+ this.buildRouteTransactionsAssignUser();
+ this.buildRouteTransactionsExport();
return this.router;
}
@@ -82,4 +85,22 @@ export default class TransactionRouter {
await RouterUtils.handleServerAction(TransactionService.handleTransactionSoftStop.bind(this), ServerAction.TRANSACTION_SOFT_STOP, req, res, next);
});
}
+
+ protected buildRouteTransactionsRefund(): void {
+ this.router.post(`/${ServerRoute.REST_TRANSACTIONS_REFUND}`, async (req: Request, res: Response, next: NextFunction) => {
+ await RouterUtils.handleServerAction(TransactionService.handleRefundTransactions.bind(this), ServerAction.TRANSACTIONS_REFUND, req, res, next);
+ });
+ }
+
+ protected buildRouteTransactionsAssignUser(): void {
+ this.router.put(`/${ServerRoute.REST_TRANSACTIONS_ASSIGN_USER}`, async (req: Request, res: Response, next: NextFunction) => {
+ await RouterUtils.handleServerAction(TransactionService.handleAssignTransactionsToUser.bind(this), ServerAction.ASSIGN_TRANSACTIONS_TO_USER, req, res, next);
+ });
+ }
+
+ protected buildRouteTransactionsExport(): void {
+ this.router.get(`/${ServerRoute.REST_TRANSACTIONS_EXPORT}`, async (req: Request, res: Response, next: NextFunction) => {
+ await RouterUtils.handleServerAction(TransactionService.handleExportTransactions.bind(this), ServerAction.TRANSACTIONS_EXPORT, req, res, next);
+ });
+ }
}

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -487,11 +487,14 @@ export enum ServerRoute {
REST_TRANSACTIONS = 'transactions',
REST_TRANSACTION = 'transactions/:id',
+ REST_TRANSACTIONS_EXPORT = 'transactions/action/export',
REST_TRANSACTION_CDR = 'transactions/:id/ocpi/cdr',
REST_TRANSACTION_CDR_EXPORT = 'transactions/:id/ocpi/cdr/action/export',
REST_TRANSACTIONS_CONSUMPTION = 'transactions/:id/consumptions',
REST_TRANSACTION_CONSUMPTIONS_REBUILD = 'transactions/:id/consumptions/rebuild',
REST_TRANSACTION_SOFT_STOP = 'transactions/:id/stop/soft',
+ REST_TRANSACTIONS_REFUND = 'transactions/action/refund',
+ REST_TRANSACTIONS_ASSIGN_USER = 'transactions/action/assign',
REST_USERS = 'users',
REST_USER = 'users/:id',

Added transaction refund/assign/export rest endpoints + doc