mixes endpoint
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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" />
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user