diff --git a/Octokit/Models/Response/License.cs b/Octokit/Models/Response/License.cs new file mode 100644 index 00000000..b42e01bf --- /dev/null +++ b/Octokit/Models/Response/License.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Globalization; +using System.Linq; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class License : LicenseMetadata + { + public License( + string key, + string name, + Uri url, + Uri htmlUrl, + bool featured, + string description, + string category, + string implementation, + string body, + IEnumerable required, + IEnumerable permitted, + IEnumerable forbidden) : base(key, name, url) + { + Ensure.ArgumentNotNull(htmlUrl, "htmlUrl"); + Ensure.ArgumentNotNull(description, "description"); + Ensure.ArgumentNotNull(category, "category"); + Ensure.ArgumentNotNull(implementation, "implementation"); + Ensure.ArgumentNotNull(body, "body"); + Ensure.ArgumentNotNull(required, "required"); + Ensure.ArgumentNotNull(permitted, "permitted"); + Ensure.ArgumentNotNull(forbidden, "forbidden"); + + HtmlUrl = htmlUrl; + Featured = featured; + Description = description; + Category = category; + Implementation = implementation; + Body = body; + Required = new ReadOnlyCollection(required.ToList()); + Permitted = new ReadOnlyCollection(permitted.ToList()); + Forbidden = new ReadOnlyCollection(forbidden.ToList()); + } + + public License() + { + } + + /// + /// Url to the license on https://choosealicense.com + /// + public Uri HtmlUrl { get; protected set; } + + /// + /// Whether the license is one of the licenses featured on https://choosealicense.com + /// + public bool Featured { get; protected set; } + + /// + /// A description of the license. + /// + public string Description { get; protected set; } + + /// + /// A group or family that the license belongs to such as the GPL family of licenses. + /// + public string Category { get; protected set; } + + /// + /// Notes on how to properly apply the license. + /// + public string Implementation { get; protected set; } + + /// + /// Set of codes for what is required under the terms of the license. For example, "include-copyright" + /// + public IReadOnlyCollection Required { get; protected set; } + + /// + /// Set of codes for what is permitted under the terms of the license. For example, "commerical-use" + /// + public IReadOnlyCollection Permitted { get; protected set; } + + /// + /// Set of codes for what is forbidden under the terms of the license. For example, "no-liability" + /// + public IReadOnlyCollection Forbidden { get; protected set; } + + /// + /// The text of the license + /// + public string Body { get; set; } + + internal override string DebuggerDisplay + { + get + { + return String.Format(CultureInfo.InvariantCulture, "{0} Category: {1}", base.DebuggerDisplay, Category); + } + } + } +} diff --git a/Octokit/Models/Response/LicenseMetadata.cs b/Octokit/Models/Response/LicenseMetadata.cs new file mode 100644 index 00000000..5c00da3b --- /dev/null +++ b/Octokit/Models/Response/LicenseMetadata.cs @@ -0,0 +1,48 @@ +using System; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class LicenseMetadata + { + public LicenseMetadata(string key, string name, Uri url) + { + Ensure.ArgumentNotNullOrEmptyString(key, "key"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(url, "url"); + + Key = key; + Name = name; + Url = url; + } + + public LicenseMetadata() + { + } + + /// + /// The + /// + public string Key { get; protected set; } + + /// + /// Friendly name of the license. + /// + public string Name { get; protected set; } + + /// + /// URL to retrieve details about a license. + /// + public Uri Url { get; protected set; } + + internal virtual string DebuggerDisplay + { + get + { + return String.Format(CultureInfo.InvariantCulture, "Key: {0} Name: {1}", Key, Name); + } + } + } +} diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj index 911ffb26..be0415f6 100644 --- a/Octokit/Octokit-Mono.csproj +++ b/Octokit/Octokit-Mono.csproj @@ -379,6 +379,8 @@ + + \ No newline at end of file diff --git a/Octokit/Octokit-MonoAndroid.csproj b/Octokit/Octokit-MonoAndroid.csproj index 2f6a3603..2680ecd3 100644 --- a/Octokit/Octokit-MonoAndroid.csproj +++ b/Octokit/Octokit-MonoAndroid.csproj @@ -391,6 +391,8 @@ + + \ No newline at end of file diff --git a/Octokit/Octokit-Monotouch.csproj b/Octokit/Octokit-Monotouch.csproj index 6c115035..1582335c 100644 --- a/Octokit/Octokit-Monotouch.csproj +++ b/Octokit/Octokit-Monotouch.csproj @@ -384,6 +384,8 @@ + + diff --git a/Octokit/Octokit-Portable.csproj b/Octokit/Octokit-Portable.csproj index 41aa90fa..ef12a34b 100644 --- a/Octokit/Octokit-Portable.csproj +++ b/Octokit/Octokit-Portable.csproj @@ -377,6 +377,8 @@ + + diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index f5c7dc53..f5debdf3 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -381,6 +381,8 @@ + + diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 8e2a6764..d75e762c 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -105,6 +105,8 @@ + +