mixes endpoint

This commit is contained in:
2014-11-23 19:02:05 +01:00
parent 543a3310e7
commit 55c8605a6f
5 changed files with 70 additions and 4 deletions
+51
View File
@@ -0,0 +1,51 @@
using FeedlySharp.Models;
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.Linq;
namespace FeedlySharp
{
public partial class FeedlyClient
{
public async Task<List<FeedlyEntry>> GetMixes(
string contentId,
int? count = null,
bool unreadOnly = false,
int? limitHours = null,
DateTime? newerThan = null,
bool backfill = true,
CancellationToken cancellationToken = default(CancellationToken))
{
if (newerThan.HasValue && limitHours.HasValue)
{
throw new ArgumentException("It is not possible to use both newerThan and limitHours");
}
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters["streamId"] = contentId;
parameters["unreadOnly"] = unreadOnly.ToString();
parameters["backfill"] = backfill.ToString();
if (count.HasValue)
{
parameters["count"] = count.Value.ToString();
}
if (limitHours.HasValue)
{
parameters["hours"] = limitHours.Value.ToString();
}
if (newerThan.HasValue)
{
DateTime date = ((DateTime)newerThan.Value).ToUniversalTime();
DateTime epoc = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
parameters["newerThan"] = Math.Truncate(date.Subtract(epoc).TotalMilliseconds).ToString();
}
return (await Client.Request<MixesResponse>(HttpMethod.Get, "v3/mixes/contents", parameters, false, true, cancellationToken)).List;
}
}
}
+10 -2
View File
@@ -28,7 +28,7 @@ namespace FeedlySharp.Extensions
internal static string ToQueryString(this IDictionary<string, string> dict)
{
if (dict.Count == 0) return string.Empty;
if (dict.Count == 0) return String.Empty;
var buffer = new StringBuilder();
int count = 0;
@@ -36,9 +36,17 @@ namespace FeedlySharp.Extensions
foreach (var key in dict.Keys)
{
if (String.IsNullOrWhiteSpace(dict[key]))
{
continue;
}
string value = WebUtility.UrlEncode(dict[key]);
if (count == dict.Count - 1) end = true;
if (count == dict.Count - 1)
{
end = true;
}
if (end) buffer.AppendFormat("{0}={1}", key, value);
else buffer.AppendFormat("{0}={1}&", key, value);
+1
View File
@@ -37,6 +37,7 @@
<Compile Include="Endpoints\Entries.cs" />
<Compile Include="Endpoints\Feeds.cs" />
<Compile Include="Endpoints\Markers.cs" />
<Compile Include="Endpoints\Mixes.cs" />
<Compile Include="Endpoints\Subscriptions.cs" />
<Compile Include="Endpoints\Topics.cs" />
<Compile Include="Models\FeedlyCategoryUnreadCount.cs" />
+6
View File
@@ -42,6 +42,12 @@ namespace FeedlySharp.Models
public List<FeedlyCategoryUnreadCount> List { get; set; }
}
internal class MixesResponse
{
[JsonProperty("items")]
public List<FeedlyEntry> List { get; set; }
}
public enum FeedlyUserAccountPlan
{
+2 -2
View File
@@ -19,8 +19,8 @@
7. ✔ OPML endpoint
8. ✔ Entries endpoint
9. ✔ Feeds endpoint
10. Markers endpoint
11. Mixes endpoint
10. Markers endpoint
11. Mixes endpoint
12. Search endpoint
13. Streams endpoint
14. ✔ Subscriptions endpoint