using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PartnerBLL.Interfaces; using static GB5Shared.GB5Constant.Constant; namespace PartnerSL.EndPoints.PartnerApiKey { public class GetPartnerApiKeyList : BaseEndpoint> { private readonly IPartnerApiKeyBLL _bll; public GetPartnerApiKeyList(IPartnerApiKeyBLL bll) => _bll = bll; public override void Configure() { Get("/PartnerKey/GetPartnerApiKeyList"); AllowAnonymous(); } public record GetPartnerApiKeyListParameters( [property: FromHeader] string Login, [property: QueryParam] int PartnerProductId ); protected override string? GetCacheKey(GetPartnerApiKeyListParameters req, LoginDTO loginDTO) => KeyGenerator.KeyGeneration(req.PartnerProductId, EntityConstant.OBJECTPARTNERAPIKEY, CacheKeyLevel.CLIENT_LEVEL, loginDTO); protected override async Task> ExecuteAsync( GetPartnerApiKeyListParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _bll.GetPartnerApiKeyList(req.PartnerProductId, loginDTO); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.CLIENT_LEVEL, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, loginDTO, ex.Message, 500); } } } }