using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using RecruitmentBLL.FlsBridge; using RecruitmentDAL.DTO.FlsBridge; using static GB5Shared.GB5Constant.Constant; namespace RecruitmentSL.EndPoints.FlsBridge { // Internal caller — dispatches an FLS-coordinated token link for one of the 5 candidate/ // referee-facing action types (e.g. called right after an offer save, a reference-check // dispatch, a shortlist decision, or an interview being scheduled). AllowAnonymous here // matches every other endpoint in this SL module (no host in this repo configures // AddAuthentication — see PayRollSL's GetHRMSDashboard.cs for the same documented, // repo-wide gap) but in a real deployment this endpoint should be internal-only // (recruiter/system-triggered, never a public candidate-facing call) — unlike // GetRecruitmentFlsAction/SubmitRecruitmentFlsAction below, which are genuinely meant to be // public and token-scoped. public class PrepareRecruitmentAction : BaseEndpoint> { private readonly IRecruitmentFlsBridgeBLL _BridgeBLL; public PrepareRecruitmentAction(IRecruitmentFlsBridgeBLL bridgeBLL) { _BridgeBLL = bridgeBLL; } public override void Configure() { Post("/Recruitment/PrepareRecruitmentAction"); AllowAnonymous(); } public record Parameters( [property: FastEndpoints.FromBody] PrepareRecruitmentFlsActionDTO PrepareRecruitmentFlsActionDTO, [property: FastEndpoints.FromHeader] string Login ); protected override string? GetCacheKey(Parameters req, LoginDTO loginDTO) => null; protected override async Task> ExecuteAsync(Parameters req, LoginDTO loginDTO, CancellationToken ct) { try { var result = await _BridgeBLL.PrepareActionAsync(req.PrepareRecruitmentFlsActionDTO, loginDTO, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse(result, CacheKeyLevel.NOT_REQUIRED, loginDTO); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError(ex, CacheKeyLevel.NOT_REQUIRED, loginDTO, ex.Message, 500); } } } }