entries endpoint

This commit is contained in:
2014-11-20 20:03:09 +01:00
parent 17b22d9ec1
commit 0e1c9db8fb
10 changed files with 153 additions and 15 deletions
+26
View File
@@ -0,0 +1,26 @@
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<FeedlyEntry> GetEntry(string id, CancellationToken cancellationToken = default(CancellationToken))
{
List<FeedlyEntry> entries = await Client.Request<List<FeedlyEntry>>(HttpMethod.Get, String.Format("v3/entries/{0}", WebUtility.UrlEncode(id)), null, false, true, cancellationToken);
return entries != null && entries.Any() ? entries[0] : null;
}
public async Task<List<FeedlyEntry>> GetEntries(string[] ids, CancellationToken cancellationToken = default(CancellationToken))
{
return await Client.Request<List<FeedlyEntry>>(HttpMethod.Post, "v3/entries/.mget", ids, true, true, cancellationToken);
}
}
}
-13
View File
@@ -23,18 +23,5 @@ namespace FeedlySharp
ids = ids.Select(id => id.StartsWith("feed/") ? id : "feed/" + id).ToArray();
return await Client.Request<List<FeedlyFeed>>(HttpMethod.Post, "v3/feeds/.mget", ids, true, true, cancellationToken);
}
//public async Task<bool> AddOrUpdateTopic(string topic, Interest interest = Interest.Low, CancellationToken cancellationToken = default(CancellationToken))
//{
// if (interest == Interest.Unknown)
// {
// throw new ArgumentOutOfRangeException("Select low, medium or high for the interest.");
// }
// await Client.Request(HttpMethod.Post, "v3/topics", new { id = ValueToResource("topic", topic, false), interest = interest.ToString().ToLower() }, true, true, cancellationToken);
// return true;
//}
}
}
+6
View File
@@ -34,11 +34,17 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="Endpoints\Entries.cs" />
<Compile Include="Endpoints\Feeds.cs" />
<Compile Include="Endpoints\Subscriptions.cs" />
<Compile Include="Endpoints\Topics.cs" />
<Compile Include="Models\FeedlyEntry.cs" />
<Compile Include="Models\FeedlyFeed.cs" />
<Compile Include="Models\FeedlyImage.cs" />
<Compile Include="Models\FeedlyLink.cs" />
<Compile Include="Models\FeedlyOrigin.cs" />
<Compile Include="Models\FeedlySubscription.cs" />
<Compile Include="Models\FeedlyText.cs" />
<Compile Include="Models\FeedlyTopic.cs" />
<Compile Include="Endpoints\OPML.cs" />
<Compile Include="Extensions\JsonExtensions.cs" />
+54
View File
@@ -0,0 +1,54 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FeedlySharp.Models
{
public class FeedlyEntry
{
public string Id { get; set; }
public string Fingerprint { get; set; }
public string OriginId { get; set; }
public string Title { get; set; }
public string Author { get; set; }
[JsonProperty("published")]
public DateTime? PublishedDate { get; set; }
[JsonProperty("crawled")]
public DateTime? CrawledDate { get; set; }
[JsonProperty("updated")]
public DateTime? UpdateDate { get; set; }
[JsonProperty("unread")]
public bool IsUnread { get; set; }
public string[] Keywords { get; set; }
public List<FeedlyTag> Tags { get; set; }
public int Engagement { get; set; }
[JsonProperty("alternate")]
public List<FeedlyLink> AlternateLinks { get; set; }
[JsonProperty("canonical")]
public List<FeedlyLink> CanonicalLinks { get; set; }
public FeedlyText Summary { get; set; }
public FeedlyText Content { get; set; }
public FeedlyOrigin Origin { get; set; }
public List<FeedlyCategory> Categories { get; set; }
}
}
+17
View File
@@ -0,0 +1,17 @@
using Newtonsoft.Json;
using System;
namespace FeedlySharp.Models
{
public class FeedlyImage
{
[JsonProperty("url")]
public Uri Uri { get; set; }
public int? Width { get; set; }
public int? Height { get; set; }
public string ContentType { get; set; }
}
}
+14
View File
@@ -0,0 +1,14 @@
using Newtonsoft.Json;
using System;
namespace FeedlySharp.Models
{
public class FeedlyLink
{
[JsonProperty("href")]
public Uri Uri { get; set; }
[JsonProperty("type")]
public string ContentType { get; set; }
}
}
+17
View File
@@ -0,0 +1,17 @@
using Newtonsoft.Json;
using System;
namespace FeedlySharp.Models
{
public class FeedlyOrigin
{
[JsonProperty("streamId")]
public string Id { get; set; }
[JsonProperty("htmlUrl")]
public Uri Uri { get; set; }
[JsonProperty("title")]
public string Name { get; set; }
}
}
+1 -1
View File
@@ -11,6 +11,6 @@ namespace FeedlySharp.Models
public string Label { get; set; }
public bool IsGlobal { get; set; }
public bool IsGlobal { get { return Name.StartsWith("global."); } }
}
}
+17
View File
@@ -0,0 +1,17 @@
namespace FeedlySharp.Models
{
public class FeedlyText
{
public Direction Direction { get; set; }
public string Content { get; set; }
}
public enum Direction
{
Unknown,
Ltr,
Rtl
}
}
+1 -1
View File
@@ -18,7 +18,7 @@
6. ✔ Topics endpoint
7. ✔ OPML endpoint
8. Entries endpoint
9. Feeds endpoint
9. Feeds endpoint
10. Markers endpoint
11. Mixes endpoint
12. Search endpoint