Added supported endpoints
MODIFY
src/server/ocpi/router/emsp/EMSPRouter.ts
src/server/ocpi/router/emsp/EMSPRouter.ts
@@ -10,8 +10,11 @@ import EMSPSessionsRouterV211 from './V2.1.1/EMSPSessionsRouterV211';
import EMSPTariffsRouterV211 from './V2.1.1/EMSPTariffsRouterV211';
import EMSPTokensRouterV211 from './V2.1.1/EMSPTokensRouterV211';
import EMSPVersionsService from '../../service/emsp/EMSPVersionsService';
+import OCPIUtils from '../../OCPIUtils';
+import OCPIUtilsService from '../../service/OCPIUtilsService';
import RouterUtils from '../../../../utils/RouterUtils';
+const VERSION = '2.1.1';
export default class EMSPRouter {
private router: express.Router;
@@ -32,7 +35,10 @@ export default class EMSPRouter {
}
protected buildRouteEmspV211(): void {
- this.router.use('/2.1.1', [
+ this.router.get(`/${VERSION}`, async (req: Request, res: Response, next: NextFunction) => {
+ await RouterUtils.handleServerAction(this.getSupportedServices.bind(this), ServerAction.OCPI_CPO_GET_SERVICES, req, res, next);
+ });
+ this.router.use(`/${VERSION}`, [
new EMSPTokensRouterV211().buildRoutes(),
new EMSPLocationsRouterV211().buildRoutes(),
new EMSPSessionsRouterV211().buildRoutes(),
@@ -42,4 +48,14 @@ export default class EMSPRouter {
new CPOEMSPCredentialsRouterV211().buildRoutes(),
]);
}
+
+ protected getSupportedServices(action: ServerAction, req: Request, res: Response, next: NextFunction): void {
+ const identifiers = Array.from(Object.values(OCPIServerRoute));
+ const fullUrl = OCPIUtilsService.getServiceUrl(req, 'emsp');
+ // Build payload
+ const supportedEndpoints = identifiers.map((identifier: string) => ({ identifier, url: `${fullUrl}/${identifier}/` }));
+ // Return payload
+ res.json(OCPIUtils.success({ 'version': VERSION, 'endpoints': supportedEndpoints }));
+ next();
+ }
}

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -146,6 +146,7 @@ export enum ServerAction {
OCPI_UPDATE_CREDENTIALS = 'OcpiUpdateCredentials',
OCPI_DELETE_CREDENTIALS = 'OcpiDeleteCredentials',
+ OCPI_CPO_GET_SERVICES = 'OcpiCpoGetServices',
OCPI_CPO_COMMAND = 'OcpiCpoCommand',
OCPI_CPO_UPDATE_STATUS = 'OcpiCpoUpdateStatus',
OCPI_CPO_CHECK_CDRS = 'OcpiCpoCheckCdrs',

Added supported endpoints