using ComplianceBLL.GSTValidate; using ComplianceDAL.DTO.GSTReturn; using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using static GB5Shared.GB5Constant.Constant; namespace ComplianceSL.Endpoints.GSTValidate; // Step 2 of the OTP+auth-token flow (matches GB4's GSTCafeServiceBLL.GetAuthToken) — exchanges the // OTP the user received (via RequestOTP) for auth_token/sek. Common to all GST filing surfaces // (Outward/GSTR1, GSTR3B, Inward sync), not Outward-specific. On success, returns the full // GSTHeaderDTO; the FE replays it wholesale as the GSTHeader request header on every subsequent // SubmitGSTOutward/FileGSTReturn/SubmitGSTR3B/SyncReturnStatusFromPortal/SyncFromPortal call. public class GetAuthToken : BaseEndpoint> { private readonly IGSTValidateBLL _bll; public GetAuthToken(IGSTValidateBLL bll) => _bll = bll; public override void Configure() { Post("/GSTValidate/GetAuthToken"); AllowAnonymous(); } public record GetAuthTokenParameters( [property: FromHeader] string Login, [property: FromBody] GetAuthTokenRequestDTO Request ); protected override string? GetCacheKey(GetAuthTokenParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync(GetAuthTokenParameters req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.GetAuthTokenAsync(req.Request.GSTIN, req.Request.OTP, req.Request.AppKey, req.Request.ReturnPeriod, 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); } } }