using System.Collections.Generic;
using System.Threading.Tasks;
namespace Octokit
{
///
/// A client for GitHub's Activity Notifications API.
///
///
/// See the Activity Notifications API documentation for more information.
///
public class NotificationsClient : ApiClient, INotificationsClient
{
///
/// Instantiates a new GitHub Activity Notifications API client.
///
/// An API connection
public NotificationsClient(IApiConnection apiConnection) : base(apiConnection)
{
}
///
/// Retrieves all of the s for the current user.
///
/// Thrown if the client is not authenticated.
[ManualRoute("GET", "/notifications")]
public Task> GetAllForCurrent()
{
return GetAllForCurrent(ApiOptions.None);
}
///
/// Retrieves all of the s for the current user.
///
/// Options for changing the API response
/// Thrown if the client is not authenticated.
[ManualRoute("GET", "/notifications")]
public Task> GetAllForCurrent(ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
return ApiConnection.GetAll(ApiUrls.Notifications(), options);
}
///
/// Retrieves all of the s for the current user.
///
/// Specifies the parameters to filter notifications by
/// Thrown if the client is not authenticated.
[ManualRoute("GET", "/notifications")]
public Task> GetAllForCurrent(NotificationsRequest request)
{
Ensure.ArgumentNotNull(request, nameof(request));
return GetAllForCurrent(request, ApiOptions.None);
}
///
/// Retrieves all of the s for the current user.
///
/// Specifies the parameters to filter notifications by
/// Options for changing the API response
/// Thrown if the client is not authenticated.
[ManualRoute("GET", "/notifications")]
public Task> GetAllForCurrent(NotificationsRequest request, ApiOptions options)
{
Ensure.ArgumentNotNull(request, nameof(request));
Ensure.ArgumentNotNull(options, nameof(options));
return ApiConnection.GetAll(ApiUrls.Notifications(), request.ToParametersDictionary(), options);
}
///
/// Retrieves all of the s for the current user specific to the specified repository.
///
/// The owner of the repository.
/// The name of the repository.
/// Thrown if the client is not authenticated.
[ManualRoute("GET", "/repos/{owner}/{repo}/notifications")]
public Task> GetAllForRepository(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
return GetAllForRepository(owner, name, ApiOptions.None);
}
///
/// Retrieves all of the s for the current user specific to the specified repository.
///
/// The Id of the repository.
/// Thrown if the client is not authenticated.
[ManualRoute("GET", "/repositories/{id}/notifications")]
public Task> GetAllForRepository(long repositoryId)
{
return GetAllForRepository(repositoryId, ApiOptions.None);
}
///
/// Retrieves all of the s for the current user specific to the specified repository.
///
/// The owner of the repository.
/// The name of the repository.
/// Options for changing the API response
/// Thrown if the client is not authenticated.
[ManualRoute("GET", "/repos/{owner}/{repo}/notifications")]
public Task> GetAllForRepository(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(options, nameof(options));
return ApiConnection.GetAll(ApiUrls.Notifications(owner, name), options);
}
///
/// Retrieves all of the s for the current user specific to the specified repository.
///
/// The Id of the repository.
/// Options for changing the API response
/// Thrown if the client is not authenticated.
[ManualRoute("GET", "/repositories/{id}/notifications")]
public Task> GetAllForRepository(long repositoryId, ApiOptions options)
{
Ensure.ArgumentNotNull(options, nameof(options));
return ApiConnection.GetAll(ApiUrls.Notifications(repositoryId), options);
}
///
/// Retrieves all of the s for the current user specific to the specified repository.
///
/// The owner of the repository.
/// The name of the repository.
/// Specifies the parameters to filter notifications by
/// Thrown if the client is not authenticated.
[ManualRoute("GET", "/repos/{owner}/{repo}/notifications")]
public Task> GetAllForRepository(string owner, string name, NotificationsRequest request)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(request, nameof(request));
return GetAllForRepository(owner, name, request, ApiOptions.None);
}
///
/// Retrieves all of the s for the current user specific to the specified repository.
///
/// The Id of the repository.
/// Specifies the parameters to filter notifications by
/// Thrown if the client is not authenticated.
[ManualRoute("GET", "/repositories/{id}/notifications")]
public Task> GetAllForRepository(long repositoryId, NotificationsRequest request)
{
Ensure.ArgumentNotNull(request, nameof(request));
return GetAllForRepository(repositoryId, request, ApiOptions.None);
}
///
/// Retrieves all of the s for the current user specific to the specified repository.
///
/// The owner of the repository.
/// The name of the repository.
/// Specifies the parameters to filter notifications by
/// Options for changing the API response
/// Thrown if the client is not authenticated.
[ManualRoute("GET", "/repos/{owner}/{repo}/notifications")]
public Task> GetAllForRepository(string owner, string name, NotificationsRequest request, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));
Ensure.ArgumentNotNull(request, nameof(request));
Ensure.ArgumentNotNull(options, nameof(options));
return ApiConnection.GetAll(ApiUrls.Notifications(owner, name), request.ToParametersDictionary(), options);
}
///
/// Retrieves all of the s for the current user specific to the specified repository.
///
/// The Id of the repository.
/// Specifies the parameters to filter notifications by
/// Options for changing the API response
/// Thrown if the client is not authenticated.
[ManualRoute("GET", "/repositories/{id}/notifications")]
public Task> GetAllForRepository(long repositoryId, NotificationsRequest request, ApiOptions options)
{
Ensure.ArgumentNotNull(request, nameof(request));
Ensure.ArgumentNotNull(options, nameof(options));
return ApiConnection.GetAll(ApiUrls.Notifications(repositoryId), request.ToParametersDictionary(), options);
}
///
/// Marks all notifications as read.
///
/// http://developer.github.com/v3/activity/notifications/#mark-as-read
[ManualRoute("PUT", "/notifications")]
public Task MarkAsRead()
{
return ApiConnection.Put