Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1912563cc3 | |||
| 64c74b11d7 | |||
| e9699caf4e | |||
| 76af7fec0e | |||
| 4e40aaa0dc | |||
| 242428f94c | |||
| d009afd033 | |||
| de1e4efc70 | |||
| e198ecdd6b | |||
| fb92cb19c8 |
@@ -3,11 +3,100 @@ using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using Xunit;
|
||||
using PocketSharp.Models;
|
||||
using System.Linq;
|
||||
|
||||
namespace PocketSharp.Tests
|
||||
{
|
||||
class ModifyTagsTests : TestsBase
|
||||
public class ModifyTagsTests : TestsBase
|
||||
{
|
||||
public ModifyTagsTests() : base() { }
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task AreTagsAddedAndDeletedToAnItem()
|
||||
{
|
||||
PocketItem item = await Setup();
|
||||
|
||||
Assert.True(await client.AddTags(item, new string[] { "test_tag", "test_tag2" }));
|
||||
|
||||
item = await GetItemById(item.ID);
|
||||
|
||||
Assert.True(item.Tags.Count >= 2);
|
||||
|
||||
Assert.NotNull(item.Tags.Single<PocketTag>(tag => tag.Name == "test_tag"));
|
||||
Assert.NotNull(item.Tags.Single<PocketTag>(tag => tag.Name == "test_tag2"));
|
||||
|
||||
Assert.True(await client.RemoveTags(item, new string[] { "test_tag", "test_tag2" }));
|
||||
|
||||
item = await GetItemById(item.ID);
|
||||
|
||||
Assert.Null(item.Tags.SingleOrDefault<PocketTag>(tag => tag.Name == "test_tag"));
|
||||
Assert.Null(item.Tags.SingleOrDefault<PocketTag>(tag => tag.Name == "test_tag2"));
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task AreAllTagsRemovedFromItem()
|
||||
{
|
||||
PocketItem item = await Setup();
|
||||
|
||||
Assert.True(await client.AddTags(item, new string[] { "test_tag", "test_tag2" }));
|
||||
|
||||
item = await GetItemById(item.ID);
|
||||
|
||||
Assert.True(item.Tags.Count >= 2);
|
||||
|
||||
Assert.True(await client.RemoveTags(item));
|
||||
|
||||
item = await GetItemById(item.ID);
|
||||
|
||||
Assert.Null(item.Tags);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task AreTagsReplaced()
|
||||
{
|
||||
PocketItem item = await Setup();
|
||||
|
||||
Assert.True(await client.ReplaceTags(item.ID, new string[] { "test_tag", "test_tag2" }));
|
||||
|
||||
item = await GetItemById(item.ID);
|
||||
|
||||
Assert.Equal(item.Tags.Count, 2);
|
||||
|
||||
Assert.NotNull(item.Tags.SingleOrDefault<PocketTag>(tag => tag.Name == "test_tag"));
|
||||
Assert.NotNull(item.Tags.SingleOrDefault<PocketTag>(tag => tag.Name == "test_tag2"));
|
||||
}
|
||||
|
||||
|
||||
private async Task<PocketItem> Setup()
|
||||
{
|
||||
PocketItem item = await client.Add(
|
||||
uri: new Uri("https://github.com"),
|
||||
tags: new string[] { "github", "code", "social" }
|
||||
);
|
||||
|
||||
itemsToDelete.Add(item.ID);
|
||||
|
||||
return await GetItemById(item.ID);
|
||||
}
|
||||
|
||||
|
||||
private async Task<PocketItem> GetItemById(int id, bool archive = false)
|
||||
{
|
||||
List<PocketItem> items = await client.Retrieve(state: archive ? State.archive : State.unread);
|
||||
PocketItem itemDesired = null;
|
||||
|
||||
items.ForEach(itm =>
|
||||
{
|
||||
if (itm.ID == id)
|
||||
{
|
||||
itemDesired = itm;
|
||||
}
|
||||
});
|
||||
|
||||
return itemDesired;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,89 @@ using PocketSharp.Models;
|
||||
|
||||
namespace PocketSharp.Tests
|
||||
{
|
||||
class ModifyTests : TestsBase
|
||||
public class ModifyTests : TestsBase
|
||||
{
|
||||
public ModifyTests() : base() { }
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task IsAnItemArchivedAndUnarchived()
|
||||
{
|
||||
PocketItem item = await Setup();
|
||||
|
||||
Assert.True(await client.Archive(item));
|
||||
|
||||
item = await GetItemById(item.ID, true);
|
||||
|
||||
Assert.True(item.IsArchive);
|
||||
|
||||
Assert.True(await client.Unarchive(item));
|
||||
|
||||
item = await GetItemById(item.ID);
|
||||
|
||||
Assert.False(item.IsArchive);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task IsAnItemFavoritedAndUnfavorited()
|
||||
{
|
||||
PocketItem item = await Setup();
|
||||
|
||||
Assert.True(await client.Favorite(item));
|
||||
|
||||
item = await GetItemById(item.ID);
|
||||
|
||||
Assert.True(item.IsFavorite);
|
||||
|
||||
Assert.True(await client.Unfavorite(item));
|
||||
|
||||
item = await GetItemById(item.ID);
|
||||
|
||||
Assert.False(item.IsFavorite);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task IsAnItemDeleted()
|
||||
{
|
||||
PocketItem item = await Setup();
|
||||
|
||||
Assert.True(await client.Delete(item));
|
||||
|
||||
item = await GetItemById(item.ID);
|
||||
|
||||
Assert.Null(item);
|
||||
}
|
||||
|
||||
|
||||
private async Task<PocketItem> Setup()
|
||||
{
|
||||
PocketItem item = await client.Add(
|
||||
uri: new Uri("https://github.com"),
|
||||
tags: new string[] { "github", "code", "social" }
|
||||
);
|
||||
|
||||
itemsToDelete.Add(item.ID);
|
||||
|
||||
return await GetItemById(item.ID);
|
||||
}
|
||||
|
||||
|
||||
private async Task<PocketItem> GetItemById(int id, bool archive = false)
|
||||
{
|
||||
List<PocketItem> items = await client.Retrieve(state: archive ? State.archive : State.unread);
|
||||
PocketItem itemDesired = null;
|
||||
|
||||
items.ForEach(itm =>
|
||||
{
|
||||
if (itm.ID == id)
|
||||
{
|
||||
itemDesired = itm;
|
||||
}
|
||||
});
|
||||
|
||||
return itemDesired;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,20 +20,50 @@ namespace PocketSharp.Tests
|
||||
}
|
||||
|
||||
|
||||
//[Fact]
|
||||
//public async Task ItemContainsUri()
|
||||
//{
|
||||
// List<PocketItem> items = await client.Retrieve(new RetrieveParameters()
|
||||
// {
|
||||
// Count = 1
|
||||
// });
|
||||
[Fact]
|
||||
public async Task IsItemRetrievedById()
|
||||
{
|
||||
List<PocketItem> items = await client.Retrieve();
|
||||
PocketItem item = items[0];
|
||||
PocketItem itemDuplicate = await client.Retrieve(item.ID);
|
||||
|
||||
// Assert.True(items.Count == 1);
|
||||
Assert.True(item.ID == itemDuplicate.ID);
|
||||
Assert.True(item.Uri == itemDuplicate.Uri);
|
||||
}
|
||||
|
||||
// PocketItem item = items[0];
|
||||
|
||||
// Assert.True(item.Uri.ToString().StartsWith("http"));
|
||||
//}
|
||||
[Fact]
|
||||
public async Task AreFilteredItemsRetrieved()
|
||||
{
|
||||
List<PocketItem> items = await client.RetrieveByFilter(RetrieveFilter.Favorite);
|
||||
|
||||
Assert.True(items.Count > 0);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task RetrieveWithMultipleFilters()
|
||||
{
|
||||
List<PocketItem> items = await client.Retrieve(
|
||||
state: State.unread,
|
||||
tag: "pocket",
|
||||
sort: Sort.title,
|
||||
since: new DateTime(2010, 12, 10),
|
||||
count: 2
|
||||
);
|
||||
|
||||
Assert.InRange<int>(items.Count, 0, 2);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task ItemContainsUri()
|
||||
{
|
||||
List<PocketItem> items = await client.Retrieve(count: 1);
|
||||
|
||||
Assert.True(items.Count == 1);
|
||||
Assert.True(items[0].Uri.ToString().StartsWith("http"));
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
</h1>
|
||||
<p class="app-description">
|
||||
PocketSharp is a C#.NET class library, that integrates the Pocket API v3
|
||||
<br><br>
|
||||
Current version: <b>1.2.0</b>
|
||||
</p>
|
||||
<div class="app-nuget">
|
||||
<code>Install-Package PocketSharp</code>
|
||||
@@ -122,6 +124,8 @@ using PocketSharp.Models;</code></pre>
|
||||
|
||||
<h2>Release History</h2>
|
||||
<ul>
|
||||
<li>2013-09-17 v1.2.0 simplified retrieve methods</li>
|
||||
<li>2013-09-17 v1.1.0 fix modification requests</li>
|
||||
<li>2013-09-15 v1.0.0 convert to PCL & implement async</li>
|
||||
<li>2013-08-16 v0.3.2 tag modification fixed and full retrieval of items for Retrieve method</li>
|
||||
<li>2013-07-07 v0.3.1 authentication fixes</li>
|
||||
@@ -186,42 +190,34 @@ Note that <code>GetAccessCode</code> can only be called with an existing <em>req
|
||||
<div data-part="retrieve">
|
||||
|
||||
<h2>Retrieve</h2>
|
||||
<p>Get list of all items:</p>
|
||||
|
||||
<pre class="language-clike"><code>List<PocketItem> items = await _client.Retrieve();
|
||||
// equivalent to: await _client.Retrieve(RetrieveFilter.All)</code></pre>
|
||||
|
||||
<p>Find items by a tag:</p>
|
||||
|
||||
<pre class="language-clike"><code>List<PocketItem> items = await _client.SearchByTag("tutorial");</code></pre>
|
||||
|
||||
<p>Find items by a search string:</p>
|
||||
|
||||
<pre class="language-clike"><code>List<PocketItem> items = await _client.Search("css");</code></pre>
|
||||
|
||||
<p>Find items by a filter:</p>
|
||||
|
||||
<pre class="language-clike"><code>List<PocketItem> items = await _client.Retrieve(RetrieveFilter.Favorite); // only favorites</code></pre>
|
||||
|
||||
<p>The RetrieveFilter Enum is specified as follows:</p>
|
||||
|
||||
<pre class="language-clike"><code>enum RetrieveFilter { All, Unread, Archive, Favorite, Article, Video, Image }</code></pre>
|
||||
|
||||
<h4>Custom Parameters</h4>
|
||||
<p>You can create a completely custom parameter list for retrieval with the POCO <code>RetrieveParameters</code>:</p>
|
||||
|
||||
<pre class="language-clike"><code>
|
||||
var parameters = new RetrieveParameters()
|
||||
{
|
||||
Count = 50,
|
||||
Offset = 100,
|
||||
Sort = SortEnum.oldest
|
||||
...
|
||||
};
|
||||
List<pocketitem> items = await _client.Retrieve(parameters);
|
||||
</code></pre>
|
||||
|
||||
|
||||
<p>Get list of all items:</p>
|
||||
<p><pre class="language-clike"><code>List<PocketItem> items = await _client.Retrieve();
|
||||
// equivalent to: await _client.RetrieveByFilter(RetrieveFilter.All)</code></pre></p>
|
||||
<p>Get a list with specific parameters (explanation in the <a href="http://getpocket.com/developer/docs/v3/retrieve">Pocket Docs</a>):</p>
|
||||
<p><pre class="language-clike"><code>List<PocketItem> items = await _client.Retrieve(
|
||||
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
|
||||
);</code></pre></p>
|
||||
<p>It's best to use parameters as <em>named parameters</em>, to avoid typing <code>null</code> values:</p>
|
||||
<p><pre class="language-clike"><code>List<PocketItem> items = await _client.Retrieve(count: 10, offset: 20, sort: Sort.oldest);</code></pre></p>
|
||||
<p>Find items by a tag:</p>
|
||||
<p><pre class="language-clike"><code>List<PocketItem> items = await _client.SearchByTag("tutorial");</code></pre></p>
|
||||
<p>Find items by a search string:</p>
|
||||
<p><pre class="language-clike"><code>List<PocketItem> items = await _client.Search("css");</code></pre></p>
|
||||
<p>Get a filtered list:</p>
|
||||
<p><pre class="language-clike"><code>List<PocketItem> items = await _client.RetrieveByFilter(RetrieveFilter.Favorite);
|
||||
// returns favorites only</code></pre></p>
|
||||
<p>The RetrieveFilter Enum is specified as follows:</p>
|
||||
<p><pre class="language-clike"><code>enum RetrieveFilter { All, Unread, Archive, Favorite, Article, Video, Image }</code></pre></p>
|
||||
</div>
|
||||
|
||||
<div data-part="add">
|
||||
|
||||
@@ -56,6 +56,30 @@ namespace PocketSharp
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Removes a tag.
|
||||
/// </summary>
|
||||
/// <param name="itemID">The item ID.</param>
|
||||
/// <param name="tags">The tags.</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> RemoveTag(int itemID, string tag)
|
||||
{
|
||||
return await SendTags(itemID, "tags_remove", new string[] { tag });
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Removes a tag.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="tags">The tags.</param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> RemoveTag(PocketItem item, string tag)
|
||||
{
|
||||
return await RemoveTag(item.ID, tag);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Clears all tags.
|
||||
/// </summary>
|
||||
@@ -79,7 +103,7 @@ namespace PocketSharp
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Replaces all existing tags with new ones.
|
||||
/// Replaces all existing tags with the given tags.
|
||||
/// </summary>
|
||||
/// <param name="itemID">The item ID.</param>
|
||||
/// <param name="tags">The tags.</param>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using PocketSharp.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
|
||||
namespace PocketSharp
|
||||
{
|
||||
@@ -14,20 +16,61 @@ namespace PocketSharp
|
||||
/// </summary>
|
||||
/// <param name="parameters">parameters, which are mapped to the officials from http://getpocket.com/developer/docs/v3/retrieve </param>
|
||||
/// <returns></returns>
|
||||
internal async Task<List<PocketItem>> Retrieve(RetrieveParameters parameters)
|
||||
public async Task<List<PocketItem>> Retrieve(
|
||||
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
|
||||
)
|
||||
{
|
||||
RetrieveParameters parameters = new RetrieveParameters()
|
||||
{
|
||||
State = state,
|
||||
Favorite = favorite,
|
||||
Tag = tag,
|
||||
ContentType = contentType,
|
||||
Sort = sort,
|
||||
DetailType = DetailType.complete,
|
||||
Search = search,
|
||||
Domain = domain,
|
||||
Since = since,
|
||||
Count = count,
|
||||
Offset = offset
|
||||
};
|
||||
|
||||
Retrieve response = await Request<Retrieve>("get", parameters.Convert());
|
||||
|
||||
return response.Items;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves an item by a given ID
|
||||
/// </summary>
|
||||
/// <param name="itemID">The item ID.</param>
|
||||
/// <returns></returns>
|
||||
public async Task<PocketItem> Retrieve(int itemID)
|
||||
{
|
||||
List<PocketItem> items = await Retrieve(
|
||||
state: State.all
|
||||
);
|
||||
|
||||
return items.Single<PocketItem>(item => item.ID == itemID);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all items with a filter from pocket
|
||||
/// </summary>
|
||||
/// <param name="filter">The filter.</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<PocketItem>> Retrieve(RetrieveFilter filter = RetrieveFilter.All)
|
||||
public async Task<List<PocketItem>> RetrieveByFilter(RetrieveFilter filter = RetrieveFilter.All)
|
||||
{
|
||||
RetrieveParameters parameters = new RetrieveParameters();
|
||||
|
||||
@@ -68,15 +111,7 @@ namespace PocketSharp
|
||||
/// <returns></returns>
|
||||
public async Task<List<PocketItem>> SearchByTag(string tag)
|
||||
{
|
||||
RetrieveParameters parameters = new RetrieveParameters()
|
||||
{
|
||||
Tag = tag,
|
||||
DetailType = DetailType.complete
|
||||
};
|
||||
|
||||
Retrieve response = await Request<Retrieve>("get", parameters.Convert());
|
||||
|
||||
return response.Items;
|
||||
return await Retrieve(tag: tag);
|
||||
}
|
||||
|
||||
|
||||
@@ -87,15 +122,7 @@ namespace PocketSharp
|
||||
/// <returns></returns>
|
||||
public async Task<List<PocketItem>> Search(string searchString)
|
||||
{
|
||||
RetrieveParameters parameters = new RetrieveParameters()
|
||||
{
|
||||
Search = searchString,
|
||||
DetailType = DetailType.complete
|
||||
};
|
||||
|
||||
Retrieve response = await Request<Retrieve>("get", parameters.Convert());
|
||||
|
||||
return response.Items;
|
||||
return await Retrieve(search: searchString);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
@@ -8,7 +9,7 @@ namespace PocketSharp.Models
|
||||
/// All parameters which can be passed for a modify action
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
internal class ActionParameter : Parameters
|
||||
internal class ActionParameter
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the action.
|
||||
@@ -67,28 +68,28 @@ namespace PocketSharp.Models
|
||||
public string NewTag { get; set; }
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// Converts this instance to a parameter list.
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
//public Dictionary<string, object> Convert()
|
||||
//{
|
||||
// Dictionary<string, object> parameters = new Dictionary<string, object>
|
||||
// {
|
||||
// { "item_id", ID },
|
||||
// { "action", Action }
|
||||
// };
|
||||
/// <summary>
|
||||
/// Converts this instance to a parameter list.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Dictionary<string, object> Convert()
|
||||
{
|
||||
Dictionary<string, object> parameters = new Dictionary<string, object>
|
||||
{
|
||||
{ "item_id", ID.ToString() },
|
||||
{ "action", Action }
|
||||
};
|
||||
|
||||
// if (Time != null)
|
||||
// parameters.Add("time", Utilities.GetUnixTimestamp(Time));
|
||||
// if (Tags != null)
|
||||
// parameters.Add("tags", Tags);
|
||||
// if (OldTag != null)
|
||||
// parameters.Add("old_tag", OldTag);
|
||||
// if (NewTag != null)
|
||||
// parameters.Add("new_tag", NewTag);
|
||||
if (Time != null)
|
||||
parameters.Add("time", Time != null ? Utilities.GetUnixTimestamp(Time).ToString() : null);
|
||||
if (Tags != null)
|
||||
parameters.Add("tags", Tags);
|
||||
if (OldTag != null)
|
||||
parameters.Add("old_tag", OldTag);
|
||||
if (NewTag != null)
|
||||
parameters.Add("new_tag", NewTag);
|
||||
|
||||
// return parameters;
|
||||
//}
|
||||
return parameters;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,16 +35,30 @@ namespace PocketSharp.Models
|
||||
string name = attribute.Name ?? propertyInfo.Name.ToLower();
|
||||
object value = propertyInfo.GetValue(this, null);
|
||||
|
||||
// invalid parameter
|
||||
if (value == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// convert array to comma-seperated list
|
||||
if (value is IEnumerable && value.GetType().GetElementType() == typeof(string))
|
||||
{
|
||||
value = string.Join(",", ((IEnumerable)value).Cast<object>().Select(x => x.ToString()).ToArray());
|
||||
}
|
||||
|
||||
// convert booleans
|
||||
if (value is bool)
|
||||
{
|
||||
value = System.Convert.ToBoolean(value) ? "1" : "0";
|
||||
}
|
||||
|
||||
// convert DateTime to UNIX timestamp
|
||||
if (value is DateTime)
|
||||
{
|
||||
value = (int)((DateTime)value - new DateTime(1970, 1, 1)).TotalSeconds;
|
||||
}
|
||||
|
||||
parameterDict.Add(name, value.ToString());
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace PocketSharp.Models
|
||||
/// <value>
|
||||
/// The action results.
|
||||
/// </value>
|
||||
[JsonProperty("action_results")]
|
||||
public bool[] ActionResults { get; set; }
|
||||
//[JsonProperty("action_results")]
|
||||
//public bool[] ActionResults { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace PocketSharp
|
||||
/// <returns></returns>
|
||||
internal async Task<bool> Send(List<ActionParameter> actionParameters)
|
||||
{
|
||||
List<Dictionary<string, string>> actionParamList = new List<Dictionary<string, string>>();
|
||||
List<Dictionary<string, object>> actionParamList = new List<Dictionary<string, object>>();
|
||||
|
||||
foreach (var action in actionParameters)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<projectUrl>http://pocketsharp.frontendplay.com</projectUrl>
|
||||
<iconUrl>http://pocketsharp.frontendplay.com/Assets/Images/pocketsharp.png</iconUrl>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<description>$description$</description>
|
||||
<description>PocketSharp is a .NET class library, that integrates the Pocket API v3</description>
|
||||
<language>en-US</language>
|
||||
<releaseNotes>
|
||||
<![CDATA[
|
||||
|
||||
@@ -25,5 +25,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0")]
|
||||
[assembly: AssemblyVersion("1.2.1")]
|
||||
[assembly: AssemblyFileVersion("1.2.1")]
|
||||
@@ -19,7 +19,7 @@ PocketSharp is a **Portable Class Library** (since 1.0.0), therefore it's compat
|
||||
- **Windows Phone** >= 7.5
|
||||
- **Windows Store**
|
||||
|
||||
You can find examples for Silverlight 5, WP8 and WPF in the `PocketSharp.Examples` folder.
|
||||
You can find examples for Silverlight 5, WP8 and WPF in the `PocketSharp.Examples` ([@github](https://github.com/ceee/PocketSharp/tree/master/PocketSharp.Examples)) folder.
|
||||
|
||||
## Async Support
|
||||
|
||||
@@ -142,7 +142,30 @@ Get list of all items:
|
||||
|
||||
```csharp
|
||||
List<PocketItem> items = await _client.Retrieve();
|
||||
// equivalent to: await _client.Retrieve(RetrieveFilter.All)
|
||||
// equivalent to: await _client.RetrieveByFilter(RetrieveFilter.All)
|
||||
```
|
||||
|
||||
Get a list with specific parameters (explanation in the [Pocket Docs](http://getpocket.com/developer/docs/v3/retrieve)):
|
||||
|
||||
```csharp
|
||||
List<PocketItem> items = await _client.Retrieve(
|
||||
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
|
||||
);
|
||||
```
|
||||
|
||||
It's best to use parameters as _named parameters_, to avoid typing `null` values:
|
||||
|
||||
```csharp
|
||||
List<PocketItem> items = await _client.Retrieve(count: 10, offset: 20, sort: Sort.oldest);
|
||||
```
|
||||
|
||||
Find items by a tag:
|
||||
@@ -157,10 +180,11 @@ Find items by a search string:
|
||||
List<PocketItem> items = await _client.Search("css");
|
||||
```
|
||||
|
||||
Find items by a filter:
|
||||
Get a filtered list:
|
||||
|
||||
```csharp
|
||||
List<PocketItem> items = await _client.Retrieve(RetrieveFilter.Favorite); // only favorites
|
||||
List<PocketItem> items = await _client.RetrieveByFilter(RetrieveFilter.Favorite);
|
||||
// returns favorites only
|
||||
```
|
||||
|
||||
The RetrieveFilter Enum is specified as follows:
|
||||
@@ -169,22 +193,6 @@ The RetrieveFilter Enum is specified as follows:
|
||||
enum RetrieveFilter { All, Unread, Archive, Favorite, Article, Video, Image }
|
||||
```
|
||||
|
||||
#### Custom Parameters
|
||||
|
||||
You can create a completely custom parameter list for retrieval with the POCO `RetrieveParameters`:
|
||||
|
||||
```csharp
|
||||
var parameters = new RetrieveParameters()
|
||||
{
|
||||
Count = 50,
|
||||
Offset = 100,
|
||||
Sort = Sort.oldest
|
||||
...
|
||||
};
|
||||
|
||||
List<PocketItem> items = await _client.Retrieve(parameters);
|
||||
```
|
||||
|
||||
## Add
|
||||
|
||||
Adds a new item to your pocket list.
|
||||
@@ -257,6 +265,9 @@ Renames a tag for the specified item:
|
||||
|
||||
## Release History
|
||||
|
||||
- 2013-09-18 v1.2.1 correct parameter conversion for DateTime and Boolean
|
||||
- 2013-09-17 v1.2.0 simplified retrieve methods
|
||||
- 2013-09-17 v1.1.0 fix modification requests
|
||||
- 2013-09-15 v1.0.0 convert to PCL & implement async
|
||||
- 2013-08-16 v0.3.2 tag modification fixed and full retrieval of items for Retrieve method
|
||||
- 2013-07-07 v0.3.1 authentication fixes
|
||||
|
||||
Reference in New Issue
Block a user