19cd346b1c
- 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.
75 lines
2.2 KiB
Go
75 lines
2.2 KiB
Go
package notification
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
// NotificationService defines the interface for notification operations
|
|
type NotificationService interface {
|
|
// SendNotification sends a notification using the configured client
|
|
SendNotification(ctx context.Context, req *NotificationRequest) (*NotificationResponse, error)
|
|
|
|
// SendEmail sends an email notification
|
|
SendEmail(ctx context.Context, model Model) (*NotificationResponse, error)
|
|
|
|
// SendSMS sends an SMS notification
|
|
SendSMS(ctx context.Context, model Model) (*NotificationResponse, error)
|
|
|
|
// SendPush sends a push notification
|
|
SendPush(ctx context.Context, model Model) (*NotificationResponse, error)
|
|
|
|
// SendOTP sends an OTP notification
|
|
SendOTP(ctx context.Context, model Model) (*NotificationResponse, error)
|
|
|
|
// GetNotifications retrieves a list of notifications
|
|
GetNotifications(ctx context.Context, req *GetNotificationsRequest) (*NotificationListResponse, error)
|
|
|
|
// Health checks if the notification service is available
|
|
Health(ctx context.Context) error
|
|
|
|
// NewBuilder creates a new notification builder
|
|
NewBuilder() Builder
|
|
}
|
|
|
|
// Builder provides a fluent interface for building notification requests
|
|
type Builder interface {
|
|
// SetEventType sets the event type
|
|
SetEventType(eventType EventType) Builder
|
|
|
|
// SetMessage sets the notification message
|
|
SetMessage(message string) Builder
|
|
|
|
// SetUserID sets the user ID
|
|
SetUserID(userID string) Builder
|
|
|
|
// SetEmail sets the email address
|
|
SetEmail(email string) Builder
|
|
|
|
// SetSMS sets the SMS phone number
|
|
SetSMS(phoneNumber string) Builder
|
|
|
|
// SetPush sets the push device token
|
|
SetPush(deviceToken string) Builder
|
|
|
|
// SetOTP sets the OTP phone number
|
|
SetOTP(phoneNumber string) Builder
|
|
|
|
// SetTitle sets the notification title
|
|
SetTitle(title string) Builder
|
|
|
|
// SetType sets the notification type
|
|
SetType(notificationType string) Builder
|
|
|
|
// SetPriority sets the notification priority
|
|
SetPriority(priority string) Builder
|
|
|
|
// SetScheduledAt sets the scheduled delivery time (0 for immediate)
|
|
SetScheduledAt(scheduledAt int64) Builder
|
|
|
|
// Build creates the notification request
|
|
Build() (*NotificationRequest, error)
|
|
|
|
// Send builds and sends the notification
|
|
Send(ctx context.Context) (*NotificationResponse, error)
|
|
}
|