add stream endpoint

This commit is contained in:
2014-11-25 21:06:19 +01:00
parent a65a0a5680
commit fdedbc64c9
7 changed files with 127 additions and 26 deletions
+3 -1
View File
@@ -1 +1,3 @@
... nohing to see here yet.
### 0.1.0 (2014-11-25)
* Basic implementation of all endpoints
+70 -4
View File
@@ -9,15 +9,81 @@ namespace FeedlySharp
{
public partial class FeedlyClient
{
public async Task GetStreamEntryIds(CancellationToken cancellationToken = default(CancellationToken))
public async Task<FeedlyStreamEntryIdsResponse> GetStreamEntryIds(
string id,
ContentType type,
int? count = null,
FeedSorting sorting = FeedSorting.Newest,
bool? unreadOnly = null,
DateTime? newerThan = null,
string continuation = null,
CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters["streamId"] = ValueToResource(type, id);
parameters["ranked"] = sorting.ToString().ToLower();
if (count.HasValue)
{
parameters["count"] = count.Value.ToString();
}
if (unreadOnly.HasValue)
{
parameters["unreadOnly"] = unreadOnly.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();
}
if (!String.IsNullOrEmpty(continuation))
{
parameters["continuation"] = continuation;
}
return await Client.Request<FeedlyStreamEntryIdsResponse>(HttpMethod.Get, "v3/streams/ids", parameters, false, (type == ContentType.Category || type == ContentType.Tag), cancellationToken);
}
public async Task GetStreamContent(CancellationToken cancellationToken = default(CancellationToken))
public async Task<FeedlyStreamEntriesResponse> GetStreamEntries(
string id,
ContentType type,
int? count = null,
FeedSorting sorting = FeedSorting.Newest,
bool? unreadOnly = null,
DateTime? newerThan = null,
string continuation = null,
CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters["streamId"] = ValueToResource(type, id);
parameters["ranked"] = sorting.ToString().ToLower();
if (count.HasValue)
{
parameters["count"] = count.Value.ToString();
}
if (unreadOnly.HasValue)
{
parameters["unreadOnly"] = unreadOnly.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();
}
if (!String.IsNullOrEmpty(continuation))
{
parameters["continuation"] = continuation;
}
return await Client.Request<FeedlyStreamEntriesResponse>(HttpMethod.Get, "v3/streams/contents", parameters, false, (type == ContentType.Category || type == ContentType.Tag), cancellationToken);
}
}
public enum FeedSorting
{
Newest,
Oldest
}
}
+23 -1
View File
@@ -56,10 +56,24 @@ namespace FeedlySharp
private string ValueToResource(string key, string value, bool encode = true)
{
string text = value.StartsWith("user/") ? value : String.Format("user/{0}/{1}/{2}", UserId, key, value);
string text;
if (key == "feed") text = value.StartsWith("feed/") ? value : "feed/" + value;
else text = value.StartsWith("user/") ? value : String.Format("user/{0}/{1}/{2}", UserId, key, value);
return encode ? WebUtility.UrlEncode(text) : text;
}
private string ValueToResource(ContentType type, string value, bool encode = true)
{
string key = type == ContentType.Feed ? "feed" : (type == ContentType.Tag ? "tag" : (type == ContentType.SystemCategory ? "systemcategory" : "category"));
if (key == "systemcategory")
{
return encode ? WebUtility.UrlEncode(value) : value;
}
return ValueToResource(key, value, encode);
}
public void Dispose()
{
@@ -72,4 +86,12 @@ namespace FeedlySharp
Production,
Sandbox
}
public enum ContentType
{
Feed,
Category,
SystemCategory,
Tag
}
}
+2
View File
@@ -51,6 +51,8 @@
<Compile Include="Models\FeedlyReadOperations.cs" />
<Compile Include="Models\FeedlySearchFeed.cs" />
<Compile Include="Models\FeedlySearchResponse.cs" />
<Compile Include="Models\FeedlyStreamEntriesResponse.cs" />
<Compile Include="Models\FeedlyStreamEntryIdsResponse.cs" />
<Compile Include="Models\FeedlySubscription.cs" />
<Compile Include="Models\FeedlyText.cs" />
<Compile Include="Models\FeedlyTopic.cs" />
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FeedlySharp.Models
{
public class FeedlyStreamEntriesResponse
{
public string Continuation { get; set; }
public List<FeedlyEntry> Items { get; set; }
}
}
@@ -0,0 +1,11 @@
using System.Collections.Generic;
namespace FeedlySharp.Models
{
public class FeedlyStreamEntryIdsResponse
{
public string Continuation { get; set; }
public List<string> Ids { get; set; }
}
}
+3 -20
View File
@@ -4,27 +4,10 @@
---
**This project is work in progress!**
## This project is work in progress! Status:
---
## Status
1. ✔ Authentication / OAuth
2. ✔ Categories endpoint
3. ✔ Profile endpoint
4. ✔ Preferences endpoint
5. ✔ Tags endpoint
6. ✔ Topics endpoint
7. ✔ OPML endpoint
8. ✔ Entries endpoint
9. ✔ Feeds endpoint
10. ✔ Markers endpoint
11. ✔ Mixes endpoint
12. Search endpoint
13. Streams endpoint
14. ✔ Subscriptions endpoint
15. Social endpoint (Dropbox, Evernote, Facebook, Microsoft, Twitter)
1. ✔ Add implementation for all endpoints
2. Write tests
## Supported platforms