2025-08-18 03:00:08 -05:00
|
|
|
|
using LANCommander.SDK.Models;
|
2024-11-11 19:54:02 -06:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Threading.Tasks;
|
2025-03-14 02:18:48 -05:00
|
|
|
|
using LANCommander.SDK.Exceptions;
|
2024-11-11 19:54:02 -06:00
|
|
|
|
|
|
|
|
|
|
namespace LANCommander.SDK.Services
|
|
|
|
|
|
{
|
|
|
|
|
|
public class DepotService
|
|
|
|
|
|
{
|
2025-08-18 03:02:49 -05:00
|
|
|
|
private readonly ILogger _logger;
|
2024-11-11 19:54:02 -06:00
|
|
|
|
|
2025-08-18 03:02:49 -05:00
|
|
|
|
private readonly Client _client;
|
2024-11-11 19:54:02 -06:00
|
|
|
|
|
|
|
|
|
|
public DepotService(Client client)
|
|
|
|
|
|
{
|
2025-08-18 03:02:49 -05:00
|
|
|
|
_client = client;
|
2024-11-11 19:54:02 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DepotService(Client client, ILogger logger)
|
|
|
|
|
|
{
|
2025-08-18 03:02:49 -05:00
|
|
|
|
_client = client;
|
|
|
|
|
|
_logger = logger;
|
2024-11-11 19:54:02 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-16 00:57:11 -06:00
|
|
|
|
public async Task<DepotResults> GetAsync()
|
2024-11-11 19:54:02 -06:00
|
|
|
|
{
|
2025-08-18 03:02:49 -05:00
|
|
|
|
var results = await _client.GetRequestAsync<DepotResults>("/api/Depot");
|
2025-03-14 02:18:48 -05:00
|
|
|
|
|
|
|
|
|
|
if (results == null)
|
2025-08-18 03:02:49 -05:00
|
|
|
|
{
|
|
|
|
|
|
_logger?.LogDebug("Could not find any depot results");
|
2025-03-14 02:18:48 -05:00
|
|
|
|
throw new DepotNoResultsException("Did not find any depot results");
|
2025-08-18 03:02:49 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-14 02:18:48 -05:00
|
|
|
|
|
|
|
|
|
|
return results;
|
2024-11-11 19:54:02 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<DepotGame> GetGameAsync(Guid gameId)
|
|
|
|
|
|
{
|
2025-08-18 03:02:49 -05:00
|
|
|
|
return await _client.GetRequestAsync<DepotGame>($"/api/Depot/Games/{gameId}");
|
2024-11-11 19:54:02 -06:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|