AI-Studio/app/MindWork AI Studio/Assistants/ERI/ERIVersionExtensions.cs

27 lines
806 B
C#
Raw Normal View History

2024-12-14 18:48:47 +00:00
namespace AIStudio.Assistants.ERI;
2024-12-09 18:25:22 +00:00
2024-12-14 18:48:47 +00:00
public static class ERIVersionExtensions
2024-12-09 18:25:22 +00:00
{
2024-12-14 18:48:47 +00:00
public static async Task<string> ReadSpecification(this ERIVersion version, HttpClient httpClient)
2024-12-09 18:25:22 +00:00
{
try
{
var url = version.SpecificationURL();
var response = await httpClient.GetAsync(url);
return await response.Content.ReadAsStringAsync();
}
catch
{
return string.Empty;
}
}
2024-12-14 18:48:47 +00:00
public static string SpecificationURL(this ERIVersion version)
2024-12-09 18:25:22 +00:00
{
var nameLower = version.ToString().ToLowerInvariant();
var filename = $"{nameLower}.json";
2024-12-14 18:48:47 +00:00
return $"specs/eri/{filename}";
2024-12-09 18:25:22 +00:00
}
2024-12-14 18:48:47 +00:00
public static bool WasSpecificationSelected(this ERIVersion version) => version != ERIVersion.NONE;
2024-12-09 18:25:22 +00:00
}