package notify

// SendRequest is the payload for POST /email.
type SendRequest struct {
	To      string  `json:"to"`
	From    string  `json:"from"`
	ReplyTo string  `json:"reply_to,omitempty"`
	CC      string  `json:"cc,omitempty"`
	BCC     string  `json:"bcc,omitempty"`
	Content Content `json:"content"`
	Meta    Meta    `json:"meta"`
	Options Options `json:"options,omitempty"`
}

// Content holds the email subject and body.
type Content struct {
	Subject string `json:"subject"`
	HTML    string `json:"html,omitempty"`
	Text    string `json:"text,omitempty"`
}

// Meta contains routing metadata for the notify service.
type Meta struct {
	Host     string   `json:"host"`
	Category string   `json:"category,omitempty"`
	Tags     []string `json:"tags,omitempty"`
}

// Options contains delivery options.
type Options struct {
	IdempotencyKey string `json:"idempotency_key,omitempty"`
}

// SendResponse is returned by POST /email (202 Accepted).
type SendResponse struct {
	MessageID string `json:"message_id"`
	Status    string `json:"status"`
}

// Message is the full status of a sent message (GET /messages/{id}).
type Message struct {
	ID        string `json:"id"`
	To        string `json:"to"`
	From      string `json:"from"`
	Subject   string `json:"subject"`
	Status    string `json:"status"`
	Provider  string `json:"provider,omitempty"`
	CreatedAt string `json:"created_at"`
	SentAt    string `json:"sent_at,omitempty"`
}

// ErrorResponse is the error envelope from the notify API.
type ErrorResponse struct {
	Error   string            `json:"error"`
	Code    string            `json:"code,omitempty"`
	Details map[string]string `json:"details,omitempty"`
}
