using System.Net.Http.Json;
using DbFirst.BlazorWebApp.Models;

namespace DbFirst.BlazorWebApp.Services;

public class DashboardApiClient
{
    private readonly HttpClient _httpClient;
    private const string Endpoint = "api/dashboard/dashboards";

    public DashboardApiClient(HttpClient httpClient)
    {
        _httpClient = httpClient;
    }

    public async Task<List<DashboardInfoDto>> GetAllAsync()
    {
        var result = await _httpClient.GetFromJsonAsync<List<DashboardInfoDto>>(Endpoint);
        return result ?? new List<DashboardInfoDto>();
    }
}
