using System.Collections.Generic;
using System.Threading.Tasks;
namespace Octokit
{
///
/// A client for GitHub's Issue Comments API.
///
///
/// See the Issue Comments API documentation for more information.
///
public class IssueCommentsClient : ApiClient, IIssueCommentsClient
{
///
/// Instantiates a new GitHub Issue Comments API client.
///
/// An API connection
public IssueCommentsClient(IApiConnection apiConnection) : base(apiConnection)
{
}
///
/// Gets a single Issue Comment by id.
///
/// http://developer.github.com/v3/issues/comments/#get-a-single-comment
/// The owner of the repository
/// The name of the repository
/// The issue comment id
public Task Get(string owner, string name, int id)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return ApiConnection.Get(ApiUrls.IssueComment(owner, name, id), null, AcceptHeaders.ReactionsPreview);
}
///
/// Gets a single Issue Comment by id.
///
/// http://developer.github.com/v3/issues/comments/#get-a-single-comment
/// The ID of the repository
/// The issue comment id
public Task Get(int repositoryId, int id)
{
return ApiConnection.Get(ApiUrls.IssueComment(repositoryId, id), null, AcceptHeaders.ReactionsPreview);
}
///
/// Gets Issue Comments for a repository.
///
/// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
/// The owner of the repository
/// The name of the repository
public Task> GetAllForRepository(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return GetAllForRepository(owner, name, ApiOptions.None);
}
///
/// Gets Issue Comments for a repository.
///
/// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
/// The ID of the repository
public Task> GetAllForRepository(int repositoryId)
{
return GetAllForRepository(repositoryId, ApiOptions.None);
}
///
/// Gets Issue Comments for a repository.
///
/// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
/// The owner of the repository
/// The name of the repository
/// Options for changing the API response
public Task> GetAllForRepository(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(options, "options");
return ApiConnection.GetAll(ApiUrls.IssueComments(owner, name), null, AcceptHeaders.ReactionsPreview, options);
}
///
/// Gets Issue Comments for a repository.
///
/// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
/// The ID of the repository
/// Options for changing the API response
public Task> GetAllForRepository(int repositoryId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, "options");
return ApiConnection.GetAll(ApiUrls.IssueComments(repositoryId), null, AcceptHeaders.ReactionsPreview, options);
}
///
/// Gets Issue Comments for a specified Issue.
///
/// http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
/// The owner of the repository
/// The name of the repository
/// The issue number
public Task> GetAllForIssue(string owner, string name, int number)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return GetAllForIssue(owner, name, number, ApiOptions.None);
}
///
/// Gets Issue Comments for a specified Issue.
///
/// http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
/// The ID of the repository
/// The issue number
public Task> GetAllForIssue(int repositoryId, int number)
{
return GetAllForIssue(repositoryId, number, ApiOptions.None);
}
///
/// Gets Issue Comments for a specified Issue.
///
/// http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
/// The owner of the repository
/// The name of the repository
/// The issue number
/// Options for changing the API response
public Task> GetAllForIssue(string owner, string name, int number, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(options, "options");
return ApiConnection.GetAll(ApiUrls.IssueComments(owner, name, number), null, AcceptHeaders.ReactionsPreview, options);
}
///
/// Gets Issue Comments for a specified Issue.
///
/// http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
/// The ID of the repository
/// The issue number
/// Options for changing the API response
public Task> GetAllForIssue(int repositoryId, int number, ApiOptions options)
{
Ensure.ArgumentNotNull(options, "options");
return ApiConnection.GetAll(ApiUrls.IssueComments(repositoryId, number), null, AcceptHeaders.ReactionsPreview, options);
}
///
/// Creates a new Issue Comment for a specified Issue.
///
/// http://developer.github.com/v3/issues/comments/#create-a-comment
/// The owner of the repository
/// The name of the repository
/// The number of the issue
/// The new comment to add to the issue
public Task Create(string owner, string name, int number, string newComment)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(newComment, "newComment");
return ApiConnection.Post(ApiUrls.IssueComments(owner, name, number), new BodyWrapper(newComment));
}
///
/// Creates a new Issue Comment for a specified Issue.
///
/// http://developer.github.com/v3/issues/comments/#create-a-comment
/// The ID of the repository
/// The number of the issue
/// The new comment to add to the issue
public Task Create(int repositoryId, int number, string newComment)
{
Ensure.ArgumentNotNull(newComment, "newComment");
return ApiConnection.Post(ApiUrls.IssueComments(repositoryId, number), new BodyWrapper(newComment));
}
///
/// Updates a specified Issue Comment.
///
/// http://developer.github.com/v3/issues/comments/#edit-a-comment
/// The owner of the repository
/// The name of the repository
/// The comment id
/// The modified comment
public Task Update(string owner, string name, int id, string commentUpdate)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(commentUpdate, "commentUpdate");
return ApiConnection.Patch(ApiUrls.IssueComment(owner, name, id), new BodyWrapper(commentUpdate));
}
///
/// Updates a specified Issue Comment.
///
/// http://developer.github.com/v3/issues/comments/#edit-a-comment
/// The ID of the repository
/// The comment id
/// The modified comment
public Task Update(int repositoryId, int id, string commentUpdate)
{
Ensure.ArgumentNotNull(commentUpdate, "commentUpdate");
return ApiConnection.Patch(ApiUrls.IssueComment(repositoryId, id), new BodyWrapper(commentUpdate));
}
///
/// Deletes the specified Issue Comment
///
/// http://developer.github.com/v3/issues/comments/#delete-a-comment
/// The owner of the repository
/// The name of the repository
/// The comment id
public Task Delete(string owner, string name, int id)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
return ApiConnection.Delete(ApiUrls.IssueComment(owner, name, id));
}
///
/// Deletes the specified Issue Comment
///
/// http://developer.github.com/v3/issues/comments/#delete-a-comment
/// The ID of the repository
/// The comment id
public Task Delete(int repositoryId, int id)
{
return ApiConnection.Delete(ApiUrls.IssueComment(repositoryId, id));
}
}
}