using System; using System.Reactive.Threading.Tasks; using Octokit.Reactive.Internal; namespace Octokit.Reactive { public class ObservableAssigneesClient : IObservableAssigneesClient { readonly IAssigneesClient _client; readonly IConnection _connection; public ObservableAssigneesClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, "client"); _client = client.Issue.Assignee; _connection = client.Connection; } /// /// Gets all the available assignees (owner + collaborators) to which issues may be assigned. /// /// The owner of the repository /// The name of the repository /// public IObservable GetAllForRepository(string owner, string name) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); return _connection.GetAndFlattenAllPages(ApiUrls.Assignees(owner, name)); } /// /// 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 behaviour /// public IObservable GetAllForRepository(string owner, string name, ApiOptions options) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(options, "options"); return _connection.GetAndFlattenAllPages(ApiUrls.Assignees(owner, name), 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 IObservable CheckAssignee(string owner, string name, string assignee) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(assignee, "assignee"); return _client.CheckAssignee(owner, name, assignee).ToObservable(); } } }