using GerbilManagerWebAPI.Names; namespace GerbilManagerWebAPI.Endpoints { /// /// FEAT-NAMEGEN: GET /names/suggest — meaningful gerbil name suggestions via Gemini. /// /// 503 {code:"NamesKeyMissing"} while the AI section is unconfigured — the /// frontend maps exactly this code to its German disabled-state hint. /// public static class NamesEndpoints { public static IEndpointRouteBuilder MapNamesEndpoints(this IEndpointRouteBuilder app) { app.MapGet("/names/suggest", async ( string? letter, string? gender, string? usages, int count, NameSuggestionService service, CancellationToken ct) => { var result = await service.SuggestAsync(letter, gender, usages, count, ct); return result.Status switch { NameSuggestionStatus.Ok => Results.Ok(result.Suggestions), NameSuggestionStatus.NotConfigured => Results.Json( new { code = "NamesKeyMissing", message = result.Error ?? "" }, statusCode: 503), _ => Results.Json( new { code = "NamesUpstreamError", message = result.Error ?? "" }, statusCode: 502), }; }) .WithTags("Names"); return app; } } }