mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-08 20:45:51 +00:00
Rename IResponse<T> to IApiResponse
This commit is contained in:
@@ -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