package reporting

import (
	"errors"
	"fmt"
	"strings"

	"github.com/tidbcloud/AgentTeam/internal/coredb"
	"github.com/tidbcloud/AgentTeam/internal/objectstorage"
	"github.com/tidbcloud/AgentTeam/internal/store/storeerr"
)

var (
	ErrBadRequest  = storeerr.ErrBadRequest
	ErrRateLimited = errors.New("rate limited")
)

func badRequest(message string) error { return storeerr.BadRequest(message) }

type Options struct{}

type Store struct {
	db                 coredb.DB
	mediaObjectStorage objectstorage.Storage
}

func New(db coredb.DB, mediaObjectStorage objectstorage.Storage, options Options) *Store {
	return &Store{
		db:                 db,
		mediaObjectStorage: mediaObjectStorage,
	}
}

func (store *Store) Validate() error {
	var missing []string
	if store == nil || store.db == nil {
		missing = append(missing, "DB")
	}
	if len(missing) > 0 {
		return fmt.Errorf("reporting store: missing dependencies: %s", strings.Join(missing, ", "))
	}
	return nil
}
