cancellationToken for Modify methods
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using PocketSharp.Models;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PocketSharp
|
||||
@@ -16,7 +17,7 @@ namespace PocketSharp
|
||||
/// <exception cref="PocketException"></exception>
|
||||
public async Task<bool> Archive(int itemID)
|
||||
{
|
||||
return await SendDefault(itemID, "archive");
|
||||
return await Archive(CancellationToken.None, itemID);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +29,33 @@ namespace PocketSharp
|
||||
/// <exception cref="PocketException"></exception>
|
||||
public async Task<bool> Archive(PocketItem item)
|
||||
{
|
||||
return await Archive(item.ID);
|
||||
return await Archive(CancellationToken.None, item.ID);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Archives the specified item.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="itemID">The item ID.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="PocketException"></exception>
|
||||
public async Task<bool> Archive(CancellationToken cancellationToken, int itemID)
|
||||
{
|
||||
return await SendDefault(cancellationToken, itemID, "archive");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Archives the specified item.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="PocketException"></exception>
|
||||
public async Task<bool> Archive(CancellationToken cancellationToken, PocketItem item)
|
||||
{
|
||||
return await Archive(cancellationToken, item.ID);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +67,7 @@ namespace PocketSharp
|
||||
/// <exception cref="PocketException"></exception>
|
||||
public async Task<bool> Unarchive(int itemID)
|
||||
{
|
||||
return await SendDefault(itemID, "readd");
|
||||
return await Unarchive(CancellationToken.None, itemID);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +79,33 @@ namespace PocketSharp
|
||||
/// <exception cref="PocketException"></exception>
|
||||
public async Task<bool> Unarchive(PocketItem item)
|
||||
{
|
||||
return await Unarchive(item.ID);
|
||||
return await Unarchive(CancellationToken.None, item.ID);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Un-archives the specified item (alias for Readd).
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="itemID">The item ID.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="PocketException"></exception>
|
||||
public async Task<bool> Unarchive(CancellationToken cancellationToken, int itemID)
|
||||
{
|
||||
return await SendDefault(cancellationToken, itemID, "readd");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Unarchives the specified item.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="PocketException"></exception>
|
||||
public async Task<bool> Unarchive(CancellationToken cancellationToken, PocketItem item)
|
||||
{
|
||||
return await Unarchive(cancellationToken, item.ID);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +117,7 @@ namespace PocketSharp
|
||||
/// <exception cref="PocketException"></exception>
|
||||
public async Task<bool> Favorite(int itemID)
|
||||
{
|
||||
return await SendDefault(itemID, "favorite");
|
||||
return await Favorite(CancellationToken.None, itemID);
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +129,33 @@ namespace PocketSharp
|
||||
/// <exception cref="PocketException"></exception>
|
||||
public async Task<bool> Favorite(PocketItem item)
|
||||
{
|
||||
return await Favorite(item.ID);
|
||||
return await Favorite(CancellationToken.None, item.ID);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Favorites the specified item.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="itemID">The item ID.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="PocketException"></exception>
|
||||
public async Task<bool> Favorite(CancellationToken cancellationToken, int itemID)
|
||||
{
|
||||
return await SendDefault(cancellationToken, itemID, "favorite");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Favorites the specified item.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="PocketException"></exception>
|
||||
public async Task<bool> Favorite(CancellationToken cancellationToken, PocketItem item)
|
||||
{
|
||||
return await Favorite(cancellationToken, item.ID);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +167,7 @@ namespace PocketSharp
|
||||
/// <exception cref="PocketException"></exception>
|
||||
public async Task<bool> Unfavorite(int itemID)
|
||||
{
|
||||
return await SendDefault(itemID, "unfavorite");
|
||||
return await Unfavorite(CancellationToken.None, itemID);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +179,33 @@ namespace PocketSharp
|
||||
/// <exception cref="PocketException"></exception>
|
||||
public async Task<bool> Unfavorite(PocketItem item)
|
||||
{
|
||||
return await Unfavorite(item.ID);
|
||||
return await Unfavorite(CancellationToken.None, item.ID);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Un-favorites the specified item.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="itemID">The item ID.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="PocketException"></exception>
|
||||
public async Task<bool> Unfavorite(CancellationToken cancellationToken, int itemID)
|
||||
{
|
||||
return await SendDefault(cancellationToken, itemID, "unfavorite");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Un-favorites the specified item.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="PocketException"></exception>
|
||||
public async Task<bool> Unfavorite(CancellationToken cancellationToken, PocketItem item)
|
||||
{
|
||||
return await Unfavorite(cancellationToken, item.ID);
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +217,7 @@ namespace PocketSharp
|
||||
/// <exception cref="PocketException"></exception>
|
||||
public async Task<bool> Delete(int itemID)
|
||||
{
|
||||
return await SendDefault(itemID, "delete");
|
||||
return await Delete(CancellationToken.None, itemID);
|
||||
}
|
||||
|
||||
|
||||
@@ -123,23 +228,49 @@ namespace PocketSharp
|
||||
/// <returns></returns>
|
||||
public async Task<bool> Delete(PocketItem item)
|
||||
{
|
||||
return await Delete(item.ID);
|
||||
return await Delete(CancellationToken.None, item.ID);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the specified item.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="itemID">The item ID.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="PocketException"></exception>
|
||||
public async Task<bool> Delete(CancellationToken cancellationToken, int itemID)
|
||||
{
|
||||
return await SendDefault(cancellationToken, itemID, "delete");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the specified item.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> Delete(CancellationToken cancellationToken, PocketItem item)
|
||||
{
|
||||
return await Delete(cancellationToken, item.ID);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Puts an action
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="itemID">The item ID.</param>
|
||||
/// <param name="action">The action.</param>
|
||||
/// <returns></returns>
|
||||
protected async Task<bool> SendDefault(int itemID, string action)
|
||||
protected async Task<bool> SendDefault(CancellationToken cancellationToken, int itemID, string action)
|
||||
{
|
||||
return await Send(new ActionParameter()
|
||||
{
|
||||
Action = action,
|
||||
ID = itemID
|
||||
});
|
||||
}, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,6 +342,24 @@ namespace PocketSharp
|
||||
/// <exception cref="PocketException"></exception>
|
||||
Task<bool> Archive(PocketItem item);
|
||||
|
||||
/// <summary>
|
||||
/// Archives the specified item.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="itemID">The item ID.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="PocketException"></exception>
|
||||
Task<bool> Archive(CancellationToken cancellationToken, int itemID);
|
||||
|
||||
/// <summary>
|
||||
/// Archives the specified item.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="PocketException"></exception>
|
||||
Task<bool> Archive(CancellationToken cancellationToken, PocketItem item);
|
||||
|
||||
/// <summary>
|
||||
/// Un-archives the specified item (alias for Readd).
|
||||
/// </summary>
|
||||
@@ -358,6 +376,24 @@ namespace PocketSharp
|
||||
/// <exception cref="PocketException"></exception>
|
||||
Task<bool> Unarchive(PocketItem item);
|
||||
|
||||
/// <summary>
|
||||
/// Un-archives the specified item (alias for Readd).
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="itemID">The item ID.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="PocketException"></exception>
|
||||
Task<bool> Unarchive(CancellationToken cancellationToken, int itemID);
|
||||
|
||||
/// <summary>
|
||||
/// Unarchives the specified item.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="PocketException"></exception>
|
||||
Task<bool> Unarchive(CancellationToken cancellationToken, PocketItem item);
|
||||
|
||||
/// <summary>
|
||||
/// Favorites the specified item.
|
||||
/// </summary>
|
||||
@@ -374,6 +410,24 @@ namespace PocketSharp
|
||||
/// <exception cref="PocketException"></exception>
|
||||
Task<bool> Favorite(PocketItem item);
|
||||
|
||||
/// <summary>
|
||||
/// Favorites the specified item.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="itemID">The item ID.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="PocketException"></exception>
|
||||
Task<bool> Favorite(CancellationToken cancellationToken, int itemID);
|
||||
|
||||
/// <summary>
|
||||
/// Favorites the specified item.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="PocketException"></exception>
|
||||
Task<bool> Favorite(CancellationToken cancellationToken, PocketItem item);
|
||||
|
||||
/// <summary>
|
||||
/// Un-favorites the specified item.
|
||||
/// </summary>
|
||||
@@ -390,6 +444,24 @@ namespace PocketSharp
|
||||
/// <exception cref="PocketException"></exception>
|
||||
Task<bool> Unfavorite(PocketItem item);
|
||||
|
||||
/// <summary>
|
||||
/// Un-favorites the specified item.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="itemID">The item ID.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="PocketException"></exception>
|
||||
Task<bool> Unfavorite(CancellationToken cancellationToken, int itemID);
|
||||
|
||||
/// <summary>
|
||||
/// Un-favorites the specified item.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="PocketException"></exception>
|
||||
Task<bool> Unfavorite(CancellationToken cancellationToken, PocketItem item);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the specified item.
|
||||
/// </summary>
|
||||
@@ -404,6 +476,23 @@ namespace PocketSharp
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns></returns>
|
||||
Task<bool> Delete(PocketItem item);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the specified item.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="itemID">The item ID.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="PocketException"></exception>
|
||||
Task<bool> Delete(CancellationToken cancellationToken, int itemID);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the specified item.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns></returns>
|
||||
Task<bool> Delete(CancellationToken cancellationToken, PocketItem item);
|
||||
#endregion
|
||||
|
||||
#region modify tags methods
|
||||
|
||||
Reference in New Issue
Block a user