using FastEndpoints;
using TaxBaik.Application.Services;

namespace TaxBaik.Web.Endpoints.SiteSettings;

public class GetEndpoint : Endpoint<EmptyRequest, IReadOnlyDictionary<string, string>>
{
    private readonly SiteSettingService _siteSettingService;

    public GetEndpoint(SiteSettingService siteSettingService)
    {
        _siteSettingService = siteSettingService;
    }

    public override void Configure()
    {
        Get("/api/sitesettings");
        Policies("Bearer");
    }

    public override async Task HandleAsync(EmptyRequest _, CancellationToken ct)
    {
        var settings = await _siteSettingService.GetAllAsync(ct);
        await SendAsync(settings, 200, cancellation: ct);
    }
}
