using System.Net.Http.Json;
using JdeScoping.Core.ApiContracts;
using JdeScoping.Core.Models.Infrastructure;
namespace JdeScoping.Client.Services;
///
/// Handles refresh status API calls.
/// Authentication is handled via cookies (sent automatically by the browser).
///
public class RefreshStatusService : IRefreshStatusService
{
private readonly HttpClient _httpClient;
///
/// Initializes a new instance of the class.
///
/// The HTTP client for API communication.
public RefreshStatusService(HttpClient httpClient)
{
_httpClient = httpClient;
}
///
/// Gets the data refresh status for a date range.
///
/// The minimum date for the status query.
/// The maximum date for the status query.
/// A list of data update information for the specified date range.
public async Task> GetRefreshStatusAsync(DateTime minDt, DateTime maxDt)
{
try
{
var result = await _httpClient.GetFromJsonAsync>(
ApiRoutes.RefreshStatus.Get(minDt, maxDt));
return result ?? [];
}
catch (Exception ex)
{
Console.WriteLine($"Failed to get refresh status: {ex.Message}");
return [];
}
}
}