diff --git a/PocketSharp/Components/Modify.cs b/PocketSharp/Components/Modify.cs index 90f136c..8503a1f 100644 --- a/PocketSharp/Components/Modify.cs +++ b/PocketSharp/Components/Modify.cs @@ -1,4 +1,5 @@ using PocketSharp.Models; +using System.Threading; using System.Threading.Tasks; namespace PocketSharp @@ -16,7 +17,7 @@ namespace PocketSharp /// public async Task Archive(int itemID) { - return await SendDefault(itemID, "archive"); + return await Archive(CancellationToken.None, itemID); } @@ -28,7 +29,33 @@ namespace PocketSharp /// public async Task Archive(PocketItem item) { - return await Archive(item.ID); + return await Archive(CancellationToken.None, item.ID); + } + + + /// + /// Archives the specified item. + /// + /// The cancellation token. + /// The item ID. + /// + /// + public async Task Archive(CancellationToken cancellationToken, int itemID) + { + return await SendDefault(cancellationToken, itemID, "archive"); + } + + + /// + /// Archives the specified item. + /// + /// The cancellation token. + /// The item. + /// + /// + public async Task Archive(CancellationToken cancellationToken, PocketItem item) + { + return await Archive(cancellationToken, item.ID); } @@ -40,7 +67,7 @@ namespace PocketSharp /// public async Task Unarchive(int itemID) { - return await SendDefault(itemID, "readd"); + return await Unarchive(CancellationToken.None, itemID); } @@ -52,7 +79,33 @@ namespace PocketSharp /// public async Task Unarchive(PocketItem item) { - return await Unarchive(item.ID); + return await Unarchive(CancellationToken.None, item.ID); + } + + + /// + /// Un-archives the specified item (alias for Readd). + /// + /// The cancellation token. + /// The item ID. + /// + /// + public async Task Unarchive(CancellationToken cancellationToken, int itemID) + { + return await SendDefault(cancellationToken, itemID, "readd"); + } + + + /// + /// Unarchives the specified item. + /// + /// The cancellation token. + /// The item. + /// + /// + public async Task Unarchive(CancellationToken cancellationToken, PocketItem item) + { + return await Unarchive(cancellationToken, item.ID); } @@ -64,7 +117,7 @@ namespace PocketSharp /// public async Task Favorite(int itemID) { - return await SendDefault(itemID, "favorite"); + return await Favorite(CancellationToken.None, itemID); } @@ -76,7 +129,33 @@ namespace PocketSharp /// public async Task Favorite(PocketItem item) { - return await Favorite(item.ID); + return await Favorite(CancellationToken.None, item.ID); + } + + + /// + /// Favorites the specified item. + /// + /// The cancellation token. + /// The item ID. + /// + /// + public async Task Favorite(CancellationToken cancellationToken, int itemID) + { + return await SendDefault(cancellationToken, itemID, "favorite"); + } + + + /// + /// Favorites the specified item. + /// + /// The cancellation token. + /// The item. + /// + /// + public async Task Favorite(CancellationToken cancellationToken, PocketItem item) + { + return await Favorite(cancellationToken, item.ID); } @@ -88,7 +167,7 @@ namespace PocketSharp /// public async Task Unfavorite(int itemID) { - return await SendDefault(itemID, "unfavorite"); + return await Unfavorite(CancellationToken.None, itemID); } @@ -100,7 +179,33 @@ namespace PocketSharp /// public async Task Unfavorite(PocketItem item) { - return await Unfavorite(item.ID); + return await Unfavorite(CancellationToken.None, item.ID); + } + + + /// + /// Un-favorites the specified item. + /// + /// The cancellation token. + /// The item ID. + /// + /// + public async Task Unfavorite(CancellationToken cancellationToken, int itemID) + { + return await SendDefault(cancellationToken, itemID, "unfavorite"); + } + + + /// + /// Un-favorites the specified item. + /// + /// The cancellation token. + /// The item. + /// + /// + public async Task Unfavorite(CancellationToken cancellationToken, PocketItem item) + { + return await Unfavorite(cancellationToken, item.ID); } @@ -112,7 +217,7 @@ namespace PocketSharp /// public async Task Delete(int itemID) { - return await SendDefault(itemID, "delete"); + return await Delete(CancellationToken.None, itemID); } @@ -123,23 +228,49 @@ namespace PocketSharp /// public async Task Delete(PocketItem item) { - return await Delete(item.ID); + return await Delete(CancellationToken.None, item.ID); + } + + + /// + /// Deletes the specified item. + /// + /// The cancellation token. + /// The item ID. + /// + /// + public async Task Delete(CancellationToken cancellationToken, int itemID) + { + return await SendDefault(cancellationToken, itemID, "delete"); + } + + + /// + /// Deletes the specified item. + /// + /// The cancellation token. + /// The item. + /// + public async Task Delete(CancellationToken cancellationToken, PocketItem item) + { + return await Delete(cancellationToken, item.ID); } /// /// Puts an action /// + /// The cancellation token. /// The item ID. /// The action. /// - protected async Task SendDefault(int itemID, string action) + protected async Task SendDefault(CancellationToken cancellationToken, int itemID, string action) { return await Send(new ActionParameter() { Action = action, ID = itemID - }); + }, cancellationToken); } } } diff --git a/PocketSharp/IPocketClient.cs b/PocketSharp/IPocketClient.cs index 03fb22e..d4f5150 100644 --- a/PocketSharp/IPocketClient.cs +++ b/PocketSharp/IPocketClient.cs @@ -342,6 +342,24 @@ namespace PocketSharp /// Task Archive(PocketItem item); + /// + /// Archives the specified item. + /// + /// The cancellation token. + /// The item ID. + /// + /// + Task Archive(CancellationToken cancellationToken, int itemID); + + /// + /// Archives the specified item. + /// + /// The cancellation token. + /// The item. + /// + /// + Task Archive(CancellationToken cancellationToken, PocketItem item); + /// /// Un-archives the specified item (alias for Readd). /// @@ -358,6 +376,24 @@ namespace PocketSharp /// Task Unarchive(PocketItem item); + /// + /// Un-archives the specified item (alias for Readd). + /// + /// The cancellation token. + /// The item ID. + /// + /// + Task Unarchive(CancellationToken cancellationToken, int itemID); + + /// + /// Unarchives the specified item. + /// + /// The cancellation token. + /// The item. + /// + /// + Task Unarchive(CancellationToken cancellationToken, PocketItem item); + /// /// Favorites the specified item. /// @@ -374,6 +410,24 @@ namespace PocketSharp /// Task Favorite(PocketItem item); + /// + /// Favorites the specified item. + /// + /// The cancellation token. + /// The item ID. + /// + /// + Task Favorite(CancellationToken cancellationToken, int itemID); + + /// + /// Favorites the specified item. + /// + /// The cancellation token. + /// The item. + /// + /// + Task Favorite(CancellationToken cancellationToken, PocketItem item); + /// /// Un-favorites the specified item. /// @@ -390,6 +444,24 @@ namespace PocketSharp /// Task Unfavorite(PocketItem item); + /// + /// Un-favorites the specified item. + /// + /// The cancellation token. + /// The item ID. + /// + /// + Task Unfavorite(CancellationToken cancellationToken, int itemID); + + /// + /// Un-favorites the specified item. + /// + /// The cancellation token. + /// The item. + /// + /// + Task Unfavorite(CancellationToken cancellationToken, PocketItem item); + /// /// Deletes the specified item. /// @@ -404,6 +476,23 @@ namespace PocketSharp /// The item. /// Task Delete(PocketItem item); + + /// + /// Deletes the specified item. + /// + /// The cancellation token. + /// The item ID. + /// + /// + Task Delete(CancellationToken cancellationToken, int itemID); + + /// + /// Deletes the specified item. + /// + /// The cancellation token. + /// The item. + /// + Task Delete(CancellationToken cancellationToken, PocketItem item); #endregion #region modify tags methods