make CancellationToken an optional parameter

This commit is contained in:
2013-11-08 09:31:35 +01:00
parent bf5d8a50ce
commit 95d7a5d993
9 changed files with 142 additions and 923 deletions
-1
View File
@@ -16,7 +16,6 @@ namespace PocketSharp.Tests
public async Task AreItemsRetrieved()
{
List<PocketItem> items = await client.Get();
Assert.True(items.Count > 0);
}
+1 -1
View File
@@ -31,7 +31,7 @@ namespace PocketSharp.Tests
[Fact]
public async Task Are100IdingtemsRetrievedProperly()
{
await FillAccount(3817, 10000);
await FillAccount(4457, 10000);
}
[Fact]
+3 -51
View File
@@ -12,18 +12,6 @@ namespace PocketSharp
/// </summary>
public partial class PocketClient
{
/// <summary>
/// Retrieves the requestCode from Pocket, which is used to generate the Authentication URI to authenticate the user
/// </summary>
/// <returns></returns>
/// <exception cref="System.NullReferenceException">Authentication methods need a callbackUri on initialization of the PocketClient class</exception>
/// <exception cref="PocketException"></exception>
public async Task<string> GetRequestCode()
{
return await GetRequestCode(CancellationToken.None);
}
/// <summary>
/// Retrieves the requestCode from Pocket, which is used to generate the Authentication URI to authenticate the user
/// </summary>
@@ -31,7 +19,7 @@ namespace PocketSharp
/// <returns></returns>
/// <exception cref="System.NullReferenceException">Authentication methods need a callbackUri on initialization of the PocketClient class</exception>
/// <exception cref="PocketException"></exception>
public async Task<string> GetRequestCode(CancellationToken cancellationToken)
public async Task<string> GetRequestCode(CancellationToken cancellationToken = default(CancellationToken))
{
// check if request code is available
if (CallbackUri == null)
@@ -77,21 +65,6 @@ namespace PocketSharp
}
/// <summary>
/// Requests the access code and username after authentication
/// The access code has to permanently be stored within the users session, and should be passed in the constructor for all future PocketClient initializations.
/// </summary>
/// <param name="requestCode">The request code.</param>
/// <returns>
/// The authenticated user
/// </returns>
/// <exception cref="System.NullReferenceException">Call GetRequestCode() first to receive a request_code</exception>
public async Task<PocketUser> GetUser(string requestCode = null)
{
return await GetUser(CancellationToken.None, requestCode);
}
/// <summary>
/// Requests the access code and username after authentication
/// The access code has to permanently be stored within the users session, and should be passed in the constructor for all future PocketClient initializations.
@@ -102,7 +75,7 @@ namespace PocketSharp
/// The authenticated user
/// </returns>
/// <exception cref="System.NullReferenceException">Call GetRequestCode() first to receive a request_code</exception>
public async Task<PocketUser> GetUser(CancellationToken cancellationToken, string requestCode = null)
public async Task<PocketUser> GetUser(string requestCode = null, CancellationToken cancellationToken = default(CancellationToken))
{
// check if request code is available
if (RequestCode == null && requestCode == null)
@@ -136,28 +109,7 @@ namespace PocketSharp
/// <param name="username">The username.</param>
/// <param name="email">The email.</param>
/// <param name="password">The password.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentNullException">All parameters are required</exception>
/// <exception cref="System.FormatException">Invalid email address.
/// or
/// Invalid username. Please only use letters, numbers, and/or dashes and between 1-20 characters.
/// or
/// Invalid password.</exception>
/// <exception cref="PocketException"></exception>
public async Task<bool> RegisterAccount(string username, string email, string password)
{
return await RegisterAccount(CancellationToken.None, username, email, password);
}
/// <summary>
/// Registers a new account.
/// Account has to be activated via a activation email sent by Pocket.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="username">The username.</param>
/// <param name="email">The email.</param>
/// <param name="password">The password.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentNullException">All parameters are required</exception>
/// <exception cref="System.FormatException">Invalid email address.
@@ -166,7 +118,7 @@ namespace PocketSharp
/// or
/// Invalid password.</exception>
/// <exception cref="PocketException"></exception>
public async Task<bool> RegisterAccount(CancellationToken cancellationToken, string username, string email, string password)
public async Task<bool> RegisterAccount(string username, string email, string password, CancellationToken cancellationToken = default(CancellationToken))
{
if (username == null || email == null || password == null)
{
+7 -19
View File
@@ -17,31 +17,19 @@ namespace PocketSharp
/// <param name="tags">A comma-separated list of tags to apply to the item</param>
/// <param name="title">This can be included for cases where an item does not have a title, which is typical for image or PDF URLs. If Pocket detects a title from the content of the page, this parameter will be ignored.</param>
/// <param name="tweetID">If you are adding Pocket support to a Twitter client, please send along a reference to the tweet status id. This allows Pocket to show the original tweet alongside the article.</param>
/// <returns>
/// A simple representation of the saved item which doesn't contain all data (is only returned by calling the Retrieve method)
/// </returns>
/// <exception cref="System.FormatException">(1) Uri should be absolute.</exception>
/// <exception cref="PocketException"></exception>
public async Task<PocketItem> Add(Uri uri, string[] tags = null, string title = null, string tweetID = null)
{
return await Add(CancellationToken.None, uri, tags, title, tweetID);
}
/// <summary>
/// Adds a new item to pocket
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="uri">The URL of the item you want to save</param>
/// <param name="tags">A comma-separated list of tags to apply to the item</param>
/// <param name="title">This can be included for cases where an item does not have a title, which is typical for image or PDF URLs. If Pocket detects a title from the content of the page, this parameter will be ignored.</param>
/// <param name="tweetID">If you are adding Pocket support to a Twitter client, please send along a reference to the tweet status id. This allows Pocket to show the original tweet alongside the article.</param>
/// <returns>
/// A simple representation of the saved item which doesn't contain all data (is only returned by calling the Retrieve method)
/// </returns>
/// <exception cref="System.FormatException">(1) Uri should be absolute.</exception>
/// <exception cref="PocketException"></exception>
public async Task<PocketItem> Add(CancellationToken cancellationToken, Uri uri, string[] tags = null, string title = null, string tweetID = null)
public async Task<PocketItem> Add(
Uri uri,
string[] tags = null,
string title = null,
string tweetID = null,
CancellationToken cancellationToken = default(CancellationToken)
)
{
if (!uri.IsAbsoluteUri)
{
+9 -104
View File
@@ -26,44 +26,10 @@ namespace PocketSharp
/// <param name="since">The since.</param>
/// <param name="count">The count.</param>
/// <param name="offset">The offset.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<List<PocketItem>> Get(
State? state = null,
bool? favorite = null,
string tag = null,
ContentType? contentType = null,
Sort? sort = null,
string search = null,
string domain = null,
DateTime? since = null,
int? count = null,
int? offset = null
)
{
return await Get(CancellationToken.None, state, favorite, tag, contentType, sort, search, domain, since, count, offset);
}
/// <summary>
/// Retrieves items from pocket
/// with the given filters
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="state">The state.</param>
/// <param name="favorite">The favorite.</param>
/// <param name="tag">The tag.</param>
/// <param name="contentType">Type of the content.</param>
/// <param name="sort">The sort.</param>
/// <param name="search">The search.</param>
/// <param name="domain">The domain.</param>
/// <param name="since">The since.</param>
/// <param name="count">The count.</param>
/// <param name="offset">The offset.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<List<PocketItem>> Get(
CancellationToken cancellationToken,
State? state = null,
bool? favorite = null,
string tag = null,
@@ -73,7 +39,8 @@ namespace PocketSharp
string domain = null,
DateTime? since = null,
int? count = null,
int? offset = null
int? offset = null,
CancellationToken cancellationToken = default(CancellationToken)
)
{
RetrieveParameters parameters = new RetrieveParameters()
@@ -102,23 +69,10 @@ namespace PocketSharp
/// Note: The Pocket API contains no method, which allows to retrieve a single item, so all items are retrieved and filtered locally by the ID.
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<PocketItem> Get(int itemID)
{
return await Get(CancellationToken.None, itemID);
}
/// <summary>
/// Retrieves an item by a given ID
/// Note: The Pocket API contains no method, which allows to retrieve a single item, so all items are retrieved and filtered locally by the ID.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="itemID">The item ID.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<PocketItem> Get(CancellationToken cancellationToken, int itemID)
public async Task<PocketItem> Get(int itemID, CancellationToken cancellationToken = default(CancellationToken))
{
List<PocketItem> items = await Get(
cancellationToken: cancellationToken,
@@ -133,22 +87,10 @@ namespace PocketSharp
/// Retrieves all items by a given filter
/// </summary>
/// <param name="filter">The filter.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<List<PocketItem>> Get(RetrieveFilter filter)
{
return await Get(CancellationToken.None, filter);
}
/// <summary>
/// Retrieves all items by a given filter
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="filter">The filter.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<List<PocketItem>> Get(CancellationToken cancellationToken, RetrieveFilter filter)
public async Task<List<PocketItem>> Get(RetrieveFilter filter, CancellationToken cancellationToken = default(CancellationToken))
{
RetrieveParameters parameters = new RetrieveParameters();
@@ -185,18 +127,6 @@ namespace PocketSharp
}
/// <summary>
/// Retrieves all available tags.
/// Note: The Pocket API contains no method, which allows to retrieve all tags, so all items are retrieved and the associated tags extracted.
/// </summary>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<List<PocketTag>> GetTags()
{
return await GetTags(CancellationToken.None);
}
/// <summary>
/// Retrieves all available tags.
/// Note: The Pocket API contains no method, which allows to retrieve all tags, so all items are retrieved and the associated tags extracted.
@@ -204,7 +134,7 @@ namespace PocketSharp
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<List<PocketTag>> GetTags(CancellationToken cancellationToken)
public async Task<List<PocketTag>> GetTags(CancellationToken cancellationToken = default(CancellationToken))
{
List<PocketItem> items = await Get(
cancellationToken: cancellationToken,
@@ -223,22 +153,10 @@ namespace PocketSharp
/// Retrieves items by tag
/// </summary>
/// <param name="tag">The tag.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<List<PocketItem>> SearchByTag(string tag)
{
return await SearchByTag(CancellationToken.None, tag);
}
/// <summary>
/// Retrieves items by tag
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="tag">The tag.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<List<PocketItem>> SearchByTag(CancellationToken cancellationToken, string tag)
public async Task<List<PocketItem>> SearchByTag(string tag, CancellationToken cancellationToken = default(CancellationToken))
{
return await Get(
cancellationToken: cancellationToken,
@@ -251,27 +169,14 @@ namespace PocketSharp
/// Retrieves items which match the specified search string in title and URI
/// </summary>
/// <param name="searchString">The search string.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentOutOfRangeException">Search string length has to be a minimum of 2 chars</exception>
/// <exception cref="PocketException"></exception>
public async Task<List<PocketItem>> Search(string searchString, bool searchInUri = true)
{
return await Search(CancellationToken.None, searchString, searchInUri);
}
/// <summary>
/// Retrieves items which match the specified search string in title and URI
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="searchString">The search string.</param>
/// <param name="searchInUri">if set to <c>true</c> [search in URI].</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentOutOfRangeException">Search string length has to be a minimum of 2 chars</exception>
/// <exception cref="PocketException"></exception>
public async Task<List<PocketItem>> Search(CancellationToken cancellationToken, string searchString, bool searchInUri = true)
public async Task<List<PocketItem>> Search(string searchString, bool searchInUri = true, CancellationToken cancellationToken = default(CancellationToken))
{
List<PocketItem> items = await Get(cancellationToken, RetrieveFilter.All);
List<PocketItem> items = await Get(RetrieveFilter.All, cancellationToken);
return Search(items, searchString);
}
+19 -138
View File
@@ -13,34 +13,10 @@ namespace PocketSharp
/// Archives the specified item.
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> Archive(int itemID)
{
return await Archive(CancellationToken.None, itemID);
}
/// <summary>
/// Archives the specified item.
/// </summary>
/// <param name="item">The item.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> Archive(PocketItem item)
{
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)
public async Task<bool> Archive(int itemID, CancellationToken cancellationToken = default(CancellationToken))
{
return await SendDefault(cancellationToken, itemID, "archive");
}
@@ -49,13 +25,13 @@ namespace PocketSharp
/// <summary>
/// Archives the specified item.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="item">The item.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> Archive(CancellationToken cancellationToken, PocketItem item)
public async Task<bool> Archive(PocketItem item, CancellationToken cancellationToken = default(CancellationToken))
{
return await Archive(cancellationToken, item.ID);
return await Archive(item.ID, cancellationToken);
}
@@ -63,34 +39,10 @@ namespace PocketSharp
/// Un-archives the specified item (alias for Readd).
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> Unarchive(int itemID)
{
return await Unarchive(CancellationToken.None, itemID);
}
/// <summary>
/// Unarchives the specified item.
/// </summary>
/// <param name="item">The item.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> Unarchive(PocketItem item)
{
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)
public async Task<bool> Unarchive(int itemID, CancellationToken cancellationToken = default(CancellationToken))
{
return await SendDefault(cancellationToken, itemID, "readd");
}
@@ -99,13 +51,13 @@ namespace PocketSharp
/// <summary>
/// Unarchives the specified item.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="item">The item.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> Unarchive(CancellationToken cancellationToken, PocketItem item)
public async Task<bool> Unarchive(PocketItem item, CancellationToken cancellationToken = default(CancellationToken))
{
return await Unarchive(cancellationToken, item.ID);
return await Unarchive(item.ID, cancellationToken);
}
@@ -113,34 +65,10 @@ namespace PocketSharp
/// Favorites the specified item.
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> Favorite(int itemID)
{
return await Favorite(CancellationToken.None, itemID);
}
/// <summary>
/// Favorites the specified item.
/// </summary>
/// <param name="item">The item.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> Favorite(PocketItem item)
{
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)
public async Task<bool> Favorite(int itemID, CancellationToken cancellationToken = default(CancellationToken))
{
return await SendDefault(cancellationToken, itemID, "favorite");
}
@@ -149,13 +77,13 @@ namespace PocketSharp
/// <summary>
/// Favorites the specified item.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="item">The item.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> Favorite(CancellationToken cancellationToken, PocketItem item)
public async Task<bool> Favorite(PocketItem item, CancellationToken cancellationToken = default(CancellationToken))
{
return await Favorite(cancellationToken, item.ID);
return await Favorite(item.ID, cancellationToken);
}
@@ -163,34 +91,10 @@ namespace PocketSharp
/// Un-favorites the specified item.
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> Unfavorite(int itemID)
{
return await Unfavorite(CancellationToken.None, itemID);
}
/// <summary>
/// Un-favorites the specified item.
/// </summary>
/// <param name="item">The item.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> Unfavorite(PocketItem item)
{
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)
public async Task<bool> Unfavorite(int itemID, CancellationToken cancellationToken = default(CancellationToken))
{
return await SendDefault(cancellationToken, itemID, "unfavorite");
}
@@ -199,36 +103,13 @@ namespace PocketSharp
/// <summary>
/// Un-favorites the specified item.
/// </summary>
/// <param name="item">The item.</param>
/// <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)
public async Task<bool> Unfavorite(PocketItem item, CancellationToken cancellationToken = default(CancellationToken))
{
return await Unfavorite(cancellationToken, item.ID);
}
/// <summary>
/// Deletes the specified item.
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> Delete(int itemID)
{
return await Delete(CancellationToken.None, itemID);
}
/// <summary>
/// Deletes the specified item.
/// </summary>
/// <param name="item">The item.</param>
/// <returns></returns>
public async Task<bool> Delete(PocketItem item)
{
return await Delete(CancellationToken.None, item.ID);
return await Unfavorite(item.ID, cancellationToken);
}
@@ -239,7 +120,7 @@ namespace PocketSharp
/// <param name="itemID">The item ID.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> Delete(CancellationToken cancellationToken, int itemID)
public async Task<bool> Delete(int itemID, CancellationToken cancellationToken = default(CancellationToken))
{
return await SendDefault(cancellationToken, itemID, "delete");
}
@@ -251,9 +132,9 @@ namespace PocketSharp
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="item">The item.</param>
/// <returns></returns>
public async Task<bool> Delete(CancellationToken cancellationToken, PocketItem item)
public async Task<bool> Delete(PocketItem item, CancellationToken cancellationToken = default(CancellationToken))
{
return await Delete(cancellationToken, item.ID);
return await Delete(item.ID, cancellationToken);
}
+52 -208
View File
@@ -14,36 +14,10 @@ namespace PocketSharp
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <param name="tags">The tags.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> AddTags(int itemID, string[] tags)
{
return await AddTags(CancellationToken.None, itemID, tags);
}
/// <summary>
/// Adds the specified tags to an item.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="tags">The tags.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> AddTags(PocketItem item, string[] tags)
{
return await AddTags(CancellationToken.None, item.ID, tags);
}
/// <summary>
/// Adds the specified tags to an item.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="itemID">The item ID.</param>
/// <param name="tags">The tags.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> AddTags(CancellationToken cancellationToken, int itemID, string[] tags)
public async Task<bool> AddTags(int itemID, string[] tags, CancellationToken cancellationToken = default(CancellationToken))
{
return await SendTags(cancellationToken, itemID, "tags_add", tags);
}
@@ -52,14 +26,14 @@ namespace PocketSharp
/// <summary>
/// Adds the specified tags to an item.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="item">The item.</param>
/// <param name="tags">The tags.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> AddTags(CancellationToken cancellationToken, PocketItem item, string[] tags)
public async Task<bool> AddTags(PocketItem item, string[] tags, CancellationToken cancellationToken = default(CancellationToken))
{
return await AddTags(cancellationToken, item.ID, tags);
return await AddTags(item.ID, tags, cancellationToken);
}
@@ -68,36 +42,10 @@ namespace PocketSharp
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <param name="tags">The tags.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> RemoveTags(int itemID, string[] tags)
{
return await RemoveTags(CancellationToken.None, itemID, tags);
}
/// <summary>
/// Removes the specified tags from an item.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="tags">The tag.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> RemoveTags(PocketItem item, string[] tags)
{
return await RemoveTags(CancellationToken.None, item.ID, tags);
}
/// <summary>
/// Removes the specified tags from an item.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="itemID">The item ID.</param>
/// <param name="tags">The tags.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> RemoveTags(CancellationToken cancellationToken, int itemID, string[] tags)
public async Task<bool> RemoveTags(int itemID, string[] tags, CancellationToken cancellationToken = default(CancellationToken))
{
return await SendTags(cancellationToken, itemID, "tags_remove", tags);
}
@@ -106,52 +54,26 @@ namespace PocketSharp
/// <summary>
/// Removes the specified tags from an item.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="item">The item.</param>
/// <param name="tags">The tag.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> RemoveTags(CancellationToken cancellationToken, PocketItem item, string[] tags)
{
return await RemoveTags(cancellationToken, item.ID, tags);
}
/// <summary>
/// Removes a tag from an item.
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <param name="tags">The tag.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> RemoveTag(int itemID, string tag)
{
return await RemoveTag(CancellationToken.None, itemID, tag);
}
/// <summary>
/// Removes a tag from an item.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="tags">The tags.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> RemoveTag(PocketItem item, string tag)
{
return await RemoveTag(CancellationToken.None, item.ID, tag);
}
/// <summary>
/// Removes a tag from an item.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> RemoveTags(PocketItem item, string[] tags, CancellationToken cancellationToken = default(CancellationToken))
{
return await RemoveTags(item.ID, tags, cancellationToken);
}
/// <summary>
/// Removes a tag from an item.
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <param name="tag">The tag.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> RemoveTag(CancellationToken cancellationToken, int itemID, string tag)
public async Task<bool> RemoveTag(int itemID, string tag, CancellationToken cancellationToken = default(CancellationToken))
{
return await SendTags(cancellationToken, itemID, "tags_remove", new string[] { tag });
}
@@ -160,49 +82,25 @@ namespace PocketSharp
/// <summary>
/// Removes a tag from an item.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="item">The item.</param>
/// <param name="tag">The tag.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> RemoveTag(CancellationToken cancellationToken, PocketItem item, string tag)
{
return await RemoveTag(cancellationToken, item.ID, tag);
}
/// <summary>
/// Clears all tags from an item.
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> RemoveTags(int itemID)
{
return await RemoveTags(CancellationToken.None, itemID);
}
/// <summary>
/// Clears all tags from an item.
/// </summary>
/// <param name="item">The item.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> RemoveTags(PocketItem item)
{
return await RemoveTags(CancellationToken.None, item.ID);
}
/// <summary>
/// Clears all tags from an 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> RemoveTags(CancellationToken cancellationToken, int itemID)
public async Task<bool> RemoveTag(PocketItem item, string tag, CancellationToken cancellationToken = default(CancellationToken))
{
return await RemoveTag(item.ID, tag, cancellationToken);
}
/// <summary>
/// Clears all tags from an item.
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> RemoveTags(int itemID, CancellationToken cancellationToken = default(CancellationToken))
{
return await SendDefault(cancellationToken, itemID, "tags_clear");
}
@@ -211,13 +109,13 @@ namespace PocketSharp
/// <summary>
/// Clears all tags from an item.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="item">The item.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> RemoveTags(CancellationToken cancellationToken, PocketItem item)
public async Task<bool> RemoveTags(PocketItem item, CancellationToken cancellationToken = default(CancellationToken))
{
return await RemoveTags(cancellationToken, item.ID);
return await RemoveTags(item.ID, cancellationToken);
}
@@ -226,36 +124,10 @@ namespace PocketSharp
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <param name="tags">The tags.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> ReplaceTags(int itemID, string[] tags)
{
return await ReplaceTags(CancellationToken.None, itemID, tags);
}
/// <summary>
/// Replaces all existing tags with the given new ones in an item.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="tags">The tags.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> ReplaceTags(PocketItem item, string[] tags)
{
return await ReplaceTags(CancellationToken.None, item.ID, tags);
}
/// <summary>
/// Replaces all existing tags with the given tags in an item.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="itemID">The item ID.</param>
/// <param name="tags">The tags.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> ReplaceTags(CancellationToken cancellationToken, int itemID, string[] tags)
public async Task<bool> ReplaceTags(int itemID, string[] tags, CancellationToken cancellationToken = default(CancellationToken))
{
return await SendTags(cancellationToken, itemID, "tags_replace", tags);
}
@@ -264,55 +136,27 @@ namespace PocketSharp
/// <summary>
/// Replaces all existing tags with the given new ones in an item.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="item">The item.</param>
/// <param name="tags">The tags.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> ReplaceTags(CancellationToken cancellationToken, PocketItem item, string[] tags)
{
return await ReplaceTags(cancellationToken, item.ID, tags);
}
/// <summary>
/// Renames a tag in an item.
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <param name="oldTag">The old tag.</param>
/// <param name="newTag">The new tag name.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> RenameTag(int itemID, string oldTag, string newTag)
{
return await RenameTag(CancellationToken.None, itemID, oldTag, newTag);
}
/// <summary>
/// Renames a tag in an item.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="oldTag">The old tag.</param>
/// <param name="newTag">The new tag name.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> RenameTag(PocketItem item, string oldTag, string newTag)
{
return await RenameTag(CancellationToken.None, item.ID, oldTag, newTag);
}
/// <summary>
/// Renames a tag in an item.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> ReplaceTags(PocketItem item, string[] tags, CancellationToken cancellationToken = default(CancellationToken))
{
return await ReplaceTags(item.ID, tags, cancellationToken);
}
/// <summary>
/// Renames a tag in an item.
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <param name="oldTag">The old tag.</param>
/// <param name="newTag">The new tag name.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> RenameTag(CancellationToken cancellationToken, int itemID, string oldTag, string newTag)
public async Task<bool> RenameTag(int itemID, string oldTag, string newTag, CancellationToken cancellationToken = default(CancellationToken))
{
return await Send(new ActionParameter()
{
@@ -327,15 +171,15 @@ namespace PocketSharp
/// <summary>
/// Renames a tag in an item.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="item">The item.</param>
/// <param name="oldTag">The old tag.</param>
/// <param name="newTag">The new tag name.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<bool> RenameTag(CancellationToken cancellationToken, PocketItem item, string oldTag, string newTag)
public async Task<bool> RenameTag(PocketItem item, string oldTag, string newTag, CancellationToken cancellationToken = default(CancellationToken))
{
return await RenameTag(cancellationToken, item.ID, oldTag, newTag);
return await RenameTag(item.ID, oldTag, newTag, cancellationToken);
}
+2 -26
View File
@@ -10,42 +10,18 @@ namespace PocketSharp
/// </summary>
public partial class PocketClient
{
/// <summary>
/// Statistics from the user account.
/// </summary>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<PocketStatistics> GetUserStatistics()
{
return await GetUserStatistics(CancellationToken.None);
}
/// <summary>
/// Statistics from the user account.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<PocketStatistics> GetUserStatistics(CancellationToken cancellationToken)
public async Task<PocketStatistics> GetUserStatistics(CancellationToken cancellationToken = default(CancellationToken))
{
return await Request<PocketStatistics>("stats", cancellationToken);
}
/// <summary>
/// Returns API usage statistics.
/// If a request was made before, the data is returned synchronously from the cache.
/// Note: This method only works for authenticated users with a given AccessCode.
/// </summary>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<PocketLimits> GetUsageLimits()
{
return await GetUsageLimits(CancellationToken.None);
}
/// <summary>
/// Returns API usage statistics.
/// If a request was made before, the data is returned synchronously from the cache.
@@ -54,7 +30,7 @@ namespace PocketSharp
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
public async Task<PocketLimits> GetUsageLimits(CancellationToken cancellationToken)
public async Task<PocketLimits> GetUsageLimits(CancellationToken cancellationToken = default(CancellationToken))
{
string rateLimitForConsumerKey = TryGetHeaderValue(lastHeaders, "X-Limit-Key-Limit");
+49 -375
View File
@@ -44,14 +44,6 @@ namespace PocketSharp
#endregion
#region account methods
/// <summary>
/// Retrieves the requestCode from Pocket, which is used to generate the Authentication URI to authenticate the user
/// </summary>
/// <returns></returns>
/// <exception cref="System.NullReferenceException">Authentication methods need a callbackUri on initialization of the PocketClient class</exception>
/// <exception cref="PocketException"></exception>
Task<string> GetRequestCode();
/// <summary>
/// Retrieves the requestCode from Pocket, which is used to generate the Authentication URI to authenticate the user
/// </summary>
@@ -59,7 +51,7 @@ namespace PocketSharp
/// <returns></returns>
/// <exception cref="System.NullReferenceException">Authentication methods need a callbackUri on initialization of the PocketClient class</exception>
/// <exception cref="PocketException"></exception>
Task<string> GetRequestCode(CancellationToken cancellationToken);
Task<string> GetRequestCode(CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Generate Authentication URI from requestCode
@@ -76,23 +68,12 @@ namespace PocketSharp
/// The access code has to permanently be stored within the users session, and should be passed in the constructor for all future PocketClient initializations.
/// </summary>
/// <param name="requestCode">The request code.</param>
/// <returns>
/// The authenticated user
/// </returns>
/// <exception cref="System.NullReferenceException">Call GetRequestCode() first to receive a request_code</exception>
Task<PocketUser> GetUser(string requestCode = null);
/// <summary>
/// Requests the access code and username after authentication
/// The access code has to permanently be stored within the users session, and should be passed in the constructor for all future PocketClient initializations.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="requestCode">The request code.</param>
/// <returns>
/// The authenticated user
/// </returns>
/// <exception cref="System.NullReferenceException">Call GetRequestCode() first to receive a request_code</exception>
Task<PocketUser> GetUser(CancellationToken cancellationToken, string requestCode = null);
Task<PocketUser> GetUser(string requestCode = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Registers a new account.
@@ -101,26 +82,7 @@ namespace PocketSharp
/// <param name="username">The username.</param>
/// <param name="email">The email.</param>
/// <param name="password">The password.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentNullException">All parameters are required</exception>
/// <exception cref="System.FormatException">
/// Invalid email address.
/// or
/// Invalid username. Please only use letters, numbers, and/or dashes and between 1-20 characters.
/// or
/// Invalid password.
/// </exception>
/// <exception cref="PocketException"></exception>
Task<bool> RegisterAccount(string username, string email, string password);
/// <summary>
/// Registers a new account.
/// Account has to be activated via a activation email sent by Pocket.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="username">The username.</param>
/// <param name="email">The email.</param>
/// <param name="password">The password.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentNullException">All parameters are required</exception>
/// <exception cref="System.FormatException">Invalid email address.
@@ -129,7 +91,7 @@ namespace PocketSharp
/// or
/// Invalid password.</exception>
/// <exception cref="PocketException"></exception>
Task<bool> RegisterAccount(CancellationToken cancellationToken, string username, string email, string password);
Task<bool> RegisterAccount(string username, string email, string password, CancellationToken cancellationToken = default(CancellationToken));
#endregion
#region add methods
@@ -140,27 +102,13 @@ namespace PocketSharp
/// <param name="tags">A comma-separated list of tags to apply to the item</param>
/// <param name="title">This can be included for cases where an item does not have a title, which is typical for image or PDF URLs. If Pocket detects a title from the content of the page, this parameter will be ignored.</param>
/// <param name="tweetID">If you are adding Pocket support to a Twitter client, please send along a reference to the tweet status id. This allows Pocket to show the original tweet alongside the article.</param>
/// <returns>
/// A simple representation of the saved item which doesn't contain all data (is only returned by calling the Retrieve method)
/// </returns>
/// <exception cref="System.FormatException">(1) Uri should be absolute.</exception>
/// <exception cref="PocketException"></exception>
Task<PocketItem> Add(Uri uri, string[] tags = null, string title = null, string tweetID = null);
/// <summary>
/// Adds a new item to pocket
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="uri">The URL of the item you want to save</param>
/// <param name="tags">A comma-separated list of tags to apply to the item</param>
/// <param name="title">This can be included for cases where an item does not have a title, which is typical for image or PDF URLs. If Pocket detects a title from the content of the page, this parameter will be ignored.</param>
/// <param name="tweetID">If you are adding Pocket support to a Twitter client, please send along a reference to the tweet status id. This allows Pocket to show the original tweet alongside the article.</param>
/// <returns>
/// A simple representation of the saved item which doesn't contain all data (is only returned by calling the Retrieve method)
/// </returns>
/// <exception cref="System.FormatException">(1) Uri should be absolute.</exception>
/// <exception cref="PocketException"></exception>
Task<PocketItem> Add(CancellationToken cancellationToken, Uri uri, string[] tags = null, string title = null, string tweetID = null);
Task<PocketItem> Add(Uri uri, string[] tags = null, string title = null, string tweetID = null, CancellationToken cancellationToken = default(CancellationToken));
#endregion
#region get methods
@@ -178,6 +126,7 @@ namespace PocketSharp
/// <param name="since">The since.</param>
/// <param name="count">The count.</param>
/// <param name="offset">The offset.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<List<PocketItem>> Get(
@@ -190,38 +139,8 @@ namespace PocketSharp
string domain = null,
DateTime? since = null,
int? count = null,
int? offset = null
);
/// <summary>
/// Retrieves items from pocket
/// with the given filters
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="state">The state.</param>
/// <param name="favorite">The favorite.</param>
/// <param name="tag">The tag.</param>
/// <param name="contentType">Type of the content.</param>
/// <param name="sort">The sort.</param>
/// <param name="search">The search.</param>
/// <param name="domain">The domain.</param>
/// <param name="since">The since.</param>
/// <param name="count">The count.</param>
/// <param name="offset">The offset.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<List<PocketItem>> Get(
CancellationToken cancellationToken,
State? state = null,
bool? favorite = null,
string tag = null,
ContentType? contentType = null,
Sort? sort = null,
string search = null,
string domain = null,
DateTime? since = null,
int? count = null,
int? offset = null
int? offset = null,
CancellationToken cancellationToken = default(CancellationToken)
);
/// <summary>
@@ -229,44 +148,19 @@ namespace PocketSharp
/// Note: The Pocket API contains no method, which allows to retrieve a single item, so all items are retrieved and filtered locally by the ID.
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<PocketItem> Get(int itemID);
/// <summary>
/// Retrieves an item by a given ID
/// Note: The Pocket API contains no method, which allows to retrieve a single item, so all items are retrieved and filtered locally by the ID.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="itemID">The item ID.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<PocketItem> Get(CancellationToken cancellationToken, int itemID);
Task<PocketItem> Get(int itemID, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Retrieves all items by a given filter
/// </summary>
/// <param name="filter">The filter.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<List<PocketItem>> Get(RetrieveFilter filter);
/// <summary>
/// Retrieves all items by a given filter
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="filter">The filter.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<List<PocketItem>> Get(CancellationToken cancellationToken, RetrieveFilter filter);
/// <summary>
/// Retrieves all available tags.
/// Note: The Pocket API contains no method, which allows to retrieve all tags, so all items are retrieved and the associated tags extracted.
/// </summary>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<List<PocketTag>> GetTags();
Task<List<PocketItem>> Get(RetrieveFilter filter, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Retrieves all available tags.
@@ -275,44 +169,27 @@ namespace PocketSharp
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<List<PocketTag>> GetTags(CancellationToken cancellationToken);
Task<List<PocketTag>> GetTags(CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Retrieves items by tag
/// </summary>
/// <param name="tag">The tag.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<List<PocketItem>> SearchByTag(string tag);
/// <summary>
/// Retrieves items by tag
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="tag">The tag.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<List<PocketItem>> SearchByTag(CancellationToken cancellationToken, string tag);
Task<List<PocketItem>> SearchByTag(string tag, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Retrieves items which match the specified search string in title and URI
/// </summary>
/// <param name="searchString">The search string.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentOutOfRangeException">Search string length has to be a minimum of 2 chars</exception>
/// <exception cref="PocketException"></exception>
Task<List<PocketItem>> Search(string searchString, bool searchInUri = true);
/// <summary>
/// Retrieves items which match the specified search string in title and URI
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="searchString">The search string.</param>
/// <param name="searchInUri">if set to <c>true</c> [search in URI].</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentOutOfRangeException">Search string length has to be a minimum of 2 chars</exception>
/// <exception cref="PocketException"></exception>
Task<List<PocketItem>> Search(CancellationToken cancellationToken, string searchString, bool searchInUri = true);
Task<List<PocketItem>> Search(string searchString, bool searchInUri = true, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Finds the specified search string in title and URI for an available list of items
@@ -330,169 +207,90 @@ namespace PocketSharp
/// Archives the specified item.
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> Archive(int itemID);
Task<bool> Archive(int itemID, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Archives the specified item.
/// </summary>
/// <param name="item">The item.</param>
/// <returns></returns>
/// <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);
Task<bool> Archive(PocketItem item, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Un-archives the specified item (alias for Readd).
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> Unarchive(int itemID);
Task<bool> Unarchive(int itemID, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Unarchives the specified item.
/// </summary>
/// <param name="item">The item.</param>
/// <returns></returns>
/// <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);
Task<bool> Unarchive(PocketItem item, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Favorites the specified item.
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> Favorite(int itemID);
Task<bool> Favorite(int itemID, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Favorites the specified item.
/// </summary>
/// <param name="item">The item.</param>
/// <returns></returns>
/// <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);
Task<bool> Favorite(PocketItem item, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Un-favorites the specified item.
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> Unfavorite(int itemID);
Task<bool> Unfavorite(int itemID, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Un-favorites the specified item.
/// </summary>
/// <param name="item">The item.</param>
/// <returns></returns>
/// <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);
Task<bool> Unfavorite(PocketItem item, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Deletes the specified item.
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> Delete(int itemID);
Task<bool> Delete(int itemID, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Deletes the specified item.
/// </summary>
/// <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);
Task<bool> Delete(PocketItem item, CancellationToken cancellationToken = default(CancellationToken));
#endregion
#region modify tags methods
@@ -501,186 +299,98 @@ namespace PocketSharp
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <param name="tags">The tags.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> AddTags(int itemID, string[] tags);
Task<bool> AddTags(int itemID, string[] tags, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Adds the specified tags to an item.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="tags">The tags.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> AddTags(PocketItem item, string[] tags);
/// <summary>
/// Adds the specified tags to an item.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="itemID">The item ID.</param>
/// <param name="tags">The tags.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> AddTags(CancellationToken cancellationToken, int itemID, string[] tags);
/// <summary>
/// Adds the specified tags to an item.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="item">The item.</param>
/// <param name="tags">The tags.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> AddTags(CancellationToken cancellationToken, PocketItem item, string[] tags);
Task<bool> AddTags(PocketItem item, string[] tags, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Removes the specified tags from an item.
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <param name="tags">The tags.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> RemoveTags(int itemID, string[] tags);
Task<bool> RemoveTags(int itemID, string[] tags, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Removes the specified tags from an item.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="tags">The tag.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> RemoveTags(PocketItem item, string[] tags);
/// <summary>
/// Removes the specified tags from an item.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="itemID">The item ID.</param>
/// <param name="tags">The tags.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> RemoveTags(CancellationToken cancellationToken, int itemID, string[] tags);
/// <summary>
/// Removes the specified tags from an item.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="item">The item.</param>
/// <param name="tags">The tag.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> RemoveTags(CancellationToken cancellationToken, PocketItem item, string[] tags);
Task<bool> RemoveTags(PocketItem item, string[] tags, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Removes a tag from an item.
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <param name="tags">The tag.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> RemoveTag(int itemID, string tag);
/// <summary>
/// Removes a tag from an item.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="tags">The tags.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> RemoveTag(PocketItem item, string tag);
/// <summary>
/// Removes a tag from an item.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="itemID">The item ID.</param>
/// <param name="tag">The tag.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> RemoveTag(CancellationToken cancellationToken, int itemID, string tag);
Task<bool> RemoveTag(int itemID, string tag, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Removes a tag from an item.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="item">The item.</param>
/// <param name="tag">The tag.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> RemoveTag(CancellationToken cancellationToken, PocketItem item, string tag);
Task<bool> RemoveTag(PocketItem item, string tag, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Clears all tags from an item.
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> RemoveTags(int itemID);
Task<bool> RemoveTags(int itemID, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Clears all tags from an item.
/// </summary>
/// <param name="item">The item.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> RemoveTags(PocketItem item);
/// <summary>
/// Clears all tags from an item.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="itemID">The item ID.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> RemoveTags(CancellationToken cancellationToken, int itemID);
/// <summary>
/// Clears all tags from an item.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="item">The item.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> RemoveTags(CancellationToken cancellationToken, PocketItem item);
Task<bool> RemoveTags(PocketItem item, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Replaces all existing tags with the given tags in an item.
/// </summary>
/// <param name="itemID">The item ID.</param>
/// <param name="tags">The tags.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> ReplaceTags(int itemID, string[] tags);
Task<bool> ReplaceTags(int itemID, string[] tags, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Replaces all existing tags with the given new ones in an item.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="tags">The tags.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> ReplaceTags(PocketItem item, string[] tags);
/// <summary>
/// Replaces all existing tags with the given tags in an item.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="itemID">The item ID.</param>
/// <param name="tags">The tags.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> ReplaceTags(CancellationToken cancellationToken, int itemID, string[] tags);
/// <summary>
/// Replaces all existing tags with the given new ones in an item.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="item">The item.</param>
/// <param name="tags">The tags.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> ReplaceTags(CancellationToken cancellationToken, PocketItem item, string[] tags);
Task<bool> ReplaceTags(PocketItem item, string[] tags, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Renames a tag in an item.
@@ -688,9 +398,10 @@ namespace PocketSharp
/// <param name="itemID">The item ID.</param>
/// <param name="oldTag">The old tag.</param>
/// <param name="newTag">The new tag name.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> RenameTag(int itemID, string oldTag, string newTag);
Task<bool> RenameTag(int itemID, string oldTag, string newTag, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Renames a tag in an item.
@@ -698,57 +409,20 @@ namespace PocketSharp
/// <param name="item">The item.</param>
/// <param name="oldTag">The old tag.</param>
/// <param name="newTag">The new tag name.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> RenameTag(PocketItem item, string oldTag, string newTag);
/// <summary>
/// Renames a tag in an item.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="itemID">The item ID.</param>
/// <param name="oldTag">The old tag.</param>
/// <param name="newTag">The new tag name.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> RenameTag(CancellationToken cancellationToken, int itemID, string oldTag, string newTag);
/// <summary>
/// Renames a tag in an item.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <param name="item">The item.</param>
/// <param name="oldTag">The old tag.</param>
/// <param name="newTag">The new tag name.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<bool> RenameTag(CancellationToken cancellationToken, PocketItem item, string oldTag, string newTag);
Task<bool> RenameTag(PocketItem item, string oldTag, string newTag, CancellationToken cancellationToken = default(CancellationToken));
#endregion
#region statistics methods
/// <summary>
/// Statistics from the user account.
/// </summary>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<PocketStatistics> GetUserStatistics();
/// <summary>
/// Statistics from the user account.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<PocketStatistics> GetUserStatistics(CancellationToken cancellationToken);
/// <summary>
/// Returns API usage statistics.
/// If a request was made before, the data is returned synchronously from the cache.
/// Note: This method only works for authenticated users with a given AccessCode.
/// </summary>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<PocketLimits> GetUsageLimits();
Task<PocketStatistics> GetUserStatistics(CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Returns API usage statistics.
@@ -758,7 +432,7 @@ namespace PocketSharp
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
/// <exception cref="PocketException"></exception>
Task<PocketLimits> GetUsageLimits(CancellationToken cancellationToken);
Task<PocketLimits> GetUsageLimits(CancellationToken cancellationToken = default(CancellationToken));
#endregion
}
}