package domaintest

import (
	"gitea.dwysokinski.me/twhelp/corev3/internal/domain"
	"github.com/stretchr/testify/require"
)

type CleanUpDataCmdPayloadConfig struct {
	ServerOptions []func(cfg *ServerConfig)
}

func NewCleanUpDataCmdPayload(
	tb TestingTB,
	opts ...func(cfg *CleanUpDataCmdPayloadConfig),
) domain.CleanUpDataCmdPayload {
	tb.Helper()

	cfg := &CleanUpDataCmdPayloadConfig{}

	for _, opt := range opts {
		opt(cfg)
	}

	server := NewServer(tb, cfg.ServerOptions...)

	payloadServer, err := domain.NewCleanUpDataCmdPayloadServer(
		server.Key(),
		server.VersionCode(),
		server.Open(),
		server.Special(),
		server.PlayerDataSyncedAt(),
		server.PlayerSnapshotsCreatedAt(),
		server.TribeDataSyncedAt(),
		server.TribeSnapshotsCreatedAt(),
		server.VillageDataSyncedAt(),
		server.EnnoblementDataSyncedAt(),
	)
	require.NoError(tb, err)

	payload, err := domain.NewCleanUpDataCmdPayload(payloadServer)
	require.NoError(tb, err)

	return payload
}
