using FastEndpoints;
using KArtSell.Modules.ModelOperations.Domain;

namespace KArtSell.Modules.ModelOperations.Features.GetModelOperationsPlan;

public sealed class Endpoint : EndpointWithoutRequest<Response>
{
    public override void Configure()
    {
        Get("/internal/v1/model-operations/plan");
        Roles("Quant", "Risk", "System", "Auditor");
        Tags("ModelOperations");
    }

    public override Task HandleAsync(CancellationToken ct)
    {
        var items = ModelOperationRegistry.All.Select(x => new OperationItem(
            x.OperationCode,
            x.Name,
            x.Cadence.ToContractValue(),
            x.AutomationMode.ToContractValue(),
            x.Queue,
            x.PrimaryOwner,
            x.SecondaryOwner,
            x.RequiredEvidence,
            x.Output,
            x.Gate)).ToArray();

        return Send.OkAsync(new Response(
            "RESEARCH_CANDIDATE_NOT_PRODUCTION",
            "AUTOMATIC_ORDER_AND_KIS_SUBMISSION_OFF",
            "EVALUATION_AND_PROPOSAL_ONLY_HUMAN_APPROVAL_REQUIRED",
            items), ct);
    }
}
