mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-08 04:40:54 +00:00
Rename endpoint to uri everywhere
This commit is contained in:
+15
-15
@@ -8,44 +8,44 @@ namespace Octokit
|
||||
{
|
||||
public static class ApiExtensions
|
||||
{
|
||||
public static Task<T> Get<T>(this IApiConnection connection, Uri endpoint)
|
||||
public static Task<T> Get<T>(this IApiConnection connection, Uri uri)
|
||||
{
|
||||
Ensure.ArgumentNotNull(connection, "connection");
|
||||
Ensure.ArgumentNotNull(endpoint, "endpoint");
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
|
||||
return connection.Get<T>(endpoint, null);
|
||||
return connection.Get<T>(uri, null);
|
||||
}
|
||||
|
||||
public static Task<IReadOnlyList<T>> GetAll<T>(this IApiConnection connection, Uri endpoint)
|
||||
public static Task<IReadOnlyList<T>> GetAll<T>(this IApiConnection connection, Uri uri)
|
||||
{
|
||||
Ensure.ArgumentNotNull(connection, "connection");
|
||||
Ensure.ArgumentNotNull(endpoint, "endpoint");
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
|
||||
return connection.GetAll<T>(endpoint, null);
|
||||
return connection.GetAll<T>(uri, null);
|
||||
}
|
||||
|
||||
public static Task<string> GetHtml(this IApiConnection connection, Uri endpoint)
|
||||
public static Task<string> GetHtml(this IApiConnection connection, Uri uri)
|
||||
{
|
||||
Ensure.ArgumentNotNull(connection, "connection");
|
||||
Ensure.ArgumentNotNull(endpoint, "endpoint");
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
|
||||
return connection.GetHtml(endpoint, null);
|
||||
return connection.GetHtml(uri, null);
|
||||
}
|
||||
|
||||
public static Task<IResponse<string>> GetHtml(this IConnection connection, Uri endpoint)
|
||||
public static Task<IResponse<string>> GetHtml(this IConnection connection, Uri uri)
|
||||
{
|
||||
Ensure.ArgumentNotNull(connection, "connection");
|
||||
Ensure.ArgumentNotNull(endpoint, "endpoint");
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
|
||||
return connection.GetHtml(endpoint, null);
|
||||
return connection.GetHtml(uri, null);
|
||||
}
|
||||
|
||||
public static async Task<IResponse<T>> GetAsync<T>(this IConnection connection, Uri endpoint)
|
||||
public static async Task<IResponse<T>> GetAsync<T>(this IConnection connection, Uri uri)
|
||||
{
|
||||
Ensure.ArgumentNotNull(connection, "connection");
|
||||
Ensure.ArgumentNotNull(endpoint, "endpoint");
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
|
||||
return await connection.GetAsync<T>(endpoint, null);
|
||||
return await connection.GetAsync<T>(uri, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,9 +128,18 @@ namespace Octokit
|
||||
return await Post<T>(uri, data, null, null);
|
||||
}
|
||||
|
||||
public async Task<T> Post<T>(Uri endpoint, object data, string contentType)
|
||||
/// <summary>
|
||||
/// Creates a new API resource in the list at the specified URI.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The API resource's type.</typeparam>
|
||||
/// <param name="uri">URI of the API resource to get.</param>
|
||||
/// <param name="data">Object that describes the new API resource; this will be serialized and used as the request's body.</param>
|
||||
/// <param name="contentType">Content type of the API request.</param>
|
||||
/// <returns>The created API resource.</returns>
|
||||
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
|
||||
public async Task<T> Post<T>(Uri uri, object data, string contentType)
|
||||
{
|
||||
return await Post<T>(endpoint, data, contentType, null);
|
||||
return await Post<T>(uri, data, contentType, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -185,7 +194,7 @@ namespace Octokit
|
||||
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
|
||||
public async Task<T> Put<T>(Uri uri, object data, string twoFactorAuthenticationCode)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, "endpoint");
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
Ensure.ArgumentNotNull(data, "data");
|
||||
Ensure.ArgumentNotNullOrEmptyString(twoFactorAuthenticationCode, "twoFactorAuthenticationCode");
|
||||
|
||||
@@ -204,7 +213,7 @@ namespace Octokit
|
||||
/// <exception cref="ApiException">Thrown when an API error occurs.</exception>
|
||||
public async Task<T> Patch<T>(Uri uri, object data)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, "endpoint");
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
Ensure.ArgumentNotNull(data, "data");
|
||||
|
||||
var response = await Connection.PatchAsync<T>(uri, data);
|
||||
@@ -225,13 +234,13 @@ namespace Octokit
|
||||
}
|
||||
|
||||
async Task<IReadOnlyPagedCollection<T>> GetPage<T>(
|
||||
Uri endpoint,
|
||||
Uri uri,
|
||||
IDictionary<string, string> parameters,
|
||||
string accepts)
|
||||
{
|
||||
Ensure.ArgumentNotNull(endpoint, "endpoint");
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
|
||||
var response = await Connection.GetAsync<List<T>>(endpoint, parameters, accepts);
|
||||
var response = await Connection.GetAsync<List<T>>(uri, parameters, accepts);
|
||||
return new ReadOnlyPagedCollection<T>(response, Connection);
|
||||
}
|
||||
}
|
||||
|
||||
+27
-27
@@ -70,69 +70,69 @@ namespace Octokit
|
||||
_apiInfoParser = new ApiInfoParser();
|
||||
}
|
||||
|
||||
public async Task<IResponse<T>> GetAsync<T>(Uri endpoint, IDictionary<string, string> parameters)
|
||||
public async Task<IResponse<T>> GetAsync<T>(Uri uri, IDictionary<string, string> parameters)
|
||||
{
|
||||
Ensure.ArgumentNotNull(endpoint, "endpoint");
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
|
||||
return await GetAsync<T>(endpoint, parameters, null);
|
||||
return await GetAsync<T>(uri, parameters, null);
|
||||
}
|
||||
|
||||
public async Task<IResponse<T>> GetAsync<T>(Uri endpoint, IDictionary<string, string> parameters, string accepts)
|
||||
public async Task<IResponse<T>> GetAsync<T>(Uri uri, IDictionary<string, string> parameters, string accepts)
|
||||
{
|
||||
Ensure.ArgumentNotNull(endpoint, "endpoint");
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
|
||||
return await SendData<T>(endpoint.ApplyParameters(parameters), HttpMethod.Get, null, accepts: accepts);
|
||||
return await SendData<T>(uri.ApplyParameters(parameters), HttpMethod.Get, null, accepts: accepts);
|
||||
}
|
||||
|
||||
public async Task<IResponse<string>> GetHtml(Uri endpoint, IDictionary<string, string> parameters)
|
||||
public async Task<IResponse<string>> GetHtml(Uri uri, IDictionary<string, string> parameters)
|
||||
{
|
||||
Ensure.ArgumentNotNull(endpoint, "endpoint");
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
|
||||
return await GetHtml(new Request
|
||||
{
|
||||
Method = HttpMethod.Get,
|
||||
BaseAddress = BaseAddress,
|
||||
Endpoint = endpoint.ApplyParameters(parameters)
|
||||
Endpoint = uri.ApplyParameters(parameters)
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<IResponse<T>> PatchAsync<T>(Uri endpoint, object body)
|
||||
public async Task<IResponse<T>> PatchAsync<T>(Uri uri, object body)
|
||||
{
|
||||
Ensure.ArgumentNotNull(endpoint, "endpoint");
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
Ensure.ArgumentNotNull(body, "body");
|
||||
|
||||
|
||||
return await SendData<T>(endpoint, HttpVerb.Patch, body);
|
||||
return await SendData<T>(uri, HttpVerb.Patch, body);
|
||||
}
|
||||
|
||||
public async Task<IResponse<T>> PostAsync<T>(Uri endpoint, object body)
|
||||
public async Task<IResponse<T>> PostAsync<T>(Uri uri, object body)
|
||||
{
|
||||
return await SendData<T>(endpoint, HttpMethod.Post, body);
|
||||
return await SendData<T>(uri, HttpMethod.Post, body);
|
||||
}
|
||||
|
||||
public async Task<IResponse<T>> PostAsync<T>(Uri endpoint, object body, string contentType, string accepts)
|
||||
public async Task<IResponse<T>> PostAsync<T>(Uri uri, object body, string contentType, string accepts)
|
||||
{
|
||||
Ensure.ArgumentNotNull(endpoint, "endpoint");
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
Ensure.ArgumentNotNull(body, "body");
|
||||
|
||||
return await SendData<T>(endpoint, HttpMethod.Post, body, contentType, accepts);
|
||||
return await SendData<T>(uri, HttpMethod.Post, body, contentType, accepts);
|
||||
}
|
||||
|
||||
public async Task<IResponse<T>> PutAsync<T>(Uri endpoint, object body)
|
||||
public async Task<IResponse<T>> PutAsync<T>(Uri uri, object body)
|
||||
{
|
||||
return await SendData<T>(endpoint, HttpMethod.Put, body);
|
||||
return await SendData<T>(uri, HttpMethod.Put, body);
|
||||
}
|
||||
|
||||
public async Task<IResponse<T>> PutAsync<T>(Uri endpoint, object body, string twoFactorAuthenticationCode)
|
||||
public async Task<IResponse<T>> PutAsync<T>(Uri uri, object body, string twoFactorAuthenticationCode)
|
||||
{
|
||||
return await SendData<T>(endpoint,
|
||||
return await SendData<T>(uri,
|
||||
HttpMethod.Put,
|
||||
body,
|
||||
twoFactorAuthenticationCode: twoFactorAuthenticationCode);
|
||||
}
|
||||
|
||||
async Task<IResponse<T>> SendData<T>(
|
||||
Uri endpoint,
|
||||
Uri uri,
|
||||
HttpMethod method,
|
||||
object body,
|
||||
string contentType = "application/x-www-form-urlencoded", // Per: http://developer.github.com/v3/
|
||||
@@ -140,13 +140,13 @@ namespace Octokit
|
||||
string twoFactorAuthenticationCode = null
|
||||
)
|
||||
{
|
||||
Ensure.ArgumentNotNull(endpoint, "endpoint");
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
|
||||
var request = new Request
|
||||
{
|
||||
Method = method,
|
||||
BaseAddress = BaseAddress,
|
||||
Endpoint = endpoint,
|
||||
Endpoint = uri,
|
||||
};
|
||||
|
||||
if (!String.IsNullOrEmpty(accepts))
|
||||
@@ -168,15 +168,15 @@ namespace Octokit
|
||||
return await Run<T>(request);
|
||||
}
|
||||
|
||||
public async Task DeleteAsync(Uri endpoint)
|
||||
public async Task DeleteAsync(Uri uri)
|
||||
{
|
||||
Ensure.ArgumentNotNull(endpoint, "endpoint");
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
|
||||
await Run<object>(new Request
|
||||
{
|
||||
Method = HttpMethod.Delete,
|
||||
BaseAddress = BaseAddress,
|
||||
Endpoint = endpoint
|
||||
Endpoint = uri
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -6,16 +6,16 @@ namespace Octokit
|
||||
{
|
||||
public interface IConnection
|
||||
{
|
||||
Task<IResponse<string>> GetHtml(Uri endpoint, IDictionary<string, string> parameters);
|
||||
Task<IResponse<T>> GetAsync<T>(Uri endpoint, IDictionary<string, string> parameters);
|
||||
Task<IResponse<T>> GetAsync<T>(Uri endpoint, IDictionary<string, string> parameters, string accepts);
|
||||
Task<IResponse<T>> PatchAsync<T>(Uri endpoint, object body);
|
||||
Task<IResponse<T>> PostAsync<T>(Uri endpoint, object body);
|
||||
Task<IResponse<T>> PostAsync<T>(Uri endpoint, object body, string contentType, string accepts);
|
||||
Task<IResponse<T>> PutAsync<T>(Uri endpoint, object body);
|
||||
Task<IResponse<T>> PutAsync<T>(Uri endpoint, object body, string twoFactorAuthenticationCode);
|
||||
Task<IResponse<string>> GetHtml(Uri uri, IDictionary<string, string> parameters);
|
||||
Task<IResponse<T>> GetAsync<T>(Uri uri, IDictionary<string, string> parameters);
|
||||
Task<IResponse<T>> GetAsync<T>(Uri uri, IDictionary<string, string> parameters, string accepts);
|
||||
Task<IResponse<T>> PatchAsync<T>(Uri uri, object body);
|
||||
Task<IResponse<T>> PostAsync<T>(Uri uri, object body);
|
||||
Task<IResponse<T>> PostAsync<T>(Uri uri, object body, string contentType, string accepts);
|
||||
Task<IResponse<T>> PutAsync<T>(Uri uri, object body);
|
||||
Task<IResponse<T>> PutAsync<T>(Uri uri, object body, string twoFactorAuthenticationCode);
|
||||
|
||||
Task DeleteAsync(Uri endpoint);
|
||||
Task DeleteAsync(Uri uri);
|
||||
|
||||
Uri BaseAddress { get; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user