Enhance Notification Management with New Endpoints and Response Structures

- Added new endpoints for retrieving notifications for both admins and users, improving the flexibility of the notification system.
- Implemented query parameters for filtering notifications by status, method, event type, type, and recipient, enhancing usability.
- Introduced new response structures for notifications, including pagination information, to provide better data handling in API responses.
- Updated API documentation with Swagger comments for the new endpoints and response formats, ensuring clarity for API consumers.
- Refactored notification handling logic to support the new features, promoting a more robust notification management system.
This commit is contained in:
n.nakhostin
2025-09-20 17:41:21 +03:30
parent ab6eb3b3ed
commit 19cd346b1c
13 changed files with 1637 additions and 16 deletions
+72
View File
@@ -68,10 +68,82 @@ requests := []*notification.NotificationRequest{...}
batchResponse, err := sdk.SendBatch(ctx, requests)
```
### Getting Notifications
#### Get All Notifications
```go
// Get all notifications
response, err := sdk.GetNotifications(ctx, &notification.GetNotificationsRequest{})
```
#### Get Notifications with Filters
```go
// Get notifications for specific user
response, err := sdk.GetNotificationsByUser(ctx, "user_id_here", 1, 10)
// Get notifications by status
response, err := sdk.GetNotificationsByStatus(ctx, "sent", 1, 10)
// Get notifications with custom filters
req := &notification.GetNotificationsRequest{
Status: "sent",
Method: "email",
EventType: "EMAIL",
Type: "info",
UserID: "user_id_here",
Page: 1,
PerPage: 10,
}
response, err := sdk.GetNotifications(ctx, req)
```
#### Quick Get Notifications
```go
// Quick method for basic filtering
response, err := sdk.QuickGetNotifications(ctx, "user_id_here", "sent")
```
## API Response
### Send Notification Response
- **Success**: `{"status": "Notification sent"}`
- **Error**: `{"error": "error message"}`
### Get Notifications Response
```json
{
"data": [
{
"id": "68ceaaec99c78402b5fec555",
"user_id": "689a0aca36bf9aae890c30c1",
"title": "CHECK",
"message": "Check Send Notification Channels",
"link": "",
"image": "",
"type": "info",
"priority": "low",
"event_type": "EMAIL",
"created_at": "2025-09-20T13:23:56.664Z",
"updated_at": "0001-01-01T00:00:00Z",
"methods": {
"email": "nakhostin.nima1998@gmail.com"
},
"metadata": null,
"status": "sent",
"scheduled_at": 0,
"is_scheduled": false
}
],
"pagination": {
"total": 3,
"count": 3,
"per_page": 10,
"current_page": 1,
"total_pages": 1
}
}
```
## Error Handling
```go
if err != nil {