using AccountsBLL.Voucher; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace AccountsSL.EndPoints.Voucher { // Legacy GB4 route: Voucher.svc/Payment/Entry/Validation/?ReferenceNumber={ReferenceNumber} (GET). public class PaymentEntryValidation : BaseEndpoint> { private readonly IVoucherBLL _VoucherBLL; public PaymentEntryValidation(IVoucherBLL voucherBLL) { _VoucherBLL = voucherBLL; } public override void Configure() { Get("/Voucher/PaymentEntryValidation"); AllowAnonymous(); } public record PaymentEntryValidationParameters( [property: FromHeader] string Login, [property: QueryParam] string ReferenceNumber ); protected override string? GetCacheKey(PaymentEntryValidationParameters Parameters, LoginDTO LoginDTO) => null; protected override async Task> ExecuteAsync(PaymentEntryValidationParameters req, LoginDTO LoginDTO, CancellationToken ct) { try { var Result = await _VoucherBLL.PaymentEntryValidation(req.ReferenceNumber, LoginDTO!); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(Result, CacheKeyLevel.NOT_REQUIRED, LoginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, LoginDTO, ex.Message, 500); } } } }