diff --git a/Octokit/Http/ApiConnection.cs b/Octokit/Http/ApiConnection.cs index 1b4c1524..7276e3b8 100644 --- a/Octokit/Http/ApiConnection.cs +++ b/Octokit/Http/ApiConnection.cs @@ -236,6 +236,25 @@ namespace Octokit return response.BodyAsObject; } + /// + /// Updates the API resource at the specified URI. + /// + /// The API resource's type. + /// URI of the API resource to update + /// Object that describes the API resource; this will be serialized and used as the request's body + /// Accept header to use for the API request + /// The updated API resource. + /// Thrown when an API error occurs. + public async Task Patch(Uri uri, object data, string accepts) + { + Ensure.ArgumentNotNull(uri, "uri"); + Ensure.ArgumentNotNull(data, "data"); + + var response = await Connection.PatchAsync(uri, data, accepts).ConfigureAwait(false); + + return response.BodyAsObject; + } + /// /// Deletes the API object at the specified URI. /// diff --git a/Octokit/Http/Connection.cs b/Octokit/Http/Connection.cs index 9f0f3e7b..d7b79b79 100644 --- a/Octokit/Http/Connection.cs +++ b/Octokit/Http/Connection.cs @@ -177,6 +177,14 @@ namespace Octokit return SendData(uri, HttpVerb.Patch, body, null, null, CancellationToken.None); } + public Task> PatchAsync(Uri uri, object body, string accepts) + { + Ensure.ArgumentNotNull(uri, "uri"); + Ensure.ArgumentNotNull(body, "body"); + + return SendData(uri, HttpVerb.Patch, body, accepts, null, CancellationToken.None); + } + public Task> PostAsync(Uri uri, object body, string accepts, string contentType) { Ensure.ArgumentNotNull(uri, "uri"); diff --git a/Octokit/Http/IApiConnection.cs b/Octokit/Http/IApiConnection.cs index 353d6c25..3daa3157 100644 --- a/Octokit/Http/IApiConnection.cs +++ b/Octokit/Http/IApiConnection.cs @@ -139,6 +139,17 @@ namespace Octokit /// Thrown when an API error occurs. Task Patch(Uri uri, object data); + /// + /// Updates the API resource at the specified URI. + /// + /// The API resource's type. + /// URI of the API resource to update + /// Object that describes the API resource; this will be serialized and used as the request's body + /// Accept header to use for the API request + /// The updated API resource. + /// Thrown when an API error occurs. + Task Patch(Uri uri, object data, string accepts); + /// /// Deletes the API object at the specified URI. /// diff --git a/Octokit/Http/IConnection.cs b/Octokit/Http/IConnection.cs index f1f8f201..94ed1978 100644 --- a/Octokit/Http/IConnection.cs +++ b/Octokit/Http/IConnection.cs @@ -53,6 +53,17 @@ namespace Octokit /// representing the received HTTP response Task> PatchAsync(Uri uri, object body); + /// + /// Performs an asynchronous HTTP PATCH 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. + /// representing the received HTTP response + Task> PatchAsync(Uri uri, object body, string accepts); + /// /// Performs an asynchronous HTTP POST request. /// Attempts to map the response body to an object of type