Skip to content

Commit

Permalink
provide a Delete<T>() overload that takes a Uri and accept header, bu…
Browse files Browse the repository at this point in the history
…t no body (#1868)
  • Loading branch information
ryangribble authored Sep 8, 2018
1 parent d166a8c commit cee6635
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Octokit.Tests/Reactive/ObservableIssuesLabelsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ public void DeleteCorrectUrl()

client.RemoveFromIssue("fake", "repo", 42, "label");

connection.Received().Delete<IReadOnlyList<Label>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/labels/label"), "application/vnd.github.symmetra-preview+json");
connection.Received().Delete<IReadOnlyList<Label>>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/42/labels/label"), Arg.Any<object>(), "application/vnd.github.symmetra-preview+json");
}

[Fact]
Expand All @@ -379,7 +379,7 @@ public void DeleteCorrectUrlWithRepositoryId()

client.RemoveFromIssue(1, 42, "label");

connection.Received().Delete<IReadOnlyList<Label>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/labels/label"), "application/vnd.github.symmetra-preview+json");
connection.Received().Delete<IReadOnlyList<Label>>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/issues/42/labels/label"), Arg.Any<object>(), "application/vnd.github.symmetra-preview+json");
}

[Fact]
Expand Down
18 changes: 18 additions & 0 deletions Octokit/Http/ApiConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,24 @@ public async Task<T> Delete<T>(Uri uri, object data)
return response.Body;
}

/// <summary>
/// Performs an asynchronous HTTP DELETE request.
/// Attempts to map the response body to an object of type <typeparamref name="T"/>
/// </summary>
/// <typeparam name="T">The API resource's type.</typeparam>
/// <param name="uri">URI endpoint to send request to</param>
/// <param name="accepts">Specifies accept response media type</param>
/// <returns>The returned <seealso cref="HttpStatusCode"/></returns>
public async Task<T> Delete<T>(Uri uri, string accepts)
{
Ensure.ArgumentNotNull(uri, nameof(uri));
Ensure.ArgumentNotNull(accepts, nameof(accepts));

var response = await Connection.Delete<T>(uri, null, accepts).ConfigureAwait(false);

return response.Body;
}

/// <summary>
/// Performs an asynchronous HTTP DELETE request.
/// Attempts to map the response body to an object of type <typeparamref name="T"/>
Expand Down
10 changes: 10 additions & 0 deletions Octokit/Http/IApiConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,16 @@ public interface IApiConnection
/// <param name="data">The object to serialize as the body of the request</param>
Task<T> Delete<T>(Uri uri, object data);

/// <summary>
/// Performs an asynchronous HTTP DELETE request.
/// Attempts to map the response body to an object of type <typeparamref name="T"/>
/// </summary>
/// <typeparam name="T">The API resource's type.</typeparam>
/// <param name="uri">URI endpoint to send request to</param>
/// <param name="accepts">Specifies accept response media type</param>
/// <returns>The returned <seealso cref="HttpStatusCode"/></returns>
Task<T> Delete<T>(Uri uri, string accepts);

/// <summary>
/// Performs an asynchronous HTTP DELETE request.
/// Attempts to map the response body to an object of type <typeparamref name="T"/>
Expand Down

0 comments on commit cee6635

Please sign in to comment.