daaeba2004
Centralizes all API endpoint strings in ApiRoutes for consistency and easier maintenance. Adds Hubs class for SignalR endpoints. Removes completed plan files.
45 lines
1.5 KiB
C#
45 lines
1.5 KiB
C#
using System.Net.Http.Json;
|
|
using JdeScoping.Core.ApiContracts;
|
|
using JdeScoping.Core.Models.Infrastructure;
|
|
|
|
namespace JdeScoping.Client.Services;
|
|
|
|
/// <summary>
|
|
/// Handles refresh status API calls.
|
|
/// Authentication is handled via cookies (sent automatically by the browser).
|
|
/// </summary>
|
|
public class RefreshStatusService : IRefreshStatusService
|
|
{
|
|
private readonly HttpClient _httpClient;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="RefreshStatusService"/> class.
|
|
/// </summary>
|
|
/// <param name="httpClient">The HTTP client for API communication.</param>
|
|
public RefreshStatusService(HttpClient httpClient)
|
|
{
|
|
_httpClient = httpClient;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the data refresh status for a date range.
|
|
/// </summary>
|
|
/// <param name="minDt">The minimum date for the status query.</param>
|
|
/// <param name="maxDt">The maximum date for the status query.</param>
|
|
/// <returns>A list of data update information for the specified date range.</returns>
|
|
public async Task<List<DataUpdateDto>> GetRefreshStatusAsync(DateTime minDt, DateTime maxDt)
|
|
{
|
|
try
|
|
{
|
|
var result = await _httpClient.GetFromJsonAsync<List<DataUpdateDto>>(
|
|
ApiRoutes.RefreshStatus.Get(minDt, maxDt));
|
|
return result ?? [];
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($"Failed to get refresh status: {ex.Message}");
|
|
return [];
|
|
}
|
|
}
|
|
}
|