diff --git a/Octokit.Reactive/Clients/IObservableMiscellaneousClient.cs b/Octokit.Reactive/Clients/IObservableMiscellaneousClient.cs index 87a9382f..8f1f3bdb 100644 --- a/Octokit.Reactive/Clients/IObservableMiscellaneousClient.cs +++ b/Octokit.Reactive/Clients/IObservableMiscellaneousClient.cs @@ -14,6 +14,14 @@ namespace Octokit.Reactive Justification = "Makes a network request")] IObservable GetAllEmojis(); + /// + /// Gets the rendered Markdown for an arbitrary markdown document. + /// + /// An arbitrary Markdown document + /// Thrown when a general API error occurs. + /// The rendered Markdown. + IObservable RenderArbitraryMarkdown(NewArbitraryMarkdown markdown); + /// /// Gets the rendered Markdown for the specified plain-text Markdown document. /// diff --git a/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs b/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs index 8aa2f98b..ea9c4096 100644 --- a/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs +++ b/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs @@ -26,6 +26,17 @@ namespace Octokit.Reactive return _client.GetAllEmojis().ToObservable().SelectMany(e => e); } + /// + /// Gets the rendered Markdown for an arbitrary markdown document. + /// + /// An arbitrary Markdown document + /// Thrown when a general API error occurs. + /// The rendered Markdown. + public IObservable RenderArbitraryMarkdown(NewArbitraryMarkdown markdown) + { + return _client.RenderArbitraryMarkdown(markdown).ToObservable(); + } + /// /// Gets the rendered Markdown for the specified plain-text Markdown document. /// diff --git a/Octokit.Tests/Clients/MiscellaneousClientTests.cs b/Octokit.Tests/Clients/MiscellaneousClientTests.cs index 98eaac13..72a9b642 100644 --- a/Octokit.Tests/Clients/MiscellaneousClientTests.cs +++ b/Octokit.Tests/Clients/MiscellaneousClientTests.cs @@ -31,7 +31,27 @@ namespace Octokit.Tests.Clients "text/plain"); } } + public class TheRenderArbitrryMarkdownMethod + { + [Fact] + public async Task RequestsTheEmojiEndpoint() + { + IApiResponse response = new ApiResponse(new Response(), "Test"); + var connection = Substitute.For(); + var forTest = new NewArbitraryMarkdown("testMarkdown", "gfm", "testContext"); + connection.Post(Args.Uri,forTest, "text/html", "text/plain") + .Returns(Task.FromResult(response)); + var client = new MiscellaneousClient(connection); + var html = await client.RenderArbitraryMarkdown(forTest); + Assert.Equal("Test", html); + connection.Received() + .Post(Arg.Is(u => u.ToString() == "markdown"), + forTest, + "text/html", + "text/plain"); + } + } public class TheGetEmojisMethod { [Fact] diff --git a/Octokit.Tests/Clients/SearchClientTests.cs b/Octokit.Tests/Clients/SearchClientTests.cs index 47b47875..5c5e2d2c 100644 --- a/Octokit.Tests/Clients/SearchClientTests.cs +++ b/Octokit.Tests/Clients/SearchClientTests.cs @@ -1046,6 +1046,81 @@ namespace Octokit.Tests.Clients Arg.Is>(d => d["q"] == "something+created:2014-01-01..2014-02-02")); } + [Fact] + public void TestingTheMergedQualifier_GreaterThan() + { + var connection = Substitute.For(); + var client = new SearchClient(connection); + var request = new SearchIssuesRequest("something"); + request.Merged = DateRange.GreaterThan(new DateTime(2014, 1, 1)); + + client.SearchIssues(request); + + connection.Received().Get( + Arg.Is(u => u.ToString() == "search/issues"), + Arg.Is>(d => d["q"] == "something+merged:>2014-01-01")); + } + + [Fact] + public void TestingTheMergedQualifier_GreaterThanOrEquals() + { + var connection = Substitute.For(); + var client = new SearchClient(connection); + var request = new SearchIssuesRequest("something"); + request.Merged = DateRange.GreaterThanOrEquals(new DateTime(2014, 1, 1)); + + client.SearchIssues(request); + + connection.Received().Get( + Arg.Is(u => u.ToString() == "search/issues"), + Arg.Is>(d => d["q"] == "something+merged:>=2014-01-01")); + } + + [Fact] + public void TestingTheMergedQualifier_LessThan() + { + var connection = Substitute.For(); + var client = new SearchClient(connection); + var request = new SearchIssuesRequest("something"); + request.Merged = DateRange.LessThan(new DateTime(2014, 1, 1)); + + client.SearchIssues(request); + + connection.Received().Get( + Arg.Is(u => u.ToString() == "search/issues"), + Arg.Is>(d => d["q"] == "something+merged:<2014-01-01")); + } + + [Fact] + public void TestingTheMergedQualifier_LessThanOrEquals() + { + var connection = Substitute.For(); + var client = new SearchClient(connection); + var request = new SearchIssuesRequest("something"); + request.Merged = DateRange.LessThanOrEquals(new DateTime(2014, 1, 1)); + + client.SearchIssues(request); + + connection.Received().Get( + Arg.Is(u => u.ToString() == "search/issues"), + Arg.Is>(d => d["q"] == "something+merged:<=2014-01-01")); + } + + [Fact] + public void TestingTheMergedQualifier_Between() + { + var connection = Substitute.For(); + var client = new SearchClient(connection); + var request = new SearchIssuesRequest("something"); + request.Merged = DateRange.Between(new DateTime(2014, 1, 1), new DateTime(2014, 2, 2)); + + client.SearchIssues(request); + + connection.Received().Get( + Arg.Is(u => u.ToString() == "search/issues"), + Arg.Is>(d => d["q"] == "something+merged:2014-01-01..2014-02-02")); + } + [Fact] public void TestingTheUpdatedQualifier_GreaterThan() { diff --git a/Octokit/Clients/IMiscellaneousClient.cs b/Octokit/Clients/IMiscellaneousClient.cs index 95367c3e..6df182db 100644 --- a/Octokit/Clients/IMiscellaneousClient.cs +++ b/Octokit/Clients/IMiscellaneousClient.cs @@ -30,6 +30,14 @@ namespace Octokit /// The rendered Markdown. Task RenderRawMarkdown(string markdown); + /// + /// Gets the rendered Markdown for an arbitrary markdown document. + /// + /// An arbitrary Markdown document + /// Thrown when a general API error occurs. + /// The rendered Markdown. + Task RenderArbitraryMarkdown(NewArbitraryMarkdown markdown); + /// /// List all templates available to pass as an option when creating a repository. /// diff --git a/Octokit/Clients/MiscellaneousClient.cs b/Octokit/Clients/MiscellaneousClient.cs index 7510ca84..38cfeff4 100644 --- a/Octokit/Clients/MiscellaneousClient.cs +++ b/Octokit/Clients/MiscellaneousClient.cs @@ -58,6 +58,20 @@ namespace Octokit return response.Body; } + /// + /// Gets the rendered Markdown for an arbitrary markdown document. + /// + /// An arbitrary Markdown document + /// Thrown when a general API error occurs. + /// The rendered Markdown. + public async Task RenderArbitraryMarkdown(NewArbitraryMarkdown markdown) + { + var endpoint = new Uri("markdown", UriKind.Relative); + var response = await _connection.Post(endpoint, markdown, "text/html", "text/plain") + .ConfigureAwait(false); + return response.Body; + } + /// /// List all templates available to pass as an option when creating a repository. /// diff --git a/Octokit/Models/Request/NewArbitraryMarkDown.cs b/Octokit/Models/Request/NewArbitraryMarkDown.cs new file mode 100644 index 00000000..a2993f9c --- /dev/null +++ b/Octokit/Models/Request/NewArbitraryMarkDown.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Linq; + +namespace Octokit +{ + /// + /// Used to create anarbitrary markdown + /// + /// + /// API: https://developer.github.com/v3/markdown/#render-an-arbitrary-markdown-document + /// + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class NewArbitraryMarkdown + { + const string _markdown = "markdown"; + const string _gfm = "gfm"; + + /// + /// Create an arbitrary markdown + /// + /// The Markdown text to render + /// The rendering mode. Can be either markdown by default or gfm + /// + /// The repository context. Only taken into account when rendering as gfm + /// + public NewArbitraryMarkdown(string text, string mode, string context) + { + Text = text; + Mode = GetMode(mode); + Context = context; + } + + /// + /// Create an arbitrary markdown + /// + /// The Markdown text to render + /// + + public NewArbitraryMarkdown(string text) + :this(text,_markdown,null) + { + } + + /// + /// Create an arbitrary markdown + /// + /// The Markdown text to render + /// The rendering mode. Can be either markdown by default or gfm + /// + public NewArbitraryMarkdown(string text, string mode) + : this(text, mode, null) + { + } + + /// + /// Gets the markdown text + /// + /// + /// The text. + /// + public string Text { get; private set; } + + /// + /// Gets the mode of the text + /// + /// + /// The mode. + /// + public string Mode { get; private set; } + + /// + /// Gets the context of the markdown + /// + /// + /// The context. + /// + public string Context { get; private set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "gfm")] + static string GetMode(string mode) + { + if (mode != _markdown && mode != _gfm) + { + throw (new FormatException("The mode must be either 'markdown' or 'gfm'")); + } + else + return mode; + } + internal string DebuggerDisplay + { + get + { + return String.Format(CultureInfo.InvariantCulture, "Text: {0}", Text); + } + } + } +} diff --git a/Octokit/Models/Request/SearchIssuesRequest.cs b/Octokit/Models/Request/SearchIssuesRequest.cs index f9a5a332..c9bb7d05 100644 --- a/Octokit/Models/Request/SearchIssuesRequest.cs +++ b/Octokit/Models/Request/SearchIssuesRequest.cs @@ -43,7 +43,7 @@ namespace Octokit } /// - /// Optional Sort field. One of comments, created, or updated. + /// Optional Sort field. One of comments, created, updated or merged /// If not provided, results are sorted by best match. /// /// @@ -177,6 +177,13 @@ namespace Octokit /// public DateRange Updated { get; set; } + /// + /// Filters issues based on times when they were last merged + /// + /// + /// https://help.github.com/articles/searching-issues/#search-based-on-when-a-pull-request-was-merged + /// + public DateRange Merged { get; set; } /// /// Filters issues based on the quantity of comments. /// @@ -196,6 +203,7 @@ namespace Octokit [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public RepositoryCollection Repos { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] public override IReadOnlyList MergedQualifiers() { var parameters = new List(); @@ -261,7 +269,10 @@ namespace Octokit { parameters.Add(String.Format(CultureInfo.InvariantCulture, "updated:{0}", Updated)); } - + if (Merged != null) + { + parameters.Add(String.Format(CultureInfo.InvariantCulture, "merged:{0}", Merged)); + } if (Comments != null) { parameters.Add(String.Format(CultureInfo.InvariantCulture, "comments:{0}", Comments)); @@ -312,7 +323,12 @@ namespace Octokit /// search by last updated /// [Parameter(Value = "updated")] - Updated + Updated, + /// + /// search by last merged + /// + [Parameter(Value = "merged")] + Merged } public enum IssueInQualifier diff --git a/Octokit/Models/Response/PullRequest.cs b/Octokit/Models/Response/PullRequest.cs index a52e5b05..b93f0106 100644 --- a/Octokit/Models/Response/PullRequest.cs +++ b/Octokit/Models/Response/PullRequest.cs @@ -14,7 +14,7 @@ namespace Octokit Number = number; } - public PullRequest(Uri url, Uri htmlUrl, Uri diffUrl, Uri patchUrl, Uri issueUrl, Uri statusesUrl, int number, ItemState state, string title, string body, DateTimeOffset createdAt, DateTimeOffset updatedAt, DateTimeOffset? closedAt, DateTimeOffset? mergedAt, GitReference head, GitReference @base, User user, string mergeCommitSha, bool merged, bool? mergeable, User mergedBy, int comments, int commits, int additions, int deletions, int changedFiles) + public PullRequest(Uri url, Uri htmlUrl, Uri diffUrl, Uri patchUrl, Uri issueUrl, Uri statusesUrl, int number, ItemState state, string title, string body, DateTimeOffset createdAt, DateTimeOffset updatedAt, DateTimeOffset? closedAt, DateTimeOffset? mergedAt, GitReference head, GitReference @base, User user, User assignee, string mergeCommitSha, bool merged, bool? mergeable, User mergedBy, int comments, int commits, int additions, int deletions, int changedFiles) { Url = url; HtmlUrl = htmlUrl; @@ -33,6 +33,7 @@ namespace Octokit Head = head; Base = @base; User = user; + Assignee = assignee; MergeCommitSha = mergeCommitSha; Merged = merged; Mergeable = mergeable; @@ -129,6 +130,11 @@ namespace Octokit /// public User User { get; protected set; } + /// + /// The user who is assigned the pull request. + /// + public User Assignee { get; protected set; } + /// /// The SHA of the merge commit. /// diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj index 5a6d636b..c5b90255 100644 --- a/Octokit/Octokit-Mono.csproj +++ b/Octokit/Octokit-Mono.csproj @@ -105,6 +105,7 @@ + diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj index ea68c7d3..19a3e107 100644 --- a/Octokit/Octokit-MonoAndroid.csproj +++ b/Octokit/Octokit-MonoAndroid.csproj @@ -411,6 +411,7 @@ + \ No newline at end of file diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj index 7b228d6d..ae03fc83 100644 --- a/Octokit/Octokit-Monotouch.csproj +++ b/Octokit/Octokit-Monotouch.csproj @@ -407,7 +407,8 @@ + - + \ No newline at end of file diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj index a0429d24..29dca3fc 100644 --- a/Octokit/Octokit-Portable.csproj +++ b/Octokit/Octokit-Portable.csproj @@ -185,6 +185,7 @@ + diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index 44277e74..ada7c29d 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -408,6 +408,7 @@ + diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index bacb6546..5e547258 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -88,6 +88,7 @@ + diff --git a/SolutionInfo.cs b/SolutionInfo.cs index 2741c932..ba2f342f 100644 --- a/SolutionInfo.cs +++ b/SolutionInfo.cs @@ -3,11 +3,11 @@ using System.Reflection; using System.Runtime.InteropServices; [assembly: AssemblyProductAttribute("Octokit")] -[assembly: AssemblyVersionAttribute("0.16.0")] -[assembly: AssemblyFileVersionAttribute("0.16.0")] +[assembly: AssemblyVersionAttribute("0.17.0")] +[assembly: AssemblyFileVersionAttribute("0.17.0")] [assembly: ComVisibleAttribute(false)] namespace System { internal static class AssemblyVersionInformation { - internal const string Version = "0.16.0"; + internal const string Version = "0.17.0"; } }