using System.ComponentModel.DataAnnotations;
using System.Text.Json;
using Tiku.Application.PlatformAdmin;
using Tiku.Domain.Common;

namespace Tiku.Api.Contracts;

public sealed record PlatformApprovalDecisionDto([Required] [MaxLength(1000)] string Reason);

public sealed record UpdatePlatformApprovalPolicyDto(
    bool Enabled,
    bool AlwaysRequireApproval,
    [Range(1, int.MaxValue)] int? AmountThresholdCents,
    [Range(1, 720)] int ExpiresAfterHours,
    JsonElement? Conditions)
{
    public UpdatePlatformApprovalPolicyCommand ToCommand(string code)
    {
        return new UpdatePlatformApprovalPolicyCommand(
            code,
            Enabled,
            AlwaysRequireApproval,
            AmountThresholdCents,
            ExpiresAfterHours,
            Conditions?.Clone() ?? JsonDefaults.Object());
    }
}