package model

import (
	"time"

	"github.com/tech/sendico/pkg/db/storable"
	"go.mongodb.org/mongo-driver/v2/bson"
)

// TaskStatus tracks delivery task lifecycle.
type TaskStatus string

const (
	TaskStatusPending   TaskStatus = "PENDING"
	TaskStatusRetry     TaskStatus = "RETRY"
	TaskStatusDelivered TaskStatus = "DELIVERED"
	TaskStatusFailed    TaskStatus = "FAILED"
)

// Task is one callback delivery job.
type Task struct {
	storable.Base
	EventID        string
	EndpointRef    bson.ObjectID
	EndpointURL    string
	SigningMode    string
	SecretRef      string
	Headers        map[string]string
	Payload        []byte
	Attempt        int
	MaxAttempts    int
	MinDelay       time.Duration
	MaxDelay       time.Duration
	RequestTimeout time.Duration
	Status         TaskStatus
	NextAttemptAt  time.Time
}
