2025-08-18 03:00:08 -05:00
|
|
|
|
using LANCommander.SDK.Models;
|
2024-10-31 01:54:34 -05:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Threading.Tasks;
|
2025-09-22 00:29:51 -05:00
|
|
|
|
using LANCommander.SDK.Factories;
|
2024-10-31 01:54:34 -05:00
|
|
|
|
|
|
|
|
|
|
namespace LANCommander.SDK.Services
|
|
|
|
|
|
{
|
2025-09-24 20:58:23 -05:00
|
|
|
|
public class LibraryClient(ApiRequestFactory apiRequestFactory)
|
2024-10-31 01:54:34 -05:00
|
|
|
|
{
|
2025-01-12 02:54:41 -06:00
|
|
|
|
public async Task<IEnumerable<EntityReference>> GetAsync()
|
2024-10-31 01:54:34 -05:00
|
|
|
|
{
|
2025-09-22 00:29:51 -05:00
|
|
|
|
var results = await apiRequestFactory
|
|
|
|
|
|
.Create()
|
|
|
|
|
|
.UseAuthenticationToken()
|
|
|
|
|
|
.UseVersioning()
|
|
|
|
|
|
.UseRoute("/api/Library")
|
|
|
|
|
|
.GetAsync<IEnumerable<EntityReference>>();
|
2025-08-20 21:02:00 -05:00
|
|
|
|
|
|
|
|
|
|
return results ?? [];
|
2024-10-31 01:54:34 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<bool> AddToLibrary(Guid gameId)
|
|
|
|
|
|
{
|
2025-09-22 00:29:51 -05:00
|
|
|
|
return await apiRequestFactory
|
|
|
|
|
|
.Create()
|
|
|
|
|
|
.UseAuthenticationToken()
|
|
|
|
|
|
.UseVersioning()
|
|
|
|
|
|
.UseRoute($"/api/Library/AddToLibrary/{gameId}")
|
|
|
|
|
|
.PostAsync<bool>();
|
2024-10-31 01:54:34 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<bool> RemoveFromLibrary(Guid gameId)
|
|
|
|
|
|
{
|
2025-09-22 00:29:51 -05:00
|
|
|
|
return await apiRequestFactory
|
|
|
|
|
|
.Create()
|
|
|
|
|
|
.UseAuthenticationToken()
|
|
|
|
|
|
.UseVersioning()
|
|
|
|
|
|
.UseRoute($"/api/Library/RemoveFromLibrary/{gameId}")
|
|
|
|
|
|
.PostAsync<bool>();
|
2024-10-31 01:54:34 -05:00
|
|
|
|
}
|
2025-05-25 18:35:01 +02:00
|
|
|
|
|
|
|
|
|
|
public async Task<bool> RemoveFromLibrary(Guid gameId, Guid[] addonIds)
|
|
|
|
|
|
{
|
2025-09-22 00:29:51 -05:00
|
|
|
|
return await apiRequestFactory
|
|
|
|
|
|
.Create()
|
|
|
|
|
|
.UseAuthenticationToken()
|
|
|
|
|
|
.UseVersioning()
|
|
|
|
|
|
.UseRoute($"/api/Library/RemoveFromLibrary/{gameId}/addons")
|
|
|
|
|
|
.AddBody(new GenericGuidsRequest
|
|
|
|
|
|
{
|
|
|
|
|
|
Guids = addonIds
|
|
|
|
|
|
})
|
|
|
|
|
|
.PostAsync<bool>();
|
2025-05-25 18:35:01 +02:00
|
|
|
|
}
|
2024-10-31 01:54:34 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|