From 04c9a9a0de991af3cb3fd93a31594010a8dfe7be Mon Sep 17 00:00:00 2001 From: Grzegorz Dziadkiewicz Date: Tue, 25 Feb 2020 23:48:00 +0100 Subject: [PATCH] Update MiscellaneousClient to ApiClient approach and add pagination support to GetAllLicenses. (#1716) Co-authored-by: Brendan Forster --- .../Clients/IObservableMiscellaneousClient.cs | 9 +- .../Clients/ObservableMiscellaneousClient.cs | 14 +- .../Clients/MiscellaneousClientTests.cs | 52 +++++- .../Clients/MiscellaneousClientTests.cs | 170 +++++++++++------- .../ObservableMiscellaneousClientTests.cs | 2 +- Octokit/Clients/IMiscellaneousClient.cs | 12 +- Octokit/Clients/MiscellaneousClient.cs | 85 ++++----- Octokit/GitHubClient.cs | 2 +- Octokit/Helpers/ApiUrls.cs | 92 ++++++++++ 9 files changed, 312 insertions(+), 126 deletions(-) diff --git a/Octokit.Reactive/Clients/IObservableMiscellaneousClient.cs b/Octokit.Reactive/Clients/IObservableMiscellaneousClient.cs index 4fbf18eb66..2122d9be64 100644 --- a/Octokit.Reactive/Clients/IObservableMiscellaneousClient.cs +++ b/Octokit.Reactive/Clients/IObservableMiscellaneousClient.cs @@ -47,11 +47,18 @@ public interface IObservableMiscellaneousClient /// Returns a list of the licenses shown in the license picker on GitHub.com. This is not a comprehensive /// list of all possible OSS licenses. /// - /// This is a PREVIEW API! Use it at your own risk. /// A list of licenses available on the site [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] IObservable GetAllLicenses(); + /// + /// Returns a list of the licenses shown in the license picker on GitHub.com. This is not a comprehensive + /// list of all possible OSS licenses. + /// + /// Options for changing the API response + /// A list of licenses available on the site + IObservable GetAllLicenses(ApiOptions options); + /// /// Retrieves a license based on the license key such as "MIT" /// diff --git a/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs b/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs index 8bd20c67c0..86973c6475 100644 --- a/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs +++ b/Octokit.Reactive/Clients/ObservableMiscellaneousClient.cs @@ -70,11 +70,21 @@ public IObservable GetGitIgnoreTemplate(string templateName) /// Returns a list of the licenses shown in the license picker on GitHub.com. This is not a comprehensive /// list of all possible OSS licenses. /// - /// This is a PREVIEW API! Use it at your own risk. /// A list of licenses available on the site public IObservable GetAllLicenses() { - return _client.GetAllLicenses().ToObservable().SelectMany(l => l); + return GetAllLicenses(ApiOptions.None); + } + + /// + /// Returns a list of the licenses shown in the license picker on GitHub.com. This is not a comprehensive + /// list of all possible OSS licenses. + /// + /// Options for changing the API response + /// A list of licenses available on the site + public IObservable GetAllLicenses(ApiOptions options) + { + return _client.GetAllLicenses(options).ToObservable().SelectMany(l => l); } /// diff --git a/Octokit.Tests.Integration/Clients/MiscellaneousClientTests.cs b/Octokit.Tests.Integration/Clients/MiscellaneousClientTests.cs index cebfbe9328..0dce4f856b 100644 --- a/Octokit.Tests.Integration/Clients/MiscellaneousClientTests.cs +++ b/Octokit.Tests.Integration/Clients/MiscellaneousClientTests.cs @@ -1,4 +1,5 @@ using System.Threading.Tasks; +using Octokit; using Octokit.Tests.Integration; using Xunit; @@ -55,6 +56,47 @@ public async Task CanRetrieveListOfLicenses() Assert.True(result.Count > 2); Assert.Contains(result, license => license.Key == "mit"); } + + [IntegrationTest] + public async Task CanRetrieveListOfLicensesWithPagination() + { + var github = Helper.GetAuthenticatedClient(); + + var options = new ApiOptions + { + PageCount = 1, + PageSize = 5, + }; + + var result = await github.Miscellaneous.GetAllLicenses(options); + + Assert.Equal(5, result.Count); + } + + [IntegrationTest] + public async Task CanRetrieveDistinctListOfLicensesBasedOnPageStart() + { + var github = Helper.GetAuthenticatedClient(); + + var startOptions = new ApiOptions + { + PageSize = 1, + PageCount = 1 + }; + + var firstPage = await github.Miscellaneous.GetAllLicenses(startOptions); + + var skipStartOptions = new ApiOptions + { + PageSize = 1, + PageCount = 1, + StartPage = 2 + }; + + var secondPage = await github.Miscellaneous.GetAllLicenses(skipStartOptions); + + Assert.NotEqual(firstPage[0].Key, secondPage[0].Key); + } } public class TheGetLicenseMethod @@ -69,6 +111,14 @@ public async Task CanRetrieveListOfLicenses() Assert.Equal("mit", result.Key); Assert.Equal("MIT License", result.Name); } + + [IntegrationTest] + public async Task ReportsErrorWhenInvalidLicenseProvided() + { + var github = Helper.GetAuthenticatedClient(); + + await Assert.ThrowsAsync(() => github.Miscellaneous.GetLicense("purple-monkey-dishwasher")); + } } public class TheGetResourceRateLimitsMethod @@ -120,4 +170,4 @@ public async Task CanRetrieveMetadata() Assert.True(result.Importer.Count > 0); } } -} \ No newline at end of file +} diff --git a/Octokit.Tests/Clients/MiscellaneousClientTests.cs b/Octokit.Tests/Clients/MiscellaneousClientTests.cs index dd4c02820c..08af90000f 100644 --- a/Octokit.Tests/Clients/MiscellaneousClientTests.cs +++ b/Octokit.Tests/Clients/MiscellaneousClientTests.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Threading.Tasks; using NSubstitute; -using Octokit.Internal; using Xunit; using System.Globalization; @@ -13,20 +13,25 @@ public class MiscellaneousClientTests public class TheRenderRawMarkdownMethod { [Fact] - public async Task RequestsTheEmojiEndpoint() + public async Task RequestsTheRawMarkdownEndpoint() { - IApiResponse response = new ApiResponse(new Response(), "Test"); - var connection = Substitute.For(); - connection.Post(Args.Uri, "**Test**", "text/html", "text/plain") + var markdown = "**Test**"; + var response = "Test"; + var apiConnection = Substitute.For(); + apiConnection.Post( + Arg.Is(u => u.ToString() == "markdown/raw"), + markdown, + "text/html", + "text/plain") .Returns(Task.FromResult(response)); - var client = new MiscellaneousClient(connection); + var client = new MiscellaneousClient(apiConnection); - var html = await client.RenderRawMarkdown("**Test**"); + var html = await client.RenderRawMarkdown(markdown); Assert.Equal("Test", html); - connection.Received() + apiConnection.Received() .Post(Arg.Is(u => u.ToString() == "markdown/raw"), - "**Test**", + markdown, "text/html", "text/plain"); } @@ -34,20 +39,23 @@ public async Task RequestsTheEmojiEndpoint() public class TheRenderArbitraryMarkdownMethod { [Fact] - public async Task RequestsTheEmojiEndpoint() + public async Task RequestsTheMarkdownEndpoint() { - 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") + var response = "Test"; + + var payload = new NewArbitraryMarkdown("testMarkdown", "gfm", "testContext"); + + var apiConnection = Substitute.For(); + apiConnection.Post(Args.Uri, payload, "text/html", "text/plain") .Returns(Task.FromResult(response)); - var client = new MiscellaneousClient(connection); - var html = await client.RenderArbitraryMarkdown(forTest); + var client = new MiscellaneousClient(apiConnection); + + var html = await client.RenderArbitraryMarkdown(payload); Assert.Equal("Test", html); - connection.Received() + apiConnection.Received() .Post(Arg.Is(u => u.ToString() == "markdown"), - forTest, + payload, "text/html", "text/plain"); } @@ -57,25 +65,24 @@ public class TheGetEmojisMethod [Fact] public async Task RequestsTheEmojiEndpoint() { - IApiResponse> response = new ApiResponse> - ( - new Response(), - new Dictionary - { - { "foo", "http://example.com/foo.gif" }, - { "bar", "http://example.com/bar.gif" } - } - ); - var connection = Substitute.For(); - connection.Get>(Args.Uri, null, null).Returns(Task.FromResult(response)); - var client = new MiscellaneousClient(connection); + IReadOnlyList response = new List + { + { new Emoji("foo", "http://example.com/foo.gif") }, + { new Emoji("bar", "http://example.com/bar.gif") } + }; + + var apiConnection = Substitute.For(); + apiConnection.GetAll(Args.Uri) + .Returns(Task.FromResult(response)); + + var client = new MiscellaneousClient(apiConnection); var emojis = await client.GetAllEmojis(); Assert.Equal(2, emojis.Count); Assert.Equal("foo", emojis[0].Name); - connection.Received() - .Get>(Arg.Is(u => u.ToString() == "emojis"), null, null); + apiConnection.Received() + .GetAll(Arg.Is(u => u.ToString() == "emojis")); } } @@ -84,20 +91,17 @@ public class TheGetResourceRateLimitsMethod [Fact] public async Task RequestsTheResourceRateLimitEndpoint() { - IApiResponse response = new ApiResponse - ( - new Response(), - new MiscellaneousRateLimit( - new ResourceRateLimit( - new RateLimit(5000, 4999, 1372700873), - new RateLimit(30, 18, 1372700873) - ), - new RateLimit(100, 75, 1372700873) - ) - ); - var connection = Substitute.For(); - connection.Get(Args.Uri, null, null).Returns(Task.FromResult(response)); - var client = new MiscellaneousClient(connection); + var rateLimit = new MiscellaneousRateLimit( + new ResourceRateLimit( + new RateLimit(5000, 4999, 1372700873), + new RateLimit(30, 18, 1372700873) + ), + new RateLimit(100, 75, 1372700873) + ); + var apiConnection = Substitute.For(); + apiConnection.Get(Arg.Is(u => u.ToString() == "rate_limit")).Returns(Task.FromResult(rateLimit)); + + var client = new MiscellaneousClient(apiConnection); var result = await client.GetRateLimits(); @@ -131,8 +135,8 @@ public async Task RequestsTheResourceRateLimitEndpoint() CultureInfo.InvariantCulture); Assert.Equal(expectedReset, result.Rate.Reset); - connection.Received() - .Get(Arg.Is(u => u.ToString() == "rate_limit"), null, null); + apiConnection.Received() + .Get(Arg.Is(u => u.ToString() == "rate_limit")); } } @@ -141,22 +145,18 @@ public class TheGetMetadataMethod [Fact] public async Task RequestsTheMetadataEndpoint() { - IApiResponse response = new ApiResponse - ( - new Response(), - new Meta( - false, - "12345ABCDE", - new[] { "1.1.1.1/24", "1.1.1.2/24" }, - new[] { "1.1.2.1/24", "1.1.2.2/24" }, - new[] { "1.1.3.1/24", "1.1.3.2/24" }, - new[] { "1.1.4.1", "1.1.4.2" } - ) - ); - var connection = Substitute.For(); - connection.Get(Args.Uri, null, null) - .Returns(Task.FromResult(response)); - var client = new MiscellaneousClient(connection); + var meta = new Meta( + false, + "12345ABCDE", + new[] { "1.1.1.1/24", "1.1.1.2/24" }, + new[] { "1.1.2.1/24", "1.1.2.2/24" }, + new[] { "1.1.3.1/24", "1.1.3.2/24" }, + new[] { "1.1.4.1", "1.1.4.2" } + ); + + var apiConnection = Substitute.For(); + apiConnection.Get(Arg.Is(u => u.ToString() == "meta")).Returns(Task.FromResult(meta)); + var client = new MiscellaneousClient(apiConnection); var result = await client.GetMetadata(); @@ -167,8 +167,8 @@ public async Task RequestsTheMetadataEndpoint() Assert.Equal(result.Pages, new[] { "1.1.3.1/24", "1.1.3.2/24" }); Assert.Equal(result.Importer, new[] { "1.1.4.1", "1.1.4.2" }); - connection.Received() - .Get(Arg.Is(u => u.ToString() == "meta"), null, null); + apiConnection.Received() + .Get(Arg.Is(u => u.ToString() == "meta")); } } @@ -180,5 +180,43 @@ public void EnsuresNonNullArguments() Assert.Throws(() => new MiscellaneousClient(null)); } } + + public class TheGetAllLicensesMethod + { + [Fact] + public void EnsuresNonNullArguments() + { + var client = new MiscellaneousClient(Substitute.For()); + + Assert.ThrowsAsync(() => client.GetAllLicenses(null)); + } + + [Fact] + public async Task RequestsTheLicensesEndpoint() + { + IReadOnlyList response = new ReadOnlyCollection(new List() + { + new LicenseMetadata("foo1", "node-id-1", "foo2", "something", "http://example.com/foo1", true), + new LicenseMetadata("bar1", "node-id-1", "bar2", "something else", "http://example.com/bar1", false) + }); + + var connection = Substitute.For(); + connection.GetAll(Arg.Is(u => u.ToString() == "licenses"), null, "application/vnd.github.drax-preview+json", Args.ApiOptions) + .Returns(Task.FromResult(response)); + var client = new MiscellaneousClient(connection); + + var licenses = await client.GetAllLicenses(); + + Assert.Equal(2, licenses.Count); + Assert.Equal("foo1", licenses[0].Key); + Assert.Equal("foo2", licenses[0].Name); + Assert.Equal("http://example.com/foo1", licenses[0].Url); + Assert.Equal("bar1", licenses[1].Key); + Assert.Equal("bar2", licenses[1].Name); + Assert.Equal("http://example.com/bar1", licenses[1].Url); + connection.Received() + .GetAll(Arg.Is(u => u.ToString() == "licenses"), null, AcceptHeaders.LicensesApiPreview, Args.ApiOptions); + } + } } } diff --git a/Octokit.Tests/Reactive/ObservableMiscellaneousClientTests.cs b/Octokit.Tests/Reactive/ObservableMiscellaneousClientTests.cs index b069c08be5..602890ec27 100644 --- a/Octokit.Tests/Reactive/ObservableMiscellaneousClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableMiscellaneousClientTests.cs @@ -87,7 +87,7 @@ public void CallsIntoClient() client.GetAllLicenses(); - gitHubClient.Miscellaneous.Received(1).GetAllLicenses(); + gitHubClient.Miscellaneous.Received(1).GetAllLicenses(Args.ApiOptions); } } diff --git a/Octokit/Clients/IMiscellaneousClient.cs b/Octokit/Clients/IMiscellaneousClient.cs index 0f6ae3073f..1766c79bb5 100644 --- a/Octokit/Clients/IMiscellaneousClient.cs +++ b/Octokit/Clients/IMiscellaneousClient.cs @@ -56,16 +56,22 @@ public interface IMiscellaneousClient /// Returns a list of the licenses shown in the license picker on GitHub.com. This is not a comprehensive /// list of all possible OSS licenses. /// - /// This is a PREVIEW API! Use it at your own risk. /// A list of licenses available on the site [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] - [ExcludeFromPaginationApiOptionsConventionTest("TODO: Implement pagination for this method")] Task> GetAllLicenses(); + /// + /// Returns a list of the licenses shown in the license picker on GitHub.com. This is not a comprehensive + /// list of all possible OSS licenses. + /// + /// Options for changing the API response + /// A list of licenses available on the site + Task> GetAllLicenses(ApiOptions options); + /// /// Retrieves a license based on the license key such as "MIT" /// - /// + /// The license identifier to look for /// A that includes the license key, text, and attributes of the license. Task GetLicense(string key); diff --git a/Octokit/Clients/MiscellaneousClient.cs b/Octokit/Clients/MiscellaneousClient.cs index 9fd9bcb93c..2dc838d304 100644 --- a/Octokit/Clients/MiscellaneousClient.cs +++ b/Octokit/Clients/MiscellaneousClient.cs @@ -1,9 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using System.Linq; using System.Threading.Tasks; -using System.Collections.ObjectModel; namespace Octokit { @@ -13,19 +11,15 @@ namespace Octokit /// /// See the Miscellaneous API documentation for more details. /// - public class MiscellaneousClient : IMiscellaneousClient + public class MiscellaneousClient : ApiClient, IMiscellaneousClient { - readonly IConnection _connection; - /// /// Initializes a new GitHub miscellaneous API client. /// - /// An API connection - public MiscellaneousClient(IConnection connection) + /// An API connection. + public MiscellaneousClient(IApiConnection apiConnection) + : base(apiConnection) { - Ensure.ArgumentNotNull(connection, nameof(connection)); - - _connection = connection; } /// @@ -33,12 +27,9 @@ public MiscellaneousClient(IConnection connection) /// /// Thrown when a general API error occurs. /// An of emoji and their URI. - public async Task> GetAllEmojis() + public Task> GetAllEmojis() { - var endpoint = new Uri("emojis", UriKind.Relative); - var response = await _connection.Get>(endpoint, null, null).ConfigureAwait(false); - return new ReadOnlyCollection( - response.Body.Select(kvp => new Emoji(kvp.Key, kvp.Value)).ToArray()); + return ApiConnection.GetAll(ApiUrls.Emojis()); } /// @@ -47,11 +38,9 @@ public async Task> GetAllEmojis() /// A plain-text Markdown document /// Thrown when a general API error occurs. /// The rendered Markdown. - public async Task RenderRawMarkdown(string markdown) + public Task RenderRawMarkdown(string markdown) { - var endpoint = new Uri("markdown/raw", UriKind.Relative); - var response = await _connection.Post(endpoint, markdown, "text/html", "text/plain").ConfigureAwait(false); - return response.Body; + return ApiConnection.Post(ApiUrls.RawMarkdown(), markdown, "text/html", "text/plain"); } /// @@ -60,23 +49,18 @@ public async Task RenderRawMarkdown(string markdown) /// An arbitrary Markdown document /// Thrown when a general API error occurs. /// The rendered Markdown. - public async Task RenderArbitraryMarkdown(NewArbitraryMarkdown markdown) + public 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; + return ApiConnection.Post(ApiUrls.Markdown(), markdown, "text/html", "text/plain"); } /// /// List all templates available to pass as an option when creating a repository. /// /// A list of template names - public async Task> GetAllGitIgnoreTemplates() + public Task> GetAllGitIgnoreTemplates() { - var endpoint = new Uri("gitignore/templates", UriKind.Relative); - - var response = await _connection.Get(endpoint, null, null).ConfigureAwait(false); - return new ReadOnlyCollection(response.Body); + return ApiConnection.GetAll(ApiUrls.GitIgnoreTemplates()); } /// @@ -84,28 +68,34 @@ public async Task> GetAllGitIgnoreTemplates() /// /// /// A template and its source - public async Task GetGitIgnoreTemplate(string templateName) + public Task GetGitIgnoreTemplate(string templateName) { Ensure.ArgumentNotNullOrEmptyString(templateName, nameof(templateName)); - var endpoint = new Uri("gitignore/templates/" + Uri.EscapeUriString(templateName), UriKind.Relative); + return ApiConnection.Get(ApiUrls.GitIgnoreTemplates(templateName)); + } - var response = await _connection.Get(endpoint, null, null).ConfigureAwait(false); - return response.Body; + /// + /// Returns a list of the licenses shown in the license picker on GitHub.com. This is not a comprehensive + /// list of all possible OSS licenses. + /// + /// A list of licenses available on the site + public Task> GetAllLicenses() + { + return GetAllLicenses(ApiOptions.None); } /// /// Returns a list of the licenses shown in the license picker on GitHub.com. This is not a comprehensive /// list of all possible OSS licenses. /// - /// This is a PREVIEW API! Use it at your own risk. + /// Options for changing the API response /// A list of licenses available on the site - public async Task> GetAllLicenses() + public Task> GetAllLicenses(ApiOptions options) { - var endpoint = new Uri("licenses", UriKind.Relative); + Ensure.ArgumentNotNull(options, "options"); - var response = await _connection.Get(endpoint, null, AcceptHeaders.LicensesApiPreview).ConfigureAwait(false); - return new ReadOnlyCollection(response.Body); + return ApiConnection.GetAll(ApiUrls.Licenses(), null, AcceptHeaders.LicensesApiPreview, options); } /// @@ -113,12 +103,9 @@ public async Task> GetAllLicenses() /// /// /// A that includes the license key, text, and attributes of the license. - public async Task GetLicense(string key) + public Task GetLicense(string key) { - var endpoint = new Uri("licenses/" + Uri.EscapeUriString(key), UriKind.Relative); - - var response = await _connection.Get(endpoint, null, AcceptHeaders.LicensesApiPreview).ConfigureAwait(false); - return response.Body; + return ApiConnection.Get(ApiUrls.Licenses(key), null, AcceptHeaders.LicensesApiPreview); } /// @@ -127,11 +114,9 @@ public async Task GetLicense(string key) /// Thrown when a general API error occurs. /// An of Rate Limits. [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] - public async Task GetRateLimits() + public Task GetRateLimits() { - var endpoint = new Uri("rate_limit", UriKind.Relative); - var response = await _connection.Get(endpoint, null, null).ConfigureAwait(false); - return response.Body; + return ApiConnection.Get(ApiUrls.RateLimit()); } /// @@ -140,11 +125,9 @@ public async Task GetRateLimits() /// Thrown when a general API error occurs. /// An containing metadata about the GitHub instance. [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] - public async Task GetMetadata() + public Task GetMetadata() { - var endpoint = new Uri("meta", UriKind.Relative); - var response = await _connection.Get(endpoint, null, null).ConfigureAwait(false); - return response.Body; + return ApiConnection.Get(ApiUrls.Meta()); } } -} \ No newline at end of file +} diff --git a/Octokit/GitHubClient.cs b/Octokit/GitHubClient.cs index c830978c21..df766a1ed9 100644 --- a/Octokit/GitHubClient.cs +++ b/Octokit/GitHubClient.cs @@ -102,7 +102,7 @@ public GitHubClient(IConnection connection) GitHubApps = new GitHubAppsClient(apiConnection); Issue = new IssuesClient(apiConnection); Migration = new MigrationClient(apiConnection); - Miscellaneous = new MiscellaneousClient(connection); + Miscellaneous = new MiscellaneousClient(apiConnection); Oauth = new OauthClient(connection); Organization = new OrganizationsClient(apiConnection); PullRequest = new PullRequestsClient(apiConnection); diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs index 48cf5db7e1..43ee63855f 100644 --- a/Octokit/Helpers/ApiUrls.cs +++ b/Octokit/Helpers/ApiUrls.cs @@ -4156,5 +4156,97 @@ public static Uri CheckSuitePreferences(string owner, string repo) { return "repos/{0}/{1}/check-suites/preferences".FormatUri(owner, repo); } + + /// + /// Returns the that returns all emojis in + /// response to a GET request. + /// + /// The for emojis. + public static Uri Emojis() + { + return "emojis".FormatUri(); + } + + /// + /// Returns the that returns rendered markdown in + /// response to a POST request. + /// + /// The to render markdown. + public static Uri RawMarkdown() + { + return "markdown/raw".FormatUri(); + } + + /// + /// Returns the that returns rendered markdown in + /// response to a POST request. + /// + /// The to render markdown. + public static Uri Markdown() + { + return "markdown".FormatUri(); + } + + /// + /// Returns the that returns all git ignore templates in + /// response to a GET request. + /// + /// The to git ignore templates. + public static Uri GitIgnoreTemplates() + { + return "gitignore/templates".FormatUri(); + } + + /// + /// Returns the that returns specified git ignore templates in + /// response to a GET request. + /// + /// The name of the template to retrieve + /// The to git ignore template. + public static Uri GitIgnoreTemplates(string templateName) + { + return "gitignore/templates/{0}".FormatUri(templateName); + } + + /// + /// Returns the that returns all licenses in + /// response to a GET request. + /// + /// The to licenses. + public static Uri Licenses() + { + return "licenses".FormatUri(); + } + + /// + /// Returns the that returns specified license in + /// response to a GET request. + /// + /// The key of the license to retrieve + /// The to license. + public static Uri Licenses(string key) + { + return "licenses/{0}".FormatUri(key); + } + + /// + /// Returns the that returns rate limit in + /// response to a GET request. + /// + /// The to rate limit. + public static Uri RateLimit() + { + return "rate_limit".FormatUri(); + } + + /// + /// Returns the that returns meta in + /// response to a GET request. + /// + /// The to meta. + public static Uri Meta() + { + return "meta".FormatUri(); + } } }