diff --git a/Octokit.Reactive/Clients/ObservableStarredClient.cs b/Octokit.Reactive/Clients/ObservableStarredClient.cs index ab2e1781b3..1ae9716345 100644 --- a/Octokit.Reactive/Clients/ObservableStarredClient.cs +++ b/Octokit.Reactive/Clients/ObservableStarredClient.cs @@ -113,7 +113,7 @@ public IObservable GetAllStargazersWithTimestamps(string owner, string Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages(ApiUrls.Stargazers(owner, name), null, options); + return _connection.GetAndFlattenAllPages(ApiUrls.Stargazers(owner, name), null, AcceptHeaders.StarJson, options); } /// @@ -126,7 +126,7 @@ public IObservable GetAllStargazersWithTimestamps(long repositoryId, A { Ensure.ArgumentNotNull(options, nameof(options)); - return _connection.GetAndFlattenAllPages(ApiUrls.Stargazers(repositoryId), null, options); + return _connection.GetAndFlattenAllPages(ApiUrls.Stargazers(repositoryId), null, AcceptHeaders.StarJson, options); } /// diff --git a/Octokit.Tests.Integration/Clients/StarredClientTests.cs b/Octokit.Tests.Integration/Clients/StarredClientTests.cs index 9e6802e4d2..4187d2c78a 100644 --- a/Octokit.Tests.Integration/Clients/StarredClientTests.cs +++ b/Octokit.Tests.Integration/Clients/StarredClientTests.cs @@ -736,6 +736,9 @@ public async Task CanGetAllStargazersWithTimestamps() var userStar = users.FirstOrDefault(star => star.User.Login == _repositoryContext.RepositoryOwner); Assert.NotNull(userStar); + Assert.NotEqual(DateTimeOffset.MinValue, userStar.StarredAt); + Assert.NotNull(userStar.User); + Assert.NotNull(userStar.User.Login); Assert.True(DateTimeOffset.UtcNow.Subtract(userStar.StarredAt) < TimeSpan.FromMinutes(5)); } diff --git a/Octokit.Tests/Clients/StarredClientTests.cs b/Octokit.Tests/Clients/StarredClientTests.cs index f8eca0df50..f49ddc4198 100644 --- a/Octokit.Tests/Clients/StarredClientTests.cs +++ b/Octokit.Tests/Clients/StarredClientTests.cs @@ -412,7 +412,7 @@ public async Task RequestsCorrectUrlWithTimestamps() await client.GetAllStargazersWithTimestamps("fake", "repo"); - connection.Received().GetAll(endpoint, null, Args.ApiOptions); + connection.Received().GetAll(endpoint, null, AcceptHeaders.StarJson, Args.ApiOptions); } [Fact] @@ -424,7 +424,7 @@ public async Task RequestsCorrectUrlWithTimestampsWithRepositoryId() await client.GetAllStargazersWithTimestamps(1); - connection.Received().GetAll(endpoint, null, Args.ApiOptions); + connection.Received().GetAll(endpoint, null, AcceptHeaders.StarJson, Args.ApiOptions); } [Fact] @@ -443,7 +443,7 @@ public async Task RequestsCorrectUrlWithTimestampsWithApiOptions() await client.GetAllStargazersWithTimestamps("fake", "repo", options); - connection.Received().GetAll(endpoint, null, options); + connection.Received().GetAll(endpoint, null, AcceptHeaders.StarJson, options); } [Fact] @@ -462,7 +462,7 @@ public async Task RequestsCorrectUrlWithTimestampsWithApiOptionsWithRepositoryId await client.GetAllStargazersWithTimestamps(1, options); - connection.Received().GetAll(endpoint, null, options); + connection.Received().GetAll(endpoint, null, AcceptHeaders.StarJson, options); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservableStarredClientTests.cs b/Octokit.Tests/Reactive/ObservableStarredClientTests.cs index cd28b23dea..e67c30b0df 100644 --- a/Octokit.Tests/Reactive/ObservableStarredClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableStarredClientTests.cs @@ -102,7 +102,7 @@ public void RequestsCorrectUrlWithTimestamps() client.GetAllStargazersWithTimestamps("fight", "club"); - connection.Received().Get>(endpoint, Args.EmptyDictionary); + connection.Received().Get>(endpoint, Args.EmptyDictionary, AcceptHeaders.StarJson); } [Fact] @@ -116,7 +116,7 @@ public void RequestsCorrectUrlWithTimestampsWithRepositoryId() client.GetAllStargazersWithTimestamps(1); - connection.Received().Get>(endpoint, Args.EmptyDictionary); + connection.Received().Get>(endpoint, Args.EmptyDictionary, AcceptHeaders.StarJson); } [Fact] @@ -137,7 +137,7 @@ public void RequestsCorrectUrlWithTimestampsWithApiOptions() client.GetAllStargazersWithTimestamps("fight", "club", options); - connection.Received().Get>(endpoint, Arg.Is>(d => d.Count == 2)); + connection.Received().Get>(endpoint, Arg.Is>(d => d.Count == 2), AcceptHeaders.StarJson); } [Fact] @@ -158,7 +158,7 @@ public void RequestsCorrectUrlWithTimestampsWithApiOptionsWithRepositoryId() client.GetAllStargazersWithTimestamps(1, options); - connection.Received().Get>(endpoint, Arg.Is>(d => d.Count == 2)); + connection.Received().Get>(endpoint, Arg.Is>(d => d.Count == 2), AcceptHeaders.StarJson); } [Fact] diff --git a/Octokit/Clients/StarredClient.cs b/Octokit/Clients/StarredClient.cs index 05374044fd..6a4d81e4d3 100644 --- a/Octokit/Clients/StarredClient.cs +++ b/Octokit/Clients/StarredClient.cs @@ -117,7 +117,7 @@ public Task> GetAllStargazersWithTimestamps(string owner Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll(ApiUrls.Stargazers(owner, name), null, options); + return ApiConnection.GetAll(ApiUrls.Stargazers(owner, name), null, AcceptHeaders.StarJson, options); } /// @@ -131,7 +131,7 @@ public Task> GetAllStargazersWithTimestamps(long reposit { Ensure.ArgumentNotNull(options, nameof(options)); - return ApiConnection.GetAll(ApiUrls.Stargazers(repositoryId), null, options); + return ApiConnection.GetAll(ApiUrls.Stargazers(repositoryId), null, AcceptHeaders.StarJson, options); } /// diff --git a/Octokit/Helpers/AcceptHeaders.cs b/Octokit/Helpers/AcceptHeaders.cs index c43e9cbdfb..942c39393a 100644 --- a/Octokit/Helpers/AcceptHeaders.cs +++ b/Octokit/Helpers/AcceptHeaders.cs @@ -15,5 +15,7 @@ public static class AcceptHeaders public const string RawContentMediaType = "application/vnd.github.v3.raw"; public const string RepositoryContentMediaType = "application/vnd.github.v3.repository+json"; + + public const string StarJson = "application/vnd.github.v3.star+json"; } }