diff --git a/PiwigoDotnet/Piwigo.Client.Tests/AlbumApiTests.cs b/PiwigoDotnet/Piwigo.Client.Tests/AlbumApiTests.cs index a897527..91efd70 100644 --- a/PiwigoDotnet/Piwigo.Client.Tests/AlbumApiTests.cs +++ b/PiwigoDotnet/Piwigo.Client.Tests/AlbumApiTests.cs @@ -24,7 +24,6 @@ public class AlbumApiTests : ApiTestsBase CorrectParamShouldGetSent("category_id", "1"); } - [Test] public async Task RefreshRepresentative_should_call_api() { @@ -46,6 +45,17 @@ public class AlbumApiTests : ApiTestsBase CorrectParamShouldGetSent("image_id", "2"); } + [Test] + public async Task SetRank_should_call_api() + { + SetOkResult(); + await _albumApi.SetRankAsync(1, 2); + + CorrectMethodShouldGetCalled("pwg.categories.setRank"); + CorrectParamShouldGetSent("category_id", "1"); + CorrectParamShouldGetSent("rank", "2"); + } + [Test] public async Task Delete_should_remove_album() { diff --git a/PiwigoDotnet/Piwigo.Client/AlbumApi.cs b/PiwigoDotnet/Piwigo.Client/AlbumApi.cs index 059b8f4..87f18e6 100644 --- a/PiwigoDotnet/Piwigo.Client/AlbumApi.cs +++ b/PiwigoDotnet/Piwigo.Client/AlbumApi.cs @@ -33,6 +33,12 @@ public class AlbumApi : IAlbumApi await _context.PostAsync(_logger, "pwg.categories.setRepresentative", formParams, cancellationToken); } + public async Task SetRankAsync(int albumId, int rank, CancellationToken cancellationToken = default) + { + var formParams = new Dictionary { { "category_id", albumId.ToString() }, { "rank", rank.ToString() } }; + await _context.PostAsync(_logger, "pwg.categories.setRank", formParams, cancellationToken); + } + public async Task CalculateOrphansAsync(int albumId, CancellationToken cancellationToken = default) { var formParams = new Dictionary { { "category_id", albumId.ToString() } }; diff --git a/PiwigoDotnet/Piwigo.Client/IAlbumApi.cs b/PiwigoDotnet/Piwigo.Client/IAlbumApi.cs index e392ba8..28b3898 100644 --- a/PiwigoDotnet/Piwigo.Client/IAlbumApi.cs +++ b/PiwigoDotnet/Piwigo.Client/IAlbumApi.cs @@ -14,6 +14,8 @@ public interface IAlbumApi Task SetRepresentativeAsync(int albumId, int imageId, CancellationToken cancellationToken = default); + Task SetRankAsync(int albumId, int rank, CancellationToken cancellationToken = default); + Task AddAsync(string name, int? parentId = null, string? comment = null, bool? visible = null, CategoryStatus? status = null, bool? commentable = null, CategoryPosition? position = null, CancellationToken cancellationToken = default);