ability to retrieve all tags
This commit is contained in:
@@ -46,7 +46,7 @@ namespace PocketSharp.Silverlight
|
||||
|
||||
try
|
||||
{
|
||||
items = await client.Retrieve();
|
||||
items = await client.Get();
|
||||
|
||||
items.ForEach(item =>
|
||||
{
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace PocketSharp.WP8.ViewModels
|
||||
|
||||
try
|
||||
{
|
||||
items = await client.Retrieve().ConfigureAwait(false);
|
||||
items = await client.Get().ConfigureAwait(false);
|
||||
|
||||
items.ForEach(item =>
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace PocketSharp.Wpf
|
||||
|
||||
try
|
||||
{
|
||||
items = await client.Retrieve();
|
||||
items = await client.Get();
|
||||
|
||||
items.ForEach(item =>
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace PocketSharp.Tests
|
||||
tweetID: "380051788172632065"
|
||||
);
|
||||
|
||||
List<PocketItem> items = await client.Retrieve();
|
||||
List<PocketItem> items = await client.Get();
|
||||
PocketItem itemDesired = null;
|
||||
|
||||
items.ForEach(itm =>
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace PocketSharp.Tests
|
||||
|
||||
private async Task<PocketItem> GetItemById(int id, bool archive = false)
|
||||
{
|
||||
List<PocketItem> items = await client.Retrieve(state: archive ? State.archive : State.unread);
|
||||
List<PocketItem> items = await client.Get(state: archive ? State.archive : State.unread);
|
||||
PocketItem itemDesired = null;
|
||||
|
||||
items.ForEach(itm =>
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace PocketSharp.Tests
|
||||
|
||||
private async Task<PocketItem> GetItemById(int id, bool archive = false)
|
||||
{
|
||||
List<PocketItem> items = await client.Retrieve(state: archive ? State.archive : State.unread);
|
||||
List<PocketItem> items = await client.Get(state: archive ? State.archive : State.unread);
|
||||
PocketItem itemDesired = null;
|
||||
|
||||
items.ForEach(itm =>
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace PocketSharp.Tests
|
||||
[Fact]
|
||||
public async Task AreItemsRetrieved()
|
||||
{
|
||||
List<PocketItem> items = await client.Retrieve();
|
||||
List<PocketItem> items = await client.Get();
|
||||
|
||||
Assert.True(items.Count > 0);
|
||||
}
|
||||
@@ -23,9 +23,9 @@ namespace PocketSharp.Tests
|
||||
[Fact]
|
||||
public async Task IsItemRetrievedById()
|
||||
{
|
||||
List<PocketItem> items = await client.Retrieve();
|
||||
List<PocketItem> items = await client.Get();
|
||||
PocketItem item = items[0];
|
||||
PocketItem itemDuplicate = await client.Retrieve(item.ID);
|
||||
PocketItem itemDuplicate = await client.Get(item.ID);
|
||||
|
||||
Assert.True(item.ID == itemDuplicate.ID);
|
||||
Assert.True(item.Uri == itemDuplicate.Uri);
|
||||
@@ -35,7 +35,7 @@ namespace PocketSharp.Tests
|
||||
[Fact]
|
||||
public async Task AreFilteredItemsRetrieved()
|
||||
{
|
||||
List<PocketItem> items = await client.RetrieveByFilter(RetrieveFilter.Favorite);
|
||||
List<PocketItem> items = await client.Get(RetrieveFilter.Favorite);
|
||||
|
||||
Assert.True(items.Count > 0);
|
||||
}
|
||||
@@ -44,7 +44,7 @@ namespace PocketSharp.Tests
|
||||
[Fact]
|
||||
public async Task RetrieveWithMultipleFilters()
|
||||
{
|
||||
List<PocketItem> items = await client.Retrieve(
|
||||
List<PocketItem> items = await client.Get(
|
||||
state: State.unread,
|
||||
tag: "pocket",
|
||||
sort: Sort.title,
|
||||
@@ -59,7 +59,7 @@ namespace PocketSharp.Tests
|
||||
[Fact]
|
||||
public async Task ItemContainsUri()
|
||||
{
|
||||
List<PocketItem> items = await client.Retrieve(count: 1);
|
||||
List<PocketItem> items = await client.Get(count: 1);
|
||||
|
||||
Assert.True(items.Count == 1);
|
||||
Assert.True(items[0].Uri.ToString().StartsWith("http"));
|
||||
@@ -69,18 +69,18 @@ namespace PocketSharp.Tests
|
||||
[Fact]
|
||||
public async Task InvalidRetrievalReturnsNoResults()
|
||||
{
|
||||
List<PocketItem> items = await client.Retrieve(
|
||||
List<PocketItem> items = await client.Get(
|
||||
favorite: true,
|
||||
search: "xoiu987a#;"
|
||||
);
|
||||
|
||||
Assert.False(items.Count > 0);
|
||||
|
||||
PocketItem item = await client.Retrieve(99999999);
|
||||
PocketItem item = await client.Get(99999999);
|
||||
|
||||
Assert.Null(item);
|
||||
|
||||
items = await client.RetrieveByFilter(RetrieveFilter.Video);
|
||||
items = await client.Get(RetrieveFilter.Video);
|
||||
|
||||
Assert.False(items.Count > 0);
|
||||
}
|
||||
@@ -105,6 +105,15 @@ namespace PocketSharp.Tests
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task RetrieveTagsReturnsResult()
|
||||
{
|
||||
List<PocketTag> items = await client.GetTags();
|
||||
|
||||
Assert.True(items.Count > 0);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task SearchByTagsReturnsResult()
|
||||
{
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using PocketSharp.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
|
||||
namespace PocketSharp
|
||||
{
|
||||
@@ -8,6 +10,26 @@ namespace PocketSharp
|
||||
/// </summary>
|
||||
public partial class PocketClient
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
List<PocketItem> items = await Get(
|
||||
state: State.all
|
||||
);
|
||||
|
||||
return items.Where(item => item.Tags != null)
|
||||
.SelectMany(item => item.Tags)
|
||||
.GroupBy(item => item.Name)
|
||||
.Select(item => item.First())
|
||||
.ToList<PocketTag>();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Adds the specified tags to an item.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user