adds RenameAsync for tags
This commit is contained in:
parent
d61ecf8d76
commit
a36ac7442d
@ -93,4 +93,17 @@ public class TagApiTests : ApiTestsBase
|
|||||||
|
|
||||||
await Verify(response);
|
await Verify(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task RenameAsync_should_pass_correct_parameters()
|
||||||
|
{
|
||||||
|
SetJsonResult(@"{""stat"":""ok"",""result"":{""id"":1,""name"":""tag1new"",""url_name"":""tag1new""}}");
|
||||||
|
|
||||||
|
await _tagApi.RenameAsync(1, "tag1new", ApiToken);
|
||||||
|
|
||||||
|
CorrectMethodShouldGetCalled("pwg.tags.rename");
|
||||||
|
CorrectParamShouldGetSent("tag_id", "1");
|
||||||
|
CorrectParamShouldGetSent("new_name", "tag1new");
|
||||||
|
CorrectParamShouldGetSent("pwg_token", ApiToken);
|
||||||
|
}
|
||||||
}
|
}
|
@ -63,6 +63,18 @@ public interface ITagApi
|
|||||||
/// <param name="cancellationToken">
|
/// <param name="cancellationToken">
|
||||||
/// <see cref="CancellationToken" />
|
/// <see cref="CancellationToken" />
|
||||||
/// </param>
|
/// </param>
|
||||||
/// <returns></returns>
|
/// <returns>Information about the merge result</returns>
|
||||||
Task<MergeResult> MergeAsync(int targetTagId, int sourceTagId, string apiToken, CancellationToken cancellationToken = default);
|
Task<MergeResult> MergeAsync(int targetTagId, int sourceTagId, string apiToken, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// renames a existing tag
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tagId">the tag id that gets renamed</param>
|
||||||
|
/// <param name="newName">the new name of the existing tag</param>
|
||||||
|
/// <param name="apiToken">The API token that can be read from <see cref="Piwigo.Client.Session.SessionStatus" /></param>
|
||||||
|
/// <param name="cancellationToken">
|
||||||
|
/// <see cref="CancellationToken" />
|
||||||
|
/// </param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task RenameAsync(int tagId, string newName, string apiToken, CancellationToken cancellationToken = default);
|
||||||
}
|
}
|
@ -76,4 +76,16 @@ public class TagApi : ITagApi
|
|||||||
|
|
||||||
return response.Result;
|
return response.Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task RenameAsync(int tagId, string newName, string apiToken, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
var formParams = new Dictionary<string, string>
|
||||||
|
{
|
||||||
|
{ "tag_id", tagId.ToString() },
|
||||||
|
{ "new_name", newName },
|
||||||
|
{ "pwg_token", apiToken }
|
||||||
|
};
|
||||||
|
|
||||||
|
await _context.PostAsync<PiwigoResponse>(_logger, "pwg.tags.rename", formParams, cancellationToken);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user