From 6c05651d6426e052f31104e7204fd1ca4cdacf26 Mon Sep 17 00:00:00 2001 From: Haacked Date: Fri, 2 Jan 2015 00:25:18 -0800 Subject: [PATCH] Remove the redundant ApiInfo property --- .../Helpers/ConnectionExtensions.cs | 2 +- Octokit.Tests/Http/ConnectionTests.cs | 4 +-- Octokit/Http/ApiResponse.cs | 2 -- Octokit/Http/IResponse.cs | 36 +++++++++++++++++-- Octokit/Http/Response.cs | 19 +++++++++- 5 files changed, 55 insertions(+), 8 deletions(-) diff --git a/Octokit.Reactive/Helpers/ConnectionExtensions.cs b/Octokit.Reactive/Helpers/ConnectionExtensions.cs index 471781db..0094134c 100644 --- a/Octokit.Reactive/Helpers/ConnectionExtensions.cs +++ b/Octokit.Reactive/Helpers/ConnectionExtensions.cs @@ -27,7 +27,7 @@ namespace Octokit.Reactive.Internal { return getPageFunc(uri, parameters).Expand(resp => { - var nextPageUrl = resp.ApiInfo.GetNextPageUrl(); + var nextPageUrl = resp.HttpResponse.ApiInfo.GetNextPageUrl(); return nextPageUrl == null ? Observable.Empty>>() : Observable.Defer(() => getPageFunc(nextPageUrl, null)); diff --git a/Octokit.Tests/Http/ConnectionTests.cs b/Octokit.Tests/Http/ConnectionTests.cs index 61bc1b7a..3e352839 100644 --- a/Octokit.Tests/Http/ConnectionTests.cs +++ b/Octokit.Tests/Http/ConnectionTests.cs @@ -81,8 +81,8 @@ namespace Octokit.Tests.Http Substitute.For()); var resp = await connection.GetResponse(new Uri("endpoint", UriKind.Relative)); - Assert.NotNull(resp.ApiInfo); - Assert.Equal("user", resp.ApiInfo.AcceptedOauthScopes.First()); + Assert.NotNull(resp.HttpResponse.ApiInfo); + Assert.Equal("user", resp.HttpResponse.ApiInfo.AcceptedOauthScopes.First()); } [Fact] diff --git a/Octokit/Http/ApiResponse.cs b/Octokit/Http/ApiResponse.cs index 07252b64..7445c0fc 100644 --- a/Octokit/Http/ApiResponse.cs +++ b/Octokit/Http/ApiResponse.cs @@ -17,7 +17,6 @@ namespace Octokit.Internal HttpResponse = response; Headers = response.Headers; Body = body; - ApiInfo = response.ApiInfo; StatusCode = response.StatusCode; ContentType = response.ContentType; Body = bodyAsObject; @@ -25,7 +24,6 @@ namespace Octokit.Internal public T Body { get; private set; } public IReadOnlyDictionary Headers { get; private set; } - public ApiInfo ApiInfo { get; set; } public HttpStatusCode StatusCode { get; set; } public IResponse HttpResponse { get; private set; } public string ContentType { get; set; } diff --git a/Octokit/Http/IResponse.cs b/Octokit/Http/IResponse.cs index 0d885e36..549464d7 100644 --- a/Octokit/Http/IResponse.cs +++ b/Octokit/Http/IResponse.cs @@ -4,23 +4,55 @@ using System.Net; namespace Octokit { + /// + /// A response from an API call that includes the deserialized object instance. + /// public interface IApiResponse { + /// + /// Object deserialized from the JSON response body. + /// T Body { get; } - ApiInfo ApiInfo { get; } - + /// + /// The response status code. + /// HttpStatusCode StatusCode { get; } + /// + /// The original non-deserialized http response. + /// IResponse HttpResponse { get; } } + /// + /// Represents a generic HTTP response + /// public interface IResponse { + /// + /// Raw response body. Typically a string, but when requesting images, it will be a byte array. + /// object Body { get; } + + /// + /// Information about the API. + /// IReadOnlyDictionary Headers { get; } + + /// + /// Information about the API response parsed from the response headers. + /// ApiInfo ApiInfo { get; } + + /// + /// The response status code. + /// HttpStatusCode StatusCode { get; } + + /// + /// The content type of the response. + /// string ContentType { get; } } } diff --git a/Octokit/Http/Response.cs b/Octokit/Http/Response.cs index 7fefd82d..8620bb6c 100644 --- a/Octokit/Http/Response.cs +++ b/Octokit/Http/Response.cs @@ -1,10 +1,12 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Net; -using Octokit.Internal; namespace Octokit.Internal { + /// + /// Represents a generic HTTP response + /// public class Response : IResponse { public Response() : this(new Dictionary()) @@ -30,10 +32,25 @@ namespace Octokit.Internal ContentType = contentType; } + /// + /// Raw response body. Typically a string, but when requesting images, it will be a byte array. + /// public object Body { get; private set; } + /// + /// Information about the API. + /// public IReadOnlyDictionary Headers { get; private set; } + /// + /// Information about the API response parsed from the response headers. + /// public ApiInfo ApiInfo { get; private set; } + /// + /// The response status code. + /// public HttpStatusCode StatusCode { get; private set; } + /// + /// The content type of the response. + /// public string ContentType { get; private set; } } } \ No newline at end of file