From dfebfe31b6ef4b5a05545beee94bbeb00a1d0153 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Thu, 2 Jun 2016 11:21:30 +0200 Subject: [PATCH] Add ApiOption overloads to IIssuesClient and IObservableIssuesClient (#1274) --- .../Clients/IObservableIssuesClient.cs | 139 +++++++++-- .../Clients/ObservableIssuesClient.cs | 226 +++++++++++++++--- .../Clients/IssuesClientTests.cs | 84 +++++-- .../Reactive/ObservableIssuesClientTests.cs | 42 +++- Octokit.Tests/Clients/IssuesClientTests.cs | 139 +++++++++-- .../Reactive/ObservableIssuesClientTests.cs | 108 ++++++++- Octokit/Clients/IIssuesClient.cs | 127 +++++++++- Octokit/Clients/IssuesClient.cs | 187 +++++++++++++-- 8 files changed, 909 insertions(+), 143 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableIssuesClient.cs b/Octokit.Reactive/Clients/IObservableIssuesClient.cs index d9ca53a334..26efd33d5d 100644 --- a/Octokit.Reactive/Clients/IObservableIssuesClient.cs +++ b/Octokit.Reactive/Clients/IObservableIssuesClient.cs @@ -42,7 +42,7 @@ public interface IObservableIssuesClient /// The owner of the repository /// The name of the repository /// The issue number - /// + /// A signal containing the requested s. [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "Method makes a network request")] IObservable Get(string owner, string name, int number); @@ -55,9 +55,21 @@ public interface IObservableIssuesClient /// Issues are sorted by the create date descending. /// http://developer.github.com/v3/issues/#list-issues /// - /// + /// A signal containing one or more s. IObservable GetAllForCurrent(); + /// + /// Gets all open issues assigned to the authenticated user across all the authenticated user’s visible + /// repositories including owned repositories, member repositories, and organization repositories. + /// + /// Options for changing the API response + /// + /// Issues are sorted by the create date descending. + /// http://developer.github.com/v3/issues/#list-issues + /// + /// A signal containing one or more s. + IObservable GetAllForCurrent(ApiOptions options); + /// /// Gets all issues across all the authenticated user’s visible repositories including owned repositories, /// member repositories, and organization repositories. @@ -66,9 +78,21 @@ public interface IObservableIssuesClient /// http://developer.github.com/v3/issues/#list-issues /// /// Used to filter and sort the list of issues returned - /// + /// A signal containing one or more s. IObservable GetAllForCurrent(IssueRequest request); + /// + /// Gets all issues across all the authenticated user’s visible repositories including owned repositories, + /// member repositories, and organization repositories. + /// + /// + /// http://developer.github.com/v3/issues/#list-issues + /// + /// Used to filter and sort the list of issues returned + /// Options for changing the API response + /// A signal containing one or more s. + IObservable GetAllForCurrent(IssueRequest request, ApiOptions options); + /// /// Gets all open issues assigned to the authenticated user across owned and member repositories for the /// authenticated user. @@ -77,9 +101,21 @@ public interface IObservableIssuesClient /// Issues are sorted by the create date descending. /// http://developer.github.com/v3/issues/#list-issues /// - /// + /// A signal containing one or more s. IObservable GetAllForOwnedAndMemberRepositories(); + /// + /// Gets all open issues assigned to the authenticated user across owned and member repositories for the + /// authenticated user. + /// + /// Options for changing the API response + /// + /// Issues are sorted by the create date descending. + /// http://developer.github.com/v3/issues/#list-issues + /// + /// A signal containing one or more s. + IObservable GetAllForOwnedAndMemberRepositories(ApiOptions options); + /// /// Gets all issues across owned and member repositories for the authenticated user. /// @@ -87,9 +123,20 @@ public interface IObservableIssuesClient /// http://developer.github.com/v3/issues/#list-issues /// /// Used to filter and sort the list of issues returned - /// + /// A signal containing one or more s. IObservable GetAllForOwnedAndMemberRepositories(IssueRequest request); + /// + /// Gets all issues across owned and member repositories for the authenticated user. + /// + /// + /// http://developer.github.com/v3/issues/#list-issues + /// + /// Used to filter and sort the list of issues returned + /// Options for changing the API response + /// A signal containing one or more s. + IObservable GetAllForOwnedAndMemberRepositories(IssueRequest request, ApiOptions options); + /// /// Gets all open issues assigned to the authenticated user for a given organization for the authenticated user. /// @@ -97,9 +144,20 @@ public interface IObservableIssuesClient /// http://developer.github.com/v3/issues/#list-issues /// /// The name of the organization - /// + /// A signal containing one or more s. IObservable GetAllForOrganization(string organization); + /// + /// Gets all open issues assigned to the authenticated user for a given organization for the authenticated user. + /// + /// + /// http://developer.github.com/v3/issues/#list-issues + /// + /// The name of the organization + /// Options for changing the API response + /// A signal containing one or more s. + IObservable GetAllForOrganization(string organization, ApiOptions options); + /// /// Gets all issues for a given organization for the authenticated user. /// @@ -108,9 +166,21 @@ public interface IObservableIssuesClient /// /// The name of the organization /// Used to filter and sort the list of issues returned - /// + /// A signal containing one or more s. IObservable GetAllForOrganization(string organization, IssueRequest request); + /// + /// Gets all issues for a given organization for the authenticated user. + /// + /// + /// http://developer.github.com/v3/issues/#list-issues + /// + /// The name of the organization + /// Used to filter and sort the list of issues returned + /// Options for changing the API response + /// A signal containing one or more s. + IObservable GetAllForOrganization(string organization, IssueRequest request, ApiOptions options); + /// /// Gets all open issues assigned to the authenticated user for the repository. /// @@ -119,9 +189,21 @@ public interface IObservableIssuesClient /// /// The owner of the repository /// The name of the repository - /// + /// A signal containing one or more s. IObservable GetAllForRepository(string owner, string name); + /// + /// Gets all open issues assigned to the authenticated user for the repository. + /// + /// + /// http://developer.github.com/v3/issues/#list-issues-for-a-repository + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// A signal containing one or more s. + IObservable GetAllForRepository(string owner, string name, ApiOptions options); + /// /// Gets issues for a repository. /// @@ -131,9 +213,22 @@ public interface IObservableIssuesClient /// The owner of the repository /// The name of the repository /// Used to filter and sort the list of issues returned - /// + /// A signal containing one or more s. IObservable GetAllForRepository(string owner, string name, RepositoryIssueRequest request); + /// + /// Gets issues for a repository. + /// + /// + /// http://developer.github.com/v3/issues/#list-issues-for-a-repository + /// + /// The owner of the repository + /// The name of the repository + /// Used to filter and sort the list of issues returned + /// Options for changing the API response + /// A signal containing one or more s. + IObservable GetAllForRepository(string owner, string name, RepositoryIssueRequest request, ApiOptions options); + /// /// Creates an issue for the specified repository. Any user with pull access to a repository can create an /// issue. @@ -142,7 +237,7 @@ public interface IObservableIssuesClient /// The owner of the repository /// The name of the repository /// A instance describing the new issue to create - /// + /// A signal containing the new . IObservable Create(string owner, string name, NewIssue newIssue); /// @@ -155,18 +250,18 @@ public interface IObservableIssuesClient /// The issue number /// An instance describing the changes to make to the issue /// - /// + /// A signal containing the updated . IObservable Update(string owner, string name, int number, IssueUpdate issueUpdate); - - /// - /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. - /// - /// https://developer.github.com/v3/issues/#lock-an-issue - /// The owner of the repository - /// The name of the repository - /// The issue number - /// - IObservable Lock(string owner, string name, int number); + + /// + /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. + /// + /// https://developer.github.com/v3/issues/#lock-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// A signal indicating completion. + IObservable Lock(string owner, string name, int number); /// /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. @@ -175,7 +270,7 @@ public interface IObservableIssuesClient /// The owner of the repository /// The name of the repository /// The issue number - /// + /// A signal indicating completion. IObservable Unlock(string owner, string name, int number); } } \ No newline at end of file diff --git a/Octokit.Reactive/Clients/ObservableIssuesClient.cs b/Octokit.Reactive/Clients/ObservableIssuesClient.cs index 007b743db4..343c057d67 100644 --- a/Octokit.Reactive/Clients/ObservableIssuesClient.cs +++ b/Octokit.Reactive/Clients/ObservableIssuesClient.cs @@ -55,7 +55,7 @@ public ObservableIssuesClient(IGitHubClient client) /// The owner of the repository /// The name of the repository /// The issue number - /// + /// A signal containing the requested s. public IObservable Get(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); @@ -72,10 +72,27 @@ public IObservable Get(string owner, string name, int number) /// Issues are sorted by the create date descending. /// http://developer.github.com/v3/issues/#list-issues /// - /// + /// A signal containing one or more s. public IObservable GetAllForCurrent() { - return GetAllForCurrent(new IssueRequest()); + return GetAllForCurrent(ApiOptions.None); + } + + /// + /// Gets all open issues assigned to the authenticated user across all the authenticated user’s visible + /// repositories including owned repositories, member repositories, and organization repositories. + /// + /// Options for changing the API response + /// + /// Issues are sorted by the create date descending. + /// http://developer.github.com/v3/issues/#list-issues + /// + /// A signal containing one or more s. + public IObservable GetAllForCurrent(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return GetAllForCurrent(new IssueRequest(), options); } /// @@ -86,12 +103,30 @@ public IObservable GetAllForCurrent() /// http://developer.github.com/v3/issues/#list-issues /// /// Used to filter and sort the list of issues returned - /// + /// A signal containing one or more s. public IObservable GetAllForCurrent(IssueRequest request) { Ensure.ArgumentNotNull(request, "request"); - return _connection.GetAndFlattenAllPages(ApiUrls.Issues(), request.ToParametersDictionary()); + return GetAllForCurrent(request, ApiOptions.None); + } + + /// + /// Gets all issues across all the authenticated user’s visible repositories including owned repositories, + /// member repositories, and organization repositories. + /// + /// + /// http://developer.github.com/v3/issues/#list-issues + /// + /// Used to filter and sort the list of issues returned + /// Options for changing the API response + /// A signal containing one or more s. + public IObservable GetAllForCurrent(IssueRequest request, ApiOptions options) + { + Ensure.ArgumentNotNull(request, "request"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.Issues(), request.ToParametersDictionary(), options); } /// @@ -102,12 +137,29 @@ public IObservable GetAllForCurrent(IssueRequest request) /// Issues are sorted by the create date descending. /// http://developer.github.com/v3/issues/#list-issues /// - /// + /// A signal containing one or more s. public IObservable GetAllForOwnedAndMemberRepositories() { return GetAllForOwnedAndMemberRepositories(new IssueRequest()); } + /// + /// Gets all open issues assigned to the authenticated user across owned and member repositories for the + /// authenticated user. + /// + /// + /// Issues are sorted by the create date descending. + /// http://developer.github.com/v3/issues/#list-issues + /// + /// Options for changing the API response + /// A signal containing one or more s. + public IObservable GetAllForOwnedAndMemberRepositories(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return GetAllForOwnedAndMemberRepositories(new IssueRequest(), options); + } + /// /// Gets all issues across owned and member repositories for the authenticated user. /// @@ -115,12 +167,29 @@ public IObservable GetAllForOwnedAndMemberRepositories() /// http://developer.github.com/v3/issues/#list-issues /// /// Used to filter and sort the list of issues returned - /// + /// A signal containing one or more s. public IObservable GetAllForOwnedAndMemberRepositories(IssueRequest request) { Ensure.ArgumentNotNull(request, "request"); - return _connection.GetAndFlattenAllPages(ApiUrls.IssuesForOwnedAndMember(), request.ToParametersDictionary()); + return GetAllForOwnedAndMemberRepositories(request, ApiOptions.None); + } + + /// + /// Gets all issues across owned and member repositories for the authenticated user. + /// + /// + /// http://developer.github.com/v3/issues/#list-issues + /// + /// Used to filter and sort the list of issues returned + /// Options for changing the API response + /// A signal containing one or more s. + public IObservable GetAllForOwnedAndMemberRepositories(IssueRequest request, ApiOptions options) + { + Ensure.ArgumentNotNull(request, "request"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.IssuesForOwnedAndMember(), request.ToParametersDictionary(), options); } /// @@ -130,10 +199,29 @@ public IObservable GetAllForOwnedAndMemberRepositories(IssueRequest reque /// http://developer.github.com/v3/issues/#list-issues /// /// The name of the organization - /// + /// A signal containing one or more s. public IObservable GetAllForOrganization(string organization) { - return GetAllForOrganization(organization, new IssueRequest()); + Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); + + return GetAllForOrganization(organization, ApiOptions.None); + } + + /// + /// Gets all open issues assigned to the authenticated user for a given organization for the authenticated user. + /// + /// + /// http://developer.github.com/v3/issues/#list-issues + /// + /// The name of the organization + /// Options for changing the API response + /// A signal containing one or more s. + public IObservable GetAllForOrganization(string organization, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); + Ensure.ArgumentNotNull(options, "options"); + + return GetAllForOrganization(organization, new IssueRequest(), options); } /// @@ -144,13 +232,32 @@ public IObservable GetAllForOrganization(string organization) /// /// The name of the organization /// Used to filter and sort the list of issues returned - /// + /// A signal containing one or more s. public IObservable GetAllForOrganization(string organization, IssueRequest request) { Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); Ensure.ArgumentNotNull(request, "request"); - return _connection.GetAndFlattenAllPages(ApiUrls.Issues(organization), request.ToParametersDictionary()); + return GetAllForOrganization(organization, request, ApiOptions.None); + } + + /// + /// Gets all issues for a given organization for the authenticated user. + /// + /// + /// http://developer.github.com/v3/issues/#list-issues + /// + /// The name of the organization + /// Used to filter and sort the list of issues returned + /// Options for changing the API response + /// A signal containing one or more s. + public IObservable GetAllForOrganization(string organization, IssueRequest request, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); + Ensure.ArgumentNotNull(request, "request"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.Issues(organization), request.ToParametersDictionary(), options); } /// @@ -161,10 +268,32 @@ public IObservable GetAllForOrganization(string organization, IssueReques /// /// The owner of the repository /// The name of the repository - /// + /// A signal containing one or more s. public IObservable GetAllForRepository(string owner, string name) { - return GetAllForRepository(owner, name, new RepositoryIssueRequest()); + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return GetAllForRepository(owner, name, ApiOptions.None); + } + + /// + /// Gets all open issues assigned to the authenticated user for the repository. + /// + /// + /// http://developer.github.com/v3/issues/#list-issues-for-a-repository + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// A signal containing one or more s. + public IObservable GetAllForRepository(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + + return GetAllForRepository(owner, name, new RepositoryIssueRequest(), options); } /// @@ -176,14 +305,35 @@ public IObservable GetAllForRepository(string owner, string name) /// The owner of the repository /// The name of the repository /// Used to filter and sort the list of issues returned - /// + /// A signal containing one or more s. public IObservable GetAllForRepository(string owner, string name, RepositoryIssueRequest request) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(request, "request"); - return _connection.GetAndFlattenAllPages(ApiUrls.Issues(owner, name), request.ToParametersDictionary()); + return GetAllForRepository(owner, name, request, ApiOptions.None); + } + + /// + /// Gets issues for a repository. + /// + /// + /// http://developer.github.com/v3/issues/#list-issues-for-a-repository + /// + /// The owner of the repository + /// The name of the repository + /// Used to filter and sort the list of issues returned + /// Options for changing the API response + /// A signal containing one or more s. + public IObservable GetAllForRepository(string owner, string name, RepositoryIssueRequest request, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(request, "request"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.Issues(owner, name), request.ToParametersDictionary(), options); } /// @@ -194,7 +344,7 @@ public IObservable GetAllForRepository(string owner, string name, Reposit /// The owner of the repository /// The name of the repository /// A instance describing the new issue to create - /// + /// A signal containing the new . public IObservable Create(string owner, string name, NewIssue newIssue) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); @@ -214,7 +364,7 @@ public IObservable Create(string owner, string name, NewIssue newIssue) /// The issue number /// An instance describing the changes to make to the issue /// - /// + /// A signal containing the updated . public IObservable Update(string owner, string name, int number, IssueUpdate issueUpdate) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); @@ -223,32 +373,32 @@ public IObservable Update(string owner, string name, int number, IssueUpd return _client.Update(owner, name, number, issueUpdate).ToObservable(); } - - /// - /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. - /// - /// https://developer.github.com/v3/issues/#lock-an-issue - /// The owner of the repository - /// The name of the repository - /// The issue number - /// - public IObservable Lock(string owner, string name, int number) + + /// + /// Locks an issue for the specified repository. Issue owners and users with push access can lock an issue. + /// + /// https://developer.github.com/v3/issues/#lock-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// A signal indicating completion. + public IObservable Lock(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); return _client.Lock(owner, name, number).ToObservable(); } - - /// - /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. - /// - /// https://developer.github.com/v3/issues/#unlock-an-issue - /// The owner of the repository - /// The name of the repository - /// The issue number - /// - public IObservable Unlock(string owner, string name, int number) + + /// + /// Unlocks an issue for the specified repository. Issue owners and users with push access can unlock an issue. + /// + /// https://developer.github.com/v3/issues/#unlock-an-issue + /// The owner of the repository + /// The name of the repository + /// The issue number + /// A signal indicating completion. + public IObservable Unlock(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); diff --git a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs index eb12698cd1..8d07644856 100644 --- a/Octokit.Tests.Integration/Clients/IssuesClientTests.cs +++ b/Octokit.Tests.Integration/Clients/IssuesClientTests.cs @@ -1,13 +1,11 @@ using System; using System.Globalization; using System.Linq; -using System.Threading; using System.Threading.Tasks; using Octokit; using Octokit.Tests.Integration; -using Xunit; using Octokit.Tests.Integration.Helpers; -using System.Collections.Generic; +using Xunit; public class IssuesClientTests : IDisposable { @@ -29,15 +27,64 @@ public async Task CanDeserializeIssue() const string description = "A new unassigned issue"; var newIssue = new NewIssue(title) { Body = description }; var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue); + + Assert.True(issue.Id > 0); + Assert.False(issue.Locked); + Assert.Equal(title, issue.Title); + Assert.Equal(description, issue.Body); + var retrieved = await _issuesClient.Get(_context.RepositoryOwner, _context.RepositoryName, issue.Number); - Assert.NotNull(retrieved); - Assert.NotEqual(0, issue.Id); - Assert.Equal(false, issue.Locked); + Assert.True(retrieved.Id > 0); + Assert.False(retrieved.Locked); Assert.Equal(title, retrieved.Title); Assert.Equal(description, retrieved.Body); } + [IntegrationTest] + public async Task ReturnsPageOfIssuesForARepository() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var issues = await _issuesClient.GetAllForRepository("libgit2", "libgit2sharp", options); + + Assert.Equal(5, issues.Count); + } + + [IntegrationTest] + public async Task ReturnsPageOfIssuesFromStartForARepository() + { + var first = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstPage = await _issuesClient.GetAllForRepository("libgit2", "libgit2sharp", first); + + var second = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondPage = await _issuesClient.GetAllForRepository("libgit2", "libgit2sharp", second); + + Assert.Equal(5, firstPage.Count); + Assert.Equal(5, secondPage.Count); + + Assert.NotEqual(firstPage[0].Id, secondPage[0].Id); + Assert.NotEqual(firstPage[1].Id, secondPage[1].Id); + Assert.NotEqual(firstPage[2].Id, secondPage[2].Id); + Assert.NotEqual(firstPage[3].Id, secondPage[3].Id); + Assert.NotEqual(firstPage[4].Id, secondPage[4].Id); + } + [IntegrationTest] public async Task CanCreateRetrieveAndCloseIssue() { @@ -54,9 +101,7 @@ public async Task CanCreateRetrieveAndCloseIssue() } finally { - var closed = _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, - new IssueUpdate { State = ItemState.Closed }) - .Result; + var closed = _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue.Number, new IssueUpdate { State = ItemState.Closed }).Result; Assert.NotNull(closed); } } @@ -87,9 +132,10 @@ public async Task CanListOpenIssuesWithDefaultSort() var newIssue3 = new NewIssue("A test issue3") { Body = "A new unassigned issue" }; var newIssue4 = new NewIssue("A test issue4") { Body = "A new unassigned issue" }; await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue1); - Thread.Sleep(1000); + + await Task.Delay(1000); await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue2); - Thread.Sleep(1000); + await Task.Delay(1000); await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue3); var closed = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue4); await _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, closed.Number, @@ -111,9 +157,9 @@ public async Task CanListIssuesWithAscendingSort() var newIssue3 = new NewIssue("A test issue3") { Body = "A new unassigned issue" }; var newIssue4 = new NewIssue("A test issue4") { Body = "A new unassigned issue" }; await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue1); - Thread.Sleep(1000); + await Task.Delay(1000); await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue2); - Thread.Sleep(1000); + await Task.Delay(1000); await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue3); var closed = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue4); await _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, closed.Number, @@ -162,7 +208,7 @@ public async Task CanListMilestoneIssues() Assert.Equal("A milestone issue", issues[0].Title); } - [IntegrationTest(Skip = "This is paging for a long long time")] + [IntegrationTest] public async Task CanRetrieveAllIssues() { var newIssue1 = new NewIssue("A test issue1") { Body = "A new unassigned issue" }; @@ -173,13 +219,13 @@ public async Task CanRetrieveAllIssues() var issue2 = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue2); var issue3 = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue3); var issue4 = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, newIssue4); - await _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue4.Number, - new IssueUpdate { State = ItemState.Closed }); + await _issuesClient.Update(_context.RepositoryOwner, _context.RepositoryName, issue4.Number, new IssueUpdate { State = ItemState.Closed }); + + var request = new RepositoryIssueRequest { State = ItemStateFilter.All }; - var retrieved = await _issuesClient.GetAllForRepository(_context.RepositoryOwner, _context.RepositoryName, - new RepositoryIssueRequest { }); + var retrieved = await _issuesClient.GetAllForRepository(_context.RepositoryOwner, _context.RepositoryName, request); - Assert.True(retrieved.Count >= 4); + Assert.Equal(4, retrieved.Count); Assert.True(retrieved.Any(i => i.Number == issue1.Number)); Assert.True(retrieved.Any(i => i.Number == issue2.Number)); Assert.True(retrieved.Any(i => i.Number == issue3.Number)); diff --git a/Octokit.Tests.Integration/Reactive/ObservableIssuesClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableIssuesClientTests.cs index 9c6acf9885..dc195ee123 100644 --- a/Octokit.Tests.Integration/Reactive/ObservableIssuesClientTests.cs +++ b/Octokit.Tests.Integration/Reactive/ObservableIssuesClientTests.cs @@ -33,11 +33,47 @@ public async Task ReturnsSpecifiedIssue() } [IntegrationTest] - public async Task ReturnsAllIssuesForARepository() + public async Task ReturnsPageOfIssuesForARepository() { - var issues = await _client.GetAllForRepository("libgit2", "libgit2sharp").ToList(); + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; - Assert.NotEmpty(issues); + var issues = await _client.GetAllForRepository("libgit2", "libgit2sharp", options).ToList(); + + Assert.Equal(5, issues.Count); + } + + [IntegrationTest] + public async Task ReturnsPageOfIssuesFromStartForARepository() + { + var first = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstPage = await _client.GetAllForRepository("libgit2", "libgit2sharp", first).ToList(); + + var second = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondPage = await _client.GetAllForRepository("libgit2", "libgit2sharp", second).ToList(); + + Assert.Equal(5, firstPage.Count); + Assert.Equal(5, secondPage.Count); + + Assert.NotEqual(firstPage[0].Id, secondPage[0].Id); + Assert.NotEqual(firstPage[1].Id, secondPage[1].Id); + Assert.NotEqual(firstPage[2].Id, secondPage[2].Id); + Assert.NotEqual(firstPage[3].Id, secondPage[3].Id); + Assert.NotEqual(firstPage[4].Id, secondPage[4].Id); } [IntegrationTest] diff --git a/Octokit.Tests/Clients/IssuesClientTests.cs b/Octokit.Tests/Clients/IssuesClientTests.cs index 9dbe0436a5..131f6ac5c3 100644 --- a/Octokit.Tests/Clients/IssuesClientTests.cs +++ b/Octokit.Tests/Clients/IssuesClientTests.cs @@ -35,6 +35,17 @@ public async Task EnsuresNonNullArguments() public class TheGetAllForCurrentMethod { + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new IssuesClient(Substitute.For()); + + await Assert.ThrowsAsync(() => client.GetAllForCurrent((ApiOptions)null)); + await Assert.ThrowsAsync(() => client.GetAllForCurrent((IssueRequest)null)); + await Assert.ThrowsAsync(() => client.GetAllForCurrent(null, new ApiOptions())); + await Assert.ThrowsAsync(() => client.GetAllForCurrent(new IssueRequest(), null)); + } + [Fact] public void RequestsCorrectUrl() { @@ -44,7 +55,7 @@ public void RequestsCorrectUrl() client.GetAllForCurrent(); connection.Received().GetAll(Arg.Is(u => u.ToString() == "issues"), - Arg.Any>()); + Arg.Any>(), Args.ApiOptions); } [Fact] @@ -60,12 +71,24 @@ public void SendsAppropriateParameters() && d["filter"] == "assigned" && d["sort"] == "created" && d["state"] == "open" - && d["direction"] == "asc")); + && d["direction"] == "asc"), + Args.ApiOptions); } } public class TheGetAllForOwnedAndMemberRepositoriesMethod { + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new IssuesClient(Substitute.For()); + + await Assert.ThrowsAsync(() => client.GetAllForOwnedAndMemberRepositories((ApiOptions)null)); + await Assert.ThrowsAsync(() => client.GetAllForOwnedAndMemberRepositories((IssueRequest)null)); + await Assert.ThrowsAsync(() => client.GetAllForOwnedAndMemberRepositories(null, new ApiOptions())); + await Assert.ThrowsAsync(() => client.GetAllForOwnedAndMemberRepositories(new IssueRequest(), null)); + } + [Fact] public void RequestsCorrectUrl() { @@ -75,22 +98,49 @@ public void RequestsCorrectUrl() client.GetAllForOwnedAndMemberRepositories(); connection.Received().GetAll(Arg.Is(u => u.ToString() == "user/issues"), - Arg.Any>()); + Arg.Any>(), + Args.ApiOptions); } } - public class TheGetForRepositoryMethod + public class TheGetAllForOrganizationMethod { + [Fact] + public async Task EnsuresArgumentsNotNull() + { + var client = new IssuesClient(Substitute.For()); + + var options = new ApiOptions(); + var request = new RepositoryIssueRequest(); + + await Assert.ThrowsAsync(() => client.GetAllForOrganization(null)); + await Assert.ThrowsAsync(() => client.GetAllForOrganization(null, options)); + await Assert.ThrowsAsync(() => client.GetAllForOrganization(null, request)); + await Assert.ThrowsAsync(() => client.GetAllForOrganization(null, request, options)); + + await Assert.ThrowsAsync(() => client.GetAllForOrganization("")); + await Assert.ThrowsAsync(() => client.GetAllForOrganization("", options)); + await Assert.ThrowsAsync(() => client.GetAllForOrganization("", request)); + await Assert.ThrowsAsync(() => client.GetAllForOrganization("", request, options)); + + await Assert.ThrowsAsync(() => client.GetAllForOrganization("org", (ApiOptions)null)); + await Assert.ThrowsAsync(() => client.GetAllForOrganization("org", (IssueRequest)null)); + + await Assert.ThrowsAsync(() => client.GetAllForOrganization("org", null, options)); + await Assert.ThrowsAsync(() => client.GetAllForOrganization("org", request, null)); + } + [Fact] public void RequestsCorrectUrl() { var connection = Substitute.For(); var client = new IssuesClient(connection); - client.GetAllForRepository("fake", "repo"); + client.GetAllForOrganization("fake"); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues"), - Arg.Any>()); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "orgs/fake/issues"), + Arg.Any>(), + Args.ApiOptions); } [Fact] @@ -99,30 +149,89 @@ public void SendsAppropriateParameters() var connection = Substitute.For(); var client = new IssuesClient(connection); - client.GetAllForRepository("fake", "repo", new RepositoryIssueRequest + client.GetAllForOrganization("fake", new RepositoryIssueRequest { SortDirection = SortDirection.Ascending }); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues"), + connection.Received().GetAll(Arg.Is(u => u.ToString() == "orgs/fake/issues"), Arg.Is>(d => d.Count == 4 && d["state"] == "open" && d["direction"] == "asc" && d["sort"] == "created" - && d["filter"] == "assigned")); + && d["filter"] == "assigned"), + Args.ApiOptions); } + } + public class TheGetAllForRepositoryMethod + { [Fact] public async Task EnsuresArgumentsNotNull() + { + var client = new IssuesClient(Substitute.For()); + + var options = new ApiOptions(); + var request = new RepositoryIssueRequest(); + + await Assert.ThrowsAsync(() => client.GetAllForRepository(null, "name")); + await Assert.ThrowsAsync(() => client.GetAllForRepository(null, "name", options)); + await Assert.ThrowsAsync(() => client.GetAllForRepository(null, "name", request)); + await Assert.ThrowsAsync(() => client.GetAllForRepository(null, "name", request, options)); + + await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name")); + await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name", options)); + await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name", request)); + await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name", request, options)); + + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", null)); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", null, options)); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", null, request)); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", null, request, options)); + + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "")); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "", options)); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "", request)); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "", request, options)); + + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "name", (ApiOptions)null)); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "name", (RepositoryIssueRequest)null)); + + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "name", null, options)); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "name", request, null)); + } + + [Fact] + public void RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new IssuesClient(connection); + + client.GetAllForRepository("fake", "repo"); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues"), + Arg.Any>(), + Args.ApiOptions); + } + + [Fact] + public void SendsAppropriateParameters() { var connection = Substitute.For(); var client = new IssuesClient(connection); - await Assert.ThrowsAsync(() => client.GetAllForRepository(null, "name", new RepositoryIssueRequest())); - await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name", new RepositoryIssueRequest())); - await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", null, new RepositoryIssueRequest())); - await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "", new RepositoryIssueRequest())); - await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "name", null)); + client.GetAllForRepository("fake", "repo", new RepositoryIssueRequest + { + SortDirection = SortDirection.Ascending + }); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/issues"), + Arg.Is>(d => d.Count == 4 + && d["state"] == "open" + && d["direction"] == "asc" + && d["sort"] == "created" + && d["filter"] == "assigned"), + Args.ApiOptions); } } diff --git a/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs b/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs index c063e5d451..0360cac12d 100644 --- a/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableIssuesClientTests.cs @@ -36,8 +36,43 @@ public async Task EnsuresNonNullArguments() } } - public class TheGetForRepositoryMethod + public class TheGetAllForRepositoryMethod { + [Fact] + public async Task EnsuresArgumentsNotNull() + { + var client = new ObservableIssuesClient(Substitute.For()); + + var options = new ApiOptions(); + var request = new RepositoryIssueRequest(); + + await Assert.ThrowsAsync(() => client.GetAllForRepository(null, "name").ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForRepository(null, "name", options).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForRepository(null, "name", request).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForRepository(null, "name", request, options).ToTask()); + + await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name").ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name", options).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name", request).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name", request, options).ToTask()); + + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", null).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", null, options).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", null, request).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", null, request, options).ToTask()); + + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "").ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "", options).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "", request).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "", request, options).ToTask()); + + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "name", (ApiOptions)null).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "name", (RepositoryIssueRequest)null).ToTask()); + + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "name", null, options).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "name", request, null).ToTask()); + } + [Fact] public async Task ReturnsEveryPageOfIssues() { @@ -82,9 +117,9 @@ public async Task ReturnsEveryPageOfIssues() && d["sort"] == "created" && d["filter"] == "assigned"), Arg.Any()) .Returns(Task.Factory.StartNew>>(() => firstPageResponse)); - gitHubClient.Connection.Get>(secondPageUrl, null, null) + gitHubClient.Connection.Get>(secondPageUrl, Arg.Any>(), null) .Returns(Task.Factory.StartNew>>(() => secondPageResponse)); - gitHubClient.Connection.Get>(thirdPageUrl, null, null) + gitHubClient.Connection.Get>(thirdPageUrl, Arg.Any>(), null) .Returns(Task.Factory.StartNew>>(() => lastPageResponse)); var client = new ObservableIssuesClient(gitHubClient); @@ -99,6 +134,21 @@ public async Task ReturnsEveryPageOfIssues() public class TheGetAllForOwnedAndMemberRepositoriesMethod { + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ObservableIssuesClient(Substitute.For()); + + await Assert.ThrowsAsync( + () => client.GetAllForOwnedAndMemberRepositories((ApiOptions)null).ToTask()); + await Assert.ThrowsAsync( + () => client.GetAllForOwnedAndMemberRepositories((IssueRequest)null).ToTask()); + await Assert.ThrowsAsync( + () => client.GetAllForOwnedAndMemberRepositories(null, new ApiOptions()).ToTask()); + await Assert.ThrowsAsync( + () => client.GetAllForOwnedAndMemberRepositories(new IssueRequest(), null).ToTask()); + } + [Fact] public async Task ReturnsEveryPageOfIssues() { @@ -141,11 +191,12 @@ public async Task ReturnsEveryPageOfIssues() && d["direction"] == "desc" && d["state"] == "open" && d["sort"] == "created" - && d["filter"] == "assigned"), Arg.Any()) + && d["filter"] == "assigned"), + Arg.Any()) .Returns(Task.Factory.StartNew>>(() => firstPageResponse)); - gitHubClient.Connection.Get>(secondPageUrl, null, null) + gitHubClient.Connection.Get>(secondPageUrl, Arg.Any>(), null) .Returns(Task.Factory.StartNew>>(() => secondPageResponse)); - gitHubClient.Connection.Get>(thirdPageUrl, null, null) + gitHubClient.Connection.Get>(thirdPageUrl, Arg.Any>(), null) .Returns(Task.Factory.StartNew>>(() => lastPageResponse)); var client = new ObservableIssuesClient(gitHubClient); @@ -160,6 +211,31 @@ public async Task ReturnsEveryPageOfIssues() public class TheGetAllForOrganizationMethod { + [Fact] + public async Task EnsuresArgumentsNotNull() + { + var client = new ObservableIssuesClient(Substitute.For()); + + var options = new ApiOptions(); + var request = new RepositoryIssueRequest(); + + await Assert.ThrowsAsync(() => client.GetAllForOrganization(null).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForOrganization(null, options).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForOrganization(null, request).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForOrganization(null, request, options).ToTask()); + + await Assert.ThrowsAsync(() => client.GetAllForOrganization("").ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForOrganization("", options).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForOrganization("", request).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForOrganization("", request, options).ToTask()); + + await Assert.ThrowsAsync(() => client.GetAllForOrganization("org", (ApiOptions)null).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForOrganization("org", (IssueRequest)null).ToTask()); + + await Assert.ThrowsAsync(() => client.GetAllForOrganization("org", null, options).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForOrganization("org", request, null).ToTask()); + } + [Fact] public async Task ReturnsEveryPageOfIssues() { @@ -204,10 +280,11 @@ public async Task ReturnsEveryPageOfIssues() && d["sort"] == "created" && d["filter"] == "assigned"), Arg.Any()) .Returns(Task.Factory.StartNew>>(() => firstPageResponse)); - gitHubClient.Connection.Get>(secondPageUrl, null, null) + gitHubClient.Connection.Get>(secondPageUrl, Arg.Any>(), null) .Returns(Task.Factory.StartNew>>(() => secondPageResponse)); - gitHubClient.Connection.Get>(thirdPageUrl, null, null) + gitHubClient.Connection.Get>(thirdPageUrl, Arg.Any>(), null) .Returns(Task.Factory.StartNew>>(() => lastPageResponse)); + var client = new ObservableIssuesClient(gitHubClient); var results = await client.GetAllForOrganization("test").ToArray(); @@ -221,6 +298,17 @@ public async Task ReturnsEveryPageOfIssues() public class TheGetAllForCurrentMethod { + [Fact] + public async Task EnsuresNonNullArguments() + { + var client = new ObservableIssuesClient(Substitute.For()); + + await Assert.ThrowsAsync(() => client.GetAllForCurrent((ApiOptions)null).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForCurrent((IssueRequest)null).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForCurrent(null, new ApiOptions()).ToTask()); + await Assert.ThrowsAsync(() => client.GetAllForCurrent(new IssueRequest(), null).ToTask()); + } + [Fact] public async Task ReturnsEveryPageOfIssues() { @@ -265,9 +353,9 @@ public async Task ReturnsEveryPageOfIssues() && d["sort"] == "created" && d["filter"] == "assigned"), Arg.Any()) .Returns(Task.Factory.StartNew>>(() => firstPageResponse)); - gitHubClient.Connection.Get>(secondPageUrl, null, null) + gitHubClient.Connection.Get>(secondPageUrl, Arg.Any>(), null) .Returns(Task.Factory.StartNew>>(() => secondPageResponse)); - gitHubClient.Connection.Get>(thirdPageUrl, null, null) + gitHubClient.Connection.Get>(thirdPageUrl, Arg.Any>(), null) .Returns(Task.Factory.StartNew>>(() => lastPageResponse)); var client = new ObservableIssuesClient(gitHubClient); diff --git a/Octokit/Clients/IIssuesClient.cs b/Octokit/Clients/IIssuesClient.cs index bea894bfdf..e830086bc0 100644 --- a/Octokit/Clients/IIssuesClient.cs +++ b/Octokit/Clients/IIssuesClient.cs @@ -48,7 +48,7 @@ public interface IIssuesClient /// The owner of the repository /// The name of the repository /// The issue number - /// + /// The created representing requesting the issue from the API. [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", Justification = "Method makes a network request")] Task Get(string owner, string name, int number); @@ -61,9 +61,21 @@ public interface IIssuesClient /// Issues are sorted by the create date descending. /// http://developer.github.com/v3/issues/#list-issues /// - /// + /// The created representing requesting a list of issue from the API. Task> GetAllForCurrent(); + /// + /// Gets all open issues assigned to the authenticated user across all the authenticated user’s visible + /// repositories including owned repositories, member repositories, and organization repositories. + /// + /// Options for changing the API response + /// + /// Issues are sorted by the create date descending. + /// http://developer.github.com/v3/issues/#list-issues + /// + /// The created representing requesting a list of issue from the API. + Task> GetAllForCurrent(ApiOptions options); + /// /// Gets all issues across all the authenticated user’s visible repositories including owned repositories, /// member repositories, and organization repositories. @@ -72,9 +84,23 @@ public interface IIssuesClient /// http://developer.github.com/v3/issues/#list-issues /// /// Used to filter and sort the list of issues returned - /// + /// The created representing requesting a list of issue from the API. + Task> GetAllForCurrent(IssueRequest request); + /// + /// Gets all issues across all the authenticated user’s visible repositories including owned repositories, + /// member repositories, and organization repositories. + /// + /// Options for changing the API response + /// + /// http://developer.github.com/v3/issues/#list-issues + /// + /// Used to filter and sort the list of issues returned + /// The created representing requesting a list of issue from the API. + + Task> GetAllForCurrent(IssueRequest request, ApiOptions options); + /// /// Gets all open issues assigned to the authenticated user across owned and member repositories for the /// authenticated user. @@ -83,9 +109,23 @@ public interface IIssuesClient /// Issues are sorted by the create date descending. /// http://developer.github.com/v3/issues/#list-issues /// - /// + /// The created representing requesting a list of issue from the API. + Task> GetAllForOwnedAndMemberRepositories(); + /// + /// Gets all open issues assigned to the authenticated user across owned and member repositories for the + /// authenticated user. + /// + /// Options for changing the API response + /// + /// Issues are sorted by the create date descending. + /// http://developer.github.com/v3/issues/#list-issues + /// + /// The created representing requesting a list of issue from the API. + + Task> GetAllForOwnedAndMemberRepositories(ApiOptions options); + /// /// Gets all issues across owned and member repositories for the authenticated user. /// @@ -93,9 +133,22 @@ public interface IIssuesClient /// http://developer.github.com/v3/issues/#list-issues /// /// Used to filter and sort the list of issues returned - /// + /// The created representing requesting a list of issue from the API. + Task> GetAllForOwnedAndMemberRepositories(IssueRequest request); + /// + /// Gets all issues across owned and member repositories for the authenticated user. + /// + /// + /// http://developer.github.com/v3/issues/#list-issues + /// + /// Used to filter and sort the list of issues returned + /// Options for changing the API response + /// The created representing requesting a list of issue from the API. + + Task> GetAllForOwnedAndMemberRepositories(IssueRequest request, ApiOptions options); + /// /// Gets all open issues assigned to the authenticated user for a given organization for the authenticated user. /// @@ -103,9 +156,20 @@ public interface IIssuesClient /// http://developer.github.com/v3/issues/#list-issues /// /// The name of the organization - /// + /// The created representing requesting a list of issue from the API. Task> GetAllForOrganization(string organization); + /// + /// Gets all open issues assigned to the authenticated user for a given organization for the authenticated user. + /// + /// + /// http://developer.github.com/v3/issues/#list-issues + /// + /// The name of the organization + /// Options for changing the API response + /// The created representing requesting a list of issue from the API. + Task> GetAllForOrganization(string organization, ApiOptions options); + /// /// Gets all issues for a given organization for the authenticated user. /// @@ -114,9 +178,21 @@ public interface IIssuesClient /// /// The name of the organization /// Used to filter and sort the list of issues returned - /// + /// The created representing requesting a list of issue from the API. Task> GetAllForOrganization(string organization, IssueRequest request); + /// + /// Gets all issues for a given organization for the authenticated user. + /// + /// + /// http://developer.github.com/v3/issues/#list-issues + /// + /// The name of the organization + /// Used to filter and sort the list of issues returned + /// Options for changing the API response + /// The created representing requesting a list of issue from the API. + Task> GetAllForOrganization(string organization, IssueRequest request, ApiOptions options); + /// /// Gets all open issues assigned to the authenticated user for the repository. /// @@ -125,9 +201,21 @@ public interface IIssuesClient /// /// The owner of the repository /// The name of the repository - /// + /// The created representing requesting a list of issue from the API. Task> GetAllForRepository(string owner, string name); + /// + /// Gets all open issues assigned to the authenticated user for the repository. + /// + /// + /// http://developer.github.com/v3/issues/#list-issues-for-a-repository + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// The created representing requesting a list of issue from the API. + Task> GetAllForRepository(string owner, string name, ApiOptions options); + /// /// Gets issues for a repository. /// @@ -137,9 +225,22 @@ public interface IIssuesClient /// The owner of the repository /// The name of the repository /// Used to filter and sort the list of issues returned - /// + /// The created representing requesting a list of issue from the API. Task> GetAllForRepository(string owner, string name, RepositoryIssueRequest request); + /// + /// Gets issues for a repository. + /// + /// + /// http://developer.github.com/v3/issues/#list-issues-for-a-repository + /// + /// The owner of the repository + /// The name of the repository + /// Used to filter and sort the list of issues returned + /// Options for changing the API response + /// The created representing requesting a list of issue from the API. + Task> GetAllForRepository(string owner, string name, RepositoryIssueRequest request, ApiOptions options); + /// /// Creates an issue for the specified repository. Any user with pull access to a repository can create an /// issue. @@ -148,7 +249,7 @@ public interface IIssuesClient /// The owner of the repository /// The name of the repository /// A instance describing the new issue to create - /// + /// The created representing the new issue from the API. Task Create(string owner, string name, NewIssue newIssue); /// @@ -161,7 +262,7 @@ public interface IIssuesClient /// The issue number /// An instance describing the changes to make to the issue /// - /// + /// The created representing the updated issue from the API. Task Update(string owner, string name, int number, IssueUpdate issueUpdate); /// @@ -171,7 +272,7 @@ public interface IIssuesClient /// The owner of the repository /// The name of the repository /// The issue number - /// + /// The created representing accessing the API. Task Lock(string owner, string name, int number); /// @@ -181,7 +282,7 @@ public interface IIssuesClient /// The owner of the repository /// The name of the repository /// The issue number - /// + /// The created representing accessing the API. Task Unlock(string owner, string name, int number); } } diff --git a/Octokit/Clients/IssuesClient.cs b/Octokit/Clients/IssuesClient.cs index 4757c01403..690e17ebde 100644 --- a/Octokit/Clients/IssuesClient.cs +++ b/Octokit/Clients/IssuesClient.cs @@ -56,7 +56,7 @@ public IssuesClient(IApiConnection apiConnection) : base(apiConnection) /// The owner of the repository /// The name of the repository /// The issue number - /// + /// The created representing requesting the issue from the API. public Task Get(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); @@ -73,10 +73,27 @@ public Task Get(string owner, string name, int number) /// Issues are sorted by the create date descending. /// http://developer.github.com/v3/issues/#list-issues /// - /// + /// The created representing requesting a list of issue from the API. public Task> GetAllForCurrent() { - return GetAllForCurrent(new IssueRequest()); + return GetAllForCurrent(ApiOptions.None); + } + + /// + /// Gets all open issues assigned to the authenticated user across all the authenticated user’s visible + /// repositories including owned repositories, member repositories, and organization repositories. + /// + /// Options for changing the API response + /// + /// Issues are sorted by the create date descending. + /// http://developer.github.com/v3/issues/#list-issues + /// + /// The created representing requesting a list of issue from the API. + public Task> GetAllForCurrent(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return GetAllForCurrent(new IssueRequest(), options); } /// @@ -87,12 +104,30 @@ public Task> GetAllForCurrent() /// http://developer.github.com/v3/issues/#list-issues /// /// Used to filter and sort the list of issues returned - /// + /// The created representing requesting a list of issue from the API. public Task> GetAllForCurrent(IssueRequest request) { Ensure.ArgumentNotNull(request, "request"); - return ApiConnection.GetAll(ApiUrls.Issues(), request.ToParametersDictionary()); + return GetAllForCurrent(request, ApiOptions.None); + } + + /// + /// Gets all issues across all the authenticated user’s visible repositories including owned repositories, + /// member repositories, and organization repositories. + /// + /// + /// http://developer.github.com/v3/issues/#list-issues + /// + /// Used to filter and sort the list of issues returned + /// Options for changing the API response + /// The created representing requesting a list of issue from the API. + public Task> GetAllForCurrent(IssueRequest request, ApiOptions options) + { + Ensure.ArgumentNotNull(request, "request"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.Issues(), request.ToParametersDictionary(), options); } /// @@ -103,10 +138,27 @@ public Task> GetAllForCurrent(IssueRequest request) /// Issues are sorted by the create date descending. /// http://developer.github.com/v3/issues/#list-issues /// - /// + /// The created representing requesting a list of issue from the API. public Task> GetAllForOwnedAndMemberRepositories() { - return GetAllForOwnedAndMemberRepositories(new IssueRequest()); + return GetAllForOwnedAndMemberRepositories(ApiOptions.None); + } + + /// + /// Gets all open issues assigned to the authenticated user across owned and member repositories for the + /// authenticated user. + /// + /// Options for changing the API response + /// + /// Issues are sorted by the create date descending. + /// http://developer.github.com/v3/issues/#list-issues + /// + /// The created representing requesting a list of issue from the API. + public Task> GetAllForOwnedAndMemberRepositories(ApiOptions options) + { + Ensure.ArgumentNotNull(options, "options"); + + return GetAllForOwnedAndMemberRepositories(new IssueRequest(), options); } /// @@ -116,13 +168,29 @@ public Task> GetAllForOwnedAndMemberRepositories() /// http://developer.github.com/v3/issues/#list-issues /// /// Used to filter and sort the list of issues returned - /// + /// The created representing requesting a list of issue from the API. public Task> GetAllForOwnedAndMemberRepositories(IssueRequest request) { Ensure.ArgumentNotNull(request, "request"); - return ApiConnection.GetAll(ApiUrls.IssuesForOwnedAndMember(), - request.ToParametersDictionary()); + return GetAllForOwnedAndMemberRepositories(request, ApiOptions.None); + } + + /// + /// Gets all issues across owned and member repositories for the authenticated user. + /// + /// + /// http://developer.github.com/v3/issues/#list-issues + /// + /// Used to filter and sort the list of issues returned + /// Options for changing the API response + /// The created representing requesting a list of issue from the API. + public Task> GetAllForOwnedAndMemberRepositories(IssueRequest request, ApiOptions options) + { + Ensure.ArgumentNotNull(request, "request"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.IssuesForOwnedAndMember(), request.ToParametersDictionary(), options); } /// @@ -132,10 +200,29 @@ public Task> GetAllForOwnedAndMemberRepositories(IssueReque /// http://developer.github.com/v3/issues/#list-issues /// /// The name of the organization - /// + /// The created representing requesting a list of issue from the API. public Task> GetAllForOrganization(string organization) { - return GetAllForOrganization(organization, new IssueRequest()); + Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); + + return GetAllForOrganization(organization, ApiOptions.None); + } + + /// + /// Gets all open issues assigned to the authenticated user for a given organization for the authenticated user. + /// + /// + /// http://developer.github.com/v3/issues/#list-issues + /// + /// The name of the organization + /// Options for changing the API response + /// The created representing requesting a list of issue from the API. + public Task> GetAllForOrganization(string organization, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); + Ensure.ArgumentNotNull(options, "options"); + + return GetAllForOrganization(organization, new IssueRequest(), options); } /// @@ -146,13 +233,32 @@ public Task> GetAllForOrganization(string organization) /// /// The name of the organization /// Used to filter and sort the list of issues returned - /// + /// The created representing requesting a list of issue from the API. public Task> GetAllForOrganization(string organization, IssueRequest request) { Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); Ensure.ArgumentNotNull(request, "request"); - return ApiConnection.GetAll(ApiUrls.Issues(organization), request.ToParametersDictionary()); + return GetAllForOrganization(organization, request, ApiOptions.None); + } + + /// + /// Gets all issues for a given organization for the authenticated user. + /// + /// + /// http://developer.github.com/v3/issues/#list-issues + /// + /// The name of the organization + /// Used to filter and sort the list of issues returned + /// Options for changing the API response + /// The created representing requesting a list of issue from the API. + public Task> GetAllForOrganization(string organization, IssueRequest request, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); + Ensure.ArgumentNotNull(request, "request"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.Issues(organization), request.ToParametersDictionary(), options); } /// @@ -163,12 +269,46 @@ public Task> GetAllForOrganization(string organization, Iss /// /// The owner of the repository /// The name of the repository - /// + /// The created representing requesting a list of issue from the API. public Task> GetAllForRepository(string owner, string name) { return GetAllForRepository(owner, name, new RepositoryIssueRequest()); } + /// + /// Gets all open issues assigned to the authenticated user for the repository. + /// + /// + /// http://developer.github.com/v3/issues/#list-issues-for-a-repository + /// + /// The owner of the repository + /// The name of the repository + /// Options for changing the API response + /// The created representing requesting a list of issue from the API. + public Task> GetAllForRepository(string owner, string name, ApiOptions options) + { + return GetAllForRepository(owner, name, new RepositoryIssueRequest(), options); + } + + /// + /// Gets issues for a repository. + /// + /// + /// http://developer.github.com/v3/issues/#list-issues-for-a-repository + /// + /// The owner of the repository + /// The name of the repository + /// Used to filter and sort the list of issues returned + /// The created representing requesting a list of issue from the API. + public Task> GetAllForRepository(string owner, string name, RepositoryIssueRequest request) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(request, "request"); + + return GetAllForRepository(owner, name, request, ApiOptions.None); + } + /// /// Gets issues for a repository. /// @@ -178,15 +318,16 @@ public Task> GetAllForRepository(string owner, string name) /// The owner of the repository /// The name of the repository /// Used to filter and sort the list of issues returned - /// - public Task> GetAllForRepository(string owner, string name, - RepositoryIssueRequest request) + /// Options for changing the API response + /// The created representing requesting a list of issue from the API. + public Task> GetAllForRepository(string owner, string name, RepositoryIssueRequest request, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(request, "request"); + Ensure.ArgumentNotNull(options, "options"); - return ApiConnection.GetAll(ApiUrls.Issues(owner, name), request.ToParametersDictionary()); + return ApiConnection.GetAll(ApiUrls.Issues(owner, name), request.ToParametersDictionary(), options); } /// @@ -197,7 +338,7 @@ public Task> GetAllForRepository(string owner, string name, /// The owner of the repository /// The name of the repository /// A instance describing the new issue to create - /// + /// The created representing the new issue from the API. public Task Create(string owner, string name, NewIssue newIssue) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); @@ -216,7 +357,7 @@ public Task Create(string owner, string name, NewIssue newIssue) /// The issue number /// An instance describing the changes to make to the issue /// - /// + /// The created representing the updated issue from the API. public Task Update(string owner, string name, int number, IssueUpdate issueUpdate) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); @@ -233,7 +374,7 @@ public Task Update(string owner, string name, int number, IssueUpdate iss /// The owner of the repository /// The name of the repository /// The issue number - /// + /// The created representing accessing the API. public Task Lock(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); @@ -249,7 +390,7 @@ public Task Lock(string owner, string name, int number) /// The owner of the repository /// The name of the repository /// The issue number - /// + /// The created representing accessing the API. public Task Unlock(string owner, string name, int number) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner");