-
Notifications
You must be signed in to change notification settings - Fork 86
API Documentation_NotificationCenter
Overview
This document provides API specifications for managing user notifications in the Notification Center module. The API includes:
- A GET endpoint to fetch both Help Match and General notifications relevant to the user.
- A POST endpoint to accept a Help Match Request and assign it to the current user.
- A POST endpoint to deny a Help Match Request and mark it as handled.
- The expected request and response payloads for each endpoint.
Endpoints
1. Get Notifications
Endpoint: GET /api/notifications
Description: Retrieves all notifications relevant to the current user, including Help Match Requests and General Notifications.
Request Parameters: userId
Response:
{
"type": "Volunteer",
"title": "New Match Request",
"message": "You have new Volunteer match request in Logistics",
"date": "Mar 15, 2023, 10:30 AM"
}
{
"type": "helpRequest",
"title": "Educational Help",
"message": "Need help with Logistics",
"date": "Dec 16, 2023, 10:30 AM"
}
2. Accept Match Request
**Endpoint:** POST /api/notifications/accept
**Description:** Assigns the current user to the selected Help Match Request.
**Request Parameters:** None (Requires body)
Request Body:
{
"requestId": "abc123"
}
Response:
{
"message": "Request accepted successfully",
"status": "assigned",
"requestId": "abc123".
}
3. Deny Match Request
**Endpoint:** POST /api/notifications/deny
**Description:** Denies the selected Help Match Request and marks it as handled or reassigns it.
**Request Parameters:** None (Requires body)
Request Body:
{
"requestId": "abc123"
}
Response:
{
"message": "Request denied successfully",
"status": "denied",
"requestId": "abc123"
}
Error Responses:
- 400 Bad Request – The request was invalid or missing required data.
- 401 Unauthorized – The user is not authenticated. Authentication token is missing or invalid.
- 404 Not Found – The requested resource (e.g., notification or help request) was not found.
- 500 Internal Server Error – An unexpected error occurred on the server.
Notes
- Notification APIs do not require path or query parameters; all necessary data is included in the request body (for POST endpoints).
- Notifications are auto-fetched every 2 minutes to ensure timely updates without manual refresh.
- Help Match Requests are actionable and must be accepted or denied using the appropriate POST endpoints. General notifications are non-actionable and meant for display only.
- Valid requestId must be included in the request body for Accept and Deny APIs.
- UI should disable Accept/Deny buttons after an action is performed and reflect the updated status.
- Notification components should use stable IDs for consistent rendering and styling.
- Authentication may be required to fetch and interact with notifications.
Prepared by: Meghana Atmuri