package ports

import (
	"context"

	"github.com/rede5/gohorsejobs/backend/internal/core/domain/entity"
)

type CompanyRepository interface {
	Save(ctx context.Context, company *entity.Company) (*entity.Company, error)
	FindByID(ctx context.Context, id string) (*entity.Company, error)
	FindAll(ctx context.Context) ([]*entity.Company, error)
	Update(ctx context.Context, company *entity.Company) (*entity.Company, error)
	Delete(ctx context.Context, id string) error
}

type UserRepository interface {
	Save(ctx context.Context, user *entity.User) (*entity.User, error)
	FindByID(ctx context.Context, id string) (*entity.User, error)
	FindByEmail(ctx context.Context, email string) (*entity.User, error)
	// FindAllByTenant returns users strictly scoped to a tenant
	FindAllByTenant(ctx context.Context, tenantID string, limit, offset int) ([]*entity.User, int, error)
	// LinkGuestApplications links applications made as guest (by email) to a new user ID
	LinkGuestApplications(ctx context.Context, email string, userID string) error
	Update(ctx context.Context, user *entity.User) (*entity.User, error)
	Delete(ctx context.Context, id string) error
}

type EmailRepository interface {
	// Templates
	ListTemplates(ctx context.Context) ([]*entity.EmailTemplate, error)
	GetTemplate(ctx context.Context, slug string) (*entity.EmailTemplate, error)
	CreateTemplate(ctx context.Context, tmpl *entity.EmailTemplate) error
	UpdateTemplate(ctx context.Context, tmpl *entity.EmailTemplate) error
	DeleteTemplate(ctx context.Context, slug string) error

	// Settings
	GetSettings(ctx context.Context) (*entity.EmailSettings, error)
	UpdateSettings(ctx context.Context, settings *entity.EmailSettings) error
}
