Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c2b6eab709 | |||
| f19fdd227b |
@@ -6,9 +6,9 @@ using PocketSharp.Models;
|
||||
|
||||
namespace PocketSharp.Tests
|
||||
{
|
||||
public class RetrieveTests : TestsBase
|
||||
public class GetTests : TestsBase
|
||||
{
|
||||
public RetrieveTests() : base() { }
|
||||
public GetTests() : base() { }
|
||||
|
||||
|
||||
[Fact]
|
||||
@@ -70,7 +70,7 @@
|
||||
<Compile Include="AccountTests.cs" />
|
||||
<Compile Include="ModifyTagsTests.cs" />
|
||||
<Compile Include="ModifyTests.cs" />
|
||||
<Compile Include="RetrieveTests.cs" />
|
||||
<Compile Include="GetTests.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="TestsBase.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<p class="app-description">
|
||||
PocketSharp is a C#.NET class library, that integrates the Pocket API v3
|
||||
<br><br>
|
||||
Current version: <b>1.5.0</b><br>
|
||||
Current version: <b>1.5.1</b><br>
|
||||
<a href="https://www.nuget.org/packages/PocketSharp/">@ nuget</a>
|
||||
</p>
|
||||
<div class="app-nuget">
|
||||
@@ -125,8 +125,9 @@ using PocketSharp.Models;</code></pre>
|
||||
|
||||
<h2>Release History</h2>
|
||||
<ul>
|
||||
<li><b>1.5.1</b> (2013-09-30) <code>RetrieveFilter.All</code> didn't work; improve search speed</li>
|
||||
<li><b>1.5.0</b> (2013-09-28) add statistics and registration API</li>
|
||||
<li><b>1.4.0</b> (2013-09-21) rename <code>Retrieve</code> to <code>Get</code> + update IntelliSense documentation + add <code>GetTags</code> method
|
||||
<li><b>1.4.0</b> (2013-09-21) rename <code>Retrieve</code> to <code>Get</code> + update IntelliSense documentation + add <code>GetTags</code> method</li>
|
||||
<li><b>1.3.0</b> (2013-09-19) get Item by ID + tag modification bugfixes</li>
|
||||
<li><b>1.2.1</b> (2013-09-18) correct parameter conversion for DateTime and Boolean</li>
|
||||
<li><b>1.2.0</b> (2013-09-17) simplified retrieve methods</li>
|
||||
@@ -226,8 +227,10 @@ Note that <code>GetAccessCode</code> can only be called with an existing <em>req
|
||||
<p><pre class="language-clike"><code>PocketItem item = await _client.Get(1298198);</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>Find items by a search string.<br>PocketSharp uses an internal search, which is significantly faster than the Search API by Pocket.</p>
|
||||
<p><pre class="language-clike"><code>List<PocketItem> items = await _client.Search("css");</code></pre></p>
|
||||
<p>Find items by a search string by already available items:</p>
|
||||
<p><pre class="language-clike"><code>List<PocketItem> items = await _client.Search(myPocketItemList, "css");</code></pre></p>
|
||||
<p>Get all tags:</p>
|
||||
<p><pre class="language-clike"><code>List<PocketTag> items = await _client.GetTags();</code></pre></p>
|
||||
<p>Get a filtered list:</p>
|
||||
|
||||
@@ -99,6 +99,9 @@ namespace PocketSharp
|
||||
case RetrieveFilter.Archive:
|
||||
parameters.State = State.archive;
|
||||
break;
|
||||
case RetrieveFilter.All:
|
||||
parameters.State = State.all;
|
||||
break;
|
||||
}
|
||||
|
||||
parameters.DetailType = DetailType.complete;
|
||||
@@ -142,14 +145,39 @@ namespace PocketSharp
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves items which match the specified search string in title or content
|
||||
/// 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)
|
||||
public async Task<List<PocketItem>> Search(string searchString, bool searchInUri = true)
|
||||
{
|
||||
return await Get(search: searchString);
|
||||
List<PocketItem> items = await Get(RetrieveFilter.All);
|
||||
|
||||
return Search(items, searchString);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Finds the specified search string in title and URI for an available list of items
|
||||
/// </summary>
|
||||
/// <param name="availableItems">The available items.</param>
|
||||
/// <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 List<PocketItem> Search(List<PocketItem> availableItems, string searchString)
|
||||
{
|
||||
if (searchString.Length < 2)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("Search string length has to be a minimum of 2 chars");
|
||||
}
|
||||
|
||||
return availableItems.Where(item => (
|
||||
(!String.IsNullOrEmpty(item.FullTitle) && item.FullTitle.ToLower().Contains(searchString))
|
||||
|| item.Uri.ToString().ToLower().Contains(searchString)
|
||||
)).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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.5.0")]
|
||||
[assembly: AssemblyFileVersion("1.5.0")]
|
||||
[assembly: AssemblyVersion("1.5.1")]
|
||||
[assembly: AssemblyFileVersion("1.5.1")]
|
||||
@@ -209,12 +209,19 @@ Find items by a tag:
|
||||
List<PocketItem> items = await _client.SearchByTag("tutorial");
|
||||
```
|
||||
|
||||
Find items by a search string:
|
||||
Find items by a search string.
|
||||
<br>PocketSharp uses an internal search, which is significantly faster than the Search API by Pocket.
|
||||
|
||||
```csharp
|
||||
List<PocketItem> items = await _client.Search("css");
|
||||
```
|
||||
|
||||
Find items by a search string by already available items:
|
||||
|
||||
```csharp
|
||||
List<PocketItem> items = await _client.Search(myPocketItemList, "css");
|
||||
```
|
||||
|
||||
Get all tags:
|
||||
|
||||
```csharp
|
||||
@@ -335,6 +342,7 @@ PocketStatistics statistics = await client.Statistics();
|
||||
|
||||
## Release History
|
||||
|
||||
- **1.5.1** (2013-09-30) `RetrieveFilter.All` didn't work; improve search speed
|
||||
- **1.5.0** (2013-09-28) add statistics and registration API
|
||||
- **1.4.0** (2013-09-21) rename `Retrieve` to `Get` + update IntelliSense documentation + add `GetTags` method
|
||||
- **1.3.0** (2013-09-19) get Item by ID + tag modification bugfixes
|
||||
|
||||
Reference in New Issue
Block a user