docs for auth + categories

This commit is contained in:
2014-11-26 21:37:24 +01:00
parent a890c1ee0c
commit 421134f975
2 changed files with 62 additions and 7 deletions
+38 -4
View File
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using FeedlySharp.Extensions;
using FeedlySharp.Models;
@@ -13,6 +11,13 @@ namespace FeedlySharp
{
public partial class FeedlyClient
{
/// <summary>
/// Creates the authentication URI to redirect the user to.
/// </summary>
/// <remarks>auth-endpoint (https://developer.feedly.com/v3/auth/#authenticating-a-user-and-obtaining-a-code)</remarks>
/// <param name="scope">The scope.</param>
/// <param name="state">The state which is passed and returned when finished.</param>
/// <returns></returns>
public string GetAuthenticationUri(string scope = "subscriptions", string state = default(String))
{
return String.Format("{0}/v3/auth/auth?redirect_uri={1}&client_id={2}&scope={3}&state={4}&response_type=code",
@@ -24,13 +29,21 @@ namespace FeedlySharp
);
}
/// <summary>
/// Parses the authentication response URI and creates the response object.
/// </summary>
/// <param name="uri">The URI where the user has been redirected to after authentication.</param>
/// <returns></returns>
public AuthenticationResponse ParseAuthenticationResponseUri(string uri)
{
return ParseAuthenticationResponseUri(new Uri(uri, UriKind.Absolute));
}
/// <summary>
/// Parses the authentication response URI and creates the response object.
/// </summary>
/// <param name="uri">The URI where the user has been redirected to after authentication.</param>
/// <returns></returns>
public AuthenticationResponse ParseAuthenticationResponseUri(Uri uri)
{
Dictionary<string, string> queryParams = uri.ParseQueryString();
@@ -46,6 +59,13 @@ namespace FeedlySharp
}
/// <summary>
/// Request to get the access token.
/// </summary>
/// <remarks>auth-endpoint (https://developer.feedly.com/v3/auth/#exchanging-a-code-for-a-refresh-token-and-an-access-token)</remarks>
/// <param name="authenticationCode">The authentication code.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
public async Task<AccessTokenResponse> RequestAccessToken(string authenticationCode, CancellationToken cancellationToken = default(CancellationToken))
{
return await Client.Request<AccessTokenResponse>(HttpMethod.Post, "v3/auth/token", new Dictionary<string, string>()
@@ -59,6 +79,13 @@ namespace FeedlySharp
}
/// <summary>
/// Request to get a new refresh token and update authentication.
/// </summary>
/// <remarks>auth-endpoint (https://developer.feedly.com/v3/auth/#using-a-refresh-token)</remarks>
/// <param name="refreshToken">The current refresh token.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
public async Task<AccessTokenResponse> RequestRefreshToken(string refreshToken, CancellationToken cancellationToken = default(CancellationToken))
{
return await Client.Request<AccessTokenResponse>(HttpMethod.Post, "v3/auth/token", new Dictionary<string, string>()
@@ -71,6 +98,13 @@ namespace FeedlySharp
}
/// <summary>
/// Revokes the current refresh token and logs out.
/// </summary>
/// <remarks>auth-endpoint (https://developer.feedly.com/v3/auth/#revoking-a-refresh-token)</remarks>
/// <param name="refreshToken">The refresh token.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
public async Task RevokeRefreshToken(string refreshToken, CancellationToken cancellationToken = default(CancellationToken))
{
await Client.Request<object>(HttpMethod.Post, "v3/auth/token", new Dictionary<string, string>()
+24 -3
View File
@@ -1,7 +1,6 @@
using FeedlySharp.Models;
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
@@ -10,18 +9,40 @@ namespace FeedlySharp
{
public partial class FeedlyClient
{
/// <summary>
/// Returns all categories created by the user.
/// Authentication required.
/// </summary>
/// <remarks>categories-endpoint (https://developer.feedly.com/v3/categories/#get-the-list-of-all-categories)</remarks>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
public async Task<List<FeedlyCategory>> GetCategories(CancellationToken cancellationToken = default(CancellationToken))
{
return await Client.Request<List<FeedlyCategory>>(HttpMethod.Get, "v3/categories", null, false, true, cancellationToken);
}
/// <summary>
/// Renames a user category.
/// Authentication required.
/// </summary>
/// <remarks>categories-endpoint (https://developer.feedly.com/v3/categories/#change-the-label-of-an-existing-category)</remarks>
/// <param name="id">The category id.</param>
/// <param name="label">The new label.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
public async Task RenameCategory(string id, string label, CancellationToken cancellationToken = default(CancellationToken))
{
await Client.Request<FeedlyUser>(HttpMethod.Post, String.Format("v3/categories/{0}", ValueToResource("category", id)), new { label = label }, true, true, cancellationToken);
}
/// <summary>
/// Deletes a user category.
/// Authentication required.
/// </summary>
/// <remarks>categories-endpoint (https://developer.feedly.com/v3/categories/#delete-a-category)</remarks>
/// <param name="id">The category id.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
public async Task DeleteCategory(string id, CancellationToken cancellationToken = default(CancellationToken))
{
await Client.Request<FeedlyUser>(HttpMethod.Delete, String.Format("v3/categories/{0}", ValueToResource("category", id)), null, false, true, cancellationToken);