mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-03 11:05:56 +00:00
Adds support for alternate accept header to retrieve star creation timestamps
This commit is contained in:
@@ -13,6 +13,15 @@ namespace Octokit.Reactive
|
||||
/// <returns>A <see cref="IObservable{User}"/> of <see cref="User"/>s starring the passed repository</returns>
|
||||
IObservable<User> GetAllStargazers(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the stargazers for the passed repository with star creation timestamps.
|
||||
/// </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="IObservable{UserStar}"/> of <see cref="User"/>s starring the passed repository with star creation timestamps.</returns>
|
||||
IObservable<UserStar> GetAllStargazersWithTimestamps(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user
|
||||
/// </summary>
|
||||
@@ -22,6 +31,15 @@ namespace Octokit.Reactive
|
||||
/// </returns>
|
||||
IObservable<Repository> GetAllForCurrent();
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user with star creation timestamps.
|
||||
/// </summary>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>
|
||||
/// A <see cref="IObservable{RepoStar}"/> of <see cref="Repository"/>(ies) starred by the current authenticated user with star creation timestamps.
|
||||
/// </returns>
|
||||
IObservable<RepositoryStar> GetAllForCurrentWithTimestamps();
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user
|
||||
/// </summary>
|
||||
@@ -33,6 +51,17 @@ namespace Octokit.Reactive
|
||||
/// </returns>
|
||||
IObservable<Repository> GetAllForCurrent(StarredRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user with star creation timestamps.
|
||||
/// </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="IObservable{RepoStar}"/> of <see cref="Repository"/>(ies) starred by the current user,
|
||||
/// sorted according to the passed request parameters and with star creation timestamps.
|
||||
/// </returns>
|
||||
IObservable<RepositoryStar> GetAllForCurrentWithTimestamps(StarredRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user
|
||||
/// </summary>
|
||||
@@ -41,6 +70,16 @@ namespace Octokit.Reactive
|
||||
/// <returns>A <see cref="IObservable{Repository}"/> starred by the specified user</returns>
|
||||
IObservable<Repository> GetAllForUser(string user);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user with star creation timestamps.
|
||||
/// </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="IObservable{RepoStar}"/>(ies) starred by the specified user with star creation timestamps.
|
||||
/// </returns>
|
||||
IObservable<RepositoryStar> GetAllForUserWithTimestamps(string user);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user
|
||||
/// </summary>
|
||||
@@ -50,6 +89,18 @@ namespace Octokit.Reactive
|
||||
/// <returns>A <see cref="IObservable{Repository}"/> starred by the specified user</returns>
|
||||
IObservable<Repository> GetAllForUser(string user, StarredRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user with star creation timestamps.
|
||||
/// </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="IObservable{RepoStar}"/> of <see cref="Repository"/>(ies) starred by the specified user,
|
||||
/// sorted according to the passed request parameters and with star creation timestamps.
|
||||
/// </returns>
|
||||
IObservable<RepositoryStar> GetAllForUserWithTimestamps(string user, StarredRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Check if a repository is starred by the current authenticated user
|
||||
/// </summary>
|
||||
|
||||
@@ -32,6 +32,21 @@ namespace Octokit.Reactive
|
||||
return _connection.GetAndFlattenAllPages<User>(ApiUrls.Stargazers(owner, name));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the stargazers for the passed repository with star creation timestamps.
|
||||
/// </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="IObservable{UserStar}"/> of <see cref="User"/>s starring the passed repository with star creation timestamps.</returns>
|
||||
public IObservable<UserStar> GetAllStargazersWithTimestamps(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return _connection.GetAndFlattenAllPages<UserStar>(ApiUrls.Stargazers(owner, name), null, AcceptHeaders.StarCreationTimestamps);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user
|
||||
/// </summary>
|
||||
@@ -44,6 +59,18 @@ namespace Octokit.Reactive
|
||||
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.Starred());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user with star creation timestamps.
|
||||
/// </summary>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>
|
||||
/// A <see cref="IObservable{RepoStar}"/> of <see cref="Repository"/>(ies) starred by the current authenticated user with star creation timestamps.
|
||||
/// </returns>
|
||||
public IObservable<RepositoryStar> GetAllForCurrentWithTimestamps()
|
||||
{
|
||||
return _connection.GetAndFlattenAllPages<RepositoryStar>(ApiUrls.Starred(), null, AcceptHeaders.StarCreationTimestamps);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user
|
||||
/// </summary>
|
||||
@@ -61,6 +88,23 @@ namespace Octokit.Reactive
|
||||
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.Starred(), request.ToParametersDictionary());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user with star creation timestamps.
|
||||
/// </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="IObservable{RepoStar}"/> of <see cref="Repository"/>(ies) starred by the current user,
|
||||
/// sorted according to the passed request parameters and with star creation timestamps.
|
||||
/// </returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
|
||||
public IObservable<RepositoryStar> GetAllForCurrentWithTimestamps(StarredRequest request)
|
||||
{
|
||||
Ensure.ArgumentNotNull(request, "request");
|
||||
|
||||
return _connection.GetAndFlattenAllPages<RepositoryStar>(ApiUrls.Starred(), request.ToParametersDictionary(), AcceptHeaders.StarCreationTimestamps);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user
|
||||
/// </summary>
|
||||
@@ -74,6 +118,21 @@ namespace Octokit.Reactive
|
||||
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.StarredByUser(user));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user with star creation timestamps.
|
||||
/// </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="IObservable{RepoStar}"/>(ies) starred by the specified user with star creation timestamps.
|
||||
/// </returns>
|
||||
public IObservable<RepositoryStar> GetAllForUserWithTimestamps(string user)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(user, "user");
|
||||
|
||||
return _connection.GetAndFlattenAllPages<RepositoryStar>(ApiUrls.StarredByUser(user), null, AcceptHeaders.StarCreationTimestamps);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user
|
||||
/// </summary>
|
||||
@@ -90,6 +149,25 @@ namespace Octokit.Reactive
|
||||
return _connection.GetAndFlattenAllPages<Repository>(ApiUrls.StarredByUser(user), request.ToParametersDictionary());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user with star creation timestamps.
|
||||
/// </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="IObservable{RepoStar}"/> of <see cref="Repository"/>(ies) starred by the specified user,
|
||||
/// sorted according to the passed request parameters and with star creation timestamps.
|
||||
/// </returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
|
||||
public IObservable<RepositoryStar> GetAllForUserWithTimestamps(string user, StarredRequest request)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(user, "user");
|
||||
Ensure.ArgumentNotNull(request, "request");
|
||||
|
||||
return _connection.GetAndFlattenAllPages<RepositoryStar>(ApiUrls.StarredByUser(user), request.ToParametersDictionary(), AcceptHeaders.StarCreationTimestamps);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if a repository is starred by the current authenticated user
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using Octokit.Tests.Integration.Helpers;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace Octokit.Tests.Integration.Clients
|
||||
{
|
||||
public class StarredClientTests
|
||||
{
|
||||
private readonly IGitHubClient _client;
|
||||
private readonly IStarredClient _fixture;
|
||||
|
||||
public StarredClientTests()
|
||||
{
|
||||
_client = Helper.GetAuthenticatedClient();
|
||||
_fixture = _client.Activity.Starring;
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task CanCreateAndRetrieveStarsWithTimestamps()
|
||||
{
|
||||
using (var context = await _client.CreateRepositoryContext("public-repo"))
|
||||
{
|
||||
await _fixture.RemoveStarFromRepo(context.RepositoryOwner, context.RepositoryName);
|
||||
await _fixture.StarRepo(context.RepositoryOwner, context.RepositoryName);
|
||||
var currentUser = await _client.User.Current();
|
||||
var userStars = await _fixture.GetAllStargazersWithTimestamps(context.RepositoryOwner, context.RepositoryName);
|
||||
var userStar = userStars.SingleOrDefault(x => x.User.Id == currentUser.Id);
|
||||
Assert.NotNull(userStar);
|
||||
Assert.True(DateTimeOffset.UtcNow.Subtract(userStar.StarredAt) < TimeSpan.FromMinutes(5));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,6 +96,7 @@
|
||||
<Compile Include="Clients\RepositoryForksClientTests.cs" />
|
||||
<Compile Include="Clients\RepositoryHooksClientTests.cs" />
|
||||
<Compile Include="Clients\SearchClientTests.cs" />
|
||||
<Compile Include="Clients\StarredClientTests.cs" />
|
||||
<Compile Include="Clients\StatisticsClientTests.cs" />
|
||||
<Compile Include="Clients\TreeClientTests.cs" />
|
||||
<Compile Include="Clients\UserEmailsClientTests.cs" />
|
||||
|
||||
@@ -20,6 +20,15 @@ namespace Octokit
|
||||
/// <returns>A <see cref="IReadOnlyPagedCollection{User}"/> of <see cref="User"/>s starring the passed repository.</returns>
|
||||
Task<IReadOnlyList<User>> GetAllStargazers(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the stargazers for the passed repository with star creation timestamps.
|
||||
/// </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{UserStar}"/> of <see cref="User"/>s starring the passed repository with star creation timestamps.</returns>
|
||||
Task<IReadOnlyList<UserStar>> GetAllStargazersWithTimestamps(string owner, string name);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user.
|
||||
/// </summary>
|
||||
@@ -29,6 +38,15 @@ namespace Octokit
|
||||
/// </returns>
|
||||
Task<IReadOnlyList<Repository>> GetAllForCurrent();
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user with star creation timestamps.
|
||||
/// </summary>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>
|
||||
/// A <see cref="IReadOnlyPagedCollection{RepoStar}"/> of <see cref="Repository"/>(ies) starred by the current authenticated user with star creation timestamps.
|
||||
/// </returns>
|
||||
Task<IReadOnlyList<RepositoryStar>> GetAllForCurrentWithTimestamps();
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user.
|
||||
/// </summary>
|
||||
@@ -39,7 +57,18 @@ namespace Octokit
|
||||
/// sorted according to the passed request parameters.
|
||||
/// </returns>
|
||||
Task<IReadOnlyList<Repository>> GetAllForCurrent(StarredRequest request);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user with star creation timestamps.
|
||||
/// </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{RepoStar}"/> of <see cref="Repository"/>(ies) starred by the current user,
|
||||
/// sorted according to the passed request parameters and with star creation timestamps.
|
||||
/// </returns>
|
||||
Task<IReadOnlyList<RepositoryStar>> GetAllForCurrentWithTimestamps(StarredRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user.
|
||||
/// </summary>
|
||||
@@ -50,6 +79,16 @@ namespace Octokit
|
||||
/// </returns>
|
||||
Task<IReadOnlyList<Repository>> GetAllForUser(string user);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user with star creation timestamps.
|
||||
/// </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{RepoStar}"/>(ies) starred by the specified user with star creation timestamps.
|
||||
/// </returns>
|
||||
Task<IReadOnlyList<RepositoryStar>> GetAllForUserWithTimestamps(string user);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user.
|
||||
/// </summary>
|
||||
@@ -58,6 +97,18 @@ namespace Octokit
|
||||
/// <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>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user with star creation timestamps.
|
||||
/// </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{RepoStar}"/> of <see cref="Repository"/>(ies) starred by the specified user,
|
||||
/// sorted according to the passed request parameters and with star creation timestamps.
|
||||
/// </returns>
|
||||
Task<IReadOnlyList<RepositoryStar>> GetAllForUserWithTimestamps(string user, StarredRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// Check if a repository is starred by the current authenticated user.
|
||||
|
||||
@@ -35,6 +35,21 @@ namespace Octokit
|
||||
return ApiConnection.GetAll<User>(ApiUrls.Stargazers(owner, name));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the stargazers for the passed repository with star creation timestamps.
|
||||
/// </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{UserStar}"/> of <see cref="User"/>s starring the passed repository with star creation timestamps.</returns>
|
||||
public Task<IReadOnlyList<UserStar>> GetAllStargazersWithTimestamps(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return ApiConnection.GetAll<UserStar>(ApiUrls.Stargazers(owner, name), null, AcceptHeaders.StarCreationTimestamps);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user.
|
||||
/// </summary>
|
||||
@@ -47,6 +62,18 @@ namespace Octokit
|
||||
return ApiConnection.GetAll<Repository>(ApiUrls.Starred());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user with star creation timestamps.
|
||||
/// </summary>
|
||||
/// <exception cref="AuthorizationException">Thrown if the client is not authenticated.</exception>
|
||||
/// <returns>
|
||||
/// A <see cref="IReadOnlyPagedCollection{RepoStar}"/> of <see cref="Repository"/>(ies) starred by the current authenticated user with star creation timestamps.
|
||||
/// </returns>
|
||||
public Task<IReadOnlyList<RepositoryStar>> GetAllForCurrentWithTimestamps()
|
||||
{
|
||||
return ApiConnection.GetAll<RepositoryStar>(ApiUrls.Starred(), null, AcceptHeaders.StarCreationTimestamps);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user.
|
||||
/// </summary>
|
||||
@@ -65,6 +92,24 @@ namespace Octokit
|
||||
return ApiConnection.GetAll<Repository>(ApiUrls.Starred(), request.ToParametersDictionary());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the starred <see cref="Repository"/>(ies) for the current user with star creation timestamps.
|
||||
/// </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{RepoStar}"/> of <see cref="Repository"/>(ies) starred by the current user,
|
||||
/// sorted according to the passed request parameters and with star creation timestamps.
|
||||
/// </returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters",
|
||||
Justification = "But i think i do need star-specific request parameters")]
|
||||
public Task<IReadOnlyList<RepositoryStar>> GetAllForCurrentWithTimestamps(StarredRequest request)
|
||||
{
|
||||
Ensure.ArgumentNotNull(request, "request");
|
||||
|
||||
return ApiConnection.GetAll<RepositoryStar>(ApiUrls.Starred(), request.ToParametersDictionary(), AcceptHeaders.StarCreationTimestamps);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user.
|
||||
/// </summary>
|
||||
@@ -80,6 +125,21 @@ namespace Octokit
|
||||
return ApiConnection.GetAll<Repository>(ApiUrls.StarredByUser(user));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user with star creation timestamps.
|
||||
/// </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{RepoStar}"/>(ies) starred by the specified user with star creation timestamps.
|
||||
/// </returns>
|
||||
public Task<IReadOnlyList<RepositoryStar>> GetAllForUserWithTimestamps(string user)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(user, "user");
|
||||
|
||||
return ApiConnection.GetAll<RepositoryStar>(ApiUrls.StarredByUser(user), null, AcceptHeaders.StarCreationTimestamps);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user.
|
||||
/// </summary>
|
||||
@@ -96,6 +156,25 @@ namespace Octokit
|
||||
return ApiConnection.GetAll<Repository>(ApiUrls.StarredByUser(user), request.ToParametersDictionary());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all of the <see cref="Repository"/>(ies) starred by the specified user with star creation timestamps.
|
||||
/// </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{RepoStar}"/> of <see cref="Repository"/>(ies) starred by the specified user,
|
||||
/// sorted according to the passed request parameters and with star creation timestamps.
|
||||
/// </returns>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
|
||||
public Task<IReadOnlyList<RepositoryStar>> GetAllForUserWithTimestamps(string user, StarredRequest request)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(user, "user");
|
||||
Ensure.ArgumentNotNull(request, "request");
|
||||
|
||||
return ApiConnection.GetAll<RepositoryStar>(ApiUrls.StarredByUser(user), request.ToParametersDictionary(), AcceptHeaders.StarCreationTimestamps);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if a repository is starred by the current authenticated user.
|
||||
/// </summary>
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
public const string LicensesApiPreview = "application/vnd.github.drax-preview+json";
|
||||
|
||||
public const string ProtectedBranchesApiPreview = "application/vnd.github.loki-preview+json";
|
||||
|
||||
public const string StarCreationTimestamps = "application/vnd.github.v3.star+json";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents additional information about a star (such as creation time)
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class RepositoryStar
|
||||
{
|
||||
public RepositoryStar() { }
|
||||
|
||||
public RepositoryStar(DateTimeOffset starredAt, Repository repo)
|
||||
{
|
||||
StarredAt = starredAt;
|
||||
Repo = repo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The date the star was created.
|
||||
/// </summary>
|
||||
public DateTimeOffset StarredAt { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// The repository associated with the star.
|
||||
/// </summary>
|
||||
public Repository Repo { get; protected set; }
|
||||
|
||||
internal string DebuggerDisplay
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, Repo.DebuggerDisplay);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents additional information about a star (such as creation time)
|
||||
/// </summary>
|
||||
[DebuggerDisplay("{DebuggerDisplay,nq}")]
|
||||
public class UserStar
|
||||
{
|
||||
public UserStar() { }
|
||||
|
||||
public UserStar(DateTimeOffset starredAt, User user)
|
||||
{
|
||||
StarredAt = starredAt;
|
||||
User = user;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The date the star was created.
|
||||
/// </summary>
|
||||
public DateTimeOffset StarredAt { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// The user associated with the star.
|
||||
/// </summary>
|
||||
public User User { get; protected set; }
|
||||
|
||||
internal string DebuggerDisplay
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, User.DebuggerDisplay);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -414,6 +414,8 @@
|
||||
<Compile Include="Helpers\WebHookConfigComparer.cs" />
|
||||
<Compile Include="Exceptions\PullRequestNotMergeableException.cs" />
|
||||
<Compile Include="Exceptions\PullRequestMismatchException.cs" />
|
||||
<Compile Include="Models\Response\RepositoryStar.cs" />
|
||||
<Compile Include="Models\Response\UserStar.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -421,6 +421,8 @@
|
||||
<Compile Include="Models\Request\BranchUpdate.cs" />
|
||||
<Compile Include="Models\Response\BranchProtection.cs" />
|
||||
<Compile Include="Helpers\AcceptHeaders.cs" />
|
||||
<Compile Include="Models\Response\RepositoryStar.cs" />
|
||||
<Compile Include="Models\Response\UserStar.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -417,6 +417,8 @@
|
||||
<Compile Include="Models\Request\BranchUpdate.cs" />
|
||||
<Compile Include="Models\Response\BranchProtection.cs" />
|
||||
<Compile Include="Helpers\AcceptHeaders.cs" />
|
||||
<Compile Include="Models\Response\RepositoryStar.cs" />
|
||||
<Compile Include="Models\Response\UserStar.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.MonoTouch.CSharp.targets" />
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
@@ -411,6 +411,8 @@
|
||||
<Compile Include="Helpers\WebHookConfigComparer.cs" />
|
||||
<Compile Include="Exceptions\PullRequestNotMergeableException.cs" />
|
||||
<Compile Include="Exceptions\PullRequestMismatchException.cs" />
|
||||
<Compile Include="Models\Response\RepositoryStar.cs" />
|
||||
<Compile Include="Models\Response\UserStar.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CodeAnalysisDictionary Include="..\CustomDictionary.xml">
|
||||
|
||||
@@ -418,6 +418,8 @@
|
||||
<Compile Include="Helpers\WebHookConfigComparer.cs" />
|
||||
<Compile Include="Exceptions\PullRequestNotMergeableException.cs" />
|
||||
<Compile Include="Exceptions\PullRequestMismatchException.cs" />
|
||||
<Compile Include="Models\Response\RepositoryStar.cs" />
|
||||
<Compile Include="Models\Response\UserStar.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CodeAnalysisDictionary Include="..\CustomDictionary.xml">
|
||||
|
||||
@@ -430,6 +430,8 @@
|
||||
<Compile Include="SimpleJson.cs" />
|
||||
<Compile Include="Models\Request\NewRepository.cs" />
|
||||
<Compile Include="Clients\UsersClient.cs" />
|
||||
<Compile Include="Models\Response\RepositoryStar.cs" />
|
||||
<Compile Include="Models\Response\UserStar.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CodeAnalysisDictionary Include="..\CustomDictionary.xml">
|
||||
|
||||
Reference in New Issue
Block a user