Added setting update/delete endpoints+doc
MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
"$ref": "#/components/responses/ResourceDoesNotExists"
}
}
+ },
+ "put": {
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "description": "Update a Setting",
+ "tags": [
+ "Settings"
+ ],
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/SettingID"
+ }
+ ],
+ "requestBody": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Setting"
+ }
+ }
+ }
+ },
+ "responses": {
+ "200": {
+ "description": "Setting 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 Setting",
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/SettingID"
+ }
+ ],
+ "tags": [
+ "Settings"
+ ],
+ "responses": {
+ "200": {
+ "description": "Setting deleted successfully"
+ },
+ "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/SettingRouter.ts
src/server/rest/v1/router/api/SettingRouter.ts
@@ -17,6 +17,8 @@ export default class SettingRouter {
this.buildRouteSettings();
this.buildRouteSetting();
this.buildRouteCreateSetting();
+ this.buildRouteUpdateSetting();
+ this.buildRouteDeleteSetting();
return this.router;
}
@@ -43,4 +45,18 @@ export default class SettingRouter {
await RouterUtils.handleServerAction(SettingService.handleCreateSetting.bind(this), ServerAction.SETTING_CREATE, req, res, next);
});
}
+
+ private buildRouteUpdateSetting(): void {
+ this.router.put(`/${ServerRoute.REST_SETTING}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.body.id = req.params.id;
+ await RouterUtils.handleServerAction(SettingService.handleUpdateSetting.bind(this), ServerAction.SETTING_UPDATE, req, res, next);
+ });
+ }
+
+ private buildRouteDeleteSetting(): void {
+ this.router.delete(`/${ServerRoute.REST_SETTING}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.query.ID = req.params.id;
+ await RouterUtils.handleServerAction(SettingService.handleDeleteSetting.bind(this), ServerAction.SETTING_DELETE, req, res, next);
+ });
+ }
}

MODIFY
test/api/client/SettingApi.ts
test/api/client/SettingApi.ts
@@ -25,11 +25,11 @@ export default class SettingApi extends CrudApi {
}
public async update(data) {
- return super.update(data, '/client/api/SettingUpdate');
+ return super.update(data, this.buildRestEndpointUrl(ServerRoute.REST_SETTING, { id: data.id }));
}
public async delete(id) {
- return super.delete(id, '/client/api/SettingDelete');
+ return super.delete(id, this.buildRestEndpointUrl(ServerRoute.REST_SETTING, { id }));
}
}

Added setting update/delete endpoints+doc