using Baya.Application.Contracts.Common;
using Baya.Application.Models.Common;
using Mediator;

namespace Baya.Application.Features.System.Queries.Ping;

internal sealed class PingQueryHandler(IDateTimeProvider dateTimeProvider)
    : IRequestHandler<PingQuery, OperationResult<PingQueryResult>>
{
    public ValueTask<OperationResult<PingQueryResult>> Handle(PingQuery request, CancellationToken cancellationToken)
    {
        var result = new PingQueryResult("Baya.Web.Api", "ok", dateTimeProvider.UtcNow);

        return ValueTask.FromResult(OperationResult<PingQueryResult>.SuccessResult(result));
    }
}
