From 349f123e9d6577237ad734f78ffcf66938e6adac Mon Sep 17 00:00:00 2001 From: Tobias Klika Date: Wed, 26 Nov 2014 22:56:52 +0100 Subject: [PATCH] finalize docs --- FeedlySharp/Endpoints/Profile.cs | 16 ++++++-- FeedlySharp/Endpoints/Search.cs | 33 ++++++++++++++++- FeedlySharp/Endpoints/Streams.cs | 26 +++++++++++++ FeedlySharp/Endpoints/Subscriptions.cs | 23 +++++++++++- FeedlySharp/Endpoints/Tags.cs | 51 +++++++++++++++++++++++--- FeedlySharp/Endpoints/Topics.cs | 39 +++++++++++++------- FeedlySharp/FeedlyClient.cs | 32 ++++++++++++---- README.md | 3 +- 8 files changed, 190 insertions(+), 33 deletions(-) diff --git a/FeedlySharp/Endpoints/Profile.cs b/FeedlySharp/Endpoints/Profile.cs index 27d3aa4..a85c247 100644 --- a/FeedlySharp/Endpoints/Profile.cs +++ b/FeedlySharp/Endpoints/Profile.cs @@ -1,7 +1,5 @@ using FeedlySharp.Models; -using System; using System.Collections.Generic; -using System.Net; using System.Net.Http; using System.Threading; using System.Threading.Tasks; @@ -10,12 +8,24 @@ namespace FeedlySharp { public partial class FeedlyClient { + /// + /// Get the profile of the user. + /// + /// profile-endpoint (https://developer.feedly.com/v3/profile/#get-the-profile-of-the-user) + /// The cancellation token. + /// public async Task GetProfile(CancellationToken cancellationToken = default(CancellationToken)) { return await Client.Request(HttpMethod.Get, "v3/profile", null, false, true, cancellationToken); } - + /// + /// Update the profile of the user. + /// + /// profile-endpoint (https://developer.feedly.com/v3/profile/#update-the-profile-of-the-user) + /// The update profile parameters, see https://developer.feedly.com/v3/profile/#update-the-profile-of-the-user + /// The cancellation token. + /// public async Task UpdateProfile(Dictionary parameters, CancellationToken cancellationToken = default(CancellationToken)) { return await Client.Request(HttpMethod.Post, "v3/profile", parameters, true, true, cancellationToken); diff --git a/FeedlySharp/Endpoints/Search.cs b/FeedlySharp/Endpoints/Search.cs index e2cbebc..ffec2c7 100644 --- a/FeedlySharp/Endpoints/Search.cs +++ b/FeedlySharp/Endpoints/Search.cs @@ -9,6 +9,15 @@ namespace FeedlySharp { public partial class FeedlyClient { + /// + /// Find feeds based on title, url or #topic. + /// + /// search-endpoint (https://developer.feedly.com/v3/search/#find-feeds-based-on-title-url-or-topic) + /// Query can be a feed url, a site title, a site url or a #topic. + /// Number of results. Default value is 20. + /// Hint the search engine to return feeds in that locale (e.g. “pt”, “fr_FR”). + /// The cancellation token. + /// public async Task> FindFeeds(string searchQuery, int? count = null, string locale = null, CancellationToken cancellationToken = default(CancellationToken)) { Dictionary parameters = new Dictionary(); @@ -26,6 +35,25 @@ namespace FeedlySharp } + /// + /// Search the content of a stream. + /// + /// search-endpoint (https://developer.feedly.com/v3/search/#search-the-content-of-a-stream) + /// + /// A feedId, a categoryId, a tagId or a system category ids. + /// If none is provided, the server will use the “global.all” category. + /// The special topic “topic/global.popular” can also be used to search the most popular 50,000 sources in feedly. + /// + /// See the http://feedly.uservoice.com/knowledgebase/articles/441699-power-search-tutorial for syntax. + /// Date from where to fetch. + /// A continuation id is used to page through the content. Pass the continuation from a search result to get the next set of results for this search. Note: this value is ignored for non-Pro users. + /// A comma-separated list of fields. By default, all fields are used for matching. Valid field names: all, title, author, keywords. Default is all. + /// Audio, video, doc or any limit results to also include this media type. “any” means the article must contain at least one embed. Default behavior is to not filter by embedded. + /// Medium or high limit results to articles that have the specified engagement. Default behavior is to not filter by engagement. + /// Number of entries to return. Default is 10. max is 20. Note: if the user isn’t pro, only 2 articles will be returned. + /// Used to filter by locale. Only used in topic/global.popular searches. + /// The cancellation token. + /// public async Task FindEntries( string contentId, string searchQuery, @@ -39,7 +67,10 @@ namespace FeedlySharp CancellationToken cancellationToken = default(CancellationToken)) { Dictionary parameters = new Dictionary(); - parameters["streamId"] = contentId; + if (!String.IsNullOrWhiteSpace(contentId)) + { + parameters["streamId"] = contentId; + } parameters["query"] = searchQuery; if (newerThan.HasValue) { diff --git a/FeedlySharp/Endpoints/Streams.cs b/FeedlySharp/Endpoints/Streams.cs index 03ddbd6..a6b2e35 100644 --- a/FeedlySharp/Endpoints/Streams.cs +++ b/FeedlySharp/Endpoints/Streams.cs @@ -9,6 +9,19 @@ namespace FeedlySharp { public partial class FeedlyClient { + /// + /// Get a list of entry ids for a specific stream. + /// + /// streams-endpoint (https://developer.feedly.com/v3/streams/#get-a-list-of-entry-ids-for-a-specific-stream) + /// A feedId, a categoryId, a tagId or a system category id. + /// The type of the . + /// Number of entry ids to return. Default is 20, max is 10000. + /// Newest or oldest. Default is newest. + /// if true, return unread entry ids only. + /// Date from where to search on. + /// A continuation id is used to page through the entry ids. + /// The cancellation token. + /// public async Task GetStreamEntryIds( string id, ContentType type, @@ -45,6 +58,19 @@ namespace FeedlySharp } + /// + /// Get a list of entries for a specific stream. + /// + /// streams-endpoint (https://developer.feedly.com/v3/streams/#get-the-content-of-a-stream) + /// A feedId, a categoryId, a tagId or a system category id. + /// The type of the . + /// Number of entry ids to return. Default is 20, max is 10000. + /// Newest or oldest. Default is newest. + /// if true, return unread entries only. + /// Date from where to search on. + /// A continuation id is used to page through the entries. + /// The cancellation token. + /// public async Task GetStreamEntries( string id, ContentType type, diff --git a/FeedlySharp/Endpoints/Subscriptions.cs b/FeedlySharp/Endpoints/Subscriptions.cs index 45171c2..993df32 100644 --- a/FeedlySharp/Endpoints/Subscriptions.cs +++ b/FeedlySharp/Endpoints/Subscriptions.cs @@ -11,12 +11,26 @@ namespace FeedlySharp { public partial class FeedlyClient { + /// + /// Get the users subscriptions. + /// + /// subscriptions-endpoint (https://developer.feedly.com/v3/subscriptions/#get-the-users-subscriptions) + /// The cancellation token. + /// public async Task> GetSubscriptions(CancellationToken cancellationToken = default(CancellationToken)) { return await Client.Request>(HttpMethod.Get, "v3/subscriptions", null, false, true, cancellationToken); } - + /// + /// Adds or updates a subscription. + /// + /// subscriptions-endpoint (https://developer.feedly.com/v3/subscriptions/#subscribe-to-a-feed) + /// The id of the subscription/feed. + /// The categories where the feed to assign to. + /// The optional title for the feed. + /// The cancellation token. + /// public async Task AddOrUpdateSubscription(string id, List categories = null, string optionalTitle = null, CancellationToken cancellationToken = default(CancellationToken)) { dynamic parameters = new { id = (id.StartsWith("feed/") ? id : "feed/" + id) }; @@ -34,7 +48,12 @@ namespace FeedlySharp return true; } - + /// + /// Unsubscribe from a feed. + /// + /// The id of the subscription/feed. + /// The cancellation token. + /// public async Task RemoveSubscription(string id, CancellationToken cancellationToken = default(CancellationToken)) { id = id.StartsWith("feed/") ? id : "feed/" + id; diff --git a/FeedlySharp/Endpoints/Tags.cs b/FeedlySharp/Endpoints/Tags.cs index 6f97aef..1a2f0c8 100644 --- a/FeedlySharp/Endpoints/Tags.cs +++ b/FeedlySharp/Endpoints/Tags.cs @@ -11,12 +11,25 @@ namespace FeedlySharp { public partial class FeedlyClient { + /// + /// Get the list of tags created by the user. + /// + /// tags-endpoint (https://developer.feedly.com/v3/tags/#get-the-list-of-tags-created-by-the-user) + /// The cancellation token. + /// public async Task> GetTags(CancellationToken cancellationToken = default(CancellationToken)) { return await Client.Request>(HttpMethod.Get, "v3/tags", null, false, true, cancellationToken); } - + /// + /// Update tags for an existing entry. + /// + /// tags-endpoint (https://developer.feedly.com/v3/tags/#tag-an-existing-entry) + /// The entry id. + /// The new tags. + /// The cancellation token. + /// public async Task UpdateTags(string entryId, string[] tags, CancellationToken cancellationToken = default(CancellationToken)) { string tagsString = String.Join(",", tags.Select(x => ValueToResource("tag", x))); @@ -24,7 +37,14 @@ namespace FeedlySharp return true; } - + /// + /// Update tags for existing entries. + /// + /// tags-endpoint (https://developer.feedly.com/v3/tags/#tag-multiple-entries) + /// The entry ids. + /// The new tags. + /// The cancellation token. + /// public async Task UpdateTags(string[] entryIds, string[] tags, CancellationToken cancellationToken = default(CancellationToken)) { string tagsString = String.Join(",", tags.Select(x => ValueToResource("tag", x))); @@ -32,14 +52,28 @@ namespace FeedlySharp return true; } - + /// + /// Change a tag label. + /// + /// tags-endpoint (https://developer.feedly.com/v3/tags/#change-a-tag-label) + /// The old tag label. + /// The new tag label. + /// The cancellation token. + /// public async Task RenameTag(string oldTag, string newTag, CancellationToken cancellationToken = default(CancellationToken)) { await Client.Request(HttpMethod.Post, String.Format("v3/tags/{0}", ValueToResource("tag", oldTag)), new { label = newTag }, true, true, cancellationToken); return true; } - + /// + /// Untag multiple entries. + /// + /// tags-endpoint (https://developer.feedly.com/v3/tags/#untag-multiple-entries) + /// The entry ids. + /// The tags to remove from the entries. + /// The cancellation token. + /// public async Task RemoveTags(string[] entryIds, string[] tags, CancellationToken cancellationToken = default(CancellationToken)) { string tagsString = String.Join(",", tags.Select(x => ValueToResource("tag", x))); @@ -48,7 +82,14 @@ namespace FeedlySharp return true; } - + /// + /// Delete tags. + /// The tags will be removed from all the entries, and from the list of tags. Note: global tags (global.read, global.saved) cannot be passed to this call. + /// + /// tags-endpoint (https://developer.feedly.com/v3/tags/#delete-tags) + /// The tags to delete. + /// The cancellation token. + /// public async Task RemoveTags(string[] tags, CancellationToken cancellationToken = default(CancellationToken)) { string tagsString = String.Join(",", tags.Select(x => ValueToResource("tag", x))); diff --git a/FeedlySharp/Endpoints/Topics.cs b/FeedlySharp/Endpoints/Topics.cs index 57c3a17..0b9670e 100644 --- a/FeedlySharp/Endpoints/Topics.cs +++ b/FeedlySharp/Endpoints/Topics.cs @@ -1,42 +1,55 @@ 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 { + /// + /// Get the list of topics the user has added to their feedly. + /// + /// topics-endpoint (https://developer.feedly.com/v3/topics/#get-the-list-of-topics-the-user-has-added-to-their-feedly) + /// The cancellation token. + /// public async Task> GetTopics(CancellationToken cancellationToken = default(CancellationToken)) { return await Client.Request>(HttpMethod.Get, "v3/topics", null, false, true, cancellationToken); } - - public async Task AddOrUpdateTopic(string topic, Interest interest = Interest.Low, CancellationToken cancellationToken = default(CancellationToken)) + /// + /// Add or update a topic- + /// + /// topics-endpoint (https://developer.feedly.com/v3/topics/#add-a-topic-to-the-user-feedly-account) + /// The topic id. + /// The interest of the topic. + /// The cancellation token. + /// + /// Select low, medium or high for the interest. + public async Task AddOrUpdateTopic(string topicId, 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); + await Client.Request(HttpMethod.Post, "v3/topics", new { id = ValueToResource("topic", topicId, false), interest = interest.ToString().ToLower() }, true, true, cancellationToken); return true; } - - public async Task RemoveTopic(string topic, Interest interest = Interest.Low, CancellationToken cancellationToken = default(CancellationToken)) + /// + /// Remove a topic from a feedly account. + /// + /// topics-endpoint (https://developer.feedly.com/v3/topics/#remove-a-topic-from-a-feedly-account) + /// The topic id. + /// The cancellation token. + /// + public async Task RemoveTopic(string topicId, CancellationToken cancellationToken = default(CancellationToken)) { - if (interest == Interest.Unknown) - { - throw new ArgumentOutOfRangeException("Select low, medium or high for the interest."); - } - - await Client.Request(HttpMethod.Delete, String.Format("v3/topics/{0}", ValueToResource("topic", topic)), null, false, true, cancellationToken); + await Client.Request(HttpMethod.Delete, String.Format("v3/topics/{0}", ValueToResource("topic", topicId)), null, false, true, cancellationToken); return true; } } diff --git a/FeedlySharp/FeedlyClient.cs b/FeedlySharp/FeedlyClient.cs index 4f9bfe0..58a73c7 100644 --- a/FeedlySharp/FeedlyClient.cs +++ b/FeedlySharp/FeedlyClient.cs @@ -9,6 +9,9 @@ namespace FeedlySharp { public partial class FeedlyClient : IDisposable { + /// + /// The environment of feedly. + /// public readonly CloudEnvironment Environment; private readonly string ClientId; @@ -25,7 +28,14 @@ namespace FeedlySharp private FeedlyHttpClient Client { get; set; } - + /// + /// Initializes a new instance of the class. + /// + /// The environment of feedly. + /// The client id. + /// The client secret. + /// The redirect URI. + /// redirectUri;Authentication and token generation requires an URI to redirect to afterwards public FeedlyClient(CloudEnvironment environment, string clientId, string clientSecret, string redirectUri) { if (String.IsNullOrEmpty(redirectUri)) @@ -40,7 +50,11 @@ namespace FeedlySharp Client = new FeedlyHttpClient(new Uri(CloudUri, UriKind.Absolute)); } - + /// + /// Activates the client to call methods which need authentication. + /// + /// The access token. + /// The user id. public void Activate(string accessToken, string userId) { AccessToken = accessToken; @@ -48,6 +62,14 @@ namespace FeedlySharp Client.AccessToken = accessToken; } + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// + public void Dispose() + { + Client.Dispose(); + } + private string GetCloudUri(CloudEnvironment environment) { @@ -73,12 +95,6 @@ namespace FeedlySharp return ValueToResource(key, value, encode); } - - - public void Dispose() - { - Client.Dispose(); - } } public enum CloudEnvironment diff --git a/README.md b/README.md index 6425bcd..14004fe 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,8 @@ **This project is work in progress.
Status:** 1. ✔ Add implementation for all endpoints -2. Write tests +2. Write inline documentation +2. Unit tests ## Supported platforms