LANCommander/LANCommander.SDK/Services/DepotService.cs

46 lines
1.1 KiB
C#
Raw Permalink Normal View History

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