using System.Collections.ObjectModel; using Flurl.Http; using Microsoft.Extensions.Logging; using Piwigo.Client.Contract; namespace Piwigo.Client; public class CategoryApi : ICategoryApi { private readonly IPiwigoContext _context; private readonly ILogger _logger; public CategoryApi(IPiwigoContext context, ILogger logger) { _context = context ?? throw new ArgumentNullException(nameof(context)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); } public async Task> GetAllCategoriesAsync() { _logger.LogInformation("Getting all existing categories from server"); var response = await _context.ConfigureRequest(_logger).PostMultipartAsync(c => c.AddMethod("pwg.categories.getList").AddString("recursive", "true")); var typedResponse = await response.GetJsonAsync>(); return new ReadOnlyCollection(typedResponse.Result.Categories); } }