diff --git a/Octokit/Clients/AuthorizationsClient.cs b/Octokit/Clients/AuthorizationsClient.cs index 614df00e..dad1bd8b 100644 --- a/Octokit/Clients/AuthorizationsClient.cs +++ b/Octokit/Clients/AuthorizationsClient.cs @@ -142,8 +142,7 @@ namespace Octokit }; var endpoint = ApiUrls.Authorizations(); - - return ApiConnection.Post(endpoint, requestData, twoFactorAuthenticationCode); + return ApiConnection.Post(endpoint, requestData, null, null, twoFactorAuthenticationCode); } /// diff --git a/Octokit/Http/ApiConnection.cs b/Octokit/Http/ApiConnection.cs index 51113271..b97b1afe 100644 --- a/Octokit/Http/ApiConnection.cs +++ b/Octokit/Http/ApiConnection.cs @@ -186,6 +186,32 @@ namespace Octokit return response.Body; } + /// + /// Creates a new API resource in the list at the specified URI. + /// + /// The API resource's type. + /// URI of the API resource to get + /// Object that describes the new API resource; this will be serialized and used as the request's body + /// Accept header to use for the API request + /// Content type of the API request + /// Two Factor Authentication Code + /// The created API resource. + /// Thrown when an API error occurs. + public async Task Post(Uri uri, object data, string accepts, string contentType, string twoFactorAuthenticationCode) + { + Ensure.ArgumentNotNull(uri, "uri"); + Ensure.ArgumentNotNull(data, "data"); + Ensure.ArgumentNotNull(twoFactorAuthenticationCode, "twoFactorAuthenticationCode"); + + var response = await Connection.Post( + uri, + data, + accepts, + contentType).ConfigureAwait(false); + return response.Body; + } + + public async Task Post(Uri uri, object data, string accepts, string contentType, TimeSpan timeout) { Ensure.ArgumentNotNull(uri, "uri"); diff --git a/Octokit/Http/Connection.cs b/Octokit/Http/Connection.cs index 4fcb69c2..7d2f3e93 100644 --- a/Octokit/Http/Connection.cs +++ b/Octokit/Http/Connection.cs @@ -192,6 +192,27 @@ namespace Octokit return SendData(uri, HttpMethod.Post, body, accepts, contentType, CancellationToken.None); } + /// + /// Performs an asynchronous HTTP POST request. + /// Attempts to map the response body to an object of type + /// + /// The type to map the response to + /// URI endpoint to send request to + /// The object to serialize as the body of the request + /// Specifies accepted response media types. + /// Specifies the media type of the request body + /// Two Factor Authentication Code + /// representing the received HTTP response + public Task> Post(Uri uri, object body, string accepts, string contentType, string twoFactorAuthenticationCode) + { + Ensure.ArgumentNotNull(uri, "uri"); + Ensure.ArgumentNotNull(body, "body"); + Ensure.ArgumentNotNullOrEmptyString(twoFactorAuthenticationCode, "twoFactorAuthenticationCode"); + + return SendData(uri, HttpMethod.Post, body, accepts, contentType, CancellationToken.None, twoFactorAuthenticationCode); + + } + public Task> Post(Uri uri, object body, string accepts, string contentType, TimeSpan timeout) { Ensure.ArgumentNotNull(uri, "uri"); diff --git a/Octokit/Http/IApiConnection.cs b/Octokit/Http/IApiConnection.cs index 5bf11f8b..9c6fee79 100644 --- a/Octokit/Http/IApiConnection.cs +++ b/Octokit/Http/IApiConnection.cs @@ -114,6 +114,19 @@ namespace Octokit /// Thrown when an API error occurs. Task Post(Uri uri, object data, string accepts, string contentType); + /// + /// Creates a new API resource in the list at the specified URI. + /// + /// The API resource's type. + /// URI of the API resource to get + /// Object that describes the new API resource; this will be serialized and used as the request's body + /// Accept header to use for the API request + /// Content type of the API request + /// Two Factor Authentication Code + /// The created API resource. + /// Thrown when an API error occurs. + Task Post(Uri uri, object data, string accepts, string contentType, string twoFactorAuthenticationCode); + /// /// Creates a new API resource in the list at the specified URI. /// diff --git a/Octokit/Http/IConnection.cs b/Octokit/Http/IConnection.cs index 37a6c004..afc5b938 100644 --- a/Octokit/Http/IConnection.cs +++ b/Octokit/Http/IConnection.cs @@ -85,6 +85,19 @@ namespace Octokit /// representing the received HTTP response Task> Post(Uri uri, object body, string accepts, string contentType); + /// + /// Performs an asynchronous HTTP POST request. + /// Attempts to map the response body to an object of type + /// + /// The type to map the response to + /// URI endpoint to send request to + /// The object to serialize as the body of the request + /// Specifies accepted response media types. + /// Specifies the media type of the request body + /// Two Factor Authentication Code + /// representing the received HTTP response + Task> Post(Uri uri, object body, string accepts, string contentType, string twoFactorAuthenticationCode); + /// /// Performs an asynchronous HTTP POST request. /// Attempts to map the response body to an object of type