Closed uloamaka closed 1 month ago
Backend logic to handle topic Updating (Admin only)
Admin can Update topics
Endpoint to allow superadmin to update existing topic
Only an authorized individual can update an topic updated topic replaces the old topic in the database
Updated topics should reflect on the database
PATCH /api/v1/help-center/topics/:id
Authentication Required: Yes (JWT Token)
Authorization Required: Yes (Admin Role)
Content-Type: application/json Authorization: Bearer Request:
{ "title": "string", "content": "string", "author": "string" }
Response: status: 200 OK
{ "success": true, "data": { "id": "string", "title": "string", "content": "string", "author": "string", "created_at": "datetime", "updated_at": "datetime", }, "status_code": 200 }
status: 401 Unauthorized (No token provided or token is invalid)
{ "success": false, "message": "Access denied. No token provided or token is invalid", "status_code": 401 }
status: 403 Forbidden (User does not have the required role of admin)
{ "success": false, "message": "Access denied", "status_code": 403 }
status: 404 Not-Found
{ "success": false, "message": "Article not found", "status_code": 404 }
422 Bad Request: Invalid input data.
{ "success": false, "message": "Invalid input data", "status_code": 422 }
Database Schema Table name: articles_table
article_id:
constraints: string(uuid), unique, primary-key, not null title:
constraints: string, unique, not null, text content:
constraints: string, not null, text createdAt:
constraints: datetime updatedAt:
constraints: datetime Database Diagram Database image
Unit Tests
ticket has been approved #121
Description
Backend logic to handle topic Updating (Admin only)
Acceptance Criteria
Admin can Update topics
Purpose
Endpoint to allow superadmin to update existing topic
Requirements
Only an authorized individual can update an topic updated topic replaces the old topic in the database
Expected Outcome
Updated topics should reflect on the database
EndPoint
PATCH /api/v1/help-center/topics/:id
Authentication Required: Yes (JWT Token)
Authorization Required: Yes (Admin Role)
Headers:
Content-Type: application/json Authorization: Bearer
Request:
Response: status: 200 OK
status: 401 Unauthorized (No token provided or token is invalid)
status: 403 Forbidden (User does not have the required role of admin)
status: 404 Not-Found
422 Bad Request: Invalid input data.
Database Schema Table name: articles_table
article_id:
constraints: string(uuid), unique, primary-key, not null title:
constraints: string, unique, not null, text content:
constraints: string, not null, text createdAt:
constraints: datetime updatedAt:
constraints: datetime Database Diagram Database image
Testing
Unit Tests