42 lines
1.2 KiB
C#

using ReportingServices.ReportingObjects;
using System.Text.Json;
namespace ReportingServices.Dependency_Injections
{
public class FabTimeReportingRepository : IFabTimeReportingRepository
{
public async Task<List<ReactorOutsByRDS>> GetMovesTrendData(string url)
{
return await GetJsonData<List<ReactorOutsByRDS>>(url);
}
public async Task<List<EquipmentStateByDay>> GetToolStateTrendData(string url)
{
return await GetJsonData<List<EquipmentStateByDay>>(url);
}
public async Task<List<ToolStateCurrent>> GetToolStateData(string url)
{
return await GetJsonData<List<ToolStateCurrent>>(url);
}
public async Task<T> GetJsonData<T>(string url)
{
T deserializedJson;
using (var client = new HttpClient())
{
using (HttpResponseMessage response = await client.GetAsync(url))
{
string apiResponse = await response.Content.ReadAsStringAsync();
deserializedJson = JsonSerializer.Deserialize<T>(apiResponse);
}
}
return deserializedJson;
}
}
}