using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using GoodBooks.PAY.PAYBLL.Gateway; using static GB5Shared.GB5Constant.Constant; namespace GoodBooks.PAY.PAYSL.Endpoints.Gateway { public class GetPayGatewayConfigByGatewayId : BaseEndpoint> { private readonly IPayGatewayConfigBLL _bll; public GetPayGatewayConfigByGatewayId(IPayGatewayConfigBLL bll) => _bll = bll; public override void Configure() { Get("/Pay/Gateway/GetPayGatewayConfigByGatewayId"); AllowAnonymous(); } public record GetPayGatewayConfigByGatewayIdParameters( [property: FromHeader] string Login, [property: QueryParam] int PayGatewayId ); /// /// NOT_REQUIRED — gateway config drives live checkout behavior; caching risks stale /// credential/flag state during an active configuration change. /// protected override string? GetCacheKey(GetPayGatewayConfigByGatewayIdParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( GetPayGatewayConfigByGatewayIdParameters req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.GetPayGatewayConfigByGatewayId(req.PayGatewayId, login, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.NOT_REQUIRED, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError( ex, CacheKeyLevel.NOT_REQUIRED, login, ex.Message, 500); } } } }