using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using MarketingBLL.Communication; using static GB5Shared.GB5Constant.Constant; namespace MarketingSL.EndPoints.Communication; public class GetCommunication : BaseEndpoint> { private readonly ICommunicationBLL _CommunicationBLL; public GetCommunication(ICommunicationBLL communicationBLL) => _CommunicationBLL = communicationBLL; public override void Configure() { Get("/Communication/GetCommunication"); AllowAnonymous(); } public record GetCommunicationParameters( [property: QueryParam] int CommunicationId, [property: FromHeader] string Login ); protected override string? GetCacheKey(GetCommunicationParameters req, LoginDTO login) => KeyGenerator.KeyGeneration(req.CommunicationId, EntityConstant.OBJECTMARKETINGCOMMUNICATION, CacheKeyLevel.CLIENT_LEVEL, login); protected override async Task> ExecuteAsync(GetCommunicationParameters req, LoginDTO login, CancellationToken ct) { try { var result = await _CommunicationBLL.GetCommunication(req.CommunicationId, login!, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.CLIENT_LEVEL, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.CLIENT_LEVEL, login, ex.Message, 500); } } }