From 691eded548ee2de405afac5c9a185ab0a5ac866d Mon Sep 17 00:00:00 2001 From: "aedampir@gmail.com" Date: Thu, 16 Jun 2016 19:15:20 +0700 Subject: [PATCH] modified XML docs added new overloads --- .../Clients/IObservablePullRequestsClient.cs | 125 +++++++++++- .../Clients/ObservablePullRequestsClient.cs | 167 ++++++++++++++- Octokit/Clients/IPullRequestsClient.cs | 120 ++++++++++- Octokit/Clients/PullRequestsClient.cs | 193 +++++++++++++++++- 4 files changed, 601 insertions(+), 4 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservablePullRequestsClient.cs b/Octokit.Reactive/Clients/IObservablePullRequestsClient.cs index ad26ec10..cfb8d4e4 100644 --- a/Octokit.Reactive/Clients/IObservablePullRequestsClient.cs +++ b/Octokit.Reactive/Clients/IObservablePullRequestsClient.cs @@ -3,6 +3,12 @@ using System.Diagnostics.CodeAnalysis; namespace Octokit.Reactive { + /// + /// A client for GitHub's Pull Requests API. + /// + /// + /// See the Pull Requests API documentation for more information. + /// public interface IObservablePullRequestsClient { /// @@ -16,11 +22,27 @@ namespace Octokit.Reactive /// /// http://developer.github.com/v3/pulls/#get-a-single-pull-request /// + /// The owner of the repository + /// The name of the repository + /// The number of the pull request /// A result [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", - Justification = "Method makes a network request")] + Justification = "Method makes a network request")] IObservable Get(string owner, string name, int number); + /// + /// Gets a single Pull Request by number. + /// + /// + /// http://developer.github.com/v3/pulls/#get-a-single-pull-request + /// + /// The ID of the repository + /// The number of the pull request + /// A result + [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", + Justification = "Method makes a network request")] + IObservable Get(int repositoryId, int number); + /// /// Gets all open pull requests for the repository. /// @@ -32,6 +54,16 @@ namespace Octokit.Reactive /// A collection of results IObservable GetAllForRepository(string owner, string name); + /// + /// Gets all open pull requests for the repository. + /// + /// + /// http://developer.github.com/v3/pulls/#list-pull-requests + /// + /// The ID of the repository + /// A collection of results + IObservable GetAllForRepository(int repositoryId); + /// /// Gets all open pull requests for the repository. /// @@ -44,6 +76,17 @@ namespace Octokit.Reactive /// A collection of results IObservable GetAllForRepository(string owner, string name, ApiOptions options); + /// + /// Gets all open pull requests for the repository. + /// + /// + /// http://developer.github.com/v3/pulls/#list-pull-requests + /// + /// The ID of the repository + /// Options for changing the API response + /// A collection of results + IObservable GetAllForRepository(int repositoryId, ApiOptions options); + /// /// Query pull requests for the repository based on criteria /// @@ -56,6 +99,17 @@ namespace Octokit.Reactive /// A collection of results IObservable GetAllForRepository(string owner, string name, PullRequestRequest request); + /// + /// Query pull requests for the repository based on criteria + /// + /// + /// http://developer.github.com/v3/pulls/#list-pull-requests + /// + /// The ID of the repository + /// Used to filter and sort the list of pull requests returned + /// A collection of results + IObservable GetAllForRepository(int repositoryId, PullRequestRequest request); + /// /// Query pull requests for the repository based on criteria /// @@ -69,6 +123,18 @@ namespace Octokit.Reactive /// A collection of results IObservable GetAllForRepository(string owner, string name, PullRequestRequest request, ApiOptions options); + /// + /// Query pull requests for the repository based on criteria + /// + /// + /// http://developer.github.com/v3/pulls/#list-pull-requests + /// + /// The ID of the repository + /// Used to filter and sort the list of pull requests returned + /// Options for changing the API response + /// A collection of results + IObservable GetAllForRepository(int repositoryId, PullRequestRequest request, ApiOptions options); + /// /// Creates a pull request for the specified repository. /// @@ -79,6 +145,15 @@ namespace Octokit.Reactive /// A created result IObservable Create(string owner, string name, NewPullRequest newPullRequest); + /// + /// Creates a pull request for the specified repository. + /// + /// http://developer.github.com/v3/pulls/#create-a-pull-request + /// The ID of the repository + /// A instance describing the new PullRequest to create + /// A created result + IObservable Create(int repositoryId, NewPullRequest newPullRequest); + /// /// Update a pull request for the specified repository. /// @@ -91,6 +166,17 @@ namespace Octokit.Reactive /// An updated result IObservable Update(string owner, string name, int number, PullRequestUpdate pullRequestUpdate); + /// + /// Update a pull request for the specified repository. + /// + /// http://developer.github.com/v3/pulls/#update-a-pull-request + /// The ID of the repository + /// The PullRequest number + /// An instance describing the changes to make to the PullRequest + /// + /// An updated result + IObservable Update(int repositoryId, int number, PullRequestUpdate pullRequestUpdate); + /// /// Merge a pull request. /// @@ -102,6 +188,16 @@ namespace Octokit.Reactive /// A result IObservable Merge(string owner, string name, int number, MergePullRequest mergePullRequest); + /// + /// Merge a pull request. + /// + /// http://developer.github.com/v3/pulls/#merge-a-pull-request-merge-buttontrade + /// The ID of the repository + /// The pull request number + /// A instance describing a pull request merge + /// A result + IObservable Merge(int repositoryId, int number, MergePullRequest mergePullRequest); + /// /// Gets the pull request merge status. /// @@ -112,6 +208,15 @@ namespace Octokit.Reactive /// A result - true if the pull request has been merged, false otherwise IObservable Merged(string owner, string name, int number); + /// + /// Gets the pull request merge status. + /// + /// http://developer.github.com/v3/pulls/#get-if-a-pull-request-has-been-merged + /// The ID of the repository + /// The pull request number + /// A result - true if the pull request has been merged, false otherwise + IObservable Merged(int repositoryId, int number); + /// /// Gets the list of commits on a pull request. /// @@ -122,6 +227,15 @@ namespace Octokit.Reactive /// A collection of results IObservable Commits(string owner, string name, int number); + /// + /// Gets the list of commits on a pull request. + /// + /// http://developer.github.com/v3/pulls/#list-commits-on-a-pull-request + /// The ID of the repository + /// The pull request number + /// A collection of results + IObservable Commits(int repositoryId, int number); + /// /// Get the list of files on a pull request. /// @@ -131,5 +245,14 @@ namespace Octokit.Reactive /// The pull request number /// A collection of results 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 + /// A collection of results + IObservable Files(int repositoryId, int number); } } diff --git a/Octokit.Reactive/Clients/ObservablePullRequestsClient.cs b/Octokit.Reactive/Clients/ObservablePullRequestsClient.cs index 20e87680..2bb538db 100644 --- a/Octokit.Reactive/Clients/ObservablePullRequestsClient.cs +++ b/Octokit.Reactive/Clients/ObservablePullRequestsClient.cs @@ -4,6 +4,12 @@ using Octokit.Reactive.Internal; namespace Octokit.Reactive { + /// + /// A client for GitHub's Pull Requests API. + /// + /// + /// See the Pull Requests API documentation for more information. + /// public class ObservablePullRequestsClient : IObservablePullRequestsClient { readonly IPullRequestsClient _client; @@ -38,6 +44,20 @@ namespace Octokit.Reactive return _client.Get(owner, name, number).ToObservable(); } + /// + /// Gets a single Pull Request by number. + /// + /// + /// http://developer.github.com/v3/pulls/#get-a-single-pull-request + /// + /// The ID of the repository + /// The number of the pull request + /// A result + public IObservable Get(int repositoryId, int number) + { + return _client.Get(repositoryId, number).ToObservable(); + } + /// /// Gets all open pull requests for the repository. /// @@ -55,6 +75,19 @@ namespace Octokit.Reactive return GetAllForRepository(owner, name, ApiOptions.None); } + /// + /// Gets all open pull requests for the repository. + /// + /// + /// http://developer.github.com/v3/pulls/#list-pull-requests + /// + /// The ID of the repository + /// A collection of results + public IObservable GetAllForRepository(int repositoryId) + { + return GetAllForRepository(repositoryId, ApiOptions.None); + } + /// /// Gets all open pull requests for the repository. /// @@ -74,6 +107,22 @@ namespace Octokit.Reactive return _connection.GetAndFlattenAllPages(ApiUrls.PullRequests(owner, name), options); } + /// + /// Gets all open pull requests for the repository. + /// + /// + /// http://developer.github.com/v3/pulls/#list-pull-requests + /// + /// The ID of the repository + /// Options for changing the API response + /// A collection of results + public IObservable GetAllForRepository(int repositoryId, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.PullRequests(repositoryId), options); + } + /// /// Query pull requests for the repository based on criteria /// @@ -93,6 +142,22 @@ namespace Octokit.Reactive return GetAllForRepository(owner, name, request, ApiOptions.None); } + /// + /// Query pull requests for the repository based on criteria + /// + /// + /// http://developer.github.com/v3/pulls/#list-pull-requests + /// + /// The ID of the repository + /// Used to filter and sort the list of pull requests returned + /// A collection of results + public IObservable GetAllForRepository(int repositoryId, PullRequestRequest request) + { + Ensure.ArgumentNotNull(request, "request"); + + return GetAllForRepository(repositoryId, request, ApiOptions.None); + } + /// /// Query pull requests for the repository based on criteria /// @@ -115,6 +180,25 @@ namespace Octokit.Reactive request.ToParametersDictionary(), options); } + /// + /// Query pull requests for the repository based on criteria + /// + /// + /// http://developer.github.com/v3/pulls/#list-pull-requests + /// + /// The ID of the repository + /// Used to filter and sort the list of pull requests returned + /// Options for changing the API response + /// A collection of results + public IObservable GetAllForRepository(int repositoryId, PullRequestRequest request, ApiOptions options) + { + Ensure.ArgumentNotNull(request, "request"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.PullRequests(repositoryId), + request.ToParametersDictionary(), options); + } + /// /// Creates a pull request for the specified repository. /// @@ -132,6 +216,20 @@ namespace Octokit.Reactive return _client.Create(owner, name, newPullRequest).ToObservable(); } + /// + /// Creates a pull request for the specified repository. + /// + /// http://developer.github.com/v3/pulls/#create-a-pull-request + /// The ID of the repository + /// A instance describing the new PullRequest to create + /// A created result + public IObservable Create(int repositoryId, NewPullRequest newPullRequest) + { + Ensure.ArgumentNotNull(newPullRequest, "newPullRequest"); + + return _client.Create(repositoryId, newPullRequest).ToObservable(); + } + /// /// Update a pull request for the specified repository. /// @@ -151,6 +249,22 @@ namespace Octokit.Reactive return _client.Update(owner, name, number, pullRequestUpdate).ToObservable(); } + /// + /// Update a pull request for the specified repository. + /// + /// http://developer.github.com/v3/pulls/#update-a-pull-request + /// The ID of the repository + /// The PullRequest number + /// An instance describing the changes to make to the PullRequest + /// + /// An updated result + public IObservable Update(int repositoryId, int number, PullRequestUpdate pullRequestUpdate) + { + Ensure.ArgumentNotNull(pullRequestUpdate, "pullRequestUpdate"); + + return _client.Update(repositoryId, number, pullRequestUpdate).ToObservable(); + } + /// /// Merge a pull request. /// @@ -169,6 +283,21 @@ namespace Octokit.Reactive return _client.Merge(owner, name, number, mergePullRequest).ToObservable(); } + /// + /// Merge a pull request. + /// + /// http://developer.github.com/v3/pulls/#merge-a-pull-request-merge-buttontrade + /// The ID of the repository + /// The pull request number + /// A instance describing a pull request merge + /// A result + public IObservable Merge(int repositoryId, int number, MergePullRequest mergePullRequest) + { + Ensure.ArgumentNotNull(mergePullRequest, "mergePullRequest"); + + return _client.Merge(repositoryId, number, mergePullRequest).ToObservable(); + } + /// /// Gets the pull request merge status. /// @@ -185,6 +314,18 @@ namespace Octokit.Reactive return _client.Merged(owner, name, number).ToObservable(); } + /// + /// Gets the pull request merge status. + /// + /// http://developer.github.com/v3/pulls/#get-if-a-pull-request-has-been-merged + /// The ID of the repository + /// The pull request number + /// A result - true if the pull request has been merged, false otherwise + public IObservable Merged(int repositoryId, int number) + { + return _client.Merged(repositoryId, number).ToObservable(); + } + /// /// Gets the list of commits on a pull request. /// @@ -201,6 +342,18 @@ namespace Octokit.Reactive return _connection.GetAndFlattenAllPages(ApiUrls.PullRequestCommits(owner, name, number)); } + /// + /// Gets the list of commits on a pull request. + /// + /// http://developer.github.com/v3/pulls/#list-commits-on-a-pull-request + /// The ID of the repository + /// The pull request number + /// A collection of results + public IObservable Commits(int repositoryId, int number) + { + return _connection.GetAndFlattenAllPages(ApiUrls.PullRequestCommits(repositoryId, number)); + } + /// /// Get the list of files on a pull request. /// @@ -216,5 +369,17 @@ namespace Octokit.Reactive return _connection.GetAndFlattenAllPages(ApiUrls.PullRequestFiles(owner, name, 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 + /// A collection of results + public IObservable Files(int repositoryId, int number) + { + return _connection.GetAndFlattenAllPages(ApiUrls.PullRequestFiles(repositoryId, number)); + } } -} \ No newline at end of file +} diff --git a/Octokit/Clients/IPullRequestsClient.cs b/Octokit/Clients/IPullRequestsClient.cs index 1dfd8a25..ba16e8c8 100644 --- a/Octokit/Clients/IPullRequestsClient.cs +++ b/Octokit/Clients/IPullRequestsClient.cs @@ -4,6 +4,12 @@ using System.Threading.Tasks; namespace Octokit { + /// + /// A client for GitHub's Pull Requests API. + /// + /// + /// See the Pull Requests API documentation for more information. + /// public interface IPullRequestsClient { /// @@ -19,9 +25,20 @@ namespace Octokit /// /// A result [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", - Justification = "Method makes a network request")] + Justification = "Method makes a network request")] Task Get(string owner, string name, int number); + /// + /// Get a pull request by number. + /// + /// + /// http://developer.github.com/v3/pulls/#get-a-single-pull-request + /// + /// A result + [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", + Justification = "Method makes a network request")] + Task Get(int repositoryId, int number); + /// /// Get all open pull requests for the repository. /// @@ -33,6 +50,16 @@ namespace Octokit /// A of s which are currently open Task> GetAllForRepository(string owner, string name); + /// + /// Get all open pull requests for the repository. + /// + /// + /// http://developer.github.com/v3/pulls/#list-pull-requests + /// + /// The ID of the repository + /// A of s which are currently open + Task> GetAllForRepository(int repositoryId); + /// /// Get all open pull requests for the repository. /// @@ -45,6 +72,17 @@ namespace Octokit /// A of s which are currently open Task> GetAllForRepository(string owner, string name, ApiOptions options); + /// + /// Get all open pull requests for the repository. + /// + /// + /// http://developer.github.com/v3/pulls/#list-pull-requests + /// + /// The ID of the repository + /// Options for changing the API response + /// A of s which are currently open + Task> GetAllForRepository(int repositoryId, ApiOptions options); + /// /// Query pull requests for the repository based on criteria /// @@ -57,6 +95,17 @@ namespace Octokit /// A of s which match the criteria Task> GetAllForRepository(string owner, string name, PullRequestRequest request); + /// + /// Query pull requests for the repository based on criteria + /// + /// + /// http://developer.github.com/v3/pulls/#list-pull-requests + /// + /// The ID of the repository + /// Used to filter and sort the list of pull requests returned + /// A of s which match the criteria + Task> GetAllForRepository(int repositoryId, PullRequestRequest request); + /// /// Query pull requests for the repository based on criteria /// @@ -70,6 +119,18 @@ namespace Octokit /// A of s which match the criteria Task> GetAllForRepository(string owner, string name, PullRequestRequest request, ApiOptions options); + /// + /// Query pull requests for the repository based on criteria + /// + /// + /// http://developer.github.com/v3/pulls/#list-pull-requests + /// + /// The ID of the repository + /// Used to filter and sort the list of pull requests returned + /// Options for changing the API response + /// A of s which match the criteria + Task> GetAllForRepository(int repositoryId, PullRequestRequest request, ApiOptions options); + /// /// Create a pull request for the specified repository. /// @@ -80,6 +141,15 @@ namespace Octokit /// A result which was created on the server Task Create(string owner, string name, NewPullRequest newPullRequest); + /// + /// Create a pull request for the specified repository. + /// + /// http://developer.github.com/v3/pulls/#create-a-pull-request + /// The ID of the repository + /// A instance describing the new PullRequest to create + /// A result which was created on the server + Task Create(int repositoryId, NewPullRequest newPullRequest); + /// /// Create a pull request for the specified repository. /// @@ -92,6 +162,17 @@ namespace Octokit /// An updated result Task Update(string owner, string name, int number, PullRequestUpdate pullRequestUpdate); + /// + /// Create a pull request for the specified repository. + /// + /// http://developer.github.com/v3/pulls/#update-a-pull-request + /// The ID of the repository + /// The PullRequest number + /// An instance describing the changes to make to the PullRequest + /// + /// An updated result + Task Update(int repositoryId, int number, PullRequestUpdate pullRequestUpdate); + /// /// Merge a pull request. /// @@ -103,6 +184,16 @@ namespace Octokit /// An result which indicates the merge result Task Merge(string owner, string name, int number, MergePullRequest mergePullRequest); + /// + /// Merge a pull request. + /// + /// http://developer.github.com/v3/pulls/#merge-a-pull-request-merge-buttontrade + /// The ID of the repository + /// The pull request number + /// A instance describing a pull request merge + /// An result which indicates the merge result + Task Merge(int repositoryId, int number, MergePullRequest mergePullRequest); + /// /// Get the pull request merge status. /// @@ -113,6 +204,15 @@ namespace Octokit /// True if the operation has been merged, false otherwise Task Merged(string owner, string name, int number); + /// + /// Get the pull request merge status. + /// + /// http://developer.github.com/v3/pulls/#get-if-a-pull-request-has-been-merged + /// The ID of the repository + /// The pull request number + /// True if the operation has been merged, false otherwise + Task Merged(int repositoryId, int number); + /// /// Get the list of commits on a pull request. /// @@ -123,6 +223,15 @@ namespace Octokit /// A of s which are part of this pull request Task> Commits(string owner, string name, int number); + /// + /// Get the list of commits on a pull request. + /// + /// http://developer.github.com/v3/pulls/#list-commits-on-a-pull-request + /// The ID of the repository + /// The pull request number + /// A of s which are part of this pull request + Task> Commits(int repositoryId, int number); + /// /// Get the list of files on a pull request. /// @@ -132,5 +241,14 @@ namespace Octokit /// The pull request number /// A which are part of this pull request 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 + /// A which are part of this pull request + Task> Files(int repositoryId, int number); } } diff --git a/Octokit/Clients/PullRequestsClient.cs b/Octokit/Clients/PullRequestsClient.cs index f1d3f49e..29808ab2 100644 --- a/Octokit/Clients/PullRequestsClient.cs +++ b/Octokit/Clients/PullRequestsClient.cs @@ -4,6 +4,12 @@ using System.Threading.Tasks; namespace Octokit { + /// + /// A client for GitHub's Pull Requests API. + /// + /// + /// See the Pull Requests API documentation for more information. + /// public class PullRequestsClient : ApiClient, IPullRequestsClient { public PullRequestsClient(IApiConnection apiConnection) : base(apiConnection) @@ -31,6 +37,18 @@ namespace Octokit return ApiConnection.Get(ApiUrls.PullRequest(owner, name, number)); } + /// + /// Get a pull request by number. + /// + /// + /// http://developer.github.com/v3/pulls/#get-a-single-pull-request + /// + /// A result + public Task Get(int repositoryId, int number) + { + return ApiConnection.Get(ApiUrls.PullRequest(repositoryId, number)); + } + /// /// Get all open pull requests for the repository. /// @@ -48,6 +66,19 @@ namespace Octokit return GetAllForRepository(owner, name, new PullRequestRequest(), ApiOptions.None); } + /// + /// Get all open pull requests for the repository. + /// + /// + /// http://developer.github.com/v3/pulls/#list-pull-requests + /// + /// The ID of the repository + /// A of s which are currently open + public Task> GetAllForRepository(int repositoryId) + { + return GetAllForRepository(repositoryId, new PullRequestRequest(), ApiOptions.None); + } + /// /// Get all open pull requests for the repository. /// @@ -67,6 +98,22 @@ namespace Octokit return GetAllForRepository(owner, name, new PullRequestRequest(), options); } + /// + /// Get all open pull requests for the repository. + /// + /// + /// http://developer.github.com/v3/pulls/#list-pull-requests + /// + /// The ID of the repository + /// Options for changing the API response + /// A of s which are currently open + public Task> GetAllForRepository(int repositoryId, ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return GetAllForRepository(repositoryId, new PullRequestRequest(), options); + } + /// /// Query pull requests for the repository based on criteria /// @@ -86,6 +133,22 @@ namespace Octokit return GetAllForRepository(owner, name, request, ApiOptions.None); } + /// + /// Query pull requests for the repository based on criteria + /// + /// + /// http://developer.github.com/v3/pulls/#list-pull-requests + /// + /// The ID of the repository + /// Used to filter and sort the list of pull requests returned + /// A of s which match the criteria + public Task> GetAllForRepository(int repositoryId, PullRequestRequest request) + { + Ensure.ArgumentNotNull(request, "request"); + + return GetAllForRepository(repositoryId, request, ApiOptions.None); + } + /// /// Query pull requests for the repository based on criteria /// @@ -108,6 +171,25 @@ namespace Octokit request.ToParametersDictionary(), options); } + /// + /// Query pull requests for the repository based on criteria + /// + /// + /// http://developer.github.com/v3/pulls/#list-pull-requests + /// + /// The ID of the repository + /// Used to filter and sort the list of pull requests returned + /// Options for changing the API response + /// A of s which match the criteria + public Task> GetAllForRepository(int repositoryId, PullRequestRequest request, ApiOptions options) + { + Ensure.ArgumentNotNull(request, "request"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.PullRequests(repositoryId), + request.ToParametersDictionary(), options); + } + /// /// Create a pull request for the specified repository. /// @@ -125,6 +207,20 @@ namespace Octokit return ApiConnection.Post(ApiUrls.PullRequests(owner, name), newPullRequest); } + /// + /// Create a pull request for the specified repository. + /// + /// http://developer.github.com/v3/pulls/#create-a-pull-request + /// The ID of the repository + /// A instance describing the new PullRequest to create + /// A result which was created on the server + public Task Create(int repositoryId, NewPullRequest newPullRequest) + { + Ensure.ArgumentNotNull(newPullRequest, "newPullRequest"); + + return ApiConnection.Post(ApiUrls.PullRequests(repositoryId), newPullRequest); + } + /// /// Create a pull request for the specified repository. /// @@ -144,6 +240,22 @@ namespace Octokit return ApiConnection.Patch(ApiUrls.PullRequest(owner, name, number), pullRequestUpdate); } + /// + /// Create a pull request for the specified repository. + /// + /// http://developer.github.com/v3/pulls/#update-a-pull-request + /// The ID of the repository + /// The PullRequest number + /// An instance describing the changes to make to the PullRequest + /// + /// An updated result + public Task Update(int repositoryId, int number, PullRequestUpdate pullRequestUpdate) + { + Ensure.ArgumentNotNull(pullRequestUpdate, "pullRequestUpdate"); + + return ApiConnection.Patch(ApiUrls.PullRequest(repositoryId, number), pullRequestUpdate); + } + /// /// Merge a pull request. /// @@ -162,7 +274,41 @@ namespace Octokit try { var endpoint = ApiUrls.MergePullRequest(owner, name, number); - return await ApiConnection.Put(endpoint, mergePullRequest,null, + return await ApiConnection.Put(endpoint, mergePullRequest, null, + AcceptHeaders.SquashCommitPreview).ConfigureAwait(false); + } + catch (ApiException ex) + { + if (ex.StatusCode == HttpStatusCode.MethodNotAllowed) + { + throw new PullRequestNotMergeableException(ex.HttpResponse); + } + + if (ex.StatusCode == HttpStatusCode.Conflict) + { + throw new PullRequestMismatchException(ex.HttpResponse); + } + + throw; + } + } + + /// + /// Merge a pull request. + /// + /// http://developer.github.com/v3/pulls/#merge-a-pull-request-merge-buttontrade + /// The ID of the repository + /// The pull request number + /// A instance describing a pull request merge + /// An result which indicates the merge result + public async Task Merge(int repositoryId, int number, MergePullRequest mergePullRequest) + { + Ensure.ArgumentNotNull(mergePullRequest, "mergePullRequest"); + + try + { + var endpoint = ApiUrls.MergePullRequest(repositoryId, number); + return await ApiConnection.Put(endpoint, mergePullRequest, null, AcceptHeaders.SquashCommitPreview).ConfigureAwait(false); } catch (ApiException ex) @@ -206,6 +352,27 @@ namespace Octokit } } + /// + /// Get the pull request merge status. + /// + /// http://developer.github.com/v3/pulls/#get-if-a-pull-request-has-been-merged + /// The ID of the repository + /// The pull request number + /// True if the operation has been merged, false otherwise + public async Task Merged(int repositoryId, int number) + { + try + { + var endpoint = ApiUrls.MergePullRequest(repositoryId, number); + var response = await Connection.Get(endpoint, null, null).ConfigureAwait(false); + return response.HttpResponse.IsTrue(); + } + catch (NotFoundException) + { + return false; + } + } + /// /// Get the list of commits on a pull request. /// @@ -222,6 +389,18 @@ namespace Octokit return ApiConnection.GetAll(ApiUrls.PullRequestCommits(owner, name, number)); } + /// + /// Get the list of commits on a pull request. + /// + /// http://developer.github.com/v3/pulls/#list-commits-on-a-pull-request + /// The ID of the repository + /// The pull request number + /// A of s which are part of this pull request + public Task> Commits(int repositoryId, int number) + { + return ApiConnection.GetAll(ApiUrls.PullRequestCommits(repositoryId, number)); + } + /// /// Get the list of files on a pull request. /// @@ -237,5 +416,17 @@ namespace Octokit return ApiConnection.GetAll(ApiUrls.PullRequestFiles(owner, name, 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 + /// A which are part of this pull request + public Task> Files(int repositoryId, int number) + { + return ApiConnection.GetAll(ApiUrls.PullRequestFiles(repositoryId, number)); + } } }