//using FastEndpoints; //using FrameworkBLL.MessageHubService.TemplateApproval; //using FrameworkBLL.MessageHubWebhook; //using FrameworkDAL.DTO.MessageHub; //using FrameworkDAL.DTO.MessageHubService.UpdateHandleStatus; //using GB5Shared.DTO.Framework.Login; //using GB5Shared.DTO.Framework.ResponseStandard; //using GB5Shared.FastEndPoint; //using Microsoft.Extensions.Logging; //using System; //using System.Threading; //using System.Threading.Tasks; //using static GB5Shared.GB5Constant.Constant; //namespace FrameworkSL.Endpoints.MessageHubGenerator //{ // public class MessageHubWebhookEndpoint // : BaseEndpoint> // { // private readonly IMessageHubWebhookBLL _messageHubWebhookBLL; // private readonly ILogger _logger; // public MessageHubWebhookEndpoint( // IMessageHubWebhookBLL messageHubWebhookBLL, // ILogger logger) // { // _messageHubWebhookBLL = messageHubWebhookBLL; // _logger = logger; // } // public override void Configure() // { // Post("/MessageHub/MessageHubWebhook"); // AllowAnonymous(); // } // public record MessageHubWebhookParameters( // [property: FromHeader] string Login, // [property: FromBody] MessageHubWebhookDTO MessageHubWebhookDTO // ); // protected override async Task> ExecuteAsync( // MessageHubWebhookParameters req, // LoginDTO loginDTO, // CancellationToken ct) // { // if (req?.MessageHubWebhookDTO == null) // { // _logger.LogWarning("Webhook received with empty body or invalid DTO."); // return await GB5Shared.ResponseStandard.Response.CreateExceptionError( // new ArgumentNullException(nameof(req.MessageHubWebhookDTO)), // CacheKeyLevel.NOT_REQUIRED, // loginDTO, // "Invalid webhook payload: Body is null", // 400 // ); // } // try // { // _logger.LogInformation("Webhook received | LoginHeader={Login} | MessageCount={Count}", // req.Login, // req.MessageHubWebhookDTO.Messages?.Count ?? 0); // if (req.MessageHubWebhookDTO.Messages != null) // { // foreach (var msg in req.MessageHubWebhookDTO.Messages) // { // _logger.LogInformation( // "Message Details | From={From} | Type={Type} | ButtonText={ButtonText} | Payload={Payload}", // msg.From, // msg.Type, // msg.Button?.Text, // msg.Button?.Payload); // } // } // var result = await _messageHubWebhookBLL.MessageHubWebhook(req.MessageHubWebhookDTO, loginDTO!); // _logger.LogInformation("Webhook processed successfully | ResultType={ResultType}", // result?.GetType().Name ?? "null"); // return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( // result, // CacheKeyLevel.NOT_REQUIRED, // loginDTO); // } // catch (Exception ex) // { // _logger.LogError(ex, // "Error processing webhook | LoginHeader={Login} | MessageCount={Count}", // req.Login, // req.MessageHubWebhookDTO.Messages?.Count ?? 0); // return await GB5Shared.ResponseStandard.Response.CreateExceptionError( // ex, // CacheKeyLevel.NOT_REQUIRED, // loginDTO, // ex.Message, // 500 // ); // } // } // } //}