From 9faaf533046a0cfec60facffd4478cdd5d2d3c13 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Sun, 15 Mar 2015 09:44:24 +1000 Subject: [PATCH] Add methods to interface :no_mouth: and observable client --- .../IObservableAuthorizationsClient.cs | 46 ++++++++++++ .../Clients/ObservableAuthorizationsClient.cs | 74 +++++++++++++++++++ Octokit/Clients/AuthorizationsClient.cs | 2 +- Octokit/Clients/IAuthorizationsClient.cs | 46 ++++++++++++ 4 files changed, 167 insertions(+), 1 deletion(-) diff --git a/Octokit.Reactive/Clients/IObservableAuthorizationsClient.cs b/Octokit.Reactive/Clients/IObservableAuthorizationsClient.cs index 4c6894a0..c62e47f7 100644 --- a/Octokit.Reactive/Clients/IObservableAuthorizationsClient.cs +++ b/Octokit.Reactive/Clients/IObservableAuthorizationsClient.cs @@ -77,6 +77,52 @@ namespace Octokit.Reactive NewAuthorization newAuthorization, string twoFactorAuthenticationCode); + /// + /// + /// + /// This method requires authentication. + /// See the API documentation for more information. + /// + /// Client ID of the OAuth application for the token + /// The OAuth token to check + /// The valid . + IObservable CheckApplicationAuthentication(string clientId, string accessToken); + + /// + /// Resets a valid OAuth token for an OAuth application without end user involvment. + /// + /// + /// This method requires authentication. + /// See the API documentation for more information. + /// + /// ClientID of the OAuth application for the token + /// The OAuth token to reset + /// The valid with a new OAuth token + IObservable ResetApplicationAuthentication(string clientId, string accessToken); + + /// + /// Revokes a single OAuth token for an OAuth application. + /// + /// + /// This method requires authentication. + /// See the API documentation for more information. + /// + /// ClientID of the OAuth application for the token + /// The OAuth token to revoke + /// + IObservable RevokeApplicationAuthentication(string clientId, string accessToken); + + /// + /// Revokes every OAuth token for an OAuth application. + /// + /// + /// This method requires authentication. + /// See the API documentation for more information. + /// + /// ClientID of the OAuth application for the token + /// + IObservable RevokeAllApplicationAuthentications(string clientId); + /// /// Update the specified by the id. /// diff --git a/Octokit.Reactive/Clients/ObservableAuthorizationsClient.cs b/Octokit.Reactive/Clients/ObservableAuthorizationsClient.cs index 88a8cc04..6485729b 100644 --- a/Octokit.Reactive/Clients/ObservableAuthorizationsClient.cs +++ b/Octokit.Reactive/Clients/ObservableAuthorizationsClient.cs @@ -112,6 +112,80 @@ namespace Octokit.Reactive .ToObservable(); } + + /// + /// + /// + /// This method requires authentication. + /// See the API documentation for more information. + /// + /// Client ID of the OAuth application for the token + /// The OAuth token to check + /// The valid . + public IObservable CheckApplicationAuthentication(string clientId, string accessToken) + { + Ensure.ArgumentNotNullOrEmptyString("clientId", clientId); + Ensure.ArgumentNotNullOrEmptyString("accessToken", accessToken); + + return _client.CheckApplicationAuthentication(clientId, accessToken) + .ToObservable(); + } + + /// + /// Resets a valid OAuth token for an OAuth application without end user involvment. + /// + /// + /// This method requires authentication. + /// See the API documentation for more information. + /// + /// ClientID of the OAuth application for the token + /// The OAuth token to reset + /// The valid with a new OAuth token + public IObservable ResetApplicationAuthentication(string clientId, string accessToken) + { + Ensure.ArgumentNotNullOrEmptyString("clientId", clientId); + Ensure.ArgumentNotNullOrEmptyString("accessToken", accessToken); + + return _client.ResetApplicationAuthentication(clientId, accessToken) + .ToObservable(); + } + + /// + /// Revokes a single OAuth token for an OAuth application. + /// + /// + /// This method requires authentication. + /// See the API documentation for more information. + /// + /// ClientID of the OAuth application for the token + /// The OAuth token to revoke + /// + public IObservable RevokeApplicationAuthentication(string clientId, string accessToken) + { + Ensure.ArgumentNotNullOrEmptyString("clientId", clientId); + Ensure.ArgumentNotNullOrEmptyString("accessToken", accessToken); + + return _client.RevokeApplicationAuthentication(clientId, accessToken) + .ToObservable(); + } + + /// + /// Revokes every OAuth token for an OAuth application. + /// + /// + /// This method requires authentication. + /// See the API documentation for more information. + /// + /// ClientID of the OAuth application for the token + /// + public IObservable RevokeAllApplicationAuthentications(string clientId) + { + Ensure.ArgumentNotNullOrEmptyString("clientId", clientId); + + return _client.RevokeAllApplicationAuthentications(clientId) + .ToObservable(); + } + /// /// Update the specified by the id. /// diff --git a/Octokit/Clients/AuthorizationsClient.cs b/Octokit/Clients/AuthorizationsClient.cs index 1eea4c7b..b98b7fde 100644 --- a/Octokit/Clients/AuthorizationsClient.cs +++ b/Octokit/Clients/AuthorizationsClient.cs @@ -175,6 +175,7 @@ namespace Octokit throw new TwoFactorChallengeFailedException(e); } } + /// /// /// @@ -182,7 +183,6 @@ namespace Octokit /// See the API documentation for more information. /// /// Client ID of the OAuth application for the token - /// The client secret /// The OAuth token to check /// The valid . public async Task CheckApplicationAuthentication(string clientId, string accessToken) diff --git a/Octokit/Clients/IAuthorizationsClient.cs b/Octokit/Clients/IAuthorizationsClient.cs index a08b97e0..aeb25cd7 100644 --- a/Octokit/Clients/IAuthorizationsClient.cs +++ b/Octokit/Clients/IAuthorizationsClient.cs @@ -99,6 +99,52 @@ namespace Octokit NewAuthorization newAuthorization, string twoFactorAuthenticationCode); + /// + /// + /// + /// This method requires authentication. + /// See the API documentation for more information. + /// + /// Client ID of the OAuth application for the token + /// The OAuth token to check + /// The valid . + Task CheckApplicationAuthentication(string clientId, string accessToken); + + /// + /// Resets a valid OAuth token for an OAuth application without end user involvment. + /// + /// + /// This method requires authentication. + /// See the API documentation for more information. + /// + /// ClientID of the OAuth application for the token + /// The OAuth token to reset + /// The valid with a new OAuth token + Task ResetApplicationAuthentication(string clientId, string accessToken); + + /// + /// Revokes a single OAuth token for an OAuth application. + /// + /// + /// This method requires authentication. + /// See the API documentation for more information. + /// + /// ClientID of the OAuth application for the token + /// The OAuth token to revoke + /// A for the request's execution. + Task RevokeApplicationAuthentication(string clientId, string accessToken); + + /// + /// Revokes every OAuth token for an OAuth application. + /// + /// + /// This method requires authentication. + /// See the API documentation for more information. + /// + /// ClientID of the OAuth application for the token + /// A for the request's execution. + Task RevokeAllApplicationAuthentications(string clientId); + /// /// Updates the specified . ///