make components async (won't work yet)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using PocketSharp.Models;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PocketSharp
|
||||
{
|
||||
@@ -16,7 +17,7 @@ namespace PocketSharp
|
||||
/// <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></returns>
|
||||
public PocketItem Add(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)
|
||||
{
|
||||
AddParameters parameters = new AddParameters()
|
||||
{
|
||||
@@ -25,7 +26,7 @@ namespace PocketSharp
|
||||
Title = title,
|
||||
TweetID = tweetID
|
||||
};
|
||||
return Get<Add>("add", parameters.Convert(), true).Item;
|
||||
return await Request<Add>("add", parameters.Convert(), true).Item;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,9 +35,9 @@ namespace PocketSharp
|
||||
/// </summary>
|
||||
/// <param name="uri">The URL of the item you want to save</param>
|
||||
/// <returns></returns>
|
||||
public PocketItem Add(Uri uri)
|
||||
public async Task<PocketItem> Add(Uri uri)
|
||||
{
|
||||
return Add(uri, null, null, null);
|
||||
return await Add(uri, null, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using PocketSharp.Models;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PocketSharp
|
||||
{
|
||||
@@ -12,7 +13,7 @@ namespace PocketSharp
|
||||
/// Retrieves the requestCode from Pocket.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetRequestCode()
|
||||
public async Task<string> GetRequestCode()
|
||||
{
|
||||
// check if request code is available
|
||||
if (CallbackUri == null)
|
||||
@@ -21,7 +22,7 @@ namespace PocketSharp
|
||||
}
|
||||
|
||||
// do request
|
||||
RequestCode response = Get<RequestCode>("oauth/request", Utilities.CreateParamInList("redirect_uri", CallbackUri));
|
||||
RequestCode response = await Request<RequestCode>("oauth/request", Utilities.CreateParamInList("redirect_uri", CallbackUri));
|
||||
|
||||
// save code to client
|
||||
RequestCode = response.Code;
|
||||
@@ -58,7 +59,7 @@ namespace PocketSharp
|
||||
/// Requests the access code after authentification
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetAccessCode(string requestCode = null)
|
||||
public async Task<string> GetAccessCode(string requestCode = null)
|
||||
{
|
||||
// check if request code is available
|
||||
if(RequestCode == null && requestCode == null)
|
||||
@@ -73,7 +74,7 @@ namespace PocketSharp
|
||||
}
|
||||
|
||||
// do request
|
||||
AccessCode response = Get<AccessCode>("oauth/authorize", Utilities.CreateParamInList("code", RequestCode));
|
||||
AccessCode response = await Request<AccessCode>("oauth/authorize", Utilities.CreateParamInList("code", RequestCode));
|
||||
|
||||
// save code to client
|
||||
AccessCode = response.Code;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using PocketSharp.Models;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PocketSharp
|
||||
{
|
||||
@@ -12,9 +13,9 @@ namespace PocketSharp
|
||||
/// </summary>
|
||||
/// <param name="itemID">The item ID.</param>
|
||||
/// <returns></returns>
|
||||
public bool Archive(int itemID)
|
||||
public async Task<bool> Archive(int itemID)
|
||||
{
|
||||
return PutSendActionDefault(itemID, "archive");
|
||||
return await PutSendActionDefault(itemID, "archive");
|
||||
}
|
||||
|
||||
|
||||
@@ -23,9 +24,9 @@ namespace PocketSharp
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns></returns>
|
||||
public bool Archive(PocketItem item)
|
||||
public async Task<bool> Archive(PocketItem item)
|
||||
{
|
||||
return Archive(item.ID);
|
||||
return await Archive(item.ID);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,9 +35,9 @@ namespace PocketSharp
|
||||
/// </summary>
|
||||
/// <param name="itemID">The item ID.</param>
|
||||
/// <returns></returns>
|
||||
public bool Unarchive(int itemID)
|
||||
public async Task<bool> Unarchive(int itemID)
|
||||
{
|
||||
return PutSendActionDefault(itemID, "readd");
|
||||
return await PutSendActionDefault(itemID, "readd");
|
||||
}
|
||||
|
||||
|
||||
@@ -45,9 +46,9 @@ namespace PocketSharp
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns></returns>
|
||||
public bool Unarchive(PocketItem item)
|
||||
public async Task<bool> Unarchive(PocketItem item)
|
||||
{
|
||||
return Unarchive(item.ID);
|
||||
return await Unarchive(item.ID);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,9 +57,9 @@ namespace PocketSharp
|
||||
/// </summary>
|
||||
/// <param name="itemID">The item ID.</param>
|
||||
/// <returns></returns>
|
||||
public bool Favorite(int itemID)
|
||||
public async Task<bool> Favorite(int itemID)
|
||||
{
|
||||
return PutSendActionDefault(itemID, "favorite");
|
||||
return await PutSendActionDefault(itemID, "favorite");
|
||||
}
|
||||
|
||||
|
||||
@@ -67,9 +68,9 @@ namespace PocketSharp
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns></returns>
|
||||
public bool Favorite(PocketItem item)
|
||||
public async Task<bool> Favorite(PocketItem item)
|
||||
{
|
||||
return Favorite(item.ID);
|
||||
return await Favorite(item.ID);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,9 +79,9 @@ namespace PocketSharp
|
||||
/// </summary>
|
||||
/// <param name="itemID">The item ID.</param>
|
||||
/// <returns></returns>
|
||||
public bool Unfavorite(int itemID)
|
||||
public async Task<bool> Unfavorite(int itemID)
|
||||
{
|
||||
return PutSendActionDefault(itemID, "unfavorite");
|
||||
return await PutSendActionDefault(itemID, "unfavorite");
|
||||
}
|
||||
|
||||
|
||||
@@ -89,9 +90,9 @@ namespace PocketSharp
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns></returns>
|
||||
public bool Unfavorite(PocketItem item)
|
||||
public async Task<bool> Unfavorite(PocketItem item)
|
||||
{
|
||||
return Unfavorite(item.ID);
|
||||
return await Unfavorite(item.ID);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,9 +101,9 @@ namespace PocketSharp
|
||||
/// </summary>
|
||||
/// <param name="itemID">The item ID.</param>
|
||||
/// <returns></returns>
|
||||
public bool Delete(int itemID)
|
||||
public async Task<bool> Delete(int itemID)
|
||||
{
|
||||
return PutSendActionDefault(itemID, "delete");
|
||||
return await PutSendActionDefault(itemID, "delete");
|
||||
}
|
||||
|
||||
|
||||
@@ -111,9 +112,9 @@ namespace PocketSharp
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns></returns>
|
||||
public bool Delete(PocketItem item)
|
||||
public async Task<bool> Delete(PocketItem item)
|
||||
{
|
||||
return Delete(item.ID);
|
||||
return await Delete(item.ID);
|
||||
}
|
||||
|
||||
|
||||
@@ -123,9 +124,9 @@ namespace PocketSharp
|
||||
/// <param name="itemID">The item ID.</param>
|
||||
/// <param name="action">The action.</param>
|
||||
/// <returns></returns>
|
||||
protected bool PutSendActionDefault(int itemID, string action)
|
||||
protected async Task<bool> PutSendActionDefault(int itemID, string action)
|
||||
{
|
||||
return PutSendAction(new ActionParameter()
|
||||
return await PutSendAction(new ActionParameter()
|
||||
{
|
||||
Action = action,
|
||||
ID = itemID
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using PocketSharp.Models;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PocketSharp
|
||||
{
|
||||
@@ -13,9 +14,9 @@ namespace PocketSharp
|
||||
/// <param name="itemID">The item ID.</param>
|
||||
/// <param name="tags">The tags.</param>
|
||||
/// <returns></returns>
|
||||
public bool AddTags(int itemID, string[] tags)
|
||||
public async Task<bool> AddTags(int itemID, string[] tags)
|
||||
{
|
||||
return PutSendActionForTags(itemID, "tags_add", tags);
|
||||
return await PutSendActionForTags(itemID, "tags_add", tags);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +26,9 @@ namespace PocketSharp
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="tags">The tags.</param>
|
||||
/// <returns></returns>
|
||||
public bool AddTags(PocketItem item, string[] tags)
|
||||
public async Task<bool> AddTags(PocketItem item, string[] tags)
|
||||
{
|
||||
return AddTags(item.ID, tags);
|
||||
return await AddTags(item.ID, tags);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,9 +38,9 @@ namespace PocketSharp
|
||||
/// <param name="itemID">The item ID.</param>
|
||||
/// <param name="tags">The tags.</param>
|
||||
/// <returns></returns>
|
||||
public bool RemoveTags(int itemID, string[] tags)
|
||||
public async Task<bool> RemoveTags(int itemID, string[] tags)
|
||||
{
|
||||
return PutSendActionForTags(itemID, "tags_remove", tags);
|
||||
return await PutSendActionForTags(itemID, "tags_remove", tags);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,9 +50,9 @@ namespace PocketSharp
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="tags">The tags.</param>
|
||||
/// <returns></returns>
|
||||
public bool RemoveTags(PocketItem item, string[] tags)
|
||||
public async Task<bool> RemoveTags(PocketItem item, string[] tags)
|
||||
{
|
||||
return RemoveTags(item.ID, tags);
|
||||
return await RemoveTags(item.ID, tags);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,9 +61,9 @@ namespace PocketSharp
|
||||
/// </summary>
|
||||
/// <param name="itemID">The item ID.</param>
|
||||
/// <returns></returns>
|
||||
public bool RemoveTags(int itemID)
|
||||
public async Task<bool> RemoveTags(int itemID)
|
||||
{
|
||||
return PutSendActionDefault(itemID, "tags_clear");
|
||||
return await PutSendActionDefault(itemID, "tags_clear");
|
||||
}
|
||||
|
||||
|
||||
@@ -71,9 +72,9 @@ namespace PocketSharp
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns></returns>
|
||||
public bool RemoveTags(PocketItem item)
|
||||
public async Task<bool> RemoveTags(PocketItem item)
|
||||
{
|
||||
return RemoveTags(item.ID);
|
||||
return await RemoveTags(item.ID);
|
||||
}
|
||||
|
||||
|
||||
@@ -83,9 +84,9 @@ namespace PocketSharp
|
||||
/// <param name="itemID">The item ID.</param>
|
||||
/// <param name="tags">The tags.</param>
|
||||
/// <returns></returns>
|
||||
public bool ReplaceTags(int itemID, string[] tags)
|
||||
public async Task<bool> ReplaceTags(int itemID, string[] tags)
|
||||
{
|
||||
return PutSendActionForTags(itemID, "tags_replace", tags);
|
||||
return await PutSendActionForTags(itemID, "tags_replace", tags);
|
||||
}
|
||||
|
||||
|
||||
@@ -95,9 +96,9 @@ namespace PocketSharp
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="tags">The tags.</param>
|
||||
/// <returns></returns>
|
||||
public bool ReplaceTags(PocketItem item, string[] tags)
|
||||
public async Task<bool> ReplaceTags(PocketItem item, string[] tags)
|
||||
{
|
||||
return ReplaceTags(item.ID, tags);
|
||||
return await ReplaceTags(item.ID, tags);
|
||||
}
|
||||
|
||||
|
||||
@@ -108,9 +109,9 @@ namespace PocketSharp
|
||||
/// <param name="oldTag">The old tag.</param>
|
||||
/// <param name="newTag">The new tag name.</param>
|
||||
/// <returns></returns>
|
||||
public bool RenameTag(int itemID, string oldTag, string newTag)
|
||||
public async Task<bool> RenameTag(int itemID, string oldTag, string newTag)
|
||||
{
|
||||
return PutSendAction(new ActionParameter()
|
||||
return await PutSendAction(new ActionParameter()
|
||||
{
|
||||
Action = "tag_rename",
|
||||
ID = itemID,
|
||||
@@ -127,9 +128,9 @@ namespace PocketSharp
|
||||
/// <param name="oldTag">The old tag.</param>
|
||||
/// <param name="newTag">The new tag name.</param>
|
||||
/// <returns></returns>
|
||||
public bool RenameTag(PocketItem item, string oldTag, string newTag)
|
||||
public async Task<bool> RenameTag(PocketItem item, string oldTag, string newTag)
|
||||
{
|
||||
return RenameTag(item.ID, oldTag, newTag);
|
||||
return await RenameTag(item.ID, oldTag, newTag);
|
||||
}
|
||||
|
||||
|
||||
@@ -140,9 +141,9 @@ namespace PocketSharp
|
||||
/// <param name="action">The action.</param>
|
||||
/// <param name="tags">The tags.</param>
|
||||
/// <returns></returns>
|
||||
protected bool PutSendActionForTags(int itemID, string action, string[] tags)
|
||||
protected async Task<bool> PutSendActionForTags(int itemID, string action, string[] tags)
|
||||
{
|
||||
return PutSendAction(new ActionParameter()
|
||||
return await PutSendAction(new ActionParameter()
|
||||
{
|
||||
Action = action,
|
||||
ID = itemID,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using PocketSharp.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PocketSharp
|
||||
{
|
||||
@@ -13,9 +14,9 @@ namespace PocketSharp
|
||||
/// </summary>
|
||||
/// <param name="parameters">parameters, which are mapped to the officials from http://getpocket.com/developer/docs/v3/retrieve </param>
|
||||
/// <returns></returns>
|
||||
public List<PocketItem> Retrieve(RetrieveParameters parameters)
|
||||
public async Task<List<PocketItem>> Retrieve(RetrieveParameters parameters)
|
||||
{
|
||||
return Get<Retrieve>("get", parameters.Convert(), true).Items;
|
||||
return await Request<Retrieve>("get", parameters.Convert(), true).Items;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +25,7 @@ namespace PocketSharp
|
||||
/// </summary>
|
||||
/// <param name="filter">The filter.</param>
|
||||
/// <returns></returns>
|
||||
public List<PocketItem> Retrieve(RetrieveFilter filter = RetrieveFilter.All)
|
||||
public async Task<List<PocketItem>> Retrieve(RetrieveFilter filter = RetrieveFilter.All)
|
||||
{
|
||||
RetrieveParameters parameters = new RetrieveParameters();
|
||||
|
||||
@@ -52,7 +53,7 @@ namespace PocketSharp
|
||||
|
||||
parameters.DetailType = DetailType.complete;
|
||||
|
||||
return Get<Retrieve>("get", parameters.Convert(), true).Items;
|
||||
return await Request<Retrieve>("get", parameters.Convert(), true).Items;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,14 +62,14 @@ namespace PocketSharp
|
||||
/// </summary>
|
||||
/// <param name="tag">The tag.</param>
|
||||
/// <returns></returns>
|
||||
public List<PocketItem> SearchByTag(string tag)
|
||||
public async Task<List<PocketItem>> SearchByTag(string tag)
|
||||
{
|
||||
RetrieveParameters parameters = new RetrieveParameters()
|
||||
{
|
||||
Tag = tag,
|
||||
DetailType = DetailType.complete
|
||||
};
|
||||
return Get<Retrieve>("get", parameters.Convert(), true).Items;
|
||||
return await Request<Retrieve>("get", parameters.Convert(), true).Items;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,14 +78,14 @@ namespace PocketSharp
|
||||
/// </summary>
|
||||
/// <param name="searchString">The search string.</param>
|
||||
/// <returns></returns>
|
||||
public List<PocketItem> Search(string searchString)
|
||||
public async Task<List<PocketItem>> Search(string searchString)
|
||||
{
|
||||
RetrieveParameters parameters = new RetrieveParameters()
|
||||
{
|
||||
Search = searchString,
|
||||
DetailType = DetailType.complete
|
||||
};
|
||||
return Get<Retrieve>("get", parameters.Convert(), true).Items;
|
||||
return await Request<Retrieve>("get", parameters.Convert(), true).Items;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user