Skip to content

domain ​

go
import "github.com/prescriptoo/prescriptoo-api/services/notification/internal/domain"

Package domain contains core business entities for the notification service.

Index ​

Variables ​

go
var (
    // ErrTemplateNotFound indicates that a notification template does not exist.
    ErrTemplateNotFound = errors.New("template not found")
    // ErrInvalidChannel indicates that a notification channel is unsupported.
    ErrInvalidChannel = errors.New("invalid notification channel")
)

type Channel ​

Channel represents the delivery method for a notification.

go
type Channel string

go
const (
    // ChannelEmail selects email delivery.
    ChannelEmail Channel = "email"
    // ChannelSMS selects SMS delivery.
    ChannelSMS Channel = "sms"
)

type Notification ​

Notification represents a notification to be sent.

go
type Notification struct {
    ID         string         `json:"id"`
    Channel    Channel        `json:"channel"`
    Recipient  string         `json:"recipient"` // email or phone number
    TemplateID string         `json:"template_id"`
    Subject    string         `json:"subject"` // for email
    Body       string         `json:"body"`
    Variables  map[string]any `json:"variables,omitempty"`
    Status     Status         `json:"status"`
    Error      string         `json:"error,omitempty"`
    CreatedAt  time.Time      `json:"created_at"`
    SentAt     *time.Time     `json:"sent_at,omitempty"`
}

type Status ​

Status represents the delivery status of a notification.

go
type Status string

go
const (
    // StatusPending marks a notification awaiting processing.
    StatusPending Status = "pending"
    // StatusQueued marks a notification queued for delivery.
    StatusQueued Status = "queued"
    // StatusSent marks a notification sent through its delivery provider.
    StatusSent Status = "sent"
    // StatusDelivered marks a notification delivered to its recipient.
    StatusDelivered Status = "delivered"
    // StatusFailed marks a notification whose delivery failed.
    StatusFailed Status = "failed"
)

type Template ​

Template represents a reusable notification template.

go
type Template struct {
    ID        string    `json:"id"`
    Name      string    `json:"name"` // welcome_email, verification_approved, etc.
    Channel   Channel   `json:"channel"`
    Subject   string    `json:"subject"`   // for email templates
    Body      string    `json:"body"`      // template with {{variable}} syntax
    Variables []string  `json:"variables"` // required variable names
    IsActive  bool      `json:"is_active"`
    CreatedAt time.Time `json:"created_at"`
    UpdatedAt time.Time `json:"updated_at"`
}

Generated by gomarkdoc

Documentation follows the source. Planned contracts are marked explicitly.