package outbox

import (
	"time"

	"github.com/tech/sendico/pkg/db/storable"
)

const Collection = "outbox"

type Status string

const (
	StatusPending Status = "pending"
	StatusSent    Status = "sent"
	StatusFailed  Status = "failed"
)

// Event represents an outbox message pending dispatch to the broker.
type Event struct {
	storable.Base `bson:",inline" json:",inline"`

	EventID  string     `bson:"eventId" json:"eventId"`
	Subject  string     `bson:"subject" json:"subject"`
	Payload  []byte     `bson:"payload" json:"payload"`
	Status   Status     `bson:"status" json:"status"`
	Attempts int        `bson:"attempts" json:"attempts"`
	SentAt   *time.Time `bson:"sentAt,omitempty" json:"sentAt,omitempty"`
}

func (*Event) Collection() string {
	return Collection
}
