using System;
using System.Diagnostics.CodeAnalysis;
using System.Reactive.Linq;
using System.Reactive.Threading.Tasks;
namespace Octokit.Reactive
{
public class ObservableMiscellaneousClient : IObservableMiscellaneousClient
{
readonly IMiscellaneousClient _client;
public ObservableMiscellaneousClient(IGitHubClient client)
{
Ensure.ArgumentNotNull(client, nameof(client));
_client = client.Miscellaneous;
}
///
/// Gets all the emojis available to use on GitHub.
///
/// Thrown when a general API error occurs.
/// An of emoji and their URI.
public IObservable GetAllEmojis()
{
return _client.GetAllEmojis().ToObservable().SelectMany(e => e);
}
///
/// Gets the rendered Markdown for an arbitrary markdown document.
///
/// An arbitrary Markdown document
/// Thrown when a general API error occurs.
/// The rendered Markdown.
public IObservable RenderArbitraryMarkdown(NewArbitraryMarkdown markdown)
{
return _client.RenderArbitraryMarkdown(markdown).ToObservable();
}
///
/// Gets the rendered Markdown for the specified plain-text Markdown document.
///
/// A plain-text Markdown document
/// Thrown when a general API error occurs.
/// The rendered Markdown.
public IObservable RenderRawMarkdown(string markdown)
{
return _client.RenderRawMarkdown(markdown).ToObservable();
}
///
/// List all templates available to pass as an option when creating a repository.
///
/// An observable list of gitignore template names.
public IObservable GetAllGitIgnoreTemplates()
{
return _client.GetAllGitIgnoreTemplates().ToObservable().SelectMany(t => t);
}
///
/// Retrieves the source for a single GitIgnore template
///
/// Returns the template source for the given template
public IObservable GetGitIgnoreTemplate(string templateName)
{
return _client.GetGitIgnoreTemplate(templateName).ToObservable();
}
///
/// Returns a list of the licenses shown in the license picker on GitHub.com. This is not a comprehensive
/// list of all possible OSS licenses.
///
/// A list of licenses available on the site
public IObservable GetAllLicenses()
{
return GetAllLicenses(ApiOptions.None);
}
///
/// Returns a list of the licenses shown in the license picker on GitHub.com. This is not a comprehensive
/// list of all possible OSS licenses.
///
/// Options for changing the API response
/// A list of licenses available on the site
public IObservable GetAllLicenses(ApiOptions options)
{
return _client.GetAllLicenses(options).ToObservable().SelectMany(l => l);
}
///
/// Retrieves a license based on the license key such as "MIT"
///
///
/// A that includes the license key, text, and attributes of the license.
public IObservable GetLicense(string key)
{
return _client.GetLicense(key).ToObservable();
}
///
/// Gets API Rate Limits (API service rather than header info).
///
/// Thrown when a general API error occurs.
/// An of Rate Limits.
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
public IObservable GetRateLimits()
{
return _client.GetRateLimits().ToObservable();
}
///
/// Retrieves information about GitHub.com, the service or a GitHub Enterprise installation.
///
/// Thrown when a general API error occurs.
/// An containing metadata about the GitHub instance.
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
public IObservable GetMetadata()
{
return _client.GetMetadata().ToObservable();
}
}
}