From 2b002c1cef633a28a4a162c04d76e1feecddceac Mon Sep 17 00:00:00 2001 From: pltaylor Date: Wed, 6 Nov 2013 19:32:51 -0500 Subject: [PATCH] Create ObservableBlobClient and interface --- .../Clients/IObservableBlobClient.cs | 31 +++++++++++ .../Clients/ObservableBlobClient.cs | 55 +++++++++++++++++++ Octokit.Reactive/Octokit.Reactive.csproj | 2 + 3 files changed, 88 insertions(+) create mode 100644 Octokit.Reactive/Clients/IObservableBlobClient.cs create mode 100644 Octokit.Reactive/Clients/ObservableBlobClient.cs diff --git a/Octokit.Reactive/Clients/IObservableBlobClient.cs b/Octokit.Reactive/Clients/IObservableBlobClient.cs new file mode 100644 index 00000000..db6a7957 --- /dev/null +++ b/Octokit.Reactive/Clients/IObservableBlobClient.cs @@ -0,0 +1,31 @@ +using System; + +namespace Octokit.Reactive +{ + public interface IObservableBlobClient + { + /// + /// Gets a single Blob by SHA. + /// + /// + /// http://developer.github.com/v3/git/blobs/#get-a-blob + /// + /// The owner of the repository + /// The name of the repository + /// The SHA of the blob + /// The for the specified SHA. + IObservable Get(string owner, string name, string reference); + + /// + /// Creates a new Blob + /// + /// + /// http://developer.github.com/v3/git/blobs/#create-a-blob + /// + /// The owner of the repository + /// The name of the repository + /// The new Blob + /// The that was just created. + IObservable Create(string owner, string name, NewBlob newBlob); + } +} \ No newline at end of file diff --git a/Octokit.Reactive/Clients/ObservableBlobClient.cs b/Octokit.Reactive/Clients/ObservableBlobClient.cs new file mode 100644 index 00000000..26563f65 --- /dev/null +++ b/Octokit.Reactive/Clients/ObservableBlobClient.cs @@ -0,0 +1,55 @@ +using System; +using System.Reactive.Threading.Tasks; + +namespace Octokit.Reactive +{ + public class ObservableBlobClient : IObservableBlobClient + { + readonly IBlobsClient _client; + + public ObservableBlobClient(IGitHubClient client) + { + Ensure.ArgumentNotNull(client, "client"); + + _client = client.Blob; + } + + /// + /// Gets a single Blob by SHA. + /// + /// + /// http://developer.github.com/v3/git/blobs/#get-a-blob + /// + /// The owner of the repository + /// The name of the repository + /// The SHA of the blob + /// The for the specified SHA. + 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(); + } + + /// + /// Creates a new Blob + /// + /// + /// http://developer.github.com/v3/git/blobs/#create-a-blob + /// + /// The owner of the repository + /// The name of the repository + /// The new Blob + /// The that was just created. + public IObservable Create(string owner, string name, NewBlob newBlob) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(newBlob, "newBlob"); + + return _client.Create(owner, name, newBlob).ToObservable(); + } + } +} diff --git a/Octokit.Reactive/Octokit.Reactive.csproj b/Octokit.Reactive/Octokit.Reactive.csproj index 493f29cc..51c48ab7 100644 --- a/Octokit.Reactive/Octokit.Reactive.csproj +++ b/Octokit.Reactive/Octokit.Reactive.csproj @@ -73,7 +73,9 @@ Properties\SolutionInfo.cs + +