Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4e40aaa0dc | |||
| 242428f94c | |||
| d009afd033 | |||
| de1e4efc70 | |||
| e198ecdd6b |
@@ -20,6 +20,30 @@ namespace PocketSharp.Tests
|
||||
}
|
||||
|
||||
|
||||
[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()
|
||||
{
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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