using System.Collections.Generic;
using System.Threading.Tasks;
namespace Octokit
{
///
/// A client for GitHub's Issue Assignees API.
///
///
/// See the Issue Assignees API documentation for more information.
///
public class AssigneesClient : ApiClient, IAssigneesClient
{
///
/// Instantiates a new GitHub Issue Assignees API client.
///
/// An API connection
public AssigneesClient(IApiConnection apiConnection) : base(apiConnection)
{
}
///
/// Gets all the available assignees (owner + collaborators) to which issues may be assigned.
///
/// 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 all the available assignees (owner + collaborators) to which issues may be assigned.
///
/// The ID of the repository
///
public Task> GetAllForRepository(int repositoryId)
{
return GetAllForRepository(repositoryId, ApiOptions.None);
}
///
/// Gets all the available assignees (owner + collaborators) to which issues may be assigned.
///
/// The owner of the repository
/// The name of the repository
/// The options to change API's response.
///
public Task> GetAllForRepository(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNull(options, "options");
var endpoint = ApiUrls.Assignees(owner, name);
return ApiConnection.GetAll(endpoint, null, AcceptHeaders.StableVersion, options);
}
///
/// Gets all the available assignees (owner + collaborators) to which issues may be assigned.
///
/// The ID of the repository
/// The options to change API's response.
///
public Task> GetAllForRepository(int repositoryId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, "options");
var endpoint = ApiUrls.Assignees(repositoryId);
return ApiConnection.GetAll(endpoint, null, AcceptHeaders.StableVersion, options);
}
///
/// Checks to see if a user is an assignee for a repository.
///
/// The owner of the repository
/// The name of the repository
/// Username of the prospective assignee
///
public async Task CheckAssignee(string owner, string name, string assignee)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
Ensure.ArgumentNotNullOrEmptyString(name, "name");
Ensure.ArgumentNotNullOrEmptyString(assignee, "assignee");
try
{
var response = await Connection.Get