From 92d3d18838f9df9abcf13185243a0937d942d347 Mon Sep 17 00:00:00 2001 From: Amy Palamountain Date: Thu, 9 Jan 2014 22:07:05 +1300 Subject: [PATCH] Added stats/contributors client & response objects Not a fan of those suppress messages on weekly hash. Will see if we can clean this up :soon: --- Octokit/Clients/IStatisticsClient.cs | 14 +++++++++ Octokit/Models/Response/Author.cs | 43 ++++++++++++++++++++++++++ Octokit/Models/Response/Contributor.cs | 29 +++++++++++++++++ Octokit/Models/Response/WeeklyHash.cs | 19 ++++++++++++ Octokit/Octokit-Mono.csproj | 4 +++ Octokit/Octokit-netcore45.csproj | 4 +++ Octokit/Octokit.csproj | 4 +++ 7 files changed, 117 insertions(+) create mode 100644 Octokit/Clients/IStatisticsClient.cs create mode 100644 Octokit/Models/Response/Author.cs create mode 100644 Octokit/Models/Response/Contributor.cs create mode 100644 Octokit/Models/Response/WeeklyHash.cs diff --git a/Octokit/Clients/IStatisticsClient.cs b/Octokit/Clients/IStatisticsClient.cs new file mode 100644 index 00000000..657eb979 --- /dev/null +++ b/Octokit/Clients/IStatisticsClient.cs @@ -0,0 +1,14 @@ +using System.Threading.Tasks; + +namespace Octokit +{ + public interface IStatisticsClient + { + /// + /// Returns a for the current authenticated user. + /// + /// Thrown if the client is not authenticated. + /// A + Task Contributors(); + } +} \ No newline at end of file diff --git a/Octokit/Models/Response/Author.cs b/Octokit/Models/Response/Author.cs new file mode 100644 index 00000000..faa3a6ff --- /dev/null +++ b/Octokit/Models/Response/Author.cs @@ -0,0 +1,43 @@ +namespace Octokit +{ + public class Author + { + public string Login { get; set; } + + public int Id { get; set; } + + public string AvatarUrl { get; set; } + + /// + /// Hex Gravatar identifier + /// + public string GravatarId { get; set; } + + public string Url { get; set; } + + public string HtmlUrl { get; set; } + + public string FollowersUrl { get; set; } + + public string FollowingUrl { get; set; } + + public string GistsUrl { get; set; } + + public string StarredUrl { get; set; } + + public string SubscriptionsUrl { get; set; } + + public string OrganizationsUrl { get; set; } + + public string ReposUrl { get; set; } + + public string EventsUrl { get; set; } + + public string ReceivedEventsUrl { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods", Justification = "This is what is returned from the api")] + public string Type { get; set; } + + public bool SiteAdmin { get; set; } + } +} \ No newline at end of file diff --git a/Octokit/Models/Response/Contributor.cs b/Octokit/Models/Response/Contributor.cs new file mode 100644 index 00000000..8a989aa8 --- /dev/null +++ b/Octokit/Models/Response/Contributor.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + /// + /// Represents a contributor on GitHub. + /// + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class Contributor + { + public Author Author { get; set; } + + public int Total { get; set; } + + public IEnumerable Weeks { get; set; } + + internal string DebuggerDisplay + { + get + { + return String.Format(CultureInfo.InvariantCulture, + "Author: Id: {0} Login: {1}", Author.Id, Author.Login); + } + } + } +} \ No newline at end of file diff --git a/Octokit/Models/Response/WeeklyHash.cs b/Octokit/Models/Response/WeeklyHash.cs new file mode 100644 index 00000000..9ef501da --- /dev/null +++ b/Octokit/Models/Response/WeeklyHash.cs @@ -0,0 +1,19 @@ +using System; + +namespace Octokit +{ + public class WeeklyHash + { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "W")] + public DateTime W { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "A")] + public int A { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "D")] + public int D { get; set; } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "C")] + public int C { get; set; } + } +} \ No newline at end of file diff --git a/Octokit/Octokit-Mono.csproj b/Octokit/Octokit-Mono.csproj index cf077ea6..49f44dda 100644 --- a/Octokit/Octokit-Mono.csproj +++ b/Octokit/Octokit-Mono.csproj @@ -65,6 +65,7 @@ + @@ -101,11 +102,13 @@ + + @@ -134,6 +137,7 @@ + diff --git a/Octokit/Octokit-netcore45.csproj b/Octokit/Octokit-netcore45.csproj index d6eadc39..73b72e19 100644 --- a/Octokit/Octokit-netcore45.csproj +++ b/Octokit/Octokit-netcore45.csproj @@ -87,6 +87,7 @@ + @@ -194,11 +195,13 @@ + + @@ -234,6 +237,7 @@ + diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 0ee4ab8f..28eb78df 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -78,6 +78,7 @@ + @@ -105,6 +106,7 @@ + @@ -121,6 +123,7 @@ + @@ -192,6 +195,7 @@ +