using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using PartnerBLL.PartnerWebhook; using static GB5Shared.GB5Constant.Constant; namespace PartnerSL.EndPoints.PartnerWebhook { public class GetPartnerWebhookList : BaseEndpoint> { private readonly IPartnerWebhookBLL _bll; public GetPartnerWebhookList(IPartnerWebhookBLL bll) => _bll = bll; public override void Configure() { Get("/PartnerWebhook/GetPartnerWebhookList"); AllowAnonymous(); } public record GetPartnerWebhookListParameters( [property: FromHeader] string Login, [property: QueryParam] int PartnerProductId ); protected override string? GetCacheKey(GetPartnerWebhookListParameters req, LoginDTO loginDTO) => KeyGenerator.KeyGeneration(req.PartnerProductId, EntityConstant.OBJECTPARTNERWEBHOOK, CacheKeyLevel.CLIENT_LEVEL, loginDTO); protected override async Task> ExecuteAsync( GetPartnerWebhookListParameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _bll.GetPartnerWebhookList(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); } } } }