mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-06 03:55:55 +00:00
Merge branch 'master' into reactive-teams
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
<summary>@summary@</summary>
|
||||
<licenseUrl>https://github.com/octokit/octokit.net/blob/master/LICENSE.txt</licenseUrl>
|
||||
<projectUrl>https://github.com/octokit/octokit.net</projectUrl>
|
||||
<iconUrl>https://f.cloud.github.com/assets/19977/1441274/160fba8c-41a9-11e3-831d-61d88fa886f4.png</iconUrl>
|
||||
<iconUrl>https://f.cloud.github.com/assets/19977/1510987/64af2b26-4a9d-11e3-89fc-96a185171c75.png</iconUrl>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<description>@description@</description>
|
||||
<releaseNotes>@releaseNotes@</releaseNotes>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
@@ -7,17 +8,32 @@ namespace Octokit.Tests.Integration
|
||||
{
|
||||
public class ReleasesClientTests
|
||||
{
|
||||
public class TheGetReleasesMethod
|
||||
public class TheGetReleasesMethod : IDisposable
|
||||
{
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsReleases()
|
||||
readonly IReleasesClient _releaseClient;
|
||||
readonly Repository _repository;
|
||||
readonly string _repositoryOwner;
|
||||
readonly string _repositoryName;
|
||||
readonly GitHubClient _github;
|
||||
|
||||
public TheGetReleasesMethod()
|
||||
{
|
||||
var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
|
||||
_github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
|
||||
{
|
||||
Credentials = Helper.Credentials
|
||||
};
|
||||
_releaseClient = _github.Release;
|
||||
|
||||
var releases = await github.Release.GetAll("git-tfs", "git-tfs");
|
||||
var repoName = Helper.MakeNameWithTimestamp("public-repo");
|
||||
_repository = _github.Repository.Create(new NewRepository { Name = repoName, AutoInit = true }).Result;
|
||||
_repositoryOwner = _repository.Owner.Login;
|
||||
_repositoryName = _repository.Name;
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsReleases()
|
||||
{
|
||||
var releases = await _releaseClient.GetAll("git-tfs", "git-tfs");
|
||||
|
||||
Assert.True(releases.Count > 5);
|
||||
Assert.True(releases.Any(release => release.TagName == "v0.18.0"));
|
||||
@@ -26,16 +42,20 @@ namespace Octokit.Tests.Integration
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsReleasesWithNullPublishDate()
|
||||
{
|
||||
var github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
|
||||
{
|
||||
Credentials = Helper.Credentials
|
||||
};
|
||||
// create a release without a publish date
|
||||
var releaseWithNoUpdate = new ReleaseUpdate("0.1") { Draft = true };
|
||||
var release = _releaseClient.CreateRelease(_repositoryOwner, _repositoryName, releaseWithNoUpdate).Result;
|
||||
|
||||
var releases = await github.Release.GetAll("Particular", "ServiceInsight");
|
||||
var releases = await _releaseClient.GetAll(_repositoryOwner, _repositoryName);
|
||||
|
||||
Assert.True(releases.Count == 1);
|
||||
Assert.False(releases.First().PublishedAt.HasValue);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Helper.DeleteRepo(_repository);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
using Octokit.Internal;
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using NSubstitute;
|
||||
using Xunit;
|
||||
using Xunit.Extensions;
|
||||
|
||||
namespace Octokit.Tests.Clients
|
||||
{
|
||||
public class StarredClientTests
|
||||
{
|
||||
public class TheGetAllForCurrentMethod
|
||||
{
|
||||
[Fact]
|
||||
public void RequestsCorrectUrl()
|
||||
{
|
||||
var endpoint = new Uri("user/starred", UriKind.Relative);
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new StarredClient(connection);
|
||||
|
||||
client.GetAllForCurrent();
|
||||
|
||||
connection.Received().GetAll<Repository>(endpoint);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllForUserMethod
|
||||
{
|
||||
[Fact]
|
||||
public void RequestsCorrectUrl()
|
||||
{
|
||||
var endpoint = new Uri("users/banana/starred", UriKind.Relative);
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new StarredClient(connection);
|
||||
|
||||
client.GetAllForUser("banana");
|
||||
|
||||
connection.Received().GetAll<Repository>(endpoint);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllStargazersForRepoMethod
|
||||
{
|
||||
[Fact]
|
||||
public void RequestsCorrectUrl()
|
||||
{
|
||||
var endpoint = new Uri("repos/fight/club/stargazers", UriKind.Relative);
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new StarredClient(connection);
|
||||
|
||||
client.GetAllStargazers("fight", "club");
|
||||
|
||||
connection.Received().GetAll<User>(endpoint);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheCheckStarredMethod
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(HttpStatusCode.NoContent, true)]
|
||||
[InlineData(HttpStatusCode.NotFound, false)]
|
||||
public async Task ReturnsCorrectResultBasedOnStatus(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = status });
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.GetAsync<object>(Arg.Is<Uri>(u => u.ToString() == "user/starred/yes/no"), null, null)
|
||||
.Returns(response);
|
||||
var apiConnection = Substitute.For<IApiConnection>();
|
||||
apiConnection.Connection.Returns(connection);
|
||||
|
||||
var client = new StarredClient(apiConnection);
|
||||
var result = await client.CheckStarred("yes", "no");
|
||||
|
||||
Assert.Equal(expected, result);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheStarRepoMethod
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(HttpStatusCode.NoContent, true)]
|
||||
[InlineData(HttpStatusCode.NotFound, false)]
|
||||
[InlineData(HttpStatusCode.OK, false)]
|
||||
public async Task ReturnsCorrectResultBasedOnStatus(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<IResponse<object>>(() =>
|
||||
new ApiResponse<object> { StatusCode = status });
|
||||
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.PutAsync<object>(Arg.Is<Uri>(u => u.ToString() == "user/starred/yes/no"),
|
||||
Args.Object, Args.String).Returns(response);
|
||||
|
||||
var apiConnection = Substitute.For<IApiConnection>();
|
||||
apiConnection.Connection.Returns(connection);
|
||||
|
||||
var client = new StarredClient(apiConnection);
|
||||
var result = await client.StarRepo("yes", "no");
|
||||
|
||||
Assert.Equal(expected, result);
|
||||
}
|
||||
}
|
||||
|
||||
public class TheRemoveStarFromRepoMethod
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(HttpStatusCode.NoContent, true)]
|
||||
[InlineData(HttpStatusCode.NotFound, false)]
|
||||
[InlineData(HttpStatusCode.OK, false)]
|
||||
public async Task ReturnsCorrectResultBasedOnStatus(HttpStatusCode status, bool expected)
|
||||
{
|
||||
var response = Task.Factory.StartNew<HttpStatusCode>(() => status);
|
||||
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.DeleteAsync(Arg.Is<Uri>(u => u.ToString() == "user/starred/yes/no"))
|
||||
.Returns(response);
|
||||
|
||||
var apiConnection = Substitute.For<IApiConnection>();
|
||||
apiConnection.Connection.Returns(connection);
|
||||
|
||||
var client = new StarredClient(apiConnection);
|
||||
var result = await client.RemoveStarFromRepo("yes", "no");
|
||||
|
||||
Assert.Equal(expected, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
@@ -248,9 +249,9 @@ namespace Octokit.Tests.Http
|
||||
public async Task MakesDeleteRequest()
|
||||
{
|
||||
var deleteUri = new Uri("anything", UriKind.Relative);
|
||||
IResponse<object> response = new ApiResponse<object> {BodyAsObject = new object()};
|
||||
HttpStatusCode statusCode = HttpStatusCode.NoContent;
|
||||
var connection = Substitute.For<IConnection>();
|
||||
connection.DeleteAsync(Args.Uri).Returns(Task.FromResult(response));
|
||||
connection.DeleteAsync(Args.Uri).Returns(Task.FromResult(statusCode));
|
||||
var apiConnection = new ApiConnection(connection);
|
||||
|
||||
await apiConnection.Delete(deleteUri);
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
<Compile Include="Clients\OrganizationMembersClientTests.cs" />
|
||||
<Compile Include="Clients\ReleasesClientTests.cs" />
|
||||
<Compile Include="Clients\SshKeysClientTests.cs" />
|
||||
<Compile Include="Clients\StarredClientTests.cs" />
|
||||
<Compile Include="Clients\TagsClientTests.cs" />
|
||||
<Compile Include="Exceptions\ApiExceptionTests.cs" />
|
||||
<Compile Include="Exceptions\ApiValidationExceptionTests.cs" />
|
||||
|
||||
@@ -74,6 +74,7 @@
|
||||
<Compile Include="Clients\IssueCommentsClientTests.cs" />
|
||||
<Compile Include="Clients\MilestonesClientTests.cs" />
|
||||
<Compile Include="Clients\IssuesClientTests.cs" />
|
||||
<Compile Include="Clients\StarredClientTests.cs" />
|
||||
<Compile Include="Clients\NotificationsClientTests.cs" />
|
||||
<Compile Include="Clients\ReleasesClientTests.cs" />
|
||||
<Compile Include="Clients\SshKeysClientTests.cs" />
|
||||
|
||||
@@ -6,8 +6,10 @@
|
||||
: base(apiConnection)
|
||||
{
|
||||
Events = new EventsClient(apiConnection);
|
||||
Starring = new StarredClient(apiConnection);
|
||||
}
|
||||
|
||||
public IEventsClient Events { get; private set; }
|
||||
public IStarredClient Starring { get; private set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
public interface IActivitiesClient
|
||||
{
|
||||
IEventsClient Events { get; }
|
||||
IStarredClient Starring { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public interface IStarredClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieves all of the stargazers for the passed repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>A <see cref="IReadOnlyPagedCollection{User}"/> of <see cref="User"/>.</returns>
|
||||
Task<IReadOnlyList<User>> GetAllStargazers(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user.
|
||||
/// </summary>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
|
||||
Task<IReadOnlyList<Repository>> GetAllForCurrent();
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user.
|
||||
/// </summary>
|
||||
/// <param name="request">Star-specific request parameters that sort the results</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
|
||||
Task<IReadOnlyList<Repository>> GetAllForCurrent(StarredRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user.
|
||||
/// </summary>
|
||||
/// <param name="user">The login of the user</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> starred by the specified user.</returns>
|
||||
Task<IReadOnlyList<Repository>> GetAllForUser(string user);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user.
|
||||
/// </summary>
|
||||
/// <param name="user">The login of the user</param>
|
||||
/// <param name="request">Star-specific request parameters that sort the results</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> starred by the specified user.</returns>
|
||||
Task<IReadOnlyList<Repository>> GetAllForUser(string user, StarredRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Check if a repository is starred by the current authenticated user.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation</returns>
|
||||
Task<bool> CheckStarred(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Stars a repository for the authenticated user.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository to star</param>
|
||||
/// <param name="name">The name of the repository to star</param>
|
||||
/// <returns>A <c>bool</c> representing the success of starring</returns>
|
||||
Task<bool> StarRepo(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Unstars a repository for the authenticated user.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository to unstar</param>
|
||||
/// <param name="name">The name of the repository to unstar</param>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation</returns>
|
||||
Task<bool> RemoveStarFromRepo(string owner, string name);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public class StarredClient : ApiClient, IStarredClient
|
||||
{
|
||||
public StarredClient(IApiConnection apiConnection) : base(apiConnection)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the stargazers for the passed repository.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>A <see cref="IReadOnlyPagedCollection{User}"/> of <see cref="User"/>.</returns>
|
||||
public Task<IReadOnlyList<User>> GetAllStargazers(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return ApiConnection.GetAll<User>(ApiUrls.Stargazers(owner, name));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user.
|
||||
/// </summary>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
|
||||
public Task<IReadOnlyList<Repository>> GetAllForCurrent()
|
||||
{
|
||||
return ApiConnection.GetAll<Repository>(ApiUrls.Starred());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user.
|
||||
/// </summary>
|
||||
/// <param name="request">Star-specific request parameters that sort the results</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> of <see cref="Repository"/>.</returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters",
|
||||
Justification = "But i think i do need star-specific request parameters")]
|
||||
public Task<IReadOnlyList<Repository>> GetAllForCurrent(StarredRequest request)
|
||||
{
|
||||
Ensure.ArgumentNotNull(request, "request");
|
||||
|
||||
return ApiConnection.GetAll<Repository>(ApiUrls.Starred(), request.ToParametersDictionary());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user.
|
||||
/// </summary>
|
||||
/// <param name="user">The login of the user</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> starred by the specified user.</returns>
|
||||
public Task<IReadOnlyList<Repository>> GetAllForUser(string user)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(user, "user");
|
||||
|
||||
return ApiConnection.GetAll<Repository>(ApiUrls.StarredByUser(user));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user.
|
||||
/// </summary>
|
||||
/// <param name="user">The login of the user</param>
|
||||
/// <param name="request">Star-specific request parameters that sort the results</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>A <see cref="IReadOnlyPagedCollection{Repository}"/> starred by the specified user.</returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
|
||||
public Task<IReadOnlyList<Repository>> GetAllForUser(string user, StarredRequest request)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(user, "user");
|
||||
Ensure.ArgumentNotNull(request, "request");
|
||||
|
||||
return ApiConnection.GetAll<Repository>(ApiUrls.StarredByUser(user), request.ToParametersDictionary());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if a repository is starred by the current authenticated user.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>A <c>bool</c> representing the success of the operation</returns>
|
||||
public async Task<bool> CheckStarred(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
try
|
||||
{
|
||||
var response = await Connection.GetAsync<object>(ApiUrls.Starred(owner, name), null, null)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return response.StatusCode == HttpStatusCode.NoContent;
|
||||
}
|
||||
catch (NotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stars a repository for the authenticated user.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository to star</param>
|
||||
/// <param name="name">The name of the repository to star</param>
|
||||
/// <returns>A <c>bool</c> representing the success of starring the repository.</returns>
|
||||
public async Task<bool> StarRepo(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
try
|
||||
{
|
||||
var response = await Connection.PutAsync<object>(ApiUrls.Starred(owner, name), null, null)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return response.StatusCode == HttpStatusCode.NoContent;
|
||||
}
|
||||
catch (NotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unstars a repository for the authenticated user.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository to unstar</param>
|
||||
/// <param name="name">The name of the repository to unstar</param>
|
||||
/// <returns>A <c>bool</c> representing the success of unstarring the repository.</returns>
|
||||
public async Task<bool> RemoveStarFromRepo(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
try
|
||||
{
|
||||
var statusCode = await Connection.DeleteAsync(ApiUrls.Starred(owner, name))
|
||||
.ConfigureAwait(false);
|
||||
|
||||
return statusCode == HttpStatusCode.NoContent;
|
||||
}
|
||||
catch (NotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ namespace Octokit
|
||||
static readonly Uri _currentUserRepositoriesUrl = new Uri("user/repos", UriKind.Relative);
|
||||
static readonly Uri _currentUserOrganizationsUrl = new Uri("user/orgs", UriKind.Relative);
|
||||
static readonly Uri _currentUserSshKeys = new Uri("user/keys", UriKind.Relative);
|
||||
static readonly Uri _currentUserStars = new Uri("user/starred", UriKind.Relative);
|
||||
static readonly Uri _currentUserEmailsEndpoint = new Uri("user/emails", UriKind.Relative);
|
||||
static readonly Uri _currentUserAuthorizationsEndpoint = new Uri("authorizations", UriKind.Relative);
|
||||
static readonly Uri _currentUserNotificationsEndpoint = new Uri("notifications", UriKind.Relative);
|
||||
@@ -378,6 +379,41 @@ namespace Octokit
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that lists the starred repositories for the authenticated user.
|
||||
/// </summary>
|
||||
public static Uri Stargazers(string owner, string repo)
|
||||
{
|
||||
return "repos/{0}/{1}/stargazers".FormatUri(owner, repo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that lists the starred repositories for the authenticated user.
|
||||
/// </summary>
|
||||
public static Uri Starred()
|
||||
{
|
||||
return _currentUserStars;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that lists the starred repositories for the specified user.
|
||||
/// </summary>
|
||||
/// <param name="user">The user that has the stars</param>
|
||||
public static Uri StarredByUser(string user)
|
||||
{
|
||||
return "users/{0}/starred".FormatUri(user);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> that shows whether the repo is starred by the current user.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="repo">The name of the repository</param>
|
||||
/// <returns></returns>
|
||||
public static Uri Starred(string owner, string repo)
|
||||
{
|
||||
return "user/starred/{0}/{1}".FormatUri(owner, repo);
|
||||
}
|
||||
|
||||
/// Returns the <see cref="Uri"/> for the specified tag.
|
||||
/// </summary>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
|
||||
@@ -205,16 +205,17 @@ namespace Octokit
|
||||
return Run<T>(request);
|
||||
}
|
||||
|
||||
public Task DeleteAsync(Uri uri)
|
||||
public async Task<HttpStatusCode> DeleteAsync(Uri uri)
|
||||
{
|
||||
Ensure.ArgumentNotNull(uri, "uri");
|
||||
|
||||
return Run<object>(new Request
|
||||
var response = await Run<object>(new Request
|
||||
{
|
||||
Method = HttpMethod.Delete,
|
||||
BaseAddress = BaseAddress,
|
||||
Endpoint = uri
|
||||
});
|
||||
return response.StatusCode;
|
||||
}
|
||||
|
||||
public Uri BaseAddress { get; private set; }
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
@@ -13,7 +14,7 @@ namespace Octokit
|
||||
Task<IResponse<T>> PutAsync<T>(Uri uri, object body);
|
||||
Task<IResponse<T>> PutAsync<T>(Uri uri, object body, string twoFactorAuthenticationCode);
|
||||
|
||||
Task DeleteAsync(Uri uri);
|
||||
Task<HttpStatusCode> DeleteAsync(Uri uri);
|
||||
|
||||
Uri BaseAddress { get; }
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
using Octokit.Internal;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public class StarredRequest : RequestParameters
|
||||
{
|
||||
public StarredRequest()
|
||||
{
|
||||
SortProperty = StarredSort.Created;
|
||||
SortDirection = SortDirection.Ascending;
|
||||
}
|
||||
|
||||
[Parameter(Key = "sort")]
|
||||
public StarredSort SortProperty { get; set; }
|
||||
|
||||
[Parameter(Key = "direction")]
|
||||
public SortDirection SortDirection { get; set; }
|
||||
}
|
||||
|
||||
public enum StarredSort
|
||||
{
|
||||
Created,
|
||||
Updated
|
||||
}
|
||||
}
|
||||
@@ -57,10 +57,12 @@
|
||||
<Compile Include="Clients\IssueCommentsClient.cs" />
|
||||
<Compile Include="Clients\IssuesClient.cs" />
|
||||
<Compile Include="Clients\IssuesEventsClient.cs" />
|
||||
<Compile Include="Clients\IStarredClient.cs" />
|
||||
<Compile Include="Clients\ITagsClient.cs" />
|
||||
<Compile Include="Clients\ITeamsClient.cs" />
|
||||
<Compile Include="Clients\MilestonesClient.cs" />
|
||||
<Compile Include="Clients\OrganizationMembersClient.cs" />
|
||||
<Compile Include="Clients\StarredClient.cs" />
|
||||
<Compile Include="Clients\TagsClient.cs" />
|
||||
<Compile Include="Clients\TeamsClient.cs" />
|
||||
<Compile Include="Exceptions\NotFoundException.cs" />
|
||||
@@ -77,6 +79,7 @@
|
||||
<Compile Include="Models\Request\NewTeam.cs" />
|
||||
<Compile Include="Models\Request\Permission.cs" />
|
||||
<Compile Include="Models\Request\RequestParameters.cs" />
|
||||
<Compile Include="Models\Request\StarredRequest.cs" />
|
||||
<Compile Include="Models\Request\UpdateTeam.cs" />
|
||||
<Compile Include="Models\Response\Commit.cs" />
|
||||
<Compile Include="Models\Response\Activity.cs" />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -211,6 +211,10 @@
|
||||
<Compile Include="Models\Request\Permission.cs" />
|
||||
<Compile Include="Models\Request\UpdateTeam.cs" />
|
||||
<Compile Include="Models\Response\Team.cs" />
|
||||
<Compile Include="Models\Response\TeamItem.cs" />
|
||||
<Compile Include="Clients\IStarredClient.cs" />
|
||||
<Compile Include="Clients\StarredClient.cs" />
|
||||
<Compile Include="Models\Request\StarredRequest.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
|
||||
</Project>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -206,6 +206,10 @@
|
||||
<Compile Include="Models\Request\Permission.cs" />
|
||||
<Compile Include="Models\Request\UpdateTeam.cs" />
|
||||
<Compile Include="Models\Response\Team.cs" />
|
||||
<Compile Include="Models\Response\TeamItem.cs" />
|
||||
<Compile Include="Clients\IStarredClient.cs" />
|
||||
<Compile Include="Clients\StarredClient.cs" />
|
||||
<Compile Include="Models\Request\StarredRequest.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
<Compile Include="Clients\ISshKeysClient.cs" />
|
||||
<Compile Include="Clients\IssueCommentsClient.cs" />
|
||||
<Compile Include="Clients\IssuesClient.cs" />
|
||||
<Compile Include="Clients\IStarredClient.cs" />
|
||||
<Compile Include="Clients\ITagsClient.cs" />
|
||||
<Compile Include="Clients\IssuesEventsClient.cs" />
|
||||
<Compile Include="Clients\ITeamsClient.cs" />
|
||||
@@ -89,6 +90,7 @@
|
||||
<Compile Include="Clients\ReleasesClient.cs" />
|
||||
<Compile Include="Clients\RepositoriesClient.cs" />
|
||||
<Compile Include="Clients\SshKeysClient.cs" />
|
||||
<Compile Include="Clients\StarredClient.cs" />
|
||||
<Compile Include="Clients\TagsClient.cs" />
|
||||
<Compile Include="Clients\TeamsClient.cs" />
|
||||
<Compile Include="Clients\UsersClient.cs" />
|
||||
@@ -160,6 +162,7 @@
|
||||
<Compile Include="Models\Request\RepositoryIssueRequest.cs" />
|
||||
<Compile Include="Models\Request\RequestParameters.cs" />
|
||||
<Compile Include="Models\Request\SshKeyUpdate.cs" />
|
||||
<Compile Include="Models\Request\StarredRequest.cs" />
|
||||
<Compile Include="Models\Request\UpdateTeam.cs" />
|
||||
<Compile Include="Models\Request\UserUpdate.cs" />
|
||||
<Compile Include="Models\Response\Account.cs" />
|
||||
|
||||
@@ -71,10 +71,12 @@
|
||||
<Compile Include="Clients\IOrganizationMembersClient.cs" />
|
||||
<Compile Include="Clients\IssueCommentsClient.cs" />
|
||||
<Compile Include="Clients\IssuesClient.cs" />
|
||||
<Compile Include="Clients\IStarredClient.cs" />
|
||||
<Compile Include="Clients\ITagsClient.cs" />
|
||||
<Compile Include="Clients\IssuesEventsClient.cs" />
|
||||
<Compile Include="Clients\MilestonesClient.cs" />
|
||||
<Compile Include="Clients\OrganizationMembersClient.cs" />
|
||||
<Compile Include="Clients\StarredClient.cs" />
|
||||
<Compile Include="Clients\TagsClient.cs" />
|
||||
<Compile Include="Exceptions\NotFoundException.cs" />
|
||||
<Compile Include="Clients\IAssigneesClient.cs" />
|
||||
@@ -89,6 +91,7 @@
|
||||
<Compile Include="Models\Request\NewCommitStatus.cs" />
|
||||
<Compile Include="Models\Request\NewMilestone.cs" />
|
||||
<Compile Include="Models\Request\RequestParameters.cs" />
|
||||
<Compile Include="Models\Request\StarredRequest.cs" />
|
||||
<Compile Include="Models\Response\Commit.cs" />
|
||||
<Compile Include="Models\Response\CommitStatus.cs" />
|
||||
<Compile Include="Models\Request\Permission.cs" />
|
||||
@@ -233,4 +236,4 @@
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
@echo off
|
||||
|
||||
SET MinimalFAKEVersion=639
|
||||
SET FAKEVersion=1
|
||||
cls
|
||||
|
||||
if exist tools\FAKE.Core\tools\PatchVersion.txt (
|
||||
FOR /F "tokens=*" %%i in (tools\FAKE.Core\tools\PatchVersion.txt) DO (SET FAKEVersion=%%i)
|
||||
)
|
||||
|
||||
if %MinimalFAKEVersion% lss %FAKEVersion% goto Build
|
||||
if %MinimalFAKEVersion%==%FAKEVersion% goto Build
|
||||
|
||||
"tools\nuget\nuget.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-Prerelease"
|
||||
|
||||
:Build
|
||||
cls
|
||||
if not exist tools\FAKE.Core\tools\Fake.exe (
|
||||
"tools\nuget\nuget.exe" "install" "FAKE.Core" "-OutputDirectory" "tools" "-ExcludeVersion" "-Prerelease"
|
||||
)
|
||||
|
||||
SET TARGET="Default"
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ Target "CheckProjects" (fun _ ->
|
||||
|
||||
Target "FixProjects" (fun _ ->
|
||||
!! "./Octokit/Octokit*.csproj"
|
||||
|> Fake.MSBuild.ProjectSystem.FixMissingFiles "./Octokit/Octokit.csproj"
|
||||
|> Fake.MSBuild.ProjectSystem.FixProjectFiles "./Octokit/Octokit.csproj"
|
||||
)
|
||||
|
||||
Target "BuildApp" (fun _ ->
|
||||
|
||||
Reference in New Issue
Block a user