Added OCPI endpoints
MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
{
"name": "Cars",
"description": "Cars API"
+ },
+ {
+ "name": "OCPI",
+ "description": "OCPI API"
}
],
"paths": {

MODIFY
src/server/rest/v1/router/GlobalRouter.ts
src/server/rest/v1/router/GlobalRouter.ts
@@ -9,6 +9,7 @@ import ChargingStationRouter from './api/ChargingStationRouter';
import CompanyRouter from './api/CompanyRouter';
import ConnectionRouter from './api/ConnectionRouter';
import LoggingRouter from './api/LoggingRouter';
+import OCPIRouter from './api/OCPIRouter';
import { StatusCodes } from 'http-status-codes';
import SwaggerRouter from './doc/SwaggerRouter';
import TagRouter from './api/TagRouter';
@@ -49,6 +50,7 @@ export default class GlobalRouter {
new CompanyRouter().buildRoutes(),
new ConnectionRouter().buildRoutes(),
new LoggingRouter().buildRoutes(),
+ new OCPIRouter().buildRoutes(),
new TagRouter().buildRoutes(),
new TenantRouter().buildRoutes(),
new TransactionRouter().buildRoutes(),

ADD
src/server/rest/v1/router/api/OCPIRouter.ts
+/* eslint-disable @typescript-eslint/no-misused-promises */
+import { ServerAction, ServerRoute } from '../../../../../types/Server';
+import express, { NextFunction, Request, Response } from 'express';
+
+import OCPIEndpointService from '../../service/OCPIEndpointService';
+import RouterUtils from '../RouterUtils';
+
+export default class OCPIRouter {
+ private router: express.Router;
+
+ public constructor() {
+ this.router = express.Router();
+ }
+
+ public buildRoutes(): express.Router {
+ this.buildRouteOcpiEndpointCreate();
+ this.buildRouteOcpiEndpointPing();
+ this.buildRouteOcpiEndpointCheckCDRS();
+ this.buildRouteOcpiEndpointCheckLocations();
+ return this.router;
+ }
+
+ protected buildRouteOcpiEndpointCreate(): void {
+ this.router.post(`/${ServerRoute.REST_OCPI_ENDPOINT_CREATE}`, async (req: Request, res: Response, next: NextFunction) => {
+ await RouterUtils.handleServerAction(OCPIEndpointService.handleCreateOcpiEndpoint.bind(this), ServerAction.OCPI_ENDPOINT_CREATE, req, res, next);
+ });
+ }
+
+ protected buildRouteOcpiEndpointPing(): void {
+ this.router.put(`/${ServerRoute.REST_OCPI_ENDPOINT_PING}`, async (req: Request, res: Response, next: NextFunction) => {
+ await RouterUtils.handleServerAction(OCPIEndpointService.handlePingOcpiEndpoint.bind(this), ServerAction.OCPI_ENDPOINT_PING, req, res, next);
+ });
+ }
+
+ protected buildRouteOcpiEndpointCheckCDRS(): void {
+ this.router.put(`/${ServerRoute.REST_OCPI_ENDPOINT_CHECK_CDRS}`, async (req: Request, res: Response, next: NextFunction) => {
+ await RouterUtils.handleServerAction(OCPIEndpointService.handleCheckCdrsEndpoint.bind(this), ServerAction.OCPI_ENDPOINT_CHECK_CDRS, req, res, next);
+ });
+ }
+
+ protected buildRouteOcpiEndpointCheckLocations(): void {
+ this.router.put(`/${ServerRoute.REST_OCPI_ENDPOINT_CHECK_LOCATIONS}`, async (req: Request, res: Response, next: NextFunction) => {
+ await RouterUtils.handleServerAction(OCPIEndpointService.handleCheckLocationsEndpoint.bind(this), ServerAction.OCPI_ENDPOINT_CHECK_LOCATIONS, req, res, next);
+ });
+ }
+}

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -558,6 +558,25 @@ export enum ServerRoute {
REST_LOGGING = 'loggings/:id',
REST_LOGGINGS_EXPORT = 'loggings/action/export',
+ REST_OCPI_ENDPOINT_CREATE = 'ocpi/endpoints',
+ REST_OCPI_ENDPOINT_PING = 'ocpi/endpoints/:id/ping',
+ REST_OCPI_ENDPOINT_CHECK_CDRS = 'ocpi/endpoints/:id/cdrs/check',
+ REST_OCPI_ENDPOINT_CHECK_LOCATIONS = 'ocpi/endpoints/:id/locations/check',
+ REST_OCPI_ENDPOINT_CHECK_SESSIONS = 'ocpi/endpoints/:id/sessions/check',
+ REST_OCPI_ENDPOINT_PULL_CDRS = 'ocpi/endpoints/:id/cdrs/pull',
+ REST_OCPI_ENDPOINT_PULL_LOCATIONS = 'ocpi/endpoints/:id/locations/pull',
+ REST_OCPI_ENDPOINT_PULL_SESSIONS = 'ocpi/endpoints/:id/sessions/pull',
+ REST_OCPI_ENDPOINT_PULL_TOKENS = 'ocpi/endpoints/:id/tokens/pull',
+ REST_OCPI_ENDPOINT_SEND_EVSE_STATUSES = 'ocpi/endpoints/:id/evses/statuses/send',
+ REST_OCPI_ENDPOINT_SEND_TOKENS = 'ocpi/endpoints/:id/tokens/send',
+ REST_OCPI_ENDPOINT_GENERATE_LOCAL_TOKEN = 'ocpi/endpoints/:id/tokens/generate',
+ REST_OCPI_ENDPOINTS = 'ocpi/endpoints',
+ REST_OCPI_ENDPOINT = 'ocpi/endpoints/:id',
+ REST_OCPI_ENDPOINT_UPDATE = 'ocpi/endpoints/:id',
+ REST_OCPI_ENDPOINT_REGISTER = 'ocpi/endpoints/:id/register',
+ REST_OCPI_ENDPOINT_UNREGISTER = 'ocpi/endpoints/:id/unregister',
+ REST_OCPI_ENDPOINT_DELETE = 'ocpi/endpoints/:id',
+
// BILLING URLs for CRUD operations on PAYMENT METHODS
REST_BILLING_PAYMENT_METHODS = 'users/:userID/payment-methods',
REST_BILLING_PAYMENT_METHOD = 'users/:userID/payment-methods/:paymentMethodID',

MODIFY
test/api/client/OCPIEndpointApi.ts
test/api/client/OCPIEndpointApi.ts
import AuthenticatedBaseApi from './utils/AuthenticatedBaseApi';
import CrudApi from './utils/CrudApi';
+import { ServerRoute } from '../../../src/types/Server';
import TestConstants from './utils/TestConstants';
export default class OCPIEndpointApi extends CrudApi {
@@ -16,7 +17,7 @@ export default class OCPIEndpointApi extends CrudApi {
}
public async create(data) {
- return super.create(data, '/client/api/OcpiEndpointCreate');
+ return super.create(data, this.buildRestEndpointUrl(ServerRoute.REST_OCPI_ENDPOINT_CREATE));
}
public async update(data) {

Added OCPI endpoints