mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-19 21:55:12 +00:00
Moved GetReadme and GetReadmeHtml to Contents
This commit is contained in:
committed by
Haacked
parent
790c07da30
commit
bed18b9980
50
Octokit/Clients/RepositoryContentsClient.cs
Normal file
50
Octokit/Clients/RepositoryContentsClient.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Octokit
|
||||
{
|
||||
public class RepositoryContentsClient : ApiClient, IRepositoryContentsClient
|
||||
{
|
||||
public RepositoryContentsClient(IApiConnection apiConnection) : base(apiConnection)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the preferred README for the specified repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/contents/#get-the-readme">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns></returns>
|
||||
public async Task<Readme> GetReadme(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
var endpoint = ApiUrls.RepositoryReadme(owner, name);
|
||||
var readmeInfo = await ApiConnection.Get<ReadmeResponse>(endpoint, null).ConfigureAwait(false);
|
||||
|
||||
return new Readme(readmeInfo, ApiConnection);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the perferred README's HTML for the specified repository.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// See the <a href="http://developer.github.com/v3/repos/contents/#get-the-readme">API documentation</a> for more information.
|
||||
/// </remarks>
|
||||
/// <param name="owner">The owner of the repository</param>
|
||||
/// <param name="name">The name of the repository</param>
|
||||
/// <exception cref="ApiException">Thrown when a general API error occurs.</exception>
|
||||
/// <returns></returns>
|
||||
public Task<string> GetReadmeHtml(string owner, string name)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
|
||||
Ensure.ArgumentNotNullOrEmptyString(name, "name");
|
||||
|
||||
return ApiConnection.GetHtml(ApiUrls.RepositoryReadme(owner, name), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user