Added getUsers endpoint + doc
MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
{
"name": "Charging Stations",
"description": "Charging Stations API"
+ },
+ {
+ "name": "Users",
+ "description": "Users API"
}
],
"paths": {
"schema": {
"type": "object",
"required": [
- "email", "password", "acceptEula", "tenant"
+ "email",
+ "password",
+ "acceptEula",
+ "tenant"
],
"properties": {
"email": {
"schema": {
"type": "object",
"required": [
- "email", "name", "firstName", "passwords", "acceptEula", "tenant", "captcha"
+ "email",
+ "name",
+ "firstName",
+ "passwords",
+ "acceptEula",
+ "tenant",
+ "captcha"
],
"properties": {
"email": {
"application/json": {
"schema": {
"type": "object",
- "required": ["email", "tenant"],
+ "required": [
+ "email",
+ "tenant"
+ ],
"properties": {
"email": {
"type": "string",
}
}
},
- "required": ["chargeBoxID"]
+ "required": [
+ "chargeBoxID"
+ ]
}
}
}
"description": "Optional. Can be used to force a power or current profile",
"example": "A",
"enum": [
- "W", "A"
+ "W",
+ "A"
]
}
},
}
}
}
+ },
+ "/api/users": {
+ "get": {
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "description": "Retrieve a list of Users",
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/Issuer"
+ },
+ {
+ "$ref": "#/components/parameters/WithTag"
+ },
+ {
+ "$ref": "#/components/parameters/Search"
+ },
+ {
+ "$ref": "#/components/parameters/SiteID"
+ },
+ {
+ "$ref": "#/components/parameters/Role"
+ },
+ {
+ "$ref": "#/components/parameters/Status"
+ },
+ {
+ "$ref": "#/components/parameters/UserErrorType"
+ },
+ {
+ "$ref": "#/components/parameters/ExcludeSiteID"
+ },
+ {
+ "$ref": "#/components/parameters/TagID"
+ },
+ {
+ "in": "query",
+ "name": "ExcludeUserIDs",
+ "description": "Pipe separated user IDs to exclude",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "in": "query",
+ "name": "IncludeCarUserIDs",
+ "description": "Pipe separated car IDs",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "in": "query",
+ "name": "NotAssignedToCarID",
+ "description": "Car ID",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "$ref": "#/components/parameters/Skip"
+ },
+ {
+ "$ref": "#/components/parameters/Limit"
+ },
+ {
+ "$ref": "#/components/parameters/SortFields"
+ },
+ {
+ "$ref": "#/components/parameters/ProjectFields"
+ }
+ ],
+ "tags": [
+ "Users"
+ ],
+ "responses": {
+ "200": {
+ "description": "Return users list",
+ "content": {
+ "application/json": {
+ "example": {
+ "count": 1,
+ "result": [
+ {
+ "createdBy": null,
+ "createdOn": "2019-10-29T10:33:23.498Z",
+ "email": "###",
+ "firstName": "###",
+ "lastChangedBy": {
+ "firstName": "###",
+ "name": "###",
+ "id": "###"
+ },
+ "locale": "fr_FR",
+ "name": "###",
+ "role": "A",
+ "status": "A",
+ "eulaAcceptedOn": "2021-03-08T10:23:32.842Z",
+ "eulaAcceptedVersion": 310,
+ "lastChangedOn": "2021-03-08T10:23:46.445Z",
+ "issuer": true,
+ "id": "###",
+ "canRead": true,
+ "canUpdate": true,
+ "canDelete": false
+ }
+ ]
+ }
+ }
+ }
+ },
+ "401": {
+ "$ref": "#/components/responses/UnauthorizedError"
+ },
+ "403": {
+ "$ref": "#/components/responses/ForbiddenError"
+ },
+ "500": {
+ "$ref": "#/components/responses/500BackendError"
+ }
+ }
+ }
}
},
"components": {
"type": "string",
"description": "Required. The unit of measure Limit is expressed in.",
"enum": [
- "A", "W"
+ "A",
+ "W"
],
"example": "A"
},
"schema": {
"type": "number",
"enum": [
- "I", "W", "E"
+ "I",
+ "W",
+ "E"
]
}
},
"schema": {
"type": "boolean"
}
+ },
+ "WithTag": {
+ "in": "query",
+ "name": "WithTag",
+ "description": "With tag attribute",
+ "schema": {
+ "type": "boolean"
+ }
+ },
+ "Role": {
+ "in": "query",
+ "name": "Role",
+ "description": "Role attribute",
+ "schema": {
+ "type": "string",
+ "enum": [
+ "S",
+ "A",
+ "B",
+ "D"
+ ]
+ }
+ },
+ "Status": {
+ "in": "query",
+ "name": "Status",
+ "description": "Status attribute",
+ "schema": {
+ "type": "string",
+ "enum": [
+ "P",
+ "A",
+ "I",
+ "B",
+ "L"
+ ]
+ }
+ },
+ "UserErrorType": {
+ "in": "query",
+ "name": "ErrorType",
+ "description": "Error type",
+ "schema": {
+ "type": "string",
+ "enum": [
+ "inactive_user",
+ "unassigned_user",
+ "inactive_user_account",
+ "failed_billing_synchro",
+ "no_billing_data"
+ ]
+ }
+ },
+ "ExcludeSiteID": {
+ "in": "query",
+ "name": "ExcludeSiteID",
+ "description": "Site ID to exclude",
+ "schema": {
+ "type": "string"
+ }
}
}
}

MODIFY
src/server/rest/v1/router/GlobalRouter.ts
src/server/rest/v1/router/GlobalRouter.ts
@@ -7,6 +7,7 @@ import { StatusCodes } from 'http-status-codes';
import SwaggerRouter from './doc/SwaggerRouter';
import TenantRouter from './api/TenantRouter';
import TransactionRouter from './api/TransactionRouter';
+import UserRouter from './api/UserRouter';
import UtilRouter from './util/UtilRouter';
export default class GlobalRouter {
@@ -34,6 +35,7 @@ export default class GlobalRouter {
new TenantRouter().buildRoutes(),
new ChargingStationRouter().buildRoutes(),
new TransactionRouter().buildRoutes(),
+ new UserRouter().buildRoutes()
]);
}

ADD
src/server/rest/v1/router/api/UserRouter.ts
+/* eslint-disable @typescript-eslint/no-misused-promises */
+import { ServerAction, ServerRoute } from '../../../../../types/Server';
+import express, { NextFunction, Request, Response } from 'express';
+
+import RouterUtils from '../RouterUtils';
+import TenantService from '../../service/TenantService';
+import UserService from '../../service/UserService';
+import sanitize from 'mongo-sanitize';
+
+export default class UserRouter {
+ private router: express.Router;
+
+ public constructor() {
+ this.router = express.Router();
+ }
+
+ public buildRoutes(): express.Router {
+ this.buildRouteUsers();
+ return this.router;
+ }
+
+ protected buildRouteUsers(): void {
+ this.router.get(`/${ServerRoute.REST_USERS}`, async (req: Request, res: Response, next: NextFunction) => {
+ await RouterUtils.handleServerAction(UserService.handleGetUsers.bind(this), ServerAction.USERS, req, res, next);
+ });
+ }
+}

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -442,6 +442,8 @@ export enum ServerRoute {
REST_TRANSACTIONS = 'transactions',
+ REST_USERS = 'users',
+
REST_PING = 'ping',
REST_TENANTS = 'tenants'

Added getUsers endpoint + doc