adds set rank

This commit is contained in:
Philipp Häfelfinger 2022-10-17 23:56:45 +02:00
parent 23fc948424
commit 5d58aaee1c
3 changed files with 19 additions and 1 deletions

View File

@ -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()
{

View File

@ -33,6 +33,12 @@ public class AlbumApi : IAlbumApi
await _context.PostAsync<PiwigoResponse>(_logger, "pwg.categories.setRepresentative", formParams, cancellationToken);
}
public async Task SetRankAsync(int albumId, int rank, CancellationToken cancellationToken = default)
{
var formParams = new Dictionary<string, string> { { "category_id", albumId.ToString() }, { "rank", rank.ToString() } };
await _context.PostAsync<PiwigoResponse>(_logger, "pwg.categories.setRank", formParams, cancellationToken);
}
public async Task<AlbumOrphans> CalculateOrphansAsync(int albumId, CancellationToken cancellationToken = default)
{
var formParams = new Dictionary<string, string> { { "category_id", albumId.ToString() } };

View File

@ -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<int> AddAsync(string name, int? parentId = null, string? comment = null, bool? visible = null, CategoryStatus? status = null, bool? commentable = null,
CategoryPosition? position = null, CancellationToken cancellationToken = default);