Documentation
¶
Overview ¶
Package repository provides email persistence.
Index ¶
- type EmailFilter
- type EmailLog
- type EmailRepository
- type MemoryEmailRepository
- func (r *MemoryEmailRepository) Clear()
- func (r *MemoryEmailRepository) Count() int
- func (r *MemoryEmailRepository) GetEmail(ctx context.Context, emailID string) (*EmailLog, error)
- func (r *MemoryEmailRepository) ListEmails(ctx context.Context, filter EmailFilter) ([]EmailLog, error)
- func (r *MemoryEmailRepository) SaveEmail(ctx context.Context, email *EmailLog) error
- func (r *MemoryEmailRepository) UpdateStatus(ctx context.Context, emailID string, status string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EmailFilter ¶
type EmailFilter struct {
To *string
Status *string
StartTime *time.Time
EndTime *time.Time
Limit int
Offset int
}
EmailFilter defines filtering options for listing emails.
type EmailLog ¶
type EmailLog struct {
ID string `json:"id"`
MessageID string `json:"messageId,omitempty"` // Brevo message ID
To []string `json:"to"`
Subject string `json:"subject"`
TemplateType string `json:"templateType,omitempty"`
Status string `json:"status"` // sent, delivered, opened, bounced, failed
SentAt time.Time `json:"sentAt"`
DeliveredAt *time.Time `json:"deliveredAt,omitempty"`
OpenedAt *time.Time `json:"openedAt,omitempty"`
Error string `json:"error,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
EmailLog represents a logged email.
type EmailRepository ¶
type EmailRepository interface {
// SaveEmail persists an email log entry.
SaveEmail(ctx context.Context, email *EmailLog) error
// GetEmail retrieves an email log by ID.
GetEmail(ctx context.Context, emailID string) (*EmailLog, error)
// ListEmails retrieves email logs with optional filtering.
ListEmails(ctx context.Context, filter EmailFilter) ([]EmailLog, error)
// UpdateStatus updates the status of an email log.
UpdateStatus(ctx context.Context, emailID string, status string) error
}
EmailRepository defines the interface for email persistence.
type MemoryEmailRepository ¶
type MemoryEmailRepository struct {
// contains filtered or unexported fields
}
MemoryEmailRepository is an in-memory implementation of EmailRepository.
func NewMemoryEmailRepository ¶
func NewMemoryEmailRepository() *MemoryEmailRepository
NewMemoryEmailRepository creates a new in-memory email repository.
func (*MemoryEmailRepository) Clear ¶
func (r *MemoryEmailRepository) Clear()
Clear removes all emails from the repository (useful for testing).
func (*MemoryEmailRepository) Count ¶
func (r *MemoryEmailRepository) Count() int
Count returns the number of emails in the repository.
func (*MemoryEmailRepository) ListEmails ¶
func (r *MemoryEmailRepository) ListEmails(ctx context.Context, filter EmailFilter) ([]EmailLog, error)
ListEmails retrieves email logs with optional filtering.
func (*MemoryEmailRepository) SaveEmail ¶
func (r *MemoryEmailRepository) SaveEmail(ctx context.Context, email *EmailLog) error
SaveEmail persists an email log entry in memory.
func (*MemoryEmailRepository) UpdateStatus ¶
func (r *MemoryEmailRepository) UpdateStatus(ctx context.Context, emailID string, status string) error
UpdateStatus updates the status of an email log.
Click to show internal directories.
Click to hide internal directories.