using FastEndpoints;
using TaxBaik.Application.Services;

namespace TaxBaik.Web.Endpoints.Client;

public class DeleteEndpoint : Endpoint<EmptyRequest, EmptyResponse>
{
    private readonly ClientService _clientService;

    public DeleteEndpoint(ClientService clientService)
    {
        _clientService = clientService;
    }

    public override void Configure()
    {
        Delete("/api/client/{id}");
        Policies("Bearer");
    }

    public override async Task HandleAsync(EmptyRequest _, CancellationToken ct)
    {
        var id = Route<int>("id");
        await _clientService.DeleteAsync(id);
        await SendAsync(new EmptyResponse(), 204, cancellation: ct);
    }
}
