Add interface and required entities for Commit Comments.

This commit is contained in:
Will Froese
2014-02-22 22:56:22 -05:00
parent 8628a8aa36
commit fb9d400cfb
4 changed files with 201 additions and 0 deletions
@@ -0,0 +1,78 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
namespace Octokit
{
/// <summary>
/// A client for GitHub's Repository Comments API.
/// </summary>
/// <remarks>
/// See the <a href="http://developer.github.com/v3/repos/comments/">Repository Comments API documentation</a> for more information.
/// </remarks>
public interface IRepositoryCommentsClient
{
/// <summary>
/// Gets a single Repository Comment by number.
/// </summary>
/// <remarks>http://developer.github.com/v3/repos/comments/#get-a-single-commit-comment</remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="number">The comment id</param>
/// <returns></returns>
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
Justification = "Method makes a network request")]
Task<CommitComment> Get(string owner, string name, int number);
/// <summary>
/// Gets Commit Comments for a repository.
/// </summary>
/// <remarks>http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository</remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <returns></returns>
Task<IReadOnlyList<CommitComment>> GetForRepository(string owner, string name);
/// <summary>
/// Gets Commit Comments for a specified Commit.
/// </summary>
/// <remarks>http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit</remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="number">The commit id</param>
/// <returns></returns>
Task<IReadOnlyList<CommitComment>> GetForCommit(string owner, string name, int number);
/// <summary>
/// Creates a new Commit Comment for a specified Issue.
/// </summary>
/// <remarks>http://developer.github.com/v3/repos/comments/#create-a-commit-comment</remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="reference">The sha reference of commit</param>
/// <param name="newCommitComment">The new comment to add to the commit</param>
/// <returns></returns>
Task<CommitComment> Create(string owner, string name, string reference, NewCommitComment newCommitComment);
/// <summary>
/// Updates a specified Commit Comment.
/// </summary>
/// <remarks>http://developer.github.com/v3/repos/comments/#update-a-commit-comment</remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="number">The comment number</param>
/// <param name="commentUpdate">The modified comment</param>
/// <returns></returns>
Task<CommitComment> Update(string owner, string name, int number, string commentUpdate);
/// <summary>
/// Deletes the specified Commit Comment
/// </summary>
/// <remarks>http://developer.github.com/v3/repos/comments/#delete-a-commit-comment</remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="number">The comment id</param>
/// <returns></returns>
Task Delete(string owner, string name, int number);
}
}
@@ -0,0 +1,43 @@
using System;
using System.Diagnostics;
using System.Globalization;
namespace Octokit
{
/// <summary>
/// Describes a new commit comment to create via the <see cref="IRepositoryCommentsClient.Create(string,string,string,NewCommitComment)"/> method.
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class NewCommitComment
{
public NewCommitComment(string body)
{
Ensure.ArgumentNotNull(body, "body");
Body = body;
}
/// <summary>
/// The contents of the comment (required)
/// </summary>
public string Body { get; private set; }
/// <summary>
/// Relative path of the file to comment on
/// </summary>
public string Path { get; set; }
/// <summary>
/// Line index in the diff to comment on
/// </summary>
public int? Position { get; set; }
internal string DebuggerDisplay
{
get
{
return String.Format(CultureInfo.InvariantCulture, "Path: {0}, Body: {1}", Path, Body);
}
}
}
}
+77
View File
@@ -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
{
/// <summary>
/// The issue comment Id.
/// </summary>
public int Id { get; set; }
/// <summary>
/// The URL for this repository comment.
/// </summary>
public Uri Url { get; set; }
/// <summary>
/// The html URL for this repository comment.
/// </summary>
public Uri HtmlUrl { get; set; }
/// <summary>
/// Details about the repository comment.
/// </summary>
public string Body { get; set; }
/// <summary>
/// Relative path of the file that was commented on.
/// </summary>
public string Path { get; set; }
/// <summary>
/// Line index in the diff that was commented on.
/// </summary>
public int Position { get; set; }
/// <summary>
/// The line number in the file that was commented on.
/// </summary>
public int Line { get; set; }
/// <summary>
/// The commit
/// </summary>
public string CommitId { get; set; }
/// <summary>
/// The user that created the repository comment.
/// </summary>
public User User { get; set; }
/// <summary>
/// The date the repository comment was created.
/// </summary>
public DateTimeOffset CreatedAt { get; set; }
/// <summary>
/// The date the repository comment was last updated.
/// </summary>
public DateTimeOffset? UpdatedAt { get; set; }
internal string DebuggerDisplay
{
get
{
return String.Format(CultureInfo.InvariantCulture, "Id: {0}, Commit Id: {1}, CreatedAt: {2}", Id, CommitId, CreatedAt);
}
}
}
}
+3
View File
@@ -54,11 +54,14 @@
<Link>Properties\SolutionInfo.cs</Link>
</Compile>
<Compile Include="Clients\ActivitiesClient.cs" />
<Compile Include="Clients\IRepositoryCommentsClient.cs" />
<Compile Include="Clients\FeedsClient.cs" />
<Compile Include="Clients\IFeedsClient.cs" />
<Compile Include="Exceptions\PrivateRepositoryQuotaExceededException.cs" />
<Compile Include="Exceptions\RepositoryExistsException.cs" />
<Compile Include="Helpers\ApiErrorExtensions.cs" />
<Compile Include="Models\Request\NewCommitComment.cs" />
<Compile Include="Models\Response\CommitComment.cs" />
<Compile Include="Models\Response\DeploymentStatus.cs" />
<Compile Include="Clients\DeploymentStatusClient.cs" />
<Compile Include="Clients\IDeploymentStatusClient.cs" />