hngprojects / hng_boilerplate_golang_web

Apache License 2.0
77 stars 50 forks source link

[FEAT]: HELP CENTER - DELETE TOPIC #272

Closed uloamaka closed 3 months ago

uloamaka commented 3 months ago

Description

The help center contains topics that provide users with advice and assistance from the support team. This endpoint permanently deletes outdated or invalid topics (help guides) from the database.

Acceptance Criteria

Endpoint is protected. Topics can be deleted by superadmins only.

Purpose

To delete a topic previously created

Requirements

Endpoint Flow

This endpoint deletes the topic with the ID specified in the path from the help_center_topics table.

Request

Successful Response

Status Code: 200

Description: Deleted successfully

{ }

"status_code": 204

Error Response

Status Code: 403

Description: Forbidden, Only SuperAdmins can access this endpoint.

{
    "success": false,
    "message": "Access denied",
    "status_code": 403
}

Status Code: 404

Description: No topic ID matches the ID param provided.

{
    "success": false,
    "message": "Topic not found, please check and try again",
    "status_code": 404
}

Status Code: 500

Description: Internal Server error

{
    "success": false,
    "message": "Something went wrong, please try again later or contact support it persists",
    "status_code": 500
}

Validations

Database Schema

Table name: help_center_topics

id:

constraints: varchar(uuid), unique, primary-key, not null title:

constraints: varchar, unique, not null content:

constraints: text, not null, author:

constraints: varchar, unique, not null created_at:

constraints: datetime updated_at:

constraints: datetime Database diagram database diagram

Testing

Unit Tests

uloamaka commented 3 months ago

ticket has been approved #111