mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-02 02:45:32 +00:00
dropped a bunch of async/await usages
There's also some differences here between using IReadOnlyCollection and IReadOnlyList. We should decide on one and be consistent
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Net;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Reactive.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@@ -110,10 +111,10 @@ namespace Octokit.Tests.Integration
|
||||
|
||||
var emails = await github.User.GetEmails();
|
||||
|
||||
Assert.Equal(1, emails.Count);
|
||||
Assert.Equal("test-octowin@example.com", emails[0].Email);
|
||||
Assert.True(emails[0].Primary);
|
||||
Assert.False(emails[0].Verified);
|
||||
Assert.Equal(1, emails.Count());
|
||||
Assert.Equal("test-octowin@example.com", emails.First().Email);
|
||||
Assert.True(emails.First().Primary);
|
||||
Assert.False(emails.First().Verified);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
#if NET_45
|
||||
using System.Collections.ObjectModel;
|
||||
#endif
|
||||
@@ -101,7 +102,7 @@ namespace Octokit.Tests.Clients
|
||||
|
||||
usersClient.GetEmails();
|
||||
|
||||
client.Received().Get<ReadOnlyCollection<EmailAddress>>(endpoint, null);
|
||||
client.Received().Get<IReadOnlyCollection<EmailAddress>>(endpoint, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,12 @@ namespace Octokit
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <returns></returns>
|
||||
public async Task<IReadOnlyList<User>> GetForRepository(string owner, string name)
|
||||
public Task<IReadOnlyList<User>> GetForRepository(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return await ApiConnection.GetAll<User>(ApiUrls.Assignees(owner, name));
|
||||
return ApiConnection.GetAll<User>(ApiUrls.Assignees(owner, name));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -52,10 +52,10 @@ namespace Octokit
|
||||
/// </exception>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>The specified <see cref="Authorization"/>.</returns>
|
||||
public async Task<Authorization> Get(int id)
|
||||
public Task<Authorization> Get(int id)
|
||||
{
|
||||
var endpoint = "authorizations/{0}".FormatUri(id);
|
||||
return await ApiConnection.Get<Authorization>(endpoint);
|
||||
return ApiConnection.Get<Authorization>(endpoint);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -77,7 +77,7 @@ namespace Octokit
|
||||
/// </exception>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>The created <see cref="Authorization"/>.</returns>
|
||||
public async Task<Authorization> GetOrCreateApplicationAuthentication(
|
||||
public Task<Authorization> GetOrCreateApplicationAuthentication(
|
||||
string clientId,
|
||||
string clientSecret,
|
||||
NewAuthorization newAuthorization)
|
||||
@@ -95,7 +95,7 @@ namespace Octokit
|
||||
note_url = newAuthorization.NoteUrl
|
||||
};
|
||||
|
||||
return await ApiConnection.Put<Authorization>(endpoint, requestData);
|
||||
return ApiConnection.Put<Authorization>(endpoint, requestData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -118,7 +118,7 @@ namespace Octokit
|
||||
/// </exception>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>The created <see cref="Authorization"/>.</returns>
|
||||
public async Task<Authorization> GetOrCreateApplicationAuthentication(
|
||||
public Task<Authorization> GetOrCreateApplicationAuthentication(
|
||||
string clientId,
|
||||
string clientSecret,
|
||||
NewAuthorization newAuthorization,
|
||||
@@ -140,7 +140,7 @@ namespace Octokit
|
||||
|
||||
try
|
||||
{
|
||||
return await ApiConnection.Put<Authorization>(
|
||||
return ApiConnection.Put<Authorization>(
|
||||
endpoint,
|
||||
requestData,
|
||||
twoFactorAuthenticationCode);
|
||||
@@ -166,12 +166,12 @@ namespace Octokit
|
||||
/// </exception>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>The updated <see cref="Authorization"/>.</returns>
|
||||
public async Task<Authorization> Update(int id, AuthorizationUpdate authorizationUpdate)
|
||||
public Task<Authorization> Update(int id, AuthorizationUpdate authorizationUpdate)
|
||||
{
|
||||
Ensure.ArgumentNotNull(authorizationUpdate, "authorizationUpdate");
|
||||
|
||||
var endpoint = "authorizations/{0}".FormatUri(id);
|
||||
return await ApiConnection.Patch<Authorization>(endpoint, authorizationUpdate);
|
||||
return ApiConnection.Patch<Authorization>(endpoint, authorizationUpdate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -187,11 +187,11 @@ namespace Octokit
|
||||
/// </exception>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>The created <see cref="Authorization"/>.</returns>
|
||||
public async Task<Authorization> Create(NewAuthorization newAuthorization)
|
||||
public Task<Authorization> Create(NewAuthorization newAuthorization)
|
||||
{
|
||||
Ensure.ArgumentNotNull(newAuthorization, "newAuthorization");
|
||||
|
||||
return await ApiConnection.Post<Authorization>(ApiUrls.Authorizations(), newAuthorization);
|
||||
return ApiConnection.Post<Authorization>(ApiUrls.Authorizations(), newAuthorization);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -208,10 +208,10 @@ namespace Octokit
|
||||
/// </exception>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A <see cref="Task"/> for the request's execution.</returns>
|
||||
public async Task Delete(int id)
|
||||
public Task Delete(int id)
|
||||
{
|
||||
var endpoint = "authorizations/{0}".FormatUri(id);
|
||||
await ApiConnection.Delete(endpoint);
|
||||
return ApiConnection.Delete(endpoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,13 +12,13 @@ namespace Octokit
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>A <see cref="IReadOnlyPagedCollection{Notification}"/> of <see cref="Notification"/>.</returns>
|
||||
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
|
||||
Task<IReadOnlyCollection<Notification>> GetAllForCurrent();
|
||||
Task<IReadOnlyList<Notification>> GetAllForCurrent();
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Notification"/>s for the current user specific to the specified repository.
|
||||
/// </summary>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>A <see cref="IReadOnlyPagedCollection{Notification}"/> of <see cref="Notification"/>.</returns>
|
||||
Task<IReadOnlyCollection<Notification>> GetAllForRepository(string owner, string name);
|
||||
Task<IReadOnlyList<Notification>> GetAllForRepository(string owner, string name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,6 @@ namespace Octokit
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
|
||||
Task<IReadOnlyList<EmailAddress>> GetEmails();
|
||||
Task<IReadOnlyCollection<EmailAddress>> GetEmails();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,13 +18,12 @@ namespace Octokit
|
||||
/// http://developer.github.com/v3/Milestones/#get-a-single-Milestone
|
||||
/// </remarks>
|
||||
/// <returns></returns>
|
||||
public async Task<Milestone> Get(string owner, string name, int number)
|
||||
public Task<Milestone> Get(string owner, string name, int number)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return await ApiConnection.Get<Milestone>(ApiUrls.Milestone(owner, name, number));
|
||||
|
||||
return ApiConnection.Get<Milestone>(ApiUrls.Milestone(owner, name, number));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -36,9 +35,9 @@ namespace Octokit
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <returns></returns>
|
||||
public async Task<IReadOnlyList<Milestone>> GetForRepository(string owner, string name)
|
||||
public Task<IReadOnlyList<Milestone>> GetForRepository(string owner, string name)
|
||||
{
|
||||
return await GetForRepository(owner, name, new MilestoneRequest());
|
||||
return GetForRepository(owner, name, new MilestoneRequest());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -51,13 +50,13 @@ namespace Octokit
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="request">Used to filter and sort the list of Milestones returned</param>
|
||||
/// <returns></returns>
|
||||
public async Task<IReadOnlyList<Milestone>> GetForRepository(string owner, string name, MilestoneRequest request)
|
||||
public Task<IReadOnlyList<Milestone>> GetForRepository(string owner, string name, MilestoneRequest request)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNull(request, "request");
|
||||
|
||||
return await ApiConnection.GetAll<Milestone>(ApiUrls.Milestones(owner, name),
|
||||
return ApiConnection.GetAll<Milestone>(ApiUrls.Milestones(owner, name),
|
||||
request.ToParametersDictionary());
|
||||
}
|
||||
|
||||
@@ -70,13 +69,13 @@ namespace Octokit
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="newMilestone">A <see cref="NewMilestone"/> instance describing the new Milestone to create</param>
|
||||
/// <returns></returns>
|
||||
public async Task<Milestone> Create(string owner, string name, NewMilestone newMilestone)
|
||||
public Task<Milestone> Create(string owner, string name, NewMilestone newMilestone)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNull(newMilestone, "newMilestone");
|
||||
|
||||
return await ApiConnection.Post<Milestone>(ApiUrls.Milestones(owner, name), newMilestone);
|
||||
return ApiConnection.Post<Milestone>(ApiUrls.Milestones(owner, name), newMilestone);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -90,13 +89,13 @@ namespace Octokit
|
||||
/// <param name="milestoneUpdate">An <see cref="MilestoneUpdate"/> instance describing the changes to make to the Milestone
|
||||
/// </param>
|
||||
/// <returns></returns>
|
||||
public async Task<Milestone> Update(string owner, string name, int number, MilestoneUpdate milestoneUpdate)
|
||||
public Task<Milestone> Update(string owner, string name, int number, MilestoneUpdate milestoneUpdate)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
Ensure.ArgumentNotNull(milestoneUpdate, "milestoneUpdate");
|
||||
|
||||
return await ApiConnection.Patch<Milestone>(ApiUrls.Milestone(owner, name, number), milestoneUpdate);
|
||||
return ApiConnection.Patch<Milestone>(ApiUrls.Milestone(owner, name, number), milestoneUpdate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -108,12 +107,12 @@ namespace Octokit
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <param name="number">The milestone number</param>
|
||||
/// <returns></returns>
|
||||
public async Task Delete(string owner, string name, int number)
|
||||
public Task Delete(string owner, string name, int number)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
await ApiConnection.Delete(ApiUrls.Milestone(owner, name, number));
|
||||
return ApiConnection.Delete(ApiUrls.Milestone(owner, name, number));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@ namespace Octokit
|
||||
/// </summary>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>A <see cref="IReadOnlyPagedCollection{Notification}"/> of <see cref="Notification"/>.</returns>
|
||||
public async Task<IReadOnlyCollection<Notification>> GetAllForCurrent()
|
||||
public Task<IReadOnlyList<Notification>> GetAllForCurrent()
|
||||
{
|
||||
return await ApiConnection.GetAll<Notification>(ApiUrls.Notifications());
|
||||
return ApiConnection.GetAll<Notification>(ApiUrls.Notifications());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -25,9 +25,9 @@ namespace Octokit
|
||||
/// </summary>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>A <see cref="IReadOnlyPagedCollection{Notification}"/> of <see cref="Notification"/>.</returns>
|
||||
public async Task<IReadOnlyCollection<Notification>> GetAllForRepository(string owner, string name)
|
||||
public Task<IReadOnlyList<Notification>> GetAllForRepository(string owner, string name)
|
||||
{
|
||||
return await ApiConnection.GetAll<Notification>(ApiUrls.Notifications(owner, name));
|
||||
return ApiConnection.GetAll<Notification>(ApiUrls.Notifications(owner, name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,12 +28,12 @@ namespace Octokit
|
||||
/// <param name="org">login of the organization to get.</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>The specified <see cref="Organization"/>.</returns>
|
||||
public async Task<Organization> Get(string org)
|
||||
public Task<Organization> Get(string org)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(org, "org");
|
||||
|
||||
var endpoint = "orgs/{0}".FormatUri(org);
|
||||
return await ApiConnection.Get<Organization>(endpoint);
|
||||
return ApiConnection.Get<Organization>(endpoint);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -41,9 +41,9 @@ namespace Octokit
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A list of the current user's <see cref="Organization"/>s.</returns>
|
||||
public async Task<IReadOnlyList<Organization>> GetAllForCurrent()
|
||||
public Task<IReadOnlyList<Organization>> GetAllForCurrent()
|
||||
{
|
||||
return await ApiConnection.GetAll<Organization>(ApiUrls.Organizations());
|
||||
return ApiConnection.GetAll<Organization>(ApiUrls.Organizations());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -51,11 +51,11 @@ namespace Octokit
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A list of the specified user's <see cref="Organization"/>s.</returns>
|
||||
public async Task<IReadOnlyList<Organization>> GetAll(string user)
|
||||
public Task<IReadOnlyList<Organization>> GetAll(string user)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(user, "user");
|
||||
|
||||
return await ApiConnection.GetAll<Organization>(ApiUrls.Organizations(user));
|
||||
return ApiConnection.GetAll<Organization>(ApiUrls.Organizations(user));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,13 +31,13 @@ namespace Octokit
|
||||
/// <param name="name">The repository's name.</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>The list of <see cref="Release"/>s for the specified repository.</returns>
|
||||
public async Task<IReadOnlyList<Release>> GetAll(string owner, string name)
|
||||
public Task<IReadOnlyList<Release>> GetAll(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "repository");
|
||||
|
||||
var endpoint = ApiUrls.Releases(owner, name);
|
||||
return await ApiConnection.GetAll<Release>(endpoint, null, "application/vnd.github.manifold-preview");
|
||||
return ApiConnection.GetAll<Release>(endpoint, null, "application/vnd.github.manifold-preview");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -51,14 +51,14 @@ namespace Octokit
|
||||
/// <param name="data">A description of the release to create.</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>The created <see cref="Release"/>.</returns>
|
||||
public async Task<Release> CreateRelease(string owner, string name, ReleaseUpdate data)
|
||||
public Task<Release> CreateRelease(string owner, string name, ReleaseUpdate data)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "repository");
|
||||
Ensure.ArgumentNotNull(data, "data");
|
||||
|
||||
var endpoint = ApiUrls.Releases(owner, name);
|
||||
return await ApiConnection.Post<Release>(endpoint, data, "application/vnd.github.manifold-preview");
|
||||
return ApiConnection.Post<Release>(endpoint, data, "application/vnd.github.manifold-preview");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -71,13 +71,13 @@ namespace Octokit
|
||||
/// <param name="data">Description of the asset with its data.</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>The created <see cref="ReleaseAsset"/>.</returns>
|
||||
public async Task<ReleaseAsset> UploadAsset(Release release, ReleaseAssetUpload data)
|
||||
public Task<ReleaseAsset> UploadAsset(Release release, ReleaseAssetUpload data)
|
||||
{
|
||||
Ensure.ArgumentNotNull(release, "release");
|
||||
Ensure.ArgumentNotNull(data, "data");
|
||||
|
||||
var endpoint = release.UploadUrl.ExpandUriTemplate(new {name = data.FileName});
|
||||
return await ApiConnection.Post<ReleaseAsset>(
|
||||
return ApiConnection.Post<ReleaseAsset>(
|
||||
endpoint,
|
||||
data.RawData,
|
||||
"application/vnd.github.manifold-preview",
|
||||
|
||||
@@ -32,13 +32,13 @@ namespace Octokit
|
||||
/// <param name="newRepository">A <see cref="NewRepository"/> instance describing the new repository to create.</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A <see cref="Repository"/> instance for the created repository.</returns>
|
||||
public async Task<Repository> Create(NewRepository newRepository)
|
||||
public Task<Repository> Create(NewRepository newRepository)
|
||||
{
|
||||
Ensure.ArgumentNotNull(newRepository, "newRepository");
|
||||
if (string.IsNullOrEmpty(newRepository.Name))
|
||||
throw new ArgumentException("The new repository's name must not be null.");
|
||||
|
||||
return await ApiConnection.Post<Repository>(ApiUrls.Repositories(), newRepository);
|
||||
return ApiConnection.Post<Repository>(ApiUrls.Repositories(), newRepository);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -51,14 +51,14 @@ namespace Octokit
|
||||
/// <param name="newRepository">A <see cref="NewRepository"/> instance describing the new repository to create.</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A <see cref="Repository"/> instance for the created repository</returns>
|
||||
public async Task<Repository> Create(string organizationLogin, NewRepository newRepository)
|
||||
public Task<Repository> Create(string organizationLogin, NewRepository newRepository)
|
||||
{
|
||||
Ensure.ArgumentNotNull(organizationLogin, "organizationLogin");
|
||||
Ensure.ArgumentNotNull(newRepository, "newRepository");
|
||||
if (string.IsNullOrEmpty(newRepository.Name))
|
||||
throw new ArgumentException("The new repository's name must not be null.");
|
||||
|
||||
return await ApiConnection.Post<Repository>(ApiUrls.OrganizationRepositories(organizationLogin), newRepository);
|
||||
return ApiConnection.Post<Repository>(ApiUrls.OrganizationRepositories(organizationLogin), newRepository);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -71,13 +71,13 @@ namespace Octokit
|
||||
/// <param name="owner">The owner of the repository.</param>
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
public async Task Delete(string owner, string name)
|
||||
public Task Delete(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
var endpoint = "repos/{0}/{1}".FormatUri(owner, name);
|
||||
await ApiConnection.Delete(endpoint);
|
||||
return ApiConnection.Delete(endpoint);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -90,13 +90,13 @@ namespace Octokit
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A <see cref="Repository"/></returns>
|
||||
public async Task<Repository> Get(string owner, string name)
|
||||
public Task<Repository> Get(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
var endpoint = "repos/{0}/{1}".FormatUri(owner, name);
|
||||
return await ApiConnection.Get<Repository>(endpoint);
|
||||
return ApiConnection.Get<Repository>(endpoint);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -109,9 +109,9 @@ namespace Octokit
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
|
||||
public async Task<IReadOnlyList<Repository>> GetAllForCurrent()
|
||||
public Task<IReadOnlyList<Repository>> GetAllForCurrent()
|
||||
{
|
||||
return await ApiConnection.GetAll<Repository>(ApiUrls.Repositories());
|
||||
return ApiConnection.GetAll<Repository>(ApiUrls.Repositories());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -123,11 +123,11 @@ namespace Octokit
|
||||
/// </remarks>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
|
||||
public async Task<IReadOnlyList<Repository>> GetAllForUser(string login)
|
||||
public Task<IReadOnlyList<Repository>> GetAllForUser(string login)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(login, "login");
|
||||
|
||||
return await ApiConnection.GetAll<Repository>(ApiUrls.Repositories(login));
|
||||
return ApiConnection.GetAll<Repository>(ApiUrls.Repositories(login));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -139,11 +139,11 @@ namespace Octokit
|
||||
/// </remarks>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
|
||||
public async Task<IReadOnlyList<Repository>> GetAllForOrg(string organization)
|
||||
public Task<IReadOnlyList<Repository>> GetAllForOrg(string organization)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(organization, "organization");
|
||||
|
||||
return await ApiConnection.GetAll<Repository>(ApiUrls.OrganizationRepositories(organization));
|
||||
return ApiConnection.GetAll<Repository>(ApiUrls.OrganizationRepositories(organization));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -176,13 +176,13 @@ namespace Octokit
|
||||
/// <param name="name">The name of the repository.</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns></returns>
|
||||
public async Task<string> GetReadmeHtml(string owner, string name)
|
||||
public Task<string> GetReadmeHtml(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
var endpoint = "repos/{0}/{1}/readme".FormatUri(owner, name);
|
||||
return await ApiConnection.GetHtml(endpoint, null);
|
||||
return ApiConnection.GetHtml(endpoint, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -12,45 +12,45 @@ namespace Octokit
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<SshKey> Get(int id)
|
||||
public Task<SshKey> Get(int id)
|
||||
{
|
||||
var endpoint = "user/keys/{0}".FormatUri(id);
|
||||
|
||||
return await ApiConnection.Get<SshKey>(endpoint);
|
||||
return ApiConnection.Get<SshKey>(endpoint);
|
||||
}
|
||||
|
||||
public async Task<IReadOnlyList<SshKey>> GetAll(string user)
|
||||
public Task<IReadOnlyList<SshKey>> GetAll(string user)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(user, "user");
|
||||
|
||||
return await ApiConnection.GetAll<SshKey>(ApiUrls.SshKeys(user));
|
||||
return ApiConnection.GetAll<SshKey>(ApiUrls.SshKeys(user));
|
||||
}
|
||||
|
||||
public async Task<IReadOnlyList<SshKey>> GetAllForCurrent()
|
||||
public Task<IReadOnlyList<SshKey>> GetAllForCurrent()
|
||||
{
|
||||
return await ApiConnection.GetAll<SshKey>(ApiUrls.SshKeys());
|
||||
return ApiConnection.GetAll<SshKey>(ApiUrls.SshKeys());
|
||||
}
|
||||
|
||||
public async Task<SshKey> Create(SshKeyUpdate key)
|
||||
public Task<SshKey> Create(SshKeyUpdate key)
|
||||
{
|
||||
Ensure.ArgumentNotNull(key, "key");
|
||||
|
||||
return await ApiConnection.Post<SshKey>(ApiUrls.SshKeys(), key);
|
||||
return ApiConnection.Post<SshKey>(ApiUrls.SshKeys(), key);
|
||||
}
|
||||
|
||||
public async Task<SshKey> Update(int id, SshKeyUpdate key)
|
||||
public Task<SshKey> Update(int id, SshKeyUpdate key)
|
||||
{
|
||||
Ensure.ArgumentNotNull(key, "key");
|
||||
|
||||
var endpoint = "user/keys/{0}".FormatUri(id);
|
||||
return await ApiConnection.Patch<SshKey>(endpoint, key);
|
||||
return ApiConnection.Patch<SshKey>(endpoint, key);
|
||||
}
|
||||
|
||||
public async Task Delete(int id)
|
||||
public Task Delete(int id)
|
||||
{
|
||||
var endpoint = "user/keys/{0}".FormatUri(id);
|
||||
|
||||
await ApiConnection.Delete(endpoint);
|
||||
return ApiConnection.Delete(endpoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,12 +25,12 @@ namespace Octokit
|
||||
/// </summary>
|
||||
/// <param name="login">Optional GitHub login (username)</param>
|
||||
/// <returns>A <see cref="User"/></returns>
|
||||
public async Task<User> Get(string login)
|
||||
public Task<User> Get(string login)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(login, "login");
|
||||
|
||||
var endpoint = "users/{0}".FormatUri(login);
|
||||
return await ApiConnection.Get<User>(endpoint);
|
||||
return ApiConnection.Get<User>(endpoint);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -38,9 +38,9 @@ namespace Octokit
|
||||
/// </summary>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>A <see cref="User"/></returns>
|
||||
public async Task<User> Current()
|
||||
public Task<User> Current()
|
||||
{
|
||||
return await ApiConnection.Get<User>(_userEndpoint);
|
||||
return ApiConnection.Get<User>(_userEndpoint);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -49,20 +49,20 @@ namespace Octokit
|
||||
/// <param name="user"></param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>A <see cref="User"/></returns>
|
||||
public async Task<User> Update(UserUpdate user)
|
||||
public Task<User> Update(UserUpdate user)
|
||||
{
|
||||
Ensure.ArgumentNotNull(user, "user");
|
||||
|
||||
return await ApiConnection.Patch<User>(_userEndpoint, user);
|
||||
return ApiConnection.Patch<User>(_userEndpoint, user);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns emails for the current user.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<IReadOnlyList<EmailAddress>> GetEmails()
|
||||
public Task<IReadOnlyCollection<EmailAddress>> GetEmails()
|
||||
{
|
||||
return await ApiConnection.Get<ReadOnlyCollection<EmailAddress>>(ApiUrls.Emails(), null);
|
||||
return ApiConnection.Get<IReadOnlyCollection<EmailAddress>>(ApiUrls.Emails(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user