Documentation
¶
Index ¶
- type CreateTemplateRequest
- type ListNotificationsRequest
- type ListNotificationsResponse
- type Notification
- type NotificationChannel
- type NotificationPriority
- type NotificationStats
- type NotificationStatus
- type NotificationTemplate
- type NotificationType
- type PreviewTemplateRequest
- type PreviewTemplateResponse
- type SendNotificationRequest
- type SendNotificationResponse
- type UpdateTemplateRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateTemplateRequest ¶
type CreateTemplateRequest struct {
Name string `json:"name" validate:"required,min=3,max=100"`
Channel NotificationChannel `json:"channel" validate:"required,oneof=sms email push in_app"`
SubjectTemplate string `json:"subject_template,omitempty" validate:"omitempty,max=200"`
BodyTemplate string `json:"body_template" validate:"required,max=5000"`
MetadataRaw json.RawMessage `json:"metadata,omitempty"`
}
CreateTemplateRequest represents a request to create a notification template.
func (*CreateTemplateRequest) GetMetadata ¶
func (r *CreateTemplateRequest) GetMetadata() (map[string]string, error)
GetMetadata parses and returns the metadata map.
type ListNotificationsRequest ¶
type ListNotificationsRequest struct {
UserID *string `json:"user_id,omitempty" validate:"omitempty,uuid"`
Channel *NotificationChannel `json:"channel,omitempty"`
Type *NotificationType `json:"type,omitempty"`
Status *NotificationStatus `json:"status,omitempty"`
SourceService *string `json:"source_service,omitempty"`
StartDate *models.Timestamp `json:"start_date,omitempty"`
EndDate *models.Timestamp `json:"end_date,omitempty"`
Limit int `json:"limit,omitempty" validate:"omitempty,min=1,max=100"`
Offset int `json:"offset,omitempty" validate:"omitempty,min=0"`
}
ListNotificationsRequest represents a request to list notifications with filters.
type ListNotificationsResponse ¶
type ListNotificationsResponse struct {
Notifications []*Notification `json:"notifications"`
Total int64 `json:"total"`
Limit int `json:"limit"`
Offset int `json:"offset"`
}
ListNotificationsResponse represents the response for listing notifications.
type Notification ¶
type Notification struct {
ID string `json:"id" db:"id"`
UserID *string `json:"user_id,omitempty" db:"user_id"` // Null for system-wide notifications
Channel NotificationChannel `json:"channel" db:"channel"`
Type NotificationType `json:"type" db:"type"`
Priority NotificationPriority `json:"priority" db:"priority"`
Recipient string `json:"recipient" db:"recipient"` // Email address or phone number
Subject string `json:"subject,omitempty" db:"subject"` // For email/push
Body string `json:"body" db:"body"`
TemplateID *string `json:"template_id,omitempty" db:"template_id"`
Status NotificationStatus `json:"status" db:"status"`
CorrelationID *string `json:"correlation_id,omitempty" db:"correlation_id"` // For idempotency
SourceService string `json:"source_service" db:"source_service"`
Metadata map[string]interface{} `json:"metadata,omitempty" db:"metadata"`
RetryCount int `json:"retry_count" db:"retry_count"`
FailureReason *string `json:"failure_reason,omitempty" db:"failure_reason"`
QueuedAt models.Timestamp `json:"queued_at" db:"queued_at"`
SentAt *models.Timestamp `json:"sent_at,omitempty" db:"sent_at"`
DeliveredAt *models.Timestamp `json:"delivered_at,omitempty" db:"delivered_at"`
FailedAt *models.Timestamp `json:"failed_at,omitempty" db:"failed_at"`
CreatedAt models.Timestamp `json:"created_at" db:"created_at"`
UpdatedAt models.Timestamp `json:"updated_at" db:"updated_at"`
}
Notification represents a notification in the system.
func (*Notification) IsCritical ¶
func (n *Notification) IsCritical() bool
IsCritical returns true if the notification is critical priority.
func (*Notification) IsDelivered ¶
func (n *Notification) IsDelivered() bool
IsDelivered returns true if the notification was delivered.
func (*Notification) IsFailed ¶
func (n *Notification) IsFailed() bool
IsFailed returns true if the notification failed.
func (*Notification) IsQueued ¶
func (n *Notification) IsQueued() bool
IsQueued returns true if the notification is queued.
func (*Notification) IsSent ¶
func (n *Notification) IsSent() bool
IsSent returns true if the notification has been sent.
type NotificationChannel ¶
type NotificationChannel string
NotificationChannel represents the delivery channel for a notification.
const ( ChannelSMS NotificationChannel = "sms" // SMS text message ChannelEmail NotificationChannel = "email" // Email message ChannelPush NotificationChannel = "push" // Push notification ChannelInApp NotificationChannel = "in_app" // In-app notification )
type NotificationPriority ¶
type NotificationPriority string
NotificationPriority represents the priority level of a notification.
const ( PriorityCritical NotificationPriority = "critical" // OTP, security alerts PriorityHigh NotificationPriority = "high" // Transaction alerts PriorityNormal NotificationPriority = "normal" // Regular notifications PriorityLow NotificationPriority = "low" // Marketing, updates )
type NotificationStats ¶
type NotificationStats struct {
TotalNotifications int64 `json:"total_notifications"`
ByChannel map[NotificationChannel]int `json:"by_channel"`
ByStatus map[NotificationStatus]int `json:"by_status"`
ByType map[NotificationType]int `json:"by_type"`
SuccessRate float64 `json:"success_rate"` // Percentage
AverageRetries float64 `json:"average_retries"`
}
NotificationStats represents statistics for notifications.
type NotificationStatus ¶
type NotificationStatus string
NotificationStatus represents the delivery status of a notification.
const ( StatusQueued NotificationStatus = "queued" // Queued for delivery StatusSent NotificationStatus = "sent" // Sent to provider StatusDelivered NotificationStatus = "delivered" // Successfully delivered StatusFailed NotificationStatus = "failed" // Delivery failed )
type NotificationTemplate ¶
type NotificationTemplate struct {
ID string `json:"id" db:"id"`
Name string `json:"name" db:"name"` // Unique identifier (e.g., "otp_sms", "transaction_alert_email")
Channel NotificationChannel `json:"channel" db:"channel"`
SubjectTemplate string `json:"subject_template,omitempty" db:"subject_template"` // For email/push
BodyTemplate string `json:"body_template" db:"body_template"`
Version int `json:"version" db:"version"`
Metadata map[string]string `json:"metadata,omitempty" db:"metadata"`
CreatedAt models.Timestamp `json:"created_at" db:"created_at"`
UpdatedAt models.Timestamp `json:"updated_at" db:"updated_at"`
}
NotificationTemplate represents a notification template with variable substitution.
type NotificationType ¶
type NotificationType string
NotificationType represents the type of notification.
const ( TypeOTP NotificationType = "otp" // One-time password TypeTransactionAlert NotificationType = "transaction_alert" // Transaction notification TypeAccountAlert NotificationType = "account_alert" // Account-related alert TypeKYCUpdate NotificationType = "kyc_update" // KYC status update TypeWelcome NotificationType = "welcome" // Welcome message TypeSecurityAlert NotificationType = "security_alert" // Security-related alert TypeWalletAlert NotificationType = "wallet_alert" // Wallet-related alert TypeSystemAlert NotificationType = "system_alert" // System notification )
type PreviewTemplateRequest ¶
type PreviewTemplateRequest struct {
Variables map[string]interface{} `json:"variables"`
}
PreviewTemplateRequest represents a request to preview a template with variables.
type PreviewTemplateResponse ¶
type PreviewTemplateResponse struct {
Subject string `json:"subject,omitempty"`
Body string `json:"body"`
RenderedAt models.Timestamp `json:"rendered_at"`
VariableUsed []string `json:"variables_used"` // List of variables that were substituted
}
PreviewTemplateResponse represents the rendered template preview.
type SendNotificationRequest ¶
type SendNotificationRequest struct {
UserID *string `json:"user_id,omitempty" validate:"omitempty,uuid"`
Channel NotificationChannel `json:"channel" validate:"required,oneof=sms email push in_app"`
Type NotificationType `json:"type" validate:"required"`
Priority NotificationPriority `json:"priority,omitempty" validate:"omitempty,oneof=critical high normal low"`
Recipient string `json:"recipient" validate:"required"`
TemplateID *string `json:"template_id,omitempty" validate:"omitempty,uuid"`
Subject string `json:"subject,omitempty" validate:"omitempty,max=200"`
Body string `json:"body,omitempty" validate:"omitempty,max=5000"`
Variables map[string]interface{} `json:"variables,omitempty"`
CorrelationID *string `json:"correlation_id,omitempty" validate:"omitempty,max=100"`
MetadataRaw json.RawMessage `json:"metadata,omitempty"`
}
SendNotificationRequest represents a request to send a notification.
func (*SendNotificationRequest) GetMetadata ¶
func (r *SendNotificationRequest) GetMetadata() (map[string]interface{}, error)
GetMetadata parses and returns the metadata map.
type SendNotificationResponse ¶
type SendNotificationResponse struct {
NotificationID string `json:"notification_id"`
Status NotificationStatus `json:"status"`
QueuedAt models.Timestamp `json:"queued_at"`
}
SendNotificationResponse represents the response after sending a notification.
type UpdateTemplateRequest ¶
type UpdateTemplateRequest struct {
SubjectTemplate *string `json:"subject_template,omitempty" validate:"omitempty,max=200"`
BodyTemplate *string `json:"body_template,omitempty" validate:"omitempty,max=5000"`
MetadataRaw json.RawMessage `json:"metadata,omitempty"`
}
UpdateTemplateRequest represents a request to update a notification template.
func (*UpdateTemplateRequest) GetMetadata ¶
func (r *UpdateTemplateRequest) GetMetadata() (map[string]string, error)
GetMetadata parses and returns the metadata map.