mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-02 02:45:32 +00:00
Rename IResponse<T> to IApiResponse
This commit is contained in:
@@ -23,13 +23,13 @@ namespace Octokit.Reactive.Internal
|
||||
}
|
||||
|
||||
static IObservable<T> GetPages<T>(Uri uri, IDictionary<string, string> parameters,
|
||||
Func<Uri, IDictionary<string, string>, IObservable<IResponse<List<T>>>> getPageFunc)
|
||||
Func<Uri, IDictionary<string, string>, IObservable<IApiResponse<List<T>>>> getPageFunc)
|
||||
{
|
||||
return getPageFunc(uri, parameters).Expand(resp =>
|
||||
{
|
||||
var nextPageUrl = resp.ApiInfo.GetNextPageUrl();
|
||||
return nextPageUrl == null
|
||||
? Observable.Empty<IResponse<List<T>>>()
|
||||
? Observable.Empty<IApiResponse<List<T>>>()
|
||||
: Observable.Defer(() => getPageFunc(nextPageUrl, null));
|
||||
})
|
||||
.Where(resp => resp != null)
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Octokit.Tests.Clients
|
||||
[InlineData(HttpStatusCode.NotFound, false)]
|
||||
public async Task RequestsCorrectValueForStatusCode(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = status });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "repos/foo/bar/assignees/cody"),
|
||||
@@ -61,7 +61,7 @@ namespace Octokit.Tests.Clients
|
||||
[Fact]
|
||||
public async Task ThrowsExceptionForInvalidStatusCode()
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = HttpStatusCode.Conflict });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "repos/foo/bar/assignees/cody"),
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace Octokit.Tests.Clients
|
||||
[InlineData(HttpStatusCode.NotFound, false)]
|
||||
public async Task RequestsCorrectValueForStatusCode(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = status });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "user/following/alfhenrik"),
|
||||
@@ -128,7 +128,7 @@ namespace Octokit.Tests.Clients
|
||||
[Fact]
|
||||
public async Task ThrowsExceptionForInvalidStatusCode()
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = HttpStatusCode.Conflict });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "user/following/alfhenrik"),
|
||||
@@ -158,7 +158,7 @@ namespace Octokit.Tests.Clients
|
||||
[InlineData(HttpStatusCode.NotFound, false)]
|
||||
public async Task RequestsCorrectValueForStatusCode(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = status });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "users/alfhenrik/following/alfhenrik-test"),
|
||||
@@ -175,7 +175,7 @@ namespace Octokit.Tests.Clients
|
||||
[Fact]
|
||||
public async Task ThrowsExceptionForInvalidStatusCode()
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = HttpStatusCode.Conflict });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "users/alfhenrik/following/alfhenrik-test"),
|
||||
@@ -207,7 +207,7 @@ namespace Octokit.Tests.Clients
|
||||
[InlineData(HttpStatusCode.NoContent, true)]
|
||||
public async Task RequestsCorrectValueForStatusCode(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = status });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Put<object>(Arg.Is<Uri>(u => u.ToString() == "user/following/alfhenrik"),
|
||||
@@ -224,7 +224,7 @@ namespace Octokit.Tests.Clients
|
||||
[Fact]
|
||||
public async Task ThrowsExceptionForInvalidStatusCode()
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = HttpStatusCode.Conflict });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Put<object>(Arg.Is<Uri>(u => u.ToString() == "user/following/alfhenrik"),
|
||||
|
||||
@@ -196,7 +196,7 @@ public class GistsClientTests
|
||||
[InlineData(HttpStatusCode.NotFound, false)]
|
||||
public async Task RequestsCorrectValueForStatusCode(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = status });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "gists/1/star"),
|
||||
@@ -213,7 +213,7 @@ public class GistsClientTests
|
||||
[Fact]
|
||||
public async Task ThrowsExceptionForInvalidStatusCode()
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = HttpStatusCode.Conflict });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "gists/1/star"),
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Octokit.Tests.Clients
|
||||
{
|
||||
var links = new Dictionary<string, Uri>();
|
||||
var scopes = new List<string>();
|
||||
IResponse<string> response = new ApiResponse<string>
|
||||
IApiResponse<string> response = new ApiResponse<string>
|
||||
{
|
||||
ApiInfo = new ApiInfo(links, scopes, scopes, "", new RateLimit(new Dictionary<string, string>())),
|
||||
Body = "<strong>Test</strong>"
|
||||
@@ -44,7 +44,7 @@ namespace Octokit.Tests.Clients
|
||||
{
|
||||
var links = new Dictionary<string, Uri>();
|
||||
var scopes = new List<string>();
|
||||
IResponse<Dictionary<string, string>> response = new ApiResponse<Dictionary<string, string>>
|
||||
IApiResponse<Dictionary<string, string>> response = new ApiResponse<Dictionary<string, string>>
|
||||
{
|
||||
ApiInfo = new ApiInfo(links, scopes, scopes, "", new RateLimit(new Dictionary<string, string>())),
|
||||
BodyAsObject = new Dictionary<string, string>
|
||||
|
||||
@@ -55,7 +55,7 @@ public class OauthClientTests
|
||||
public async Task PostsWithCorrectBodyAndContentType()
|
||||
{
|
||||
var responseToken = new OauthToken();
|
||||
var response = Substitute.For<IResponse<OauthToken>>();
|
||||
var response = Substitute.For<IApiResponse<OauthToken>>();
|
||||
response.BodyAsObject.Returns(responseToken);
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.BaseAddress.Returns(new Uri("https://api.github.com/"));
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace Octokit.Tests.Clients
|
||||
[InlineData(HttpStatusCode.Found, false)]
|
||||
public async Task RequestsCorrectValueForStatusCode(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = status });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/members/username"),
|
||||
@@ -120,7 +120,7 @@ namespace Octokit.Tests.Clients
|
||||
[Fact]
|
||||
public async Task ThrowsExceptionForInvalidStatusCode()
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = HttpStatusCode.Conflict });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/members/username"),
|
||||
@@ -151,7 +151,7 @@ namespace Octokit.Tests.Clients
|
||||
[InlineData(HttpStatusCode.NotFound, false)]
|
||||
public async Task RequestsCorrectValueForStatusCode(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = status });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/public_members/username"),
|
||||
@@ -168,7 +168,7 @@ namespace Octokit.Tests.Clients
|
||||
[Fact]
|
||||
public async Task ThrowsExceptionForInvalidStatusCode()
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = HttpStatusCode.Conflict });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/public_members/username"),
|
||||
@@ -223,7 +223,7 @@ namespace Octokit.Tests.Clients
|
||||
[InlineData(HttpStatusCode.NoContent, true)]
|
||||
public async Task RequestsCorrectValueForStatusCode(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = status });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Put<object>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/public_members/username"),
|
||||
@@ -240,7 +240,7 @@ namespace Octokit.Tests.Clients
|
||||
[Fact]
|
||||
public async Task ThrowsExceptionForInvalidStatusCode()
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = HttpStatusCode.Conflict });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Put<object>(Arg.Is<Uri>(u => u.ToString() == "orgs/org/public_members/username"),
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace Octokit.Tests.Clients
|
||||
[InlineData(HttpStatusCode.NotFound, false)]
|
||||
public async Task RequestsCorrectValueForStatusCode(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = status });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/test/collaborators/user1"),
|
||||
@@ -72,7 +72,7 @@ namespace Octokit.Tests.Clients
|
||||
[Fact]
|
||||
public async Task ThrowsExceptionForInvalidStatusCode()
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = HttpStatusCode.Conflict });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "repos/foo/bar/assignees/cody"),
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace Octokit.Tests.Clients
|
||||
[InlineData(HttpStatusCode.NotFound, false)]
|
||||
public async Task ReturnsCorrectResultBasedOnStatus(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = status });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Arg.Is<Uri>(u => u.ToString() == "user/starred/yes/no"), null, null)
|
||||
@@ -85,7 +85,7 @@ namespace Octokit.Tests.Clients
|
||||
[InlineData(HttpStatusCode.OK, false)]
|
||||
public async Task ReturnsCorrectResultBasedOnStatus(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
var response = Task.Factory.StartNew<IApiResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = status });
|
||||
|
||||
var connection = Substitute.For<IConnection>();
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Octokit.Tests.Http
|
||||
public async Task MakesGetRequestForItem()
|
||||
{
|
||||
var getUri = new Uri("anything", UriKind.Relative);
|
||||
IResponse<object> response = new ApiResponse<object> {BodyAsObject = new object()};
|
||||
IApiResponse<object> response = new ApiResponse<object> {BodyAsObject = new object()};
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Args.Uri, null, null).Returns(Task.FromResult(response));
|
||||
var apiConnection = new ApiConnection(connection);
|
||||
@@ -35,7 +35,7 @@ namespace Octokit.Tests.Http
|
||||
{
|
||||
var getUri = new Uri("anything", UriKind.Relative);
|
||||
var accepts = "custom/accepts";
|
||||
IResponse<object> response = new ApiResponse<object> { BodyAsObject = new object() };
|
||||
IApiResponse<object> response = new ApiResponse<object> { BodyAsObject = new object() };
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<object>(Args.Uri, null, Args.String).Returns(Task.FromResult(response));
|
||||
var apiConnection = new ApiConnection(connection);
|
||||
@@ -62,7 +62,7 @@ namespace Octokit.Tests.Http
|
||||
public async Task MakesHtmlRequest()
|
||||
{
|
||||
var getUri = new Uri("anything", UriKind.Relative);
|
||||
IResponse<string> response = new ApiResponse<string> {Body = "<html />"};
|
||||
IApiResponse<string> response = new ApiResponse<string> {Body = "<html />"};
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.GetHtml(Args.Uri, null).Returns(Task.FromResult(response));
|
||||
var apiConnection = new ApiConnection(connection);
|
||||
@@ -89,7 +89,7 @@ namespace Octokit.Tests.Http
|
||||
var getAllUri = new Uri("anything", UriKind.Relative);
|
||||
var links = new Dictionary<string, Uri>();
|
||||
var scopes = new List<string>();
|
||||
IResponse<List<object>> response = new ApiResponse<List<object>>
|
||||
IApiResponse<List<object>> response = new ApiResponse<List<object>>
|
||||
{
|
||||
ApiInfo = new ApiInfo(links, scopes, scopes, "etag", new RateLimit(new Dictionary<string, string>())),
|
||||
BodyAsObject = new List<object> {new object(), new object()}
|
||||
@@ -129,7 +129,7 @@ namespace Octokit.Tests.Http
|
||||
{
|
||||
var patchUri = new Uri("anything", UriKind.Relative);
|
||||
var sentData = new object();
|
||||
IResponse<object> response = new ApiResponse<object> {BodyAsObject = new object()};
|
||||
IApiResponse<object> response = new ApiResponse<object> {BodyAsObject = new object()};
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Patch<object>(Args.Uri, Args.Object).Returns(Task.FromResult(response));
|
||||
var apiConnection = new ApiConnection(connection);
|
||||
@@ -146,7 +146,7 @@ namespace Octokit.Tests.Http
|
||||
var patchUri = new Uri("anything", UriKind.Relative);
|
||||
var sentData = new object();
|
||||
var accepts = "custom/accepts";
|
||||
IResponse<object> response = new ApiResponse<object> { BodyAsObject = new object() };
|
||||
IApiResponse<object> response = new ApiResponse<object> { BodyAsObject = new object() };
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Patch<object>(Args.Uri, Args.Object, Args.String).Returns(Task.FromResult(response));
|
||||
var apiConnection = new ApiConnection(connection);
|
||||
@@ -175,7 +175,7 @@ namespace Octokit.Tests.Http
|
||||
{
|
||||
var postUri = new Uri("anything", UriKind.Relative);
|
||||
var sentData = new object();
|
||||
IResponse<object> response = new ApiResponse<object> {BodyAsObject = new object()};
|
||||
IApiResponse<object> response = new ApiResponse<object> {BodyAsObject = new object()};
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Post<object>(Args.Uri, Args.Object, null, null).Returns(Task.FromResult(response));
|
||||
var apiConnection = new ApiConnection(connection);
|
||||
@@ -190,7 +190,7 @@ namespace Octokit.Tests.Http
|
||||
public async Task MakesUploadRequest()
|
||||
{
|
||||
var uploadUrl = new Uri("anything", UriKind.Relative);
|
||||
IResponse<string> response = new ApiResponse<string> {BodyAsObject = "the response"};
|
||||
IApiResponse<string> response = new ApiResponse<string> {BodyAsObject = "the response"};
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Post<string>(Args.Uri, Arg.Any<Stream>(), Args.String, Args.String)
|
||||
.Returns(Task.FromResult(response));
|
||||
@@ -229,7 +229,7 @@ namespace Octokit.Tests.Http
|
||||
{
|
||||
var putUri = new Uri("anything", UriKind.Relative);
|
||||
var sentData = new object();
|
||||
IResponse<object> response = new ApiResponse<object> { BodyAsObject = new object() };
|
||||
IApiResponse<object> response = new ApiResponse<object> { BodyAsObject = new object() };
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Put<object>(Args.Uri, Args.Object).Returns(Task.FromResult(response));
|
||||
var apiConnection = new ApiConnection(connection);
|
||||
@@ -245,7 +245,7 @@ namespace Octokit.Tests.Http
|
||||
{
|
||||
var putUri = new Uri("anything", UriKind.Relative);
|
||||
var sentData = new object();
|
||||
IResponse<object> response = new ApiResponse<object> { BodyAsObject = new object() };
|
||||
IApiResponse<object> response = new ApiResponse<object> { BodyAsObject = new object() };
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Put<object>(Args.Uri, Args.Object, "two-factor").Returns(Task.FromResult(response));
|
||||
var apiConnection = new ApiConnection(connection);
|
||||
@@ -312,7 +312,7 @@ namespace Octokit.Tests.Http
|
||||
var queuedOperationUrl = new Uri("anything", UriKind.Relative);
|
||||
|
||||
const HttpStatusCode statusCode = HttpStatusCode.OK;
|
||||
IResponse<object> response = new ApiResponse<object> { BodyAsObject = new object(), StatusCode = statusCode };
|
||||
IApiResponse<object> response = new ApiResponse<object> { BodyAsObject = new object(), StatusCode = statusCode };
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.GetResponse<object>(queuedOperationUrl,Args.CancellationToken).Returns(Task.FromResult(response));
|
||||
var apiConnection = new ApiConnection(connection);
|
||||
@@ -328,7 +328,7 @@ namespace Octokit.Tests.Http
|
||||
var queuedOperationUrl = new Uri("anything", UriKind.Relative);
|
||||
|
||||
const HttpStatusCode statusCode = HttpStatusCode.PartialContent;
|
||||
IResponse<object> response = new ApiResponse<object> { BodyAsObject = new object(), StatusCode = statusCode };
|
||||
IApiResponse<object> response = new ApiResponse<object> { BodyAsObject = new object(), StatusCode = statusCode };
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.GetResponse<object>(queuedOperationUrl, Args.CancellationToken).Returns(Task.FromResult(response));
|
||||
var apiConnection = new ApiConnection(connection);
|
||||
@@ -343,7 +343,7 @@ namespace Octokit.Tests.Http
|
||||
|
||||
var result = new object();
|
||||
const HttpStatusCode statusCode = HttpStatusCode.OK;
|
||||
IResponse<object> response = new ApiResponse<object> { BodyAsObject = result, StatusCode = statusCode };
|
||||
IApiResponse<object> response = new ApiResponse<object> { BodyAsObject = result, StatusCode = statusCode };
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.GetResponse<object>(queuedOperationUrl, Args.CancellationToken).Returns(Task.FromResult(response));
|
||||
var apiConnection = new ApiConnection(connection);
|
||||
@@ -358,8 +358,8 @@ namespace Octokit.Tests.Http
|
||||
var queuedOperationUrl = new Uri("anything", UriKind.Relative);
|
||||
|
||||
var result = new object();
|
||||
IResponse<object> firstResponse = new ApiResponse<object> { BodyAsObject = result, StatusCode = HttpStatusCode.Accepted };
|
||||
IResponse<object> completedResponse = new ApiResponse<object> { BodyAsObject = result, StatusCode = HttpStatusCode.OK };
|
||||
IApiResponse<object> firstResponse = new ApiResponse<object> { BodyAsObject = result, StatusCode = HttpStatusCode.Accepted };
|
||||
IApiResponse<object> completedResponse = new ApiResponse<object> { BodyAsObject = result, StatusCode = HttpStatusCode.OK };
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.GetResponse<object>(queuedOperationUrl, Args.CancellationToken)
|
||||
.Returns(x => Task.FromResult(firstResponse),
|
||||
@@ -378,7 +378,7 @@ namespace Octokit.Tests.Http
|
||||
var queuedOperationUrl = new Uri("anything", UriKind.Relative);
|
||||
|
||||
var result = new object();
|
||||
IResponse<object> accepted = new ApiResponse<object> { BodyAsObject = result, StatusCode = HttpStatusCode.Accepted };
|
||||
IApiResponse<object> accepted = new ApiResponse<object> { BodyAsObject = result, StatusCode = HttpStatusCode.Accepted };
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.GetResponse<object>(queuedOperationUrl, Args.CancellationToken).Returns(x => Task.FromResult(accepted));
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -140,14 +139,14 @@ namespace Octokit.Tests.Http
|
||||
public void DeserializesSingleObjectResponseIntoCollectionWithOneItem()
|
||||
{
|
||||
const string data = "{\"name\":\"Haack\"}";
|
||||
var response = new ApiResponse<List<SomeObject>>
|
||||
var httpResponse = new ApiResponse<List<SomeObject>>
|
||||
{
|
||||
Body = data,
|
||||
ContentType = "application/json"
|
||||
};
|
||||
var jsonPipeline = new JsonHttpPipeline();
|
||||
|
||||
jsonPipeline.DeserializeResponse(response);
|
||||
var response = jsonPipeline.DeserializeResponse<List<SomeObject>>(httpResponse);
|
||||
|
||||
Assert.Equal(1, response.BodyAsObject.Count);
|
||||
Assert.Equal("Haack", response.BodyAsObject.First().Name);
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Octokit.Tests.Models
|
||||
public async Task ReturnsTheNextPage()
|
||||
{
|
||||
var nextPageUrl = new Uri("https://example.com/page/2");
|
||||
var nextPageResponse = Task.Factory.StartNew<IResponse<List<object>>>(() =>
|
||||
var nextPageResponse = Task.Factory.StartNew<IApiResponse<List<object>>>(() =>
|
||||
new ApiResponse<List<object>> {BodyAsObject = new List<object> {new object(), new object()}});
|
||||
var links = new Dictionary<string, Uri> {{"next", nextPageUrl}};
|
||||
var scopes = new List<string>();
|
||||
|
||||
@@ -81,11 +81,11 @@ public class ObservableIssuesClientTests
|
||||
&& d["state"] == "open"
|
||||
&& d["sort"] == "created"
|
||||
&& d["filter"] == "assigned"), Arg.Any<string>())
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Issue>>>(() => firstPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Issue>>>(() => firstPageResponse));
|
||||
gitHubClient.Connection.Get<List<Issue>>(secondPageUrl, null, null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Issue>>>(() => secondPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Issue>>>(() => secondPageResponse));
|
||||
gitHubClient.Connection.Get<List<Issue>>(thirdPageUrl, null, null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Issue>>>(() => lastPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Issue>>>(() => lastPageResponse));
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
var results = await client.GetForRepository("fake", "repo").ToArray();
|
||||
@@ -130,7 +130,7 @@ public class ObservableIssuesClientTests
|
||||
{
|
||||
BodyAsObject = new List<Issue>
|
||||
{
|
||||
CreateIssue(7)
|
||||
CreateIssue(7),
|
||||
},
|
||||
ApiInfo = CreateApiInfo(new Dictionary<string, Uri>())
|
||||
};
|
||||
@@ -141,11 +141,11 @@ public class ObservableIssuesClientTests
|
||||
&& d["state"] == "open"
|
||||
&& d["sort"] == "created"
|
||||
&& d["filter"] == "assigned"), Arg.Any<string>())
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Issue>>>(() => firstPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Issue>>>(() => firstPageResponse));
|
||||
gitHubClient.Connection.Get<List<Issue>>(secondPageUrl, null, null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Issue>>>(() => secondPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Issue>>>(() => secondPageResponse));
|
||||
gitHubClient.Connection.Get<List<Issue>>(thirdPageUrl, null, null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Issue>>>(() => lastPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Issue>>>(() => lastPageResponse));
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
var results = await client.GetAllForOwnedAndMemberRepositories().ToArray();
|
||||
@@ -202,11 +202,11 @@ public class ObservableIssuesClientTests
|
||||
&& d["state"] == "open"
|
||||
&& d["sort"] == "created"
|
||||
&& d["filter"] == "assigned"), Arg.Any<string>())
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Issue>>>(() => firstPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Issue>>>(() => firstPageResponse));
|
||||
gitHubClient.Connection.Get<List<Issue>>(secondPageUrl, null, null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Issue>>>(() => secondPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Issue>>>(() => secondPageResponse));
|
||||
gitHubClient.Connection.Get<List<Issue>>(thirdPageUrl, null, null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Issue>>>(() => lastPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Issue>>>(() => lastPageResponse));
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
var results = await client.GetAllForOrganization("test").ToArray();
|
||||
@@ -263,11 +263,11 @@ public class ObservableIssuesClientTests
|
||||
&& d["state"] == "open"
|
||||
&& d["sort"] == "created"
|
||||
&& d["filter"] == "assigned"), Arg.Any<string>())
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Issue>>>(() => firstPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Issue>>>(() => firstPageResponse));
|
||||
gitHubClient.Connection.Get<List<Issue>>(secondPageUrl, null, null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Issue>>>(() => secondPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Issue>>>(() => secondPageResponse));
|
||||
gitHubClient.Connection.Get<List<Issue>>(thirdPageUrl, null, null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Issue>>>(() => lastPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Issue>>>(() => lastPageResponse));
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
var results = await client.GetAllForCurrent().ToArray();
|
||||
|
||||
@@ -77,11 +77,11 @@ namespace Octokit.Tests.Reactive
|
||||
};
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
gitHubClient.Connection.Get<List<Milestone>>(firstPageUrl, null, null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Milestone>>>(() => firstPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Milestone>>>(() => firstPageResponse));
|
||||
gitHubClient.Connection.Get<List<Milestone>>(secondPageUrl, null, null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Milestone>>>(() => secondPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Milestone>>>(() => secondPageResponse));
|
||||
gitHubClient.Connection.Get<List<Milestone>>(thirdPageUrl, null, null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Milestone>>>(() => lastPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Milestone>>>(() => lastPageResponse));
|
||||
var client = new ObservableMilestonesClient(gitHubClient);
|
||||
|
||||
var results = await client.GetForRepository("fake", "repo").ToArray();
|
||||
@@ -134,11 +134,11 @@ namespace Octokit.Tests.Reactive
|
||||
&& d["direction"] == "desc"
|
||||
&& d["state"] == "open"
|
||||
&& d["sort"] == "due_date"), Arg.Any<string>())
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Milestone>>>(() => firstPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Milestone>>>(() => firstPageResponse));
|
||||
gitHubClient.Connection.Get<List<Milestone>>(secondPageUrl, null, null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Milestone>>>(() => secondPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Milestone>>>(() => secondPageResponse));
|
||||
gitHubClient.Connection.Get<List<Milestone>>(thirdPageUrl, null, null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Milestone>>>(() => lastPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Milestone>>>(() => lastPageResponse));
|
||||
var client = new ObservableMilestonesClient(gitHubClient);
|
||||
|
||||
var results = await client.GetForRepository("fake", "repo", new MilestoneRequest { SortDirection = SortDirection.Descending }).ToArray();
|
||||
|
||||
@@ -58,11 +58,11 @@ namespace Octokit.Tests.Reactive
|
||||
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
gitHubClient.Connection.Get<List<PullRequestReviewComment>>(firstPageUrl, null, null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<PullRequestReviewComment>>>(() => firstPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => firstPageResponse));
|
||||
gitHubClient.Connection.Get<List<PullRequestReviewComment>>(secondPageUrl, null, null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<PullRequestReviewComment>>>(() => secondPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => secondPageResponse));
|
||||
gitHubClient.Connection.Get<List<PullRequestReviewComment>>(thirdPageUrl, null, null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<PullRequestReviewComment>>>(() => lastPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => lastPageResponse));
|
||||
|
||||
var client = new ObservablePullRequestReviewCommentsClient(gitHubClient);
|
||||
|
||||
@@ -136,11 +136,11 @@ namespace Octokit.Tests.Reactive
|
||||
&& d["direction"] == "desc"
|
||||
&& d["since"] == "2013-11-15T11:43:01Z"
|
||||
&& d["sort"] == "updated"), null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<PullRequestReviewComment>>>(() => firstPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => firstPageResponse));
|
||||
gitHubClient.Connection.Get<List<PullRequestReviewComment>>(secondPageUrl, null, null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<PullRequestReviewComment>>>(() => secondPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => secondPageResponse));
|
||||
gitHubClient.Connection.Get<List<PullRequestReviewComment>>(thirdPageUrl, null, null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<PullRequestReviewComment>>>(() => lastPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => lastPageResponse));
|
||||
|
||||
var client = new ObservablePullRequestReviewCommentsClient(gitHubClient);
|
||||
|
||||
@@ -207,11 +207,11 @@ namespace Octokit.Tests.Reactive
|
||||
Arg.Is<Dictionary<string, string>>(d => d.Count == 2
|
||||
&& d["direction"] == "asc"
|
||||
&& d["sort"] == "created"), null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<PullRequestReviewComment>>>(() => firstPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => firstPageResponse));
|
||||
gitHubClient.Connection.Get<List<PullRequestReviewComment>>(secondPageUrl, null, null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<PullRequestReviewComment>>>(() => secondPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => secondPageResponse));
|
||||
gitHubClient.Connection.Get<List<PullRequestReviewComment>>(thirdPageUrl, null, null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<PullRequestReviewComment>>>(() => lastPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequestReviewComment>>>(() => lastPageResponse));
|
||||
|
||||
var client = new ObservablePullRequestReviewCommentsClient(gitHubClient);
|
||||
|
||||
|
||||
@@ -77,11 +77,11 @@ namespace Octokit.Tests.Reactive
|
||||
};
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
gitHubClient.Connection.Get<List<PullRequest>>(firstPageUrl, null, null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<PullRequest>>>(() => firstPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => firstPageResponse));
|
||||
gitHubClient.Connection.Get<List<PullRequest>>(secondPageUrl, null, null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<PullRequest>>>(() => secondPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => secondPageResponse));
|
||||
gitHubClient.Connection.Get<List<PullRequest>>(thirdPageUrl, null, null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<PullRequest>>>(() => lastPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => lastPageResponse));
|
||||
var client = new ObservablePullRequestsClient(gitHubClient);
|
||||
|
||||
var results = client.GetForRepository("fake", "repo").ToArray().Wait();
|
||||
@@ -134,11 +134,11 @@ namespace Octokit.Tests.Reactive
|
||||
&& d["head"] == "user:ref-name"
|
||||
&& d["state"] == "open"
|
||||
&& d["base"] == "fake_base_branch"), Arg.Any<string>())
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<PullRequest>>>(() => firstPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => firstPageResponse));
|
||||
gitHubClient.Connection.Get<List<PullRequest>>(secondPageUrl, null, null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<PullRequest>>>(() => secondPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => secondPageResponse));
|
||||
gitHubClient.Connection.Get<List<PullRequest>>(thirdPageUrl, null, null)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<PullRequest>>>(() => lastPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<PullRequest>>>(() => lastPageResponse));
|
||||
var client = new ObservablePullRequestsClient(gitHubClient);
|
||||
|
||||
var results = client.GetForRepository("fake", "repo", new PullRequestRequest { Head = "user:ref-name", Base = "fake_base_branch" }).ToArray().Wait();
|
||||
@@ -281,7 +281,7 @@ namespace Octokit.Tests.Reactive
|
||||
var expectedUrl = string.Format("repos/fake/repo/pulls/42/commits");
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var connection = Substitute.For<IConnection>();
|
||||
IResponse<List<PullRequestCommit>> response = new ApiResponse<List<PullRequestCommit>>
|
||||
IApiResponse<List<PullRequestCommit>> response = new ApiResponse<List<PullRequestCommit>>
|
||||
{
|
||||
ApiInfo = new ApiInfo(
|
||||
new Dictionary<string, Uri>(),
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Octokit.Tests.Reactive
|
||||
public async Task IsALukeWarmObservable()
|
||||
{
|
||||
var repository = new Repository();
|
||||
var response = Task.Factory.StartNew<IResponse<Repository>>(() =>
|
||||
var response = Task.Factory.StartNew<IApiResponse<Repository>>(() =>
|
||||
new ApiResponse<Repository> { BodyAsObject = repository });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.Get<Repository>(Args.Uri, null, null).Returns(response);
|
||||
@@ -80,11 +80,11 @@ namespace Octokit.Tests.Reactive
|
||||
};
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
gitHubClient.Connection.GetResponse<List<Repository>>(firstPageUrl)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Repository>>>(() => firstPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Repository>>>(() => firstPageResponse));
|
||||
gitHubClient.Connection.GetResponse<List<Repository>>(secondPageUrl)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Repository>>>(() => secondPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Repository>>>(() => secondPageResponse));
|
||||
gitHubClient.Connection.GetResponse<List<Repository>>(thirdPageUrl)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Repository>>>(() => lastPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Repository>>>(() => lastPageResponse));
|
||||
var repositoriesClient = new ObservableRepositoriesClient(gitHubClient);
|
||||
|
||||
var results = await repositoriesClient.GetAllForCurrent().ToArray();
|
||||
@@ -143,13 +143,13 @@ namespace Octokit.Tests.Reactive
|
||||
};
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
gitHubClient.Connection.GetResponse<List<Repository>>(firstPageUrl)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Repository>>>(() => firstPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Repository>>>(() => firstPageResponse));
|
||||
gitHubClient.Connection.GetResponse<List<Repository>>(secondPageUrl)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Repository>>>(() => secondPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Repository>>>(() => secondPageResponse));
|
||||
gitHubClient.Connection.GetResponse<List<Repository>>(thirdPageUrl)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Repository>>>(() => thirdPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Repository>>>(() => thirdPageResponse));
|
||||
gitHubClient.Connection.GetResponse<List<Repository>>(fourthPageUrl)
|
||||
.Returns(Task.Factory.StartNew<IResponse<List<Repository>>>(() => lastPageResponse));
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Repository>>>(() => lastPageResponse));
|
||||
var repositoriesClient = new ObservableRepositoriesClient(gitHubClient);
|
||||
|
||||
var results = await repositoriesClient.GetAllForCurrent().Take(4).ToArray();
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Octokit
|
||||
/// <param name="connection">The connection to use</param>
|
||||
/// <param name="uri">URI endpoint to send request to</param>
|
||||
/// <returns><seealso cref="IResponse"/> representing the received HTTP response</returns>
|
||||
public static Task<IResponse<string>> GetHtml(this IConnection connection, Uri uri)
|
||||
public static Task<IApiResponse<string>> GetHtml(this IConnection connection, Uri uri)
|
||||
{
|
||||
Ensure.ArgumentNotNull(connection, "connection");
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
@@ -81,7 +81,7 @@ namespace Octokit
|
||||
/// <param name="uri">URI of the API resource to get</param>
|
||||
/// <returns>The API resource.</returns>
|
||||
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
|
||||
public static Task<IResponse<T>> GetResponse<T>(this IConnection connection, Uri uri)
|
||||
public static Task<IApiResponse<T>> GetResponse<T>(this IConnection connection, Uri uri)
|
||||
{
|
||||
Ensure.ArgumentNotNull(connection, "connection");
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
@@ -98,7 +98,7 @@ namespace Octokit
|
||||
/// <param name="cancellationToken">A token used to cancel the GetResponse request</param>
|
||||
/// <returns>The API resource.</returns>
|
||||
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
|
||||
public static Task<IResponse<T>> GetResponse<T>(this IConnection connection, Uri uri, CancellationToken cancellationToken)
|
||||
public static Task<IApiResponse<T>> GetResponse<T>(this IConnection connection, Uri uri, CancellationToken cancellationToken)
|
||||
{
|
||||
Ensure.ArgumentNotNull(connection, "connection");
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Net;
|
||||
|
||||
namespace Octokit.Internal
|
||||
{
|
||||
public class ApiResponse<T> : IResponse<T>
|
||||
public class ApiResponse<T> : IApiResponse<T>
|
||||
{
|
||||
public ApiResponse()
|
||||
{
|
||||
|
||||
+15
-15
@@ -135,14 +135,14 @@ namespace Octokit
|
||||
_jsonPipeline = new JsonHttpPipeline();
|
||||
}
|
||||
|
||||
public Task<IResponse<T>> Get<T>(Uri uri, IDictionary<string, string> parameters, string accepts)
|
||||
public Task<IApiResponse<T>> Get<T>(Uri uri, IDictionary<string, string> parameters, string accepts)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
|
||||
return SendData<T>(uri.ApplyParameters(parameters), HttpMethod.Get, null, accepts, null, CancellationToken.None);
|
||||
}
|
||||
|
||||
public Task<IResponse<T>> Get<T>(Uri uri, IDictionary<string, string> parameters, string accepts, CancellationToken cancellationToken)
|
||||
public Task<IApiResponse<T>> Get<T>(Uri uri, IDictionary<string, string> parameters, string accepts, CancellationToken cancellationToken)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
|
||||
@@ -155,7 +155,7 @@ namespace Octokit
|
||||
/// <param name="uri">URI endpoint to send request to</param>
|
||||
/// <param name="parameters">Querystring parameters for the request</param>
|
||||
/// <returns><seealso cref="IResponse"/> representing the received HTTP response</returns>
|
||||
public Task<IResponse<string>> GetHtml(Uri uri, IDictionary<string, string> parameters)
|
||||
public Task<IApiResponse<string>> GetHtml(Uri uri, IDictionary<string, string> parameters)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
|
||||
@@ -167,7 +167,7 @@ namespace Octokit
|
||||
});
|
||||
}
|
||||
|
||||
public Task<IResponse<T>> Patch<T>(Uri uri, object body)
|
||||
public Task<IApiResponse<T>> Patch<T>(Uri uri, object body)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
Ensure.ArgumentNotNull(body, "body");
|
||||
@@ -175,7 +175,7 @@ namespace Octokit
|
||||
return SendData<T>(uri, HttpVerb.Patch, body, null, null, CancellationToken.None);
|
||||
}
|
||||
|
||||
public Task<IResponse<T>> Patch<T>(Uri uri, object body, string accepts)
|
||||
public Task<IApiResponse<T>> Patch<T>(Uri uri, object body, string accepts)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
Ensure.ArgumentNotNull(body, "body");
|
||||
@@ -184,7 +184,7 @@ namespace Octokit
|
||||
return SendData<T>(uri, HttpVerb.Patch, body, accepts, null, CancellationToken.None);
|
||||
}
|
||||
|
||||
public Task<IResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType)
|
||||
public Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
Ensure.ArgumentNotNull(body, "body");
|
||||
@@ -192,7 +192,7 @@ namespace Octokit
|
||||
return SendData<T>(uri, HttpMethod.Post, body, accepts, contentType, CancellationToken.None);
|
||||
}
|
||||
|
||||
public Task<IResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, TimeSpan timeout)
|
||||
public Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, TimeSpan timeout)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
Ensure.ArgumentNotNull(body, "body");
|
||||
@@ -200,7 +200,7 @@ namespace Octokit
|
||||
return SendData<T>(uri, HttpMethod.Post, body, accepts, contentType, timeout, CancellationToken.None);
|
||||
}
|
||||
|
||||
public Task<IResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, Uri baseAddress)
|
||||
public Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, Uri baseAddress)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
Ensure.ArgumentNotNull(body, "body");
|
||||
@@ -208,12 +208,12 @@ namespace Octokit
|
||||
return SendData<T>(uri, HttpMethod.Post, body, accepts, contentType, CancellationToken.None, baseAddress: baseAddress);
|
||||
}
|
||||
|
||||
public Task<IResponse<T>> Put<T>(Uri uri, object body)
|
||||
public Task<IApiResponse<T>> Put<T>(Uri uri, object body)
|
||||
{
|
||||
return SendData<T>(uri, HttpMethod.Put, body, null, null, CancellationToken.None);
|
||||
}
|
||||
|
||||
public Task<IResponse<T>> Put<T>(Uri uri, object body, string twoFactorAuthenticationCode)
|
||||
public Task<IApiResponse<T>> Put<T>(Uri uri, object body, string twoFactorAuthenticationCode)
|
||||
{
|
||||
return SendData<T>(uri,
|
||||
HttpMethod.Put,
|
||||
@@ -224,7 +224,7 @@ namespace Octokit
|
||||
twoFactorAuthenticationCode);
|
||||
}
|
||||
|
||||
Task<IResponse<T>> SendData<T>(
|
||||
Task<IApiResponse<T>> SendData<T>(
|
||||
Uri uri,
|
||||
HttpMethod method,
|
||||
object body,
|
||||
@@ -249,7 +249,7 @@ namespace Octokit
|
||||
return SendDataInternal<T>(body, accepts, contentType, cancellationToken, twoFactorAuthenticationCode, request);
|
||||
}
|
||||
|
||||
Task<IResponse<T>> SendData<T>(
|
||||
Task<IApiResponse<T>> SendData<T>(
|
||||
Uri uri,
|
||||
HttpMethod method,
|
||||
object body,
|
||||
@@ -271,7 +271,7 @@ namespace Octokit
|
||||
return SendDataInternal<T>(body, accepts, contentType, cancellationToken, twoFactorAuthenticationCode, request);
|
||||
}
|
||||
|
||||
Task<IResponse<T>> SendDataInternal<T>(object body, string accepts, string contentType, CancellationToken cancellationToken, string twoFactorAuthenticationCode, Request request)
|
||||
Task<IApiResponse<T>> SendDataInternal<T>(object body, string accepts, string contentType, CancellationToken cancellationToken, string twoFactorAuthenticationCode, Request request)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(accepts))
|
||||
{
|
||||
@@ -412,14 +412,14 @@ namespace Octokit
|
||||
}
|
||||
}
|
||||
|
||||
async Task<IResponse<string>> GetHtml(IRequest request)
|
||||
async Task<IApiResponse<string>> GetHtml(IRequest request)
|
||||
{
|
||||
request.Headers.Add("Accept", "application/vnd.github.html");
|
||||
var response = await RunRequest(request, CancellationToken.None);
|
||||
return new ApiResponse<string>(response, response.Body);
|
||||
}
|
||||
|
||||
async Task<IResponse<T>> Run<T>(IRequest request, CancellationToken cancellationToken)
|
||||
async Task<IApiResponse<T>> Run<T>(IRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
_jsonPipeline.SerializeRequest(request);
|
||||
var response = await RunRequest(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
+10
-10
@@ -18,7 +18,7 @@ namespace Octokit
|
||||
/// <param name="uri">URI endpoint to send request to</param>
|
||||
/// <param name="parameters">Querystring parameters for the request</param>
|
||||
/// <returns><seealso cref="IResponse"/> representing the received HTTP response</returns>
|
||||
Task<IResponse<string>> GetHtml(Uri uri, IDictionary<string, string> parameters);
|
||||
Task<IApiResponse<string>> GetHtml(Uri uri, IDictionary<string, string> parameters);
|
||||
|
||||
/// <summary>
|
||||
/// Performs an asynchronous HTTP GET request.
|
||||
@@ -30,7 +30,7 @@ namespace Octokit
|
||||
/// <param name="accepts">Specifies accepted response media types.</param>
|
||||
/// <returns><seealso cref="IResponse"/> representing the received HTTP response</returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")]
|
||||
Task<IResponse<T>> Get<T>(Uri uri, IDictionary<string, string> parameters, string accepts);
|
||||
Task<IApiResponse<T>> Get<T>(Uri uri, IDictionary<string, string> parameters, string accepts);
|
||||
|
||||
/// <summary>
|
||||
/// Performs an asynchronous HTTP GET request.
|
||||
@@ -43,7 +43,7 @@ namespace Octokit
|
||||
/// <param name="cancellationToken">A token used to cancel the Get request</param>
|
||||
/// <returns><seealso cref="IResponse"/> representing the received HTTP response</returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get")]
|
||||
Task<IResponse<T>> Get<T>(Uri uri, IDictionary<string, string> parameters, string accepts, CancellationToken cancellationToken);
|
||||
Task<IApiResponse<T>> Get<T>(Uri uri, IDictionary<string, string> parameters, string accepts, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Performs an asynchronous HTTP PATCH request.
|
||||
@@ -60,7 +60,7 @@ namespace Octokit
|
||||
/// <param name="uri">URI endpoint to send request to</param>
|
||||
/// <param name="body">The object to serialize as the body of the request</param>
|
||||
/// <returns><seealso cref="IResponse"/> representing the received HTTP response</returns>
|
||||
Task<IResponse<T>> Patch<T>(Uri uri, object body);
|
||||
Task<IApiResponse<T>> Patch<T>(Uri uri, object body);
|
||||
|
||||
/// <summary>
|
||||
/// Performs an asynchronous HTTP PATCH request.
|
||||
@@ -71,7 +71,7 @@ namespace Octokit
|
||||
/// <param name="body">The object to serialize as the body of the request</param>
|
||||
/// <param name="accepts">Specifies accepted response media types.</param>
|
||||
/// <returns><seealso cref="IResponse"/> representing the received HTTP response</returns>
|
||||
Task<IResponse<T>> Patch<T>(Uri uri, object body, string accepts);
|
||||
Task<IApiResponse<T>> Patch<T>(Uri uri, object body, string accepts);
|
||||
|
||||
/// <summary>
|
||||
/// Performs an asynchronous HTTP POST request.
|
||||
@@ -83,7 +83,7 @@ namespace Octokit
|
||||
/// <param name="accepts">Specifies accepted response media types.</param>
|
||||
/// <param name="contentType">Specifies the media type of the request body</param>
|
||||
/// <returns><seealso cref="IResponse"/> representing the received HTTP response</returns>
|
||||
Task<IResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType);
|
||||
Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType);
|
||||
|
||||
/// <summary>
|
||||
/// Performs an asynchronous HTTP POST request.
|
||||
@@ -96,7 +96,7 @@ namespace Octokit
|
||||
/// <param name="contentType">Specifies the media type of the request body</param>
|
||||
/// <param name="timeout"></param>
|
||||
/// <returns><seealso cref="IResponse"/> representing the received HTTP response</returns>
|
||||
Task<IResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, TimeSpan timeout);
|
||||
Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, TimeSpan timeout);
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -114,7 +114,7 @@ namespace Octokit
|
||||
/// <param name="contentType">Specifies the media type of the request body</param>
|
||||
/// <param name="baseAddress">Allows overriding the base address for a post.</param>
|
||||
/// <returns><seealso cref="IResponse"/> representing the received HTTP response</returns>
|
||||
Task<IResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, Uri baseAddress);
|
||||
Task<IApiResponse<T>> Post<T>(Uri uri, object body, string accepts, string contentType, Uri baseAddress);
|
||||
|
||||
/// <summary>
|
||||
/// Performs an asynchronous HTTP PUT request.
|
||||
@@ -124,7 +124,7 @@ namespace Octokit
|
||||
/// <param name="uri">URI endpoint to send request to</param>
|
||||
/// <param name="body">The body of the request</param>
|
||||
/// <returns><seealso cref="IResponse"/> representing the received HTTP response</returns>
|
||||
Task<IResponse<T>> Put<T>(Uri uri, object body);
|
||||
Task<IApiResponse<T>> Put<T>(Uri uri, object body);
|
||||
|
||||
/// <summary>
|
||||
/// Performs an asynchronous HTTP PUT request using the provided two factor authentication code.
|
||||
@@ -135,7 +135,7 @@ namespace Octokit
|
||||
/// <param name="body">The object to serialize as the body of the request</param>
|
||||
/// <param name="twoFactorAuthenticationCode">Two factory authentication code to use</param>
|
||||
/// <returns><seealso cref="IResponse"/> representing the received HTTP response</returns>
|
||||
Task<IResponse<T>> Put<T>(Uri uri, object body, string twoFactorAuthenticationCode);
|
||||
Task<IApiResponse<T>> Put<T>(Uri uri, object body, string twoFactorAuthenticationCode);
|
||||
|
||||
/// <summary>
|
||||
/// Performs an asynchronous HTTP PUT request that expects an empty response.
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Net;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public interface IResponse<T> : IResponse
|
||||
public interface IApiResponse<T> : IResponse
|
||||
{
|
||||
new T BodyAsObject { get; set; }
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Octokit.Internal
|
||||
request.Body = _serializer.Serialize(request.Body);
|
||||
}
|
||||
|
||||
public IResponse<T> DeserializeResponse<T>(IResponse response)
|
||||
public IApiResponse<T> DeserializeResponse<T>(IResponse response)
|
||||
{
|
||||
Ensure.ArgumentNotNull(response, "response");
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ namespace Octokit.Internal
|
||||
public class ReadOnlyPagedCollection<T> : ReadOnlyCollection<T>, IReadOnlyPagedCollection<T>
|
||||
{
|
||||
readonly ApiInfo _info;
|
||||
readonly Func<Uri, Task<IResponse<List<T>>>> _nextPageFunc;
|
||||
readonly Func<Uri, Task<IApiResponse<List<T>>>> _nextPageFunc;
|
||||
|
||||
public ReadOnlyPagedCollection(IResponse<List<T>> response, Func<Uri, Task<IResponse<List<T>>>> nextPageFunc)
|
||||
public ReadOnlyPagedCollection(IApiResponse<List<T>> response, Func<Uri, Task<IApiResponse<List<T>>>> nextPageFunc)
|
||||
: base(response != null ? response.BodyAsObject : null)
|
||||
{
|
||||
Ensure.ArgumentNotNull(response, "response");
|
||||
|
||||
Reference in New Issue
Block a user