Documentation
¶
Overview ¶
Package notifications provides HTTP handlers for notification endpoints.
Index ¶
- type EmailAddress
- type EmailHandler
- func (h *EmailHandler) GetEmailStatus(w http.ResponseWriter, r *http.Request)
- func (h *EmailHandler) ListEmails(w http.ResponseWriter, r *http.Request)
- func (h *EmailHandler) ListTemplates(w http.ResponseWriter, r *http.Request)
- func (h *EmailHandler) SendEmail(w http.ResponseWriter, r *http.Request)
- type EmailResponse
- type ErrorResponse
- type ListEmailsResponse
- type ListTemplatesResponse
- type SendEmailRequest
- type TemplateResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EmailAddress ¶
type EmailAddress struct {
Name string `json:"name,omitempty"`
Email string `json:"email" validate:"required,email"`
}
EmailAddress represents an email recipient.
type EmailHandler ¶
type EmailHandler struct {
// contains filtered or unexported fields
}
EmailHandler handles email notification endpoints.
func NewEmailHandler ¶
func NewEmailHandler(emailService *email.EmailService) *EmailHandler
NewEmailHandler creates a new email handler.
func (*EmailHandler) GetEmailStatus ¶
func (h *EmailHandler) GetEmailStatus(w http.ResponseWriter, r *http.Request)
GetEmailStatus handles GET /api/v1/notifications/email/:id
func (*EmailHandler) ListEmails ¶
func (h *EmailHandler) ListEmails(w http.ResponseWriter, r *http.Request)
ListEmails handles GET /api/v1/notifications/email
func (*EmailHandler) ListTemplates ¶
func (h *EmailHandler) ListTemplates(w http.ResponseWriter, r *http.Request)
ListTemplates handles GET /api/v1/notifications/templates
func (*EmailHandler) SendEmail ¶
func (h *EmailHandler) SendEmail(w http.ResponseWriter, r *http.Request)
SendEmail handles POST /api/v1/notifications/email
type EmailResponse ¶
type EmailResponse struct {
ID string `json:"id"`
MessageID string `json:"messageId,omitempty"`
To []string `json:"to"`
Subject string `json:"subject"`
TemplateType string `json:"templateType,omitempty"`
Status string `json:"status"`
SentAt string `json:"sentAt"`
DeliveredAt *string `json:"deliveredAt,omitempty"`
OpenedAt *string `json:"openedAt,omitempty"`
Error string `json:"error,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
EmailResponse represents an email log in API responses.
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
Details map[string]string `json:"details,omitempty"`
}
ErrorResponse is the standard error response.
type ListEmailsResponse ¶
type ListEmailsResponse struct {
Emails []EmailResponse `json:"emails"`
Total int `json:"total"`
}
ListEmailsResponse is the response for listing emails.
type ListTemplatesResponse ¶
type ListTemplatesResponse struct {
Templates []TemplateResponse `json:"templates"`
}
ListTemplatesResponse is the response for listing templates.
type SendEmailRequest ¶
type SendEmailRequest struct {
To []EmailAddress `json:"to" validate:"required,min=1,dive"`
Cc []EmailAddress `json:"cc,omitempty" validate:"omitempty,dive"`
Bcc []EmailAddress `json:"bcc,omitempty" validate:"omitempty,dive"`
Subject string `json:"subject" validate:"required,max=255"`
TemplateType string `json:"templateType" validate:"required"`
Data map[string]any `json:"data,omitempty"`
Tags []string `json:"tags,omitempty"`
}
SendEmailRequest is the request body for sending an email.
type TemplateResponse ¶
TemplateResponse represents a template in API responses.