diff --git a/PocketSharp.Examples/PocketSharp.UWP/PocketSharp.UWP.nuget.props b/PocketSharp.Examples/PocketSharp.UWP/PocketSharp.UWP.nuget.props index 71e96f2..5a1c4ae 100644 --- a/PocketSharp.Examples/PocketSharp.UWP/PocketSharp.UWP.nuget.props +++ b/PocketSharp.Examples/PocketSharp.UWP/PocketSharp.UWP.nuget.props @@ -5,21 +5,21 @@ NuGet O:\PocketSharp\PocketSharp.Examples\PocketSharp.UWP\project.lock.json $(UserProfile)\.nuget\packages\ - C:\Users\cee\.nuget\packages\;C:\Program Files (x86)\Microsoft SDKs\NuGetPackagesFallback\ + C:\Users\cee\.nuget\packages\ ProjectJson - 4.6.2 + 4.7.0 $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - - - - - - - - + + + + + + + + \ No newline at end of file diff --git a/PocketSharp.Examples/PocketSharp.UWP/PocketSharp.UWP.nuget.targets b/PocketSharp.Examples/PocketSharp.UWP/PocketSharp.UWP.nuget.targets index 4176878..a1d5ce9 100644 --- a/PocketSharp.Examples/PocketSharp.UWP/PocketSharp.UWP.nuget.targets +++ b/PocketSharp.Examples/PocketSharp.UWP/PocketSharp.UWP.nuget.targets @@ -4,14 +4,14 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - - - + + + - - - - + + + + \ No newline at end of file diff --git a/PocketSharp.Examples/PocketSharp.UWP/project.lock.json b/PocketSharp.Examples/PocketSharp.UWP/project.lock.json index e4eddfa..3a11d31 100644 --- a/PocketSharp.Examples/PocketSharp.UWP/project.lock.json +++ b/PocketSharp.Examples/PocketSharp.UWP/project.lock.json @@ -6687,8 +6687,7 @@ "UAP,Version=v10.0.16299": [] }, "packageFolders": { - "C:\\Users\\cee\\.nuget\\packages\\": {}, - "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackagesFallback\\": {} + "C:\\Users\\cee\\.nuget\\packages\\": {} }, "project": { "restore": { @@ -6699,14 +6698,10 @@ "packagesPath": "C:\\Users\\cee\\.nuget\\packages\\", "outputPath": "O:\\PocketSharp\\PocketSharp.Examples\\PocketSharp.UWP\\obj\\", "projectStyle": "ProjectJson", - "fallbackFolders": [ - "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackagesFallback\\" - ], "configFilePaths": [ "O:\\PocketSharp\\.nuget\\NuGet.Config", "C:\\Users\\cee\\AppData\\Roaming\\NuGet\\NuGet.Config", - "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config", - "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.Fallback.config" + "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" ], "sources": { "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, diff --git a/PocketSharp.Tests/MiscTests.cs b/PocketSharp.Tests/MiscTests.cs index 60582e7..a0f822c 100644 --- a/PocketSharp.Tests/MiscTests.cs +++ b/PocketSharp.Tests/MiscTests.cs @@ -1,4 +1,4 @@ -using PocketSharp.Models; +using PocketSharp.Models; using System.Collections.Generic; using System.Threading.Tasks; using Xunit; @@ -10,8 +10,7 @@ namespace PocketSharp.Tests { private int Incrementor = 0; - public MiscTests() - : base() + public MiscTests() : base() { client.PreRequest = method => Incrementor++; } diff --git a/PocketSharp.Tests/TrendingTests.cs b/PocketSharp.Tests/TrendingTests.cs new file mode 100644 index 0000000..85b3cb7 --- /dev/null +++ b/PocketSharp.Tests/TrendingTests.cs @@ -0,0 +1,29 @@ +using PocketSharp.Models; +using System.Collections.Generic; +using System.Threading.Tasks; +using Xunit; + +namespace PocketSharp.Tests +{ + public class TrendingTests : TestsBase + { + [Fact] + public async Task AreTrendingArticlesReturned() + { + string guid = await client.GetGuid(); + var articles = await client.GetTrendingArticles(guid); + + Assert.NotEmpty(articles); + } + + + [Fact] + public async Task AreTrendingTopicsReturned() + { + string guid = await client.GetGuid(); + var topics = await client.GetTrendingTopics(guid); + + Assert.NotEmpty(topics); + } + } +} diff --git a/PocketSharp/Components/Trending.cs b/PocketSharp/Components/Trending.cs new file mode 100644 index 0000000..027a619 --- /dev/null +++ b/PocketSharp/Components/Trending.cs @@ -0,0 +1,47 @@ +using PocketSharp.Models; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace PocketSharp +{ + /// + /// PocketClient + /// + public partial class PocketClient + { + /// + /// Statistics from the user account. + /// + /// The cancellation token. + /// + /// + public async Task> GetTrendingArticles(string guid, string languageCode = "en", int count = 20, CancellationToken cancellationToken = default(CancellationToken)) + { + return (await Request("getGlobalRecs", cancellationToken, new Dictionary() + { + { "guid", guid }, + { "locale_lang", languageCode }, + { "count", count.ToString() }, + { "version", "2" } + }, false)).Items ?? new List(); + } + + + /// + /// Statistics from the user account. + /// + /// The cancellation token. + /// + /// + public async Task> GetTrendingTopics(string guid, string languageCode = "en", CancellationToken cancellationToken = default(CancellationToken)) + { + return (await Request("getTrendingTopics", cancellationToken, new Dictionary() + { + { "guid", guid }, + { "locale_lang", languageCode }, + { "version", "2" } + }, false)).Items ?? new List(); + } + } +} diff --git a/PocketSharp/IPocketClient.cs b/PocketSharp/IPocketClient.cs index feb0b61..1aeec0a 100644 --- a/PocketSharp/IPocketClient.cs +++ b/PocketSharp/IPocketClient.cs @@ -465,6 +465,10 @@ namespace PocketSharp Task GetUsageLimits(CancellationToken cancellationToken = default(CancellationToken)); #endregion + Task> GetTrendingArticles(string guid, string languageCode = "en", int count = 20, CancellationToken cancellationToken = default(CancellationToken)); + + Task> GetTrendingTopics(string guid, string languageCode = "en", CancellationToken cancellationToken = default(CancellationToken)); + /// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// diff --git a/PocketSharp/Models/Parameters/Parameters.cs b/PocketSharp/Models/Parameters/Parameters.cs index a8b11b1..c03d547 100644 --- a/PocketSharp/Models/Parameters/Parameters.cs +++ b/PocketSharp/Models/Parameters/Parameters.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Reflection; using System.Runtime.Serialization; @@ -71,7 +71,9 @@ namespace PocketSharp.Models parameterDict.Add(name, value.ToString()); } + parameterDict.Add("version", "2"); + return parameterDict; } } -} \ No newline at end of file +} diff --git a/PocketSharp/Models/PocketTopic.cs b/PocketSharp/Models/PocketTopic.cs new file mode 100644 index 0000000..1c55413 --- /dev/null +++ b/PocketSharp/Models/PocketTopic.cs @@ -0,0 +1,39 @@ +using Newtonsoft.Json; +using System; + +namespace PocketSharp.Models +{ + /// + /// Topic + /// + [JsonObject] + public class PocketTopic + { + /// + /// Gets or sets the category. + /// + /// + /// The topic category. + /// + [JsonProperty("category")] + public string Category { get; set; } + + /// + /// Gets or sets the name. + /// + /// + /// The name of the topic. + /// + [JsonProperty("name")] + public string Name { get; set; } + + /// + /// Gets or sets the URI. + /// + /// + /// Link to the topic listing on Pocket. + /// + [JsonProperty("url")] + public Uri Uri { get; set; } + } +} diff --git a/PocketSharp/Models/Response/Topics.cs b/PocketSharp/Models/Response/Topics.cs new file mode 100644 index 0000000..bb1fa02 --- /dev/null +++ b/PocketSharp/Models/Response/Topics.cs @@ -0,0 +1,22 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; + +namespace PocketSharp.Models +{ + /// + /// Topics Response + /// + [JsonObject] + internal class TopicsResponse : ResponseBase + { + /// + /// Gets the topics. + /// + /// + /// The topics. + /// + [JsonProperty("topics")] + public IEnumerable Items { get; set; } + } +}