Added registrationtoken update/delete/revoke endpoints + doc
MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
},
"500": {
"$ref": "#/components/responses/BackendError"
+ },
+ "550": {
+ "$ref": "#/components/responses/ResourceDoesNotExists"
+ }
+ }
+ },
+ "put": {
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "description": "Update a Registration Token",
+ "tags": [
+ "Registration tokens"
+ ],
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/RegistrationTokenID"
+ }
+ ],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/RegistrationToken"
+ }
+ }
+ }
+ },
+ "responses": {
+ "200": {
+ "description": "Registration Token updated successfully",
+ "content": {
+ "application/json": {
+ "example": {
+ "status": "Success"
+ }
+ }
+ }
+ },
+ "401": {
+ "$ref": "#/components/responses/UnauthorizedError"
+ },
+ "403": {
+ "$ref": "#/components/responses/ForbiddenError"
+ },
+ "500": {
+ "$ref": "#/components/responses/BackendError"
+ },
+ "550": {
+ "$ref": "#/components/responses/ResourceDoesNotExists"
+ }
+ }
+ },
+ "delete": {
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "description": "Delete a Registration Token",
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/RegistrationTokenID"
+ }
+ ],
+ "tags": [
+ "Registration tokens"
+ ],
+ "responses": {
+ "200": {
+ "description": "Registration Token deleted successfully"
+ },
+ "401": {
+ "$ref": "#/components/responses/UnauthorizedError"
+ },
+ "403": {
+ "$ref": "#/components/responses/ForbiddenError"
+ },
+ "500": {
+ "$ref": "#/components/responses/BackendError"
+ },
+ "550": {
+ "$ref": "#/components/responses/ResourceDoesNotExists"
+ }
+ }
+ }
+ },
+ "/api/registration-tokens/{id}/revoke": {
+ "put": {
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "description": "Revoke a Registration Token",
+ "tags": [
+ "Registration tokens"
+ ],
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/RegistrationTokenID"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Registration Token revoked successfully",
+ "content": {
+ "application/json": {
+ "example": {
+ "status": "Success"
+ }
+ }
+ }
+ },
+ "401": {
+ "$ref": "#/components/responses/UnauthorizedError"
+ },
+ "403": {
+ "$ref": "#/components/responses/ForbiddenError"
+ },
+ "500": {
+ "$ref": "#/components/responses/BackendError"
+ },
+ "550": {
+ "$ref": "#/components/responses/ResourceDoesNotExists"
}
}
}

MODIFY
src/server/rest/v1/router/api/RegistrationTokenRouter.ts
src/server/rest/v1/router/api/RegistrationTokenRouter.ts
@@ -17,25 +17,49 @@ export default class RegistrationTokenRouter {
this.buildRouteRegistrationTokens();
this.buildRouteRegistrationToken();
this.buildRouteCreateRegistrationTokens();
+ this.buildRouteUpdateRegistrationTokens();
+ this.buildRouteDeleteRegistrationTokens();
+ this.buildRouteRevokeRegistrationTokens();
return this.router;
}
- protected buildRouteRegistrationTokens(): void {
+ private buildRouteRegistrationTokens(): void {
this.router.get(`/${ServerRoute.REST_REGISTRATION_TOKENS}`, async (req: Request, res: Response, next: NextFunction) => {
await RouterUtils.handleServerAction(RegistrationTokenService.handleGetRegistrationTokens.bind(this), ServerAction.REGISTRATION_TOKENS, req, res, next);
});
}
- protected buildRouteRegistrationToken(): void {
+ private buildRouteRegistrationToken(): void {
this.router.get(`/${ServerRoute.REST_REGISTRATION_TOKEN}`, async (req: Request, res: Response, next: NextFunction) => {
req.query.ID = sanitize(req.params.id);
await RouterUtils.handleServerAction(RegistrationTokenService.handleGetRegistrationToken.bind(this), ServerAction.REGISTRATION_TOKEN, req, res, next);
});
}
- protected buildRouteCreateRegistrationTokens(): void {
+ private buildRouteCreateRegistrationTokens(): void {
this.router.post(`/${ServerRoute.REST_REGISTRATION_TOKENS}`, async (req: Request, res: Response, next: NextFunction) => {
await RouterUtils.handleServerAction(RegistrationTokenService.handleCreateRegistrationToken.bind(this), ServerAction.REGISTRATION_TOKEN_CREATE, req, res, next);
});
}
+
+ private buildRouteUpdateRegistrationTokens(): void {
+ this.router.put(`/${ServerRoute.REST_REGISTRATION_TOKEN}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.body.id = req.params.id;
+ await RouterUtils.handleServerAction(RegistrationTokenService.handleUpdateRegistrationToken.bind(this), ServerAction.REGISTRATION_TOKEN_UPDATE, req, res, next);
+ });
+ }
+
+ private buildRouteDeleteRegistrationTokens(): void {
+ this.router.delete(`/${ServerRoute.REST_REGISTRATION_TOKEN}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.query.ID = req.params.id;
+ await RouterUtils.handleServerAction(RegistrationTokenService.handleDeleteRegistrationToken.bind(this), ServerAction.REGISTRATION_TOKEN_DELETE, req, res, next);
+ });
+ }
+
+ private buildRouteRevokeRegistrationTokens(): void {
+ this.router.put(`/${ServerRoute.REST_REGISTRATION_TOKEN_REVOKE}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.query.ID = req.params.id;
+ await RouterUtils.handleServerAction(RegistrationTokenService.handleRevokeRegistrationToken.bind(this), ServerAction.REGISTRATION_TOKEN_REVOKE, req, res, next);
+ });
+ }
}

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -588,6 +588,7 @@ export enum ServerRoute {
REST_REGISTRATION_TOKENS = 'registration-tokens',
REST_REGISTRATION_TOKEN = 'registration-tokens/:id',
+ REST_REGISTRATION_TOKEN_REVOKE = 'registration-tokens/:id/revoke',
// BILLING URLs for CRUD operations on PAYMENT METHODS
REST_BILLING_PAYMENT_METHODS = 'users/:userID/payment-methods',

Added registrationtoken update/delete/revoke endpoints + doc