using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using RecruitmentBLL.FlsBridge; using static GB5Shared.GB5Constant.Constant; namespace RecruitmentSL.EndPoints.FlsBridge { // Public, token-scoped — same access-control mechanism as GetRecruitmentFlsAction. Confirmed // with the user: offer accept/decline (ActionType=3) needs NO OTP gate — this stays a plain // token-link submit for all 5 action types, kept deliberately simple per that decision. // // ResponsePayload is accepted as a raw JSON element rather than a strongly-typed DTO because // the 5 action types have genuinely different answer shapes (extended-application answers, // a reference-check questionnaire, an Accept/Decline decision, a shortlist ack, an // interview-confirm/reschedule flag) — RecruitmentFlsBridgeBLL.SubmitActionAsync parses only // the handful of fields it needs per ActionType (see FlsActionResponsePayload) and stores the // rest verbatim. public class SubmitRecruitmentFlsAction : BaseEndpoint> { private readonly IRecruitmentFlsBridgeBLL _BridgeBLL; public SubmitRecruitmentFlsAction(IRecruitmentFlsBridgeBLL bridgeBLL) { _BridgeBLL = bridgeBLL; } public override void Configure() { Post("/Recruitment/SubmitRecruitmentFlsAction"); AllowAnonymous(); } public record Parameters( [property: FastEndpoints.FromBody] SubmitRecruitmentFlsActionBody Body ); public record SubmitRecruitmentFlsActionBody(string Token, object ResponsePayload); protected override string? GetCacheKey(Parameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync(Parameters req, LoginDTO login, CancellationToken ct) { try { string responsePayloadJson = Newtonsoft.Json.JsonConvert.SerializeObject(req.Body.ResponsePayload); var result = await _BridgeBLL.SubmitActionAsync(req.Body.Token, responsePayloadJson, 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); } } } }