diff --git a/Octokit.Reactive/Clients/IObservableIssueCommentsClient.cs b/Octokit.Reactive/Clients/IObservableIssueCommentsClient.cs
index 24c29d48f1..9f0c2783e8 100644
--- a/Octokit.Reactive/Clients/IObservableIssueCommentsClient.cs
+++ b/Octokit.Reactive/Clients/IObservableIssueCommentsClient.cs
@@ -65,6 +65,42 @@ public interface IObservableIssueCommentsClient
/// Options for changing the API response
IObservable GetAllForRepository(long repositoryId, ApiOptions options);
+ ///
+ /// Gets Issue Comments for a repository.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
+ /// The owner of the repository
+ /// The name of the repository
+ /// The sorting parameters
+ IObservable GetAllForRepository(string owner, string name, IssueCommentRequest request);
+
+ ///
+ /// Gets Issue Comments for a repository.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
+ /// The Id of the repository
+ /// The sorting parameters
+ IObservable GetAllForRepository(long repositoryId, IssueCommentRequest request);
+
+ ///
+ /// Gets Issue Comments for a repository.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
+ /// The owner of the repository
+ /// The name of the repository
+ /// The sorting parameters
+ /// Options for changing the API response
+ IObservable GetAllForRepository(string owner, string name, IssueCommentRequest request, ApiOptions options);
+
+ ///
+ /// Gets Issue Comments for a repository.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
+ /// The Id of the repository
+ /// The sorting parameters
+ /// Options for changing the API response
+ IObservable GetAllForRepository(long repositoryId, IssueCommentRequest request, ApiOptions options);
+
///
/// Gets Issue Comments for a specified Issue.
///
diff --git a/Octokit.Reactive/Clients/ObservableIssueCommentsClient.cs b/Octokit.Reactive/Clients/ObservableIssueCommentsClient.cs
index 54527b7a48..7069091cd1 100644
--- a/Octokit.Reactive/Clients/ObservableIssueCommentsClient.cs
+++ b/Octokit.Reactive/Clients/ObservableIssueCommentsClient.cs
@@ -87,7 +87,7 @@ public IObservable GetAllForRepository(string owner, string name,
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(options, "options");
- return _connection.GetAndFlattenAllPages(ApiUrls.IssueComments(owner, name), null, AcceptHeaders.ReactionsPreview, options);
+ return GetAllForRepository(owner, name, new IssueCommentRequest(), options);
}
///
@@ -100,7 +100,69 @@ public IObservable GetAllForRepository(long repositoryId, ApiOptio
{
Ensure.ArgumentNotNull(options, "options");
- return _connection.GetAndFlattenAllPages(ApiUrls.IssueComments(repositoryId), options);
+ return GetAllForRepository(repositoryId, new IssueCommentRequest(), options);
+ }
+
+ ///
+ /// Gets Issue Comments for a repository.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
+ /// The owner of the repository
+ /// The name of the repository
+ /// The sorting parameters
+ public IObservable GetAllForRepository(string owner, string name, IssueCommentRequest request)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
+ Ensure.ArgumentNotNullOrEmptyString(name, "name");
+ Ensure.ArgumentNotNull(request, "request");
+
+ return GetAllForRepository(owner, name, request, ApiOptions.None);
+ }
+
+ ///
+ /// Gets Issue Comments for a repository.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
+ /// The Id of the repository
+ /// The sorting parameters
+ public IObservable GetAllForRepository(long repositoryId, IssueCommentRequest request)
+ {
+ Ensure.ArgumentNotNull(request, "request");
+
+ return GetAllForRepository(repositoryId, request, ApiOptions.None);
+ }
+
+ ///
+ /// Gets Issue Comments for a repository.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
+ /// The owner of the repository
+ /// The name of the repository
+ /// The sorting parameters
+ /// Options for changing the API response
+ public IObservable GetAllForRepository(string owner, string name, IssueCommentRequest request, ApiOptions options)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
+ Ensure.ArgumentNotNullOrEmptyString(name, "name");
+ Ensure.ArgumentNotNull(request, "request");
+ Ensure.ArgumentNotNull(options, "options");
+
+ return _connection.GetAndFlattenAllPages(ApiUrls.IssueComments(owner, name), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options);
+ }
+
+ ///
+ /// Gets Issue Comments for a repository.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
+ /// The Id of the repository
+ /// The sorting parameters
+ /// Options for changing the API response
+ public IObservable GetAllForRepository(long repositoryId, IssueCommentRequest request, ApiOptions options)
+ {
+ Ensure.ArgumentNotNull(request, "request");
+ Ensure.ArgumentNotNull(options, "options");
+
+ return _connection.GetAndFlattenAllPages(ApiUrls.IssueComments(repositoryId), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options);
}
///
diff --git a/Octokit.Tests/Clients/IssueCommentsClientTests.cs b/Octokit.Tests/Clients/IssueCommentsClientTests.cs
index 46a803a5fe..688feb02ba 100644
--- a/Octokit.Tests/Clients/IssueCommentsClientTests.cs
+++ b/Octokit.Tests/Clients/IssueCommentsClientTests.cs
@@ -136,9 +136,11 @@ public async Task EnsuresNonNullArguments()
await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", null));
await Assert.ThrowsAsync(() => client.GetAllForRepository(null, "name", ApiOptions.None));
await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", null, ApiOptions.None));
- await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "name", null));
+ await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "name", options: null));
+ await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "name", null, ApiOptions.None));
- await Assert.ThrowsAsync(() => client.GetAllForRepository(1, null));
+ await Assert.ThrowsAsync(() => client.GetAllForRepository(1, options: null));
+ await Assert.ThrowsAsync(() => client.GetAllForRepository(1, null, ApiOptions.None));
await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name"));
await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", ""));
diff --git a/Octokit.Tests/Reactive/ObservableIssueCommentsClientTests.cs b/Octokit.Tests/Reactive/ObservableIssueCommentsClientTests.cs
index 422379ec78..4974243004 100644
--- a/Octokit.Tests/Reactive/ObservableIssueCommentsClientTests.cs
+++ b/Octokit.Tests/Reactive/ObservableIssueCommentsClientTests.cs
@@ -57,8 +57,8 @@ public void RequestsCorrectUrl()
client.GetAllForRepository("fake", "repo");
gitHubClient.Connection.Received(1).Get>(
- new Uri("repos/fake/repo/issues/comments", UriKind.Relative),
- Args.EmptyDictionary,
+ new Uri("repos/fake/repo/issues/comments", UriKind.Relative),
+ Arg.Any>(),
"application/vnd.github.squirrel-girl-preview");
}
@@ -71,7 +71,9 @@ public void RequestsCorrectUrlWithRepositoryId()
client.GetAllForRepository(1);
gitHubClient.Connection.Received(1).Get>(
- new Uri("repositories/1/issues/comments", UriKind.Relative), Args.EmptyDictionary, null);
+ new Uri("repositories/1/issues/comments", UriKind.Relative),
+ Arg.Any>(),
+ "application/vnd.github.squirrel-girl-preview");
}
[Fact]
@@ -80,6 +82,12 @@ public void RequestsCorrectUrlWithApiOptions()
var gitHubClient = Substitute.For();
var client = new ObservableIssueCommentsClient(gitHubClient);
+ var request = new IssueCommentRequest()
+ {
+ Direction = SortDirection.Descending,
+ Since = new DateTimeOffset(2016, 11, 23, 11, 11, 11, 00, new TimeSpan()),
+ Sort = PullRequestReviewCommentSort.Updated
+ };
var options = new ApiOptions
{
StartPage = 1,
@@ -87,11 +95,14 @@ public void RequestsCorrectUrlWithApiOptions()
PageCount = 1
};
- client.GetAllForRepository("fake", "repo", options);
+ client.GetAllForRepository("fake", "repo", request, options);
gitHubClient.Connection.Received(1).Get>(
- new Uri("repos/fake/repo/issues/comments", UriKind.Relative),
- Arg.Any>(),
+ new Uri("repos/fake/repo/issues/comments", UriKind.Relative),
+ Arg.Is>(d => d.Count == 5
+ && d["direction"] == "desc"
+ && d["since"] == "2016-11-23T11:11:11Z"
+ && d["sort"] == "updated"),
"application/vnd.github.squirrel-girl-preview");
}
@@ -101,6 +112,12 @@ public void RequestsCorrectUrlWithRepositoryIdWithApiOptions()
var gitHubClient = Substitute.For();
var client = new ObservableIssueCommentsClient(gitHubClient);
+ var request = new IssueCommentRequest()
+ {
+ Direction = SortDirection.Descending,
+ Since = new DateTimeOffset(2016, 11, 23, 11, 11, 11, 00, new TimeSpan()),
+ Sort = PullRequestReviewCommentSort.Updated
+ };
var options = new ApiOptions
{
StartPage = 1,
@@ -108,10 +125,15 @@ public void RequestsCorrectUrlWithRepositoryIdWithApiOptions()
PageCount = 1
};
- client.GetAllForRepository(1, options);
+ client.GetAllForRepository(1, request, options);
gitHubClient.Connection.Received(1).Get>(
- new Uri("repositories/1/issues/comments", UriKind.Relative), Arg.Is>(d => d.Count == 2), null);
+ new Uri("repositories/1/issues/comments", UriKind.Relative),
+ Arg.Is>(d => d.Count == 5
+ && d["direction"] == "desc"
+ && d["since"] == "2016-11-23T11:11:11Z"
+ && d["sort"] == "updated"),
+ "application/vnd.github.squirrel-girl-preview");
}
[Fact]
@@ -124,9 +146,11 @@ public async Task EnsuresNonNullArguments()
Assert.Throws(() => client.GetAllForRepository("owner", null));
Assert.Throws(() => client.GetAllForRepository(null, "name", ApiOptions.None));
Assert.Throws(() => client.GetAllForRepository("owner", null, ApiOptions.None));
- Assert.Throws(() => client.GetAllForRepository("owner", "name", null));
+ Assert.Throws(() => client.GetAllForRepository("owner", "name", request: null));
+ Assert.Throws(() => client.GetAllForRepository("owner", "name", options: null));
- Assert.Throws(() => client.GetAllForRepository(1, null));
+ Assert.Throws(() => client.GetAllForRepository(1, request: null));
+ Assert.Throws(() => client.GetAllForRepository(1, options: null));
Assert.Throws(() => client.GetAllForRepository("", "name"));
Assert.Throws(() => client.GetAllForRepository("owner", ""));
diff --git a/Octokit/Clients/IIssueCommentsClient.cs b/Octokit/Clients/IIssueCommentsClient.cs
index 9906bc5c88..0f75296dec 100644
--- a/Octokit/Clients/IIssueCommentsClient.cs
+++ b/Octokit/Clients/IIssueCommentsClient.cs
@@ -65,6 +65,42 @@ public interface IIssueCommentsClient
/// Options for changing the API response
Task> GetAllForRepository(long repositoryId, ApiOptions options);
+ ///
+ /// Gets Issue Comments for a repository.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
+ /// The owner of the repository
+ /// The name of the repository
+ /// The sorting parameters
+ Task> GetAllForRepository(string owner, string name, IssueCommentRequest request);
+
+ ///
+ /// Gets Issue Comments for a repository.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
+ /// The Id of the repository
+ /// The sorting parameters
+ Task> GetAllForRepository(long repositoryId, IssueCommentRequest request);
+
+ ///
+ /// Gets Issue Comments for a repository.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
+ /// The owner of the repository
+ /// The name of the repository
+ /// The sorting parameters
+ /// Options for changing the API response
+ Task> GetAllForRepository(string owner, string name, IssueCommentRequest request, ApiOptions options);
+
+ ///
+ /// Gets Issue Comments for a repository.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
+ /// The Id of the repository
+ /// The sorting parameters
+ /// Options for changing the API response
+ Task> GetAllForRepository(long repositoryId, IssueCommentRequest request, ApiOptions options);
+
///
/// Gets Issue Comments for a specified Issue.
///
diff --git a/Octokit/Clients/IssueCommentsClient.cs b/Octokit/Clients/IssueCommentsClient.cs
index a779a5e7cb..ca91a1cb32 100644
--- a/Octokit/Clients/IssueCommentsClient.cs
+++ b/Octokit/Clients/IssueCommentsClient.cs
@@ -55,8 +55,8 @@ public Task> GetAllForRepository(string owner, strin
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
-
- return GetAllForRepository(owner, name, ApiOptions.None);
+
+ return GetAllForRepository(owner, name, new IssueCommentRequest(), ApiOptions.None);
}
///
@@ -66,7 +66,7 @@ public Task> GetAllForRepository(string owner, strin
/// The Id of the repository
public Task> GetAllForRepository(long repositoryId)
{
- return GetAllForRepository(repositoryId, ApiOptions.None);
+ return GetAllForRepository(repositoryId, new IssueCommentRequest(), ApiOptions.None);
}
///
@@ -82,7 +82,7 @@ public Task> GetAllForRepository(string owner, strin
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(options, "options");
- return ApiConnection.GetAll(ApiUrls.IssueComments(owner, name), null, AcceptHeaders.ReactionsPreview, options);
+ return GetAllForRepository(owner, name, new IssueCommentRequest(), options);
}
///
@@ -95,7 +95,69 @@ public Task> GetAllForRepository(long repositoryId,
{
Ensure.ArgumentNotNull(options, "options");
- return ApiConnection.GetAll(ApiUrls.IssueComments(repositoryId), null, AcceptHeaders.ReactionsPreview, options);
+ return GetAllForRepository(repositoryId, new IssueCommentRequest(), options);
+ }
+
+ ///
+ /// Gets Issue Comments for a repository.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
+ /// The owner of the repository
+ /// The name of the repository
+ /// The sorting parameters
+ public Task> GetAllForRepository(string owner, string name, IssueCommentRequest request)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
+ Ensure.ArgumentNotNullOrEmptyString(name, "name");
+ Ensure.ArgumentNotNull(request, "request");
+
+ return GetAllForRepository(owner, name, request, ApiOptions.None);
+ }
+
+ ///
+ /// Gets Issue Comments for a repository.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
+ /// The Id of the repository
+ /// The sorting parameters
+ public Task> GetAllForRepository(long repositoryId, IssueCommentRequest request)
+ {
+ Ensure.ArgumentNotNull(request, "request");
+
+ return GetAllForRepository(repositoryId, request, ApiOptions.None);
+ }
+
+ ///
+ /// Gets Issue Comments for a repository.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
+ /// The owner of the repository
+ /// The name of the repository
+ /// The sorting parameters
+ /// Options for changing the API response
+ public Task> GetAllForRepository(string owner, string name, IssueCommentRequest request, ApiOptions options)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
+ Ensure.ArgumentNotNullOrEmptyString(name, "name");
+ Ensure.ArgumentNotNull(request, "request");
+ Ensure.ArgumentNotNull(options, "options");
+
+ return ApiConnection.GetAll(ApiUrls.IssueComments(owner, name), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options);
+ }
+
+ ///
+ /// Gets Issue Comments for a repository.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
+ /// The Id of the repository
+ /// The sorting parameters
+ /// Options for changing the API response
+ public Task> GetAllForRepository(long repositoryId, IssueCommentRequest request, ApiOptions options)
+ {
+ Ensure.ArgumentNotNull(request, "request");
+ Ensure.ArgumentNotNull(options, "options");
+
+ return ApiConnection.GetAll(ApiUrls.IssueComments(repositoryId), request.ToParametersDictionary(), AcceptHeaders.ReactionsPreview, options);
}
///
diff --git a/Octokit/Models/Request/IssueCommentRequest.cs b/Octokit/Models/Request/IssueCommentRequest.cs
new file mode 100644
index 0000000000..21f0b12fa1
--- /dev/null
+++ b/Octokit/Models/Request/IssueCommentRequest.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Diagnostics;
+using System.Globalization;
+
+namespace Octokit
+{
+ ///
+ /// Used to filter issue comments.
+ ///
+ [DebuggerDisplay("{DebuggerDisplay,nq}")]
+ public class IssueCommentRequest : RequestParameters
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public IssueCommentRequest()
+ {
+ // Default arguments
+ Sort = PullRequestReviewCommentSort.Created;
+ Direction = SortDirection.Ascending;
+ Since = null;
+ }
+
+ ///
+ /// Can be either created or updated. Default: created.
+ ///
+ public PullRequestReviewCommentSort Sort { get; set; }
+
+ ///
+ /// Can be either asc or desc. Default: asc.
+ ///
+ public SortDirection Direction { get; set; }
+
+ ///
+ /// Only comments updated at or after this time are returned. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
+ ///
+ public DateTimeOffset? Since { get; set; }
+
+ internal string DebuggerDisplay
+ {
+ get { return string.Format(CultureInfo.InvariantCulture, "Sort: {0}, Direction: {1}, Since: {2}", Sort, Direction, Since); }
+ }
+ }
+}
diff --git a/Octokit/Models/Response/IssueComment.cs b/Octokit/Models/Response/IssueComment.cs
index 3cceb72671..6928ca38c0 100644
--- a/Octokit/Models/Response/IssueComment.cs
+++ b/Octokit/Models/Response/IssueComment.cs
@@ -62,4 +62,17 @@ internal string DebuggerDisplay
get { return string.Format(CultureInfo.InvariantCulture, "Id: {0} CreatedAt: {1}", Id, CreatedAt); }
}
}
+
+ public enum IssueCommentSort
+ {
+ ///
+ /// Sort by create date (default)
+ ///
+ Created,
+
+ ///
+ /// Sort by the date of the last update
+ ///
+ Updated
+ }
}
diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj
index 1890b1d920..25cd831e94 100644
--- a/Octokit/Octokit-Mono.csproj
+++ b/Octokit/Octokit-Mono.csproj
@@ -502,6 +502,7 @@
+
\ No newline at end of file
diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj
index 843d485fca..18647ead8a 100644
--- a/Octokit/Octokit-MonoAndroid.csproj
+++ b/Octokit/Octokit-MonoAndroid.csproj
@@ -513,6 +513,7 @@
+
\ No newline at end of file
diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj
index 03f59ce587..d197940f54 100644
--- a/Octokit/Octokit-Monotouch.csproj
+++ b/Octokit/Octokit-Monotouch.csproj
@@ -509,6 +509,7 @@
+
diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj
index 2bef9a4367..d3461e9b6c 100644
--- a/Octokit/Octokit-Portable.csproj
+++ b/Octokit/Octokit-Portable.csproj
@@ -499,6 +499,7 @@
+
diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj
index 5c1b1ed416..faa97a037e 100644
--- a/Octokit/Octokit-netcore45.csproj
+++ b/Octokit/Octokit-netcore45.csproj
@@ -506,6 +506,7 @@
+
diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj
index 9deb1cd6db..d7287d13be 100644
--- a/Octokit/Octokit.csproj
+++ b/Octokit/Octokit.csproj
@@ -146,6 +146,7 @@
+