search endpoint

This commit is contained in:
2014-11-24 20:29:48 +01:00
parent a6455c5c7b
commit a65a0a5680
6 changed files with 99 additions and 5 deletions
+59 -4
View File
@@ -9,15 +9,70 @@ namespace FeedlySharp
{
public partial class FeedlyClient
{
public async Task FindFeeds(CancellationToken cancellationToken = default(CancellationToken))
public async Task<List<FeedlySearchFeed>> FindFeeds(string searchQuery, int? count = null, string locale = null, CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters["query"] = searchQuery;
if (count.HasValue)
{
parameters["count"] = count.Value.ToString();
}
if (!String.IsNullOrEmpty(locale))
{
parameters["locale"] = locale;
}
return (await Client.Request<FindFeedsResponse>(HttpMethod.Get, "v3/search/feeds", parameters, false, true, cancellationToken)).List;
}
public async Task SearchFeeds(CancellationToken cancellationToken = default(CancellationToken))
public async Task<FeedlySearchResponse> FindEntries(
string contentId,
string searchQuery,
DateTime? newerThan = null,
string continuation = null,
string fields = null,
string embedded = null,
string engagement = null,
int? count = null,
string locale = null,
CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters["streamId"] = contentId;
parameters["query"] = searchQuery;
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;
}
if (!String.IsNullOrEmpty(fields))
{
parameters["fields"] = fields;
}
if (!String.IsNullOrEmpty(embedded))
{
parameters["embedded"] = embedded;
}
if (!String.IsNullOrEmpty(engagement))
{
parameters["engagement"] = engagement;
}
if (count.HasValue)
{
parameters["count"] = count.Value.ToString();
}
if (!String.IsNullOrEmpty(locale))
{
parameters["locale"] = locale;
}
return await Client.Request<FeedlySearchResponse>(HttpMethod.Get, "v3/search/contents", parameters, false, true, cancellationToken);
}
}
}
+2
View File
@@ -49,6 +49,8 @@
<Compile Include="Models\FeedlyLink.cs" />
<Compile Include="Models\FeedlyOrigin.cs" />
<Compile Include="Models\FeedlyReadOperations.cs" />
<Compile Include="Models\FeedlySearchFeed.cs" />
<Compile Include="Models\FeedlySearchResponse.cs" />
<Compile Include="Models\FeedlySubscription.cs" />
<Compile Include="Models\FeedlyText.cs" />
<Compile Include="Models\FeedlyTopic.cs" />
+1 -1
View File
@@ -9,7 +9,7 @@ namespace FeedlySharp.Models
{
public class FeedlyFeed
{
public string Id { get; set; }
public virtual string Id { get; set; }
[JsonProperty("title")]
public string Name { get; set; }
+11
View File
@@ -0,0 +1,11 @@
using Newtonsoft.Json;
using System;
namespace FeedlySharp.Models
{
public class FeedlySearchFeed : FeedlyFeed
{
[JsonProperty("feedId")]
public new string Id { get; set; }
}
}
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FeedlySharp.Models
{
public class FeedlySearchResponse
{
public string Continuation { get; set; }
public string Title { get; set; }
public string Id { get; set; }
public List<FeedlyEntry> Items { get; set; }
}
}
+7
View File
@@ -49,6 +49,13 @@ namespace FeedlySharp.Models
}
internal class FindFeedsResponse
{
[JsonProperty("results")]
public List<FeedlySearchFeed> List { get; set; }
}
public enum FeedlyUserAccountPlan
{
Standard,