diff --git a/Octokit.Reactive/Clients/IObservablePullRequestsClient.cs b/Octokit.Reactive/Clients/IObservablePullRequestsClient.cs index 997d662212..510769f8da 100644 --- a/Octokit.Reactive/Clients/IObservablePullRequestsClient.cs +++ b/Octokit.Reactive/Clients/IObservablePullRequestsClient.cs @@ -231,6 +231,16 @@ public interface IObservablePullRequestsClient /// The pull request number IObservable Commits(long repositoryId, int number); + /// + /// Get the list of files on a pull request. + /// + /// https://developer.github.com/v3/pulls/#list-pull-requests-files + /// The owner of the repository + /// The name of the repository + /// The pull request number + /// Options for changing the API response + IObservable Files(string owner, string name, int number, ApiOptions options); + /// /// Get the list of files on a pull request. /// @@ -240,6 +250,15 @@ public interface IObservablePullRequestsClient /// The pull request number IObservable Files(string owner, string name, int number); + /// + /// Get the list of files on a pull request. + /// + /// https://developer.github.com/v3/pulls/#list-pull-requests-files + /// The Id of the repository + /// The pull request number + /// Options for changing the API response + IObservable Files(long repositoryId, int number, ApiOptions options); + /// /// Get the list of files on a pull request. /// diff --git a/Octokit.Reactive/Clients/ObservablePullRequestsClient.cs b/Octokit.Reactive/Clients/ObservablePullRequestsClient.cs index 0f34376011..5b41a65aac 100644 --- a/Octokit.Reactive/Clients/ObservablePullRequestsClient.cs +++ b/Octokit.Reactive/Clients/ObservablePullRequestsClient.cs @@ -359,12 +359,37 @@ public IObservable Commits(long repositoryId, int number) /// The owner of the repository /// The name of the repository /// The pull request number - public IObservable Files(string owner, string name, int number) + /// Options for changing the API response + public IObservable Files(string owner, string name, int number, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - return _connection.GetAndFlattenAllPages(ApiUrls.PullRequestFiles(owner, name, number)); + return _connection.GetAndFlattenAllPages(ApiUrls.PullRequestFiles(owner, name, number), options); + } + + /// + /// Get the list of files on a pull request. + /// + /// https://developer.github.com/v3/pulls/#list-pull-requests-files + /// The owner of the repository + /// The name of the repository + /// The pull request number + public IObservable Files(string owner, string name, int number) + { + return Files(owner, name, number, ApiOptions.None); + } + + /// + /// Get the list of files on a pull request. + /// + /// https://developer.github.com/v3/pulls/#list-pull-requests-files + /// The Id of the repository + /// The pull request number + /// Options for changing the API response + public IObservable Files(long repositoryId, int number, ApiOptions options) + { + return _connection.GetAndFlattenAllPages(ApiUrls.PullRequestFiles(repositoryId, number), options); } /// @@ -375,7 +400,7 @@ public IObservable Files(string owner, string name, int number) /// The pull request number public IObservable Files(long repositoryId, int number) { - return _connection.GetAndFlattenAllPages(ApiUrls.PullRequestFiles(repositoryId, number)); + return Files(repositoryId, number, ApiOptions.None); } } } diff --git a/Octokit.Tests/Clients/PullRequestsClientTests.cs b/Octokit.Tests/Clients/PullRequestsClientTests.cs index 2f10009ad5..362ac6ae91 100644 --- a/Octokit.Tests/Clients/PullRequestsClientTests.cs +++ b/Octokit.Tests/Clients/PullRequestsClientTests.cs @@ -461,7 +461,7 @@ public async Task RequestsCorrectUrl() await client.Files("fake", "repo", 42); connection.Received() - .GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/pulls/42/files")); + .GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/pulls/42/files"), Args.ApiOptions); } [Fact] @@ -473,7 +473,7 @@ public async Task RequestsCorrectUrlWithRepositoryId() await client.Files(1, 42); connection.Received() - .GetAll(Arg.Is(u => u.ToString() == "repositories/1/pulls/42/files")); + .GetAll(Arg.Is(u => u.ToString() == "repositories/1/pulls/42/files"), Args.ApiOptions); } [Fact] diff --git a/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs b/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs index c48529d53c..c6b2932df6 100644 --- a/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservablePullRequestsClientTests.cs @@ -704,7 +704,7 @@ public async Task FetchesAllFilesForPullRequest() CreateResponse(HttpStatusCode.OK), new List { file } ); - connection.Get>(Args.Uri, null) + connection.Get>(Args.Uri, Arg.Any>()) .Returns(Task.FromResult(response)); gitHubClient.Connection.Returns(connection); var client = new ObservablePullRequestsClient(gitHubClient); @@ -713,7 +713,7 @@ public async Task FetchesAllFilesForPullRequest() Assert.Equal(1, files.Count); Assert.Same(file, files[0]); - connection.Received().Get>(new Uri(expectedUrl, UriKind.Relative), null); + connection.Received().Get>(new Uri(expectedUrl, UriKind.Relative), Arg.Any>()); } [Fact] @@ -728,7 +728,7 @@ public async Task FetchesAllFilesForPullRequestWithRepositoryId() CreateResponse(HttpStatusCode.OK), new List { file } ); - connection.Get>(Args.Uri, null) + connection.Get>(Args.Uri, Arg.Any>()) .Returns(Task.FromResult(response)); gitHubClient.Connection.Returns(connection); var client = new ObservablePullRequestsClient(gitHubClient); @@ -737,7 +737,7 @@ public async Task FetchesAllFilesForPullRequestWithRepositoryId() Assert.Equal(1, files.Count); Assert.Same(file, files[0]); - connection.Received().Get>(new Uri(expectedUrl, UriKind.Relative), null); + connection.Received().Get>(new Uri(expectedUrl, UriKind.Relative), Arg.Any>()); } [Fact] diff --git a/Octokit/Clients/IPullRequestsClient.cs b/Octokit/Clients/IPullRequestsClient.cs index e35d22d6e7..01e42c7ca2 100644 --- a/Octokit/Clients/IPullRequestsClient.cs +++ b/Octokit/Clients/IPullRequestsClient.cs @@ -228,6 +228,16 @@ public interface IPullRequestsClient /// The pull request number Task> Commits(long repositoryId, int number); + /// + /// Get the list of files on a pull request. + /// + /// https://developer.github.com/v3/pulls/#list-pull-requests-files + /// The owner of the repository + /// The name of the repository + /// The pull request number + /// Options for changing the API response + Task> Files(string owner, string name, int number, ApiOptions options); + /// /// Get the list of files on a pull request. /// @@ -237,6 +247,15 @@ public interface IPullRequestsClient /// The pull request number Task> Files(string owner, string name, int number); + /// + /// Get the list of files on a pull request. + /// + /// https://developer.github.com/v3/pulls/#list-pull-requests-files + /// The Id of the repository + /// The pull request number + /// Options for changing the API response + Task> Files(long repositoryId, int number, ApiOptions options); + /// /// Get the list of files on a pull request. /// diff --git a/Octokit/Clients/PullRequestsClient.cs b/Octokit/Clients/PullRequestsClient.cs index 34bf1cda62..bcfcfe9a11 100644 --- a/Octokit/Clients/PullRequestsClient.cs +++ b/Octokit/Clients/PullRequestsClient.cs @@ -425,11 +425,25 @@ public Task> Commits(long repositoryId, int num /// The pull request number [ManualRoute("GET", "/repos/{owner}/{repo}/pulls/{pull_number}/files")] public Task> Files(string owner, string name, int number) + { + return Files(owner, name, number, ApiOptions.None); + } + + /// + /// Get the list of files on a pull request. + /// + /// https://developer.github.com/v3/pulls/#list-pull-requests-files + /// The owner of the repository + /// The name of the repository + /// The pull request number + /// Options for changing the API response + [ManualRoute("GET", "/repos/{owner}/{repo}/pulls/{pull_number}/files")] + public Task> Files(string owner, string name, int number, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner)); Ensure.ArgumentNotNullOrEmptyString(name, nameof(name)); - return ApiConnection.GetAll(ApiUrls.PullRequestFiles(owner, name, number)); + return ApiConnection.GetAll(ApiUrls.PullRequestFiles(owner, name, number), options); } /// @@ -441,7 +455,20 @@ public Task> Files(string owner, string name, int [ManualRoute("GET", "/repositories/{id}/pulls/{number}/files")] public Task> Files(long repositoryId, int number) { - return ApiConnection.GetAll(ApiUrls.PullRequestFiles(repositoryId, number)); + return Files(repositoryId, number, ApiOptions.None); + } + + /// + /// Get the list of files on a pull request. + /// + /// https://developer.github.com/v3/pulls/#list-pull-requests-files + /// The Id of the repository + /// The pull request number + /// Options for changing the API response + [ManualRoute("GET", "/repositories/{id}/pulls/{number}/files")] + public Task> Files(long repositoryId, int number, ApiOptions options) + { + return ApiConnection.GetAll(ApiUrls.PullRequestFiles(repositoryId, number), options); } } }