using ComplianceBLL.GSTValidate; 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 1 of the OTP+auth-token flow every GST Returns call requires (matches GB4's // GSTCafeServiceBLL.GetOTPRequest) — common to all GST filing surfaces (Outward/GSTR1, GSTR3B, // Inward sync), not Outward-specific. Must be called, and its OTP entered via GetAuthToken, before // SubmitGSTOutward/FileGSTReturn/SubmitGSTR3B/SyncReturnStatusFromPortal/SyncFromPortal. public class RequestOTP : BaseEndpoint> { private readonly IGSTValidateBLL _bll; public RequestOTP(IGSTValidateBLL bll) => _bll = bll; public override void Configure() { Post("/GSTValidate/RequestOTP"); AllowAnonymous(); } public record RequestOTPParameters( [property: FromHeader] string Login, [property: QueryParam] string GSTIN, [property: QueryParam] string ReturnPeriod ); protected override string? GetCacheKey(RequestOTPParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync(RequestOTPParameters req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.RequestOTPAsync(req.GSTIN, req.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); } } }