diff --git a/Octokit.Reactive/Clients/IObservableGistsClient.cs b/Octokit.Reactive/Clients/IObservableGistsClient.cs
index 5bb29ede..31ea9da5 100644
--- a/Octokit.Reactive/Clients/IObservableGistsClient.cs
+++ b/Octokit.Reactive/Clients/IObservableGistsClient.cs
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics.CodeAnalysis;
+using System.Reactive;
namespace Octokit.Reactive
{
@@ -16,6 +17,143 @@ namespace Octokit.Reactive
/// The id of the gist
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
Justification = "Method makes a network request")]
- IObservable Get(string id);
+ IObservable Get(string id);
+
+ ///
+ /// List the authenticated user’s gists or if called anonymously,
+ /// this will return all public gists
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#list-gists
+ ///
+ IObservable GetAll();
+
+ ///
+ /// List the authenticated user’s gists or if called anonymously,
+ /// this will return all public gists
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#list-gists
+ ///
+ /// Only gists updated at or after this time are returned
+ IObservable GetAll(DateTimeOffset since);
+
+ ///
+ /// Lists all public gists
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#list-gists
+ ///
+ IObservable GetAllPublic();
+
+ ///
+ /// Lists all public gists
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#list-gists
+ ///
+ /// Only gists updated at or after this time are returned
+ IObservable GetAllPublic(DateTimeOffset since);
+
+ ///
+ /// List the authenticated user’s starred gists
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#list-gists
+ ///
+ IObservable GetAllStarred();
+
+ ///
+ /// List the authenticated user’s starred gists
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#list-gists
+ ///
+ /// Only gists updated at or after this time are returned
+ IObservable GetAllStarred(DateTimeOffset since);
+
+ ///
+ /// List a user's gists
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#list-gists
+ ///
+ /// The user
+ IObservable GetAllForUser(string user);
+
+ ///
+ /// List a user's gists
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#list-gists
+ ///
+ /// The user
+ /// Only gists updated at or after this time are returned
+ IObservable GetAllForUser(string user, DateTimeOffset since);
+
+ ///
+ /// Creates a new gist
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#create-a-gist
+ ///
+ /// The new gist to create
+ IObservable Create(NewGist newGist);
+
+ ///
+ /// Creates a fork of a gist
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#fork-a-gist
+ ///
+ /// The id of the gist to fork
+ IObservable Fork(string id);
+
+ ///
+ /// Edits a gist
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#delete-a-gist
+ ///
+ /// The id of the gist
+ /// The update to the gist
+ IObservable Edit(string id, GistUpdate gistUpdate);
+
+ ///
+ /// Deletes a gist
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#delete-a-gist
+ ///
+ /// The id of the gist
+ IObservable Delete(string id);
+
+ ///
+ /// Stars a gist
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#star-a-gist
+ ///
+ /// The id of the gist
+ IObservable Star(string id);
+
+ ///
+ /// Unstars a gist
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#unstar-a-gist
+ ///
+ /// The id of the gist
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Unstar")]
+ IObservable Unstar(string id);
+
+ ///
+ /// Checks if the gist is starred
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#check-if-a-gist-is-starred
+ ///
+ /// The id of the gist
+ IObservable IsStarred(string id);
}
}
\ No newline at end of file
diff --git a/Octokit.Reactive/Clients/ObservableGistsClient.cs b/Octokit.Reactive/Clients/ObservableGistsClient.cs
index 63c2e6b7..8fe981b8 100644
--- a/Octokit.Reactive/Clients/ObservableGistsClient.cs
+++ b/Octokit.Reactive/Clients/ObservableGistsClient.cs
@@ -1,17 +1,22 @@
using System;
using System.Reactive.Threading.Tasks;
+using System.Reactive;
+using System.Net;
+using Octokit.Reactive.Internal;
namespace Octokit.Reactive
{
public class ObservableGistsClient : IObservableGistsClient
{
readonly IGistsClient _client;
+ readonly IConnection _connection;
public ObservableGistsClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, "client");
_client = client.Gist;
+ _connection = client.Connection;
Comment = new ObservableGistCommentsClient(client);
}
@@ -31,5 +36,203 @@ namespace Octokit.Reactive
return _client.Get(id).ToObservable();
}
+
+ ///
+ /// Creates a new gist
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#create-a-gist
+ ///
+ /// The new gist to create
+ public IObservable Create(NewGist newGist)
+ {
+ Ensure.ArgumentNotNull(newGist, "newGist");
+
+ return _client.Create(newGist).ToObservable();
+ }
+
+ ///
+ /// Creates a fork of a gist
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#fork-a-gist
+ ///
+ /// The id of the gist to fork
+ public IObservable Fork(string id)
+ {
+ return _client.Fork(id).ToObservable();
+ }
+
+ ///
+ /// Deletes a gist
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#delete-a-gist
+ ///
+ /// The id of the gist
+ public IObservable Delete(string id)
+ {
+ Ensure.ArgumentNotNull(id, "id");
+
+ return _client.Delete(id).ToObservable();
+ }
+
+ ///
+ /// List the authenticated user’s gists or if called anonymously,
+ /// this will return all public gists
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#list-gists
+ ///
+ public IObservable GetAll()
+ {
+ return _connection.GetAndFlattenAllPages(ApiUrls.Gist());
+ }
+
+ ///
+ /// List the authenticated user’s gists or if called anonymously,
+ /// this will return all public gists
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#list-gists
+ ///
+ /// Only gists updated at or after this time are returned
+ public IObservable GetAll(DateTimeOffset since)
+ {
+ var request = new GistRequest(since);
+ return _connection.GetAndFlattenAllPages(ApiUrls.Gist(), request.ToParametersDictionary());
+ }
+
+ ///
+ /// Lists all public gists
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#list-gists
+ ///
+ public IObservable GetAllPublic()
+ {
+ return _connection.GetAndFlattenAllPages(ApiUrls.PublicGists());
+ }
+
+ ///
+ /// Lists all public gists
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#list-gists
+ ///
+ /// Only gists updated at or after this time are returned
+ public IObservable GetAllPublic(DateTimeOffset since)
+ {
+ var request = new GistRequest(since);
+ return _connection.GetAndFlattenAllPages(ApiUrls.PublicGists(), request.ToParametersDictionary());
+ }
+
+ ///
+ /// List the authenticated user’s starred gists
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#list-gists
+ ///
+ public IObservable GetAllStarred()
+ {
+ return _connection.GetAndFlattenAllPages(ApiUrls.StarredGists());
+ }
+
+ ///
+ /// List the authenticated user’s starred gists
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#list-gists
+ ///
+ /// Only gists updated at or after this time are returned
+ public IObservable GetAllStarred(DateTimeOffset since)
+ {
+ var request = new GistRequest(since);
+ return _connection.GetAndFlattenAllPages(ApiUrls.StarredGists(), request.ToParametersDictionary());
+ }
+
+ ///
+ /// List a user's gists
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#list-gists
+ ///
+ /// The user
+ public IObservable GetAllForUser(string user)
+ {
+ Ensure.ArgumentNotNull(user, "user");
+
+ return _connection.GetAndFlattenAllPages(ApiUrls.UsersGists(user));
+ }
+
+ ///
+ /// List a user's gists
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#list-gists
+ ///
+ /// The user
+ /// Only gists updated at or after this time are returned
+ public IObservable GetAllForUser(string user, DateTimeOffset since)
+ {
+ Ensure.ArgumentNotNull(user, "user");
+
+ var request = new GistRequest(since);
+ return _connection.GetAndFlattenAllPages(ApiUrls.UsersGists(user), request.ToParametersDictionary());
+ }
+
+ ///
+ /// Edits a gist
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#delete-a-gist
+ ///
+ /// The id of the gist
+ /// The update to the gist
+ public IObservable Edit(string id, GistUpdate gistUpdate)
+ {
+ Ensure.ArgumentNotNull(id, "id");
+ Ensure.ArgumentNotNull(gistUpdate, "gistUpdate");
+
+ return _client.Edit(id, gistUpdate).ToObservable();
+ }
+
+ ///
+ /// Stars a gist
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#star-a-gist
+ ///
+ /// The id of the gist
+ public IObservable Star(string id)
+ {
+ return _client.Star(id).ToObservable();
+ }
+
+ ///
+ /// Unstars a gist
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#unstar-a-gist
+ ///
+ /// The id of the gist
+ public IObservable Unstar(string id)
+ {
+ return _client.Unstar(id).ToObservable();
+ }
+
+ ///
+ /// Checks if the gist is starred
+ ///
+ ///
+ /// http://developer.github.com/v3/gists/#check-if-a-gist-is-starred
+ ///
+ /// The id of the gist
+ public IObservable IsStarred(string id)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(id, "id");
+
+ return _client.IsStarred(id).ToObservable();
+ }
}
}
\ No newline at end of file
diff --git a/Octokit/Helpers/ApiUrls.cs b/Octokit/Helpers/ApiUrls.cs
index a861044d..5956d371 100644
--- a/Octokit/Helpers/ApiUrls.cs
+++ b/Octokit/Helpers/ApiUrls.cs
@@ -602,7 +602,7 @@ namespace Octokit
///
public static Uri Feeds()
{
- return "feeds".FormatUri ();
+ return "feeds".FormatUri();
}
///
diff --git a/Octokit/Models/Request/GistRequest.cs b/Octokit/Models/Request/GistRequest.cs
index d37133e7..86989c94 100644
--- a/Octokit/Models/Request/GistRequest.cs
+++ b/Octokit/Models/Request/GistRequest.cs
@@ -1,8 +1,10 @@
using System;
-using Octokit.Internal;
+using System.Diagnostics;
+using System.Globalization;
namespace Octokit
{
+ [DebuggerDisplay("{DebuggerDisplay,nq}")]
public class GistRequest : RequestParameters
{
public GistRequest(DateTimeOffset since)
@@ -11,5 +13,13 @@ namespace Octokit
}
public DateTimeOffset Since { get; set; }
+
+ internal string DebuggerDisplay
+ {
+ get
+ {
+ return String.Format(CultureInfo.InvariantCulture, "Since: {0}", Since);
+ }
+ }
}
}
diff --git a/Octokit/Models/Request/GistUpdate.cs b/Octokit/Models/Request/GistUpdate.cs
index 1d89b251..c16fc488 100644
--- a/Octokit/Models/Request/GistUpdate.cs
+++ b/Octokit/Models/Request/GistUpdate.cs
@@ -1,9 +1,11 @@
using System;
using System.Collections.Generic;
-using Octokit.Internal;
+using System.Diagnostics;
+using System.Globalization;
namespace Octokit
{
+ [DebuggerDisplay("{DebuggerDisplay,nq}")]
public class GistUpdate
{
public GistUpdate()
@@ -13,6 +15,14 @@ namespace Octokit
public string Description { get; set; }
public IDictionary Files { get; private set; }
+
+ internal string DebuggerDisplay
+ {
+ get
+ {
+ return String.Format(CultureInfo.InvariantCulture, "Description: {0}", Description);
+ }
+ }
}
public class GistFileUpdate
diff --git a/Octokit/Models/Request/NewGist.cs b/Octokit/Models/Request/NewGist.cs
index 66726721..71b7fad4 100644
--- a/Octokit/Models/Request/NewGist.cs
+++ b/Octokit/Models/Request/NewGist.cs
@@ -1,8 +1,12 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
+using System.Diagnostics;
+using System;
+using System.Globalization;
namespace Octokit
{
+ [DebuggerDisplay("{DebuggerDisplay,nq}")]
public class NewGist
{
public NewGist()
@@ -25,5 +29,13 @@ namespace Octokit
/// and value as Content
///
public IDictionary Files { get; private set; }
+
+ internal string DebuggerDisplay
+ {
+ get
+ {
+ return String.Format(CultureInfo.InvariantCulture, "Description: {0}", Description);
+ }
+ }
}
}
\ No newline at end of file