package domain

import "context"

// TemplateKind — Harbor Desk 驗證／重設等郵件種類。
type TemplateKind string

const (
	TemplateEmailVerify   TemplateKind = "email_verify"
	TemplatePasswordReset TemplateKind = "password_reset"
)

// Language for templates.
type Language string

const (
	LangZhTW Language = "zh-tw"
	LangEnUS Language = "en-us"
)

// EmailRequest is a ready-to-send message.
type EmailRequest struct {
	RecipientEmail string
	SenderEmail    string
	Subject        string
	HTMLBody       string
}

// VerifyTemplateVars for template placeholders.
type VerifyTemplateVars struct {
	Username   string
	VerifyCode string
	// ResetURL — absolute link to FE reset page (password reset only).
	// e.g. https://app.example.com/reset-password?email=a%40b.com&token=123456
	ResetURL string
}

// EmailTemplate is subject + HTML body (may still contain {{.Var}}).
type EmailTemplate struct {
	Subject string
	Body    string
}

// EmailDelivery sends one email.
type EmailDelivery interface {
	SendEmail(ctx context.Context, req EmailRequest) error
	// Name is for logs (smtp / log / ses).
	Name() string
}

// UseCase — templates + send.
type UseCase interface {
	GetEmailTemplate(kind TemplateKind, lang Language) (*EmailTemplate, error)
	RenderVerify(kind TemplateKind, lang Language, vars VerifyTemplateVars) (subject, html string, err error)
	SendEmail(ctx context.Context, req EmailRequest) error
	// SenderFrom returns configured From address.
	SenderFrom() string
	// ExposeCodeInAPI is true in local/dev so FE can show mock_code without a real inbox.
	ExposeCodeInAPI() bool
	// Enabled is true when a real transport is configured (not log-only).
	Enabled() bool
	// Brand used in hermes chrome (logo etc.).
	Brand() Brand
}
