namespace NATS.Server.JetStream.Api.Handlers;

public static class AccountControlApiHandlers
{
    public static JetStreamApiResponse HandleServerRemove()
        => JetStreamApiResponse.SuccessResponse();

    public static JetStreamApiResponse HandleAccountPurge(string subject)
    {
        if (!subject.StartsWith(JetStreamApiSubjects.AccountPurge, StringComparison.Ordinal))
            return JetStreamApiResponse.NotFound(subject);

        var account = subject[JetStreamApiSubjects.AccountPurge.Length..].Trim();
        return account.Length == 0 ? JetStreamApiResponse.NotFound(subject) : JetStreamApiResponse.SuccessResponse();
    }

    public static JetStreamApiResponse HandleAccountStreamMove(string subject)
    {
        if (!subject.StartsWith(JetStreamApiSubjects.AccountStreamMove, StringComparison.Ordinal))
            return JetStreamApiResponse.NotFound(subject);

        var account = subject[JetStreamApiSubjects.AccountStreamMove.Length..].Trim();
        return account.Length == 0 ? JetStreamApiResponse.NotFound(subject) : JetStreamApiResponse.SuccessResponse();
    }

    public static JetStreamApiResponse HandleAccountStreamMoveCancel(string subject)
    {
        if (!subject.StartsWith(JetStreamApiSubjects.AccountStreamMoveCancel, StringComparison.Ordinal))
            return JetStreamApiResponse.NotFound(subject);

        var account = subject[JetStreamApiSubjects.AccountStreamMoveCancel.Length..].Trim();
        return account.Length == 0 ? JetStreamApiResponse.NotFound(subject) : JetStreamApiResponse.SuccessResponse();
    }
}
