using System;
using System.Threading.Tasks;
namespace Octokit
{
///
/// A client for GitHub's Users API.
///
///
/// See the Users API documentation for more information.
///
public class UsersClient : ApiClient, IUsersClient
{
static readonly Uri _userEndpoint = new Uri("user", UriKind.Relative);
///
/// Instantiates a new GitHub Users API client.
///
/// An API connection
public UsersClient(IApiConnection apiConnection) : base(apiConnection)
{
Email = new UserEmailsClient(apiConnection);
Followers = new FollowersClient(apiConnection);
GitSshKey = new UserKeysClient(apiConnection);
GpgKey = new UserGpgKeysClient(apiConnection);
Administration = new UserAdministrationClient(apiConnection);
}
///
/// A client for GitHub's User Emails API
///
///
/// See the Emails API documentation for more information.
///
public IUserEmailsClient Email { get; private set; }
///
/// A client for GitHub's User Keys API
///
///
/// See the Keys API documentation for more information.
///
public IUserKeysClient GitSshKey { get; private set; }
///
/// A client for GitHub's UserUser GPG Keys API.
///
///
/// See the User GPG Keys documentation for more information.
///
public IUserGpgKeysClient GpgKey { get; private set; }
///
/// Returns the user specified by the login.
///
/// The login name for the user
[ManualRoute("GET", "/users/{username}")]
public Task Get(string login)
{
Ensure.ArgumentNotNullOrEmptyString(login, nameof(login));
return ApiConnection.Get(ApiUrls.User(login));
}
///
/// Returns a for the current authenticated user.
///
/// Thrown if the client is not authenticated.
/// A
[ManualRoute("GET", "/user")]
public Task Current()
{
return ApiConnection.Get(_userEndpoint);
}
///
/// Update the specified .
///
/// The login for the user
/// Thrown if the client is not authenticated.
/// A
[ManualRoute("PATCH", "/user")]
public Task Update(UserUpdate user)
{
Ensure.ArgumentNotNull(user, nameof(user));
return ApiConnection.Patch(_userEndpoint, user);
}
///
/// A client for GitHub's User Followers API
///
///
/// See the Followers API documentation for more information.
///
public IFollowersClient Followers { get; private set; }
///
/// A client for GitHub's User Administration API
///
///
/// See the User Administration API documentation for more information.
///
public IUserAdministrationClient Administration { get; private set; }
}
}