using System; using System.Reactive.Threading.Tasks; namespace Octokit.Reactive { /// /// A client for GitHub's Git Commits API. /// /// /// See the Git Commits API documentation for more information. /// public class ObservableCommitsClient : IObservableCommitsClient { readonly ICommitsClient _client; public ObservableCommitsClient(IGitHubClient client) { Ensure.ArgumentNotNull(client, "client"); _client = client.Git.Commit; } /// /// Gets a commit for a given repository by sha reference /// /// /// http://developer.github.com/v3/git/commits/#get-a-commit /// /// The owner of the repository /// The name of the repository /// Tha sha reference of the commit public IObservable Get(string owner, string name, string reference) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); return _client.Get(owner, name, reference).ToObservable(); } /// /// Gets a commit for a given repository by sha reference /// /// /// http://developer.github.com/v3/git/commits/#get-a-commit /// /// The Id of the repository /// Tha sha reference of the commit public IObservable Get(int repositoryId, string reference) { Ensure.ArgumentNotNullOrEmptyString(reference, "reference"); return _client.Get(repositoryId, reference).ToObservable(); } /// /// Create a commit for a given repository /// /// /// http://developer.github.com/v3/git/commits/#create-a-commit /// /// The owner of the repository /// The name of the repository /// The commit to create public IObservable Create(string owner, string name, NewCommit commit) { Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNull(commit, "commit"); return _client.Create(owner, name, commit).ToObservable(); } /// /// Create a commit for a given repository /// /// /// http://developer.github.com/v3/git/commits/#create-a-commit /// /// The Id of the repository /// The commit to create public IObservable Create(int repositoryId, NewCommit commit) { Ensure.ArgumentNotNull(commit, "commit"); return _client.Create(repositoryId, commit).ToObservable(); } } }