-
Notifications
You must be signed in to change notification settings - Fork 56
Description
Description:
Implement a new API endpoint that allows exporting the list of all users in a CSV file format. This functionality should be accessible only to users with the Super Admin role. The exported CSV should include the necessary user details (e.g., user ID, Fullname, email).
Acceptance Criteria
- Only users with the Super Admin role should have access to this endpoint.
- Admins can delete any comment.
- Returns a 200 OK status with a success message when a comment is successfully deleted.
- Returns a 401 Unauthorized access You must have Super Admin privileges to export user data.
- Returns a 500 Internal Server Error if an unexpected issue occurs.
Expected Outcome
- Successful User Data Export (Super Admin Only)
- Unauthorized Access (Non-Super Admin)
- Internal Server Errors (e.g., Database Failure)
- Handling Large User Data Efficiently:
Endpoint:
The endpoint should be a GET request (e.g., GET /api/v1/users/export/csv).
The endpoint should return a CSV file containing all user data.
Responses
✅ Success Response
Status: 200 OK
🚫 Unauthorized Response
Status: 401 Unauthorized
json
{
"success: "false",
"message": "Unauthorized access. You must have Super Admin privileges to export user data.",
"status_code": "401"
}
CSV Format:
The CSV file should contain relevant columns such as:
User ID
Full Name
Email Address
The CSV should be properly formatted and downloadable.
Performance Considerations:
Ensure that the export process handles a large number of users efficiently.
The file should be generated in a reasonable time frame (e.g., < 30 seconds for 10,000 users).
Testing:
Implement unit and integration tests for the new endpoint.
Ensure that the Super Admin can successfully download the CSV, and non-Super Admin users are denied access.