From 381fc9a4366efa7b6250bc5eaff4175f1e9dd969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=A4felfinger?= Date: Fri, 21 Oct 2022 21:22:53 +0200 Subject: [PATCH] adds move to album api --- PiwigoDotnet/Piwigo.Client.Tests/AlbumApiTests.cs | 12 ++++++++++++ PiwigoDotnet/Piwigo.Client/AlbumApi.cs | 6 ++++++ PiwigoDotnet/Piwigo.Client/IAlbumApi.cs | 1 + 3 files changed, 19 insertions(+) diff --git a/PiwigoDotnet/Piwigo.Client.Tests/AlbumApiTests.cs b/PiwigoDotnet/Piwigo.Client.Tests/AlbumApiTests.cs index 61b38ef..048f122 100644 --- a/PiwigoDotnet/Piwigo.Client.Tests/AlbumApiTests.cs +++ b/PiwigoDotnet/Piwigo.Client.Tests/AlbumApiTests.cs @@ -66,6 +66,18 @@ public class AlbumApiTests : ApiTestsBase CorrectParamShouldGetSent("category_id", "1"); } + [Test] + public async Task Move_should_reassign_album() + { + SetOkResult(); + await _albumApi.MoveAsync(1, 2, "apiToken"); + + CorrectMethodShouldGetCalled("pwg.categories.move"); + CorrectParamShouldGetSent("category_id", "1"); + CorrectParamShouldGetSent("parent", "2"); + CorrectParamShouldGetSent("pwg_token", "apiToken"); + } + [Test] public async Task CalculateOrphansAsync_should_return_correct_values() { diff --git a/PiwigoDotnet/Piwigo.Client/AlbumApi.cs b/PiwigoDotnet/Piwigo.Client/AlbumApi.cs index 87f18e6..720476d 100644 --- a/PiwigoDotnet/Piwigo.Client/AlbumApi.cs +++ b/PiwigoDotnet/Piwigo.Client/AlbumApi.cs @@ -85,6 +85,12 @@ public class AlbumApi : IAlbumApi return response.Result.Id.Value; } + public async Task MoveAsync(int albumId, int parentAlbumId, string apiToken, CancellationToken cancellationToken = default) + { + var formParams = new Dictionary { { "category_id", albumId.ToString() }, { "parent", parentAlbumId.ToString() }, { "pwg_token", apiToken } }; + await _context.PostAsync(_logger, "pwg.categories.move", formParams, cancellationToken); + } + public async Task> GetAllAsync(CancellationToken cancellationToken = default) { var formParams = new Dictionary { { "recursive", "true" } }; diff --git a/PiwigoDotnet/Piwigo.Client/IAlbumApi.cs b/PiwigoDotnet/Piwigo.Client/IAlbumApi.cs index 28b3898..d594ea6 100644 --- a/PiwigoDotnet/Piwigo.Client/IAlbumApi.cs +++ b/PiwigoDotnet/Piwigo.Client/IAlbumApi.cs @@ -7,6 +7,7 @@ public interface IAlbumApi Task CalculateOrphansAsync(int albumId, CancellationToken cancellationToken = default); Task DeleteAsync(int albumId, string apiToken, CancellationToken cancellationToken = default); + Task MoveAsync(int albumId, int parentAlbumId, string apiToken, CancellationToken cancellationToken = default); Task DeleteRepresentativeAsync(int albumId, CancellationToken cancellationToken = default);