From fb9d400cfbc272a2943776669fae2419a71a90ea Mon Sep 17 00:00:00 2001 From: Will Froese Date: Sat, 22 Feb 2014 22:56:22 -0500 Subject: [PATCH] Add interface and required entities for Commit Comments. --- Octokit/Clients/IRepositoryCommentsClient.cs | 78 ++++++++++++++++++++ Octokit/Models/Request/NewCommitComment.cs | 43 +++++++++++ Octokit/Models/Response/CommitComment.cs | 77 +++++++++++++++++++ Octokit/Octokit.csproj | 3 + 4 files changed, 201 insertions(+) create mode 100644 Octokit/Clients/IRepositoryCommentsClient.cs create mode 100644 Octokit/Models/Request/NewCommitComment.cs create mode 100644 Octokit/Models/Response/CommitComment.cs diff --git a/Octokit/Clients/IRepositoryCommentsClient.cs b/Octokit/Clients/IRepositoryCommentsClient.cs new file mode 100644 index 00000000..ff4257c9 --- /dev/null +++ b/Octokit/Clients/IRepositoryCommentsClient.cs @@ -0,0 +1,78 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Threading.Tasks; + +namespace Octokit +{ + /// + /// A client for GitHub's Repository Comments API. + /// + /// + /// See the Repository Comments API documentation for more information. + /// + public interface IRepositoryCommentsClient + { + /// + /// Gets a single Repository Comment by number. + /// + /// http://developer.github.com/v3/repos/comments/#get-a-single-commit-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// + [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get", + Justification = "Method makes a network request")] + Task Get(string owner, string name, int number); + + /// + /// Gets Commit Comments for a repository. + /// + /// http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository + /// The owner of the repository + /// The name of the repository + /// + Task> GetForRepository(string owner, string name); + + /// + /// Gets Commit Comments for a specified Commit. + /// + /// http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit + /// The owner of the repository + /// The name of the repository + /// The commit id + /// + Task> GetForCommit(string owner, string name, int number); + + /// + /// Creates a new Commit Comment for a specified Issue. + /// + /// http://developer.github.com/v3/repos/comments/#create-a-commit-comment + /// The owner of the repository + /// The name of the repository + /// The sha reference of commit + /// The new comment to add to the commit + /// + Task Create(string owner, string name, string reference, NewCommitComment newCommitComment); + + /// + /// Updates a specified Commit Comment. + /// + /// http://developer.github.com/v3/repos/comments/#update-a-commit-comment + /// The owner of the repository + /// The name of the repository + /// The comment number + /// The modified comment + /// + Task Update(string owner, string name, int number, string commentUpdate); + + /// + /// Deletes the specified Commit Comment + /// + /// http://developer.github.com/v3/repos/comments/#delete-a-commit-comment + /// The owner of the repository + /// The name of the repository + /// The comment id + /// + Task Delete(string owner, string name, int number); + } +} diff --git a/Octokit/Models/Request/NewCommitComment.cs b/Octokit/Models/Request/NewCommitComment.cs new file mode 100644 index 00000000..3c312704 --- /dev/null +++ b/Octokit/Models/Request/NewCommitComment.cs @@ -0,0 +1,43 @@ +using System; +using System.Diagnostics; +using System.Globalization; + +namespace Octokit +{ + /// + /// Describes a new commit comment to create via the method. + /// + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class NewCommitComment + { + public NewCommitComment(string body) + { + Ensure.ArgumentNotNull(body, "body"); + + Body = body; + } + + /// + /// The contents of the comment (required) + /// + public string Body { get; private set; } + + /// + /// Relative path of the file to comment on + /// + public string Path { get; set; } + + /// + /// Line index in the diff to comment on + /// + public int? Position { get; set; } + + internal string DebuggerDisplay + { + get + { + return String.Format(CultureInfo.InvariantCulture, "Path: {0}, Body: {1}", Path, Body); + } + } + } +} diff --git a/Octokit/Models/Response/CommitComment.cs b/Octokit/Models/Response/CommitComment.cs new file mode 100644 index 00000000..b961f2a4 --- /dev/null +++ b/Octokit/Models/Response/CommitComment.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Octokit +{ + [DebuggerDisplay("{DebuggerDisplay,nq}")] + public class CommitComment + { + /// + /// The issue comment Id. + /// + public int Id { get; set; } + + /// + /// The URL for this repository comment. + /// + public Uri Url { get; set; } + + /// + /// The html URL for this repository comment. + /// + public Uri HtmlUrl { get; set; } + + /// + /// Details about the repository comment. + /// + public string Body { get; set; } + + /// + /// Relative path of the file that was commented on. + /// + public string Path { get; set; } + + /// + /// Line index in the diff that was commented on. + /// + public int Position { get; set; } + + /// + /// The line number in the file that was commented on. + /// + public int Line { get; set; } + + /// + /// The commit + /// + public string CommitId { get; set; } + + /// + /// The user that created the repository comment. + /// + public User User { get; set; } + + /// + /// The date the repository comment was created. + /// + public DateTimeOffset CreatedAt { get; set; } + + /// + /// The date the repository comment was last updated. + /// + public DateTimeOffset? UpdatedAt { get; set; } + + internal string DebuggerDisplay + { + get + { + return String.Format(CultureInfo.InvariantCulture, "Id: {0}, Commit Id: {1}, CreatedAt: {2}", Id, CommitId, CreatedAt); + } + } + } +} diff --git a/Octokit/Octokit.csproj b/Octokit/Octokit.csproj index 5d0559fc..8a29a0e0 100644 --- a/Octokit/Octokit.csproj +++ b/Octokit/Octokit.csproj @@ -54,11 +54,14 @@ Properties\SolutionInfo.cs + + +