show release notes on home page (#165)
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using ErsatzTV.Core;
|
||||
using ErsatzTV.Core.Interfaces.GitHub;
|
||||
using LanguageExt;
|
||||
using Refit;
|
||||
|
||||
namespace ErsatzTV.Infrastructure.GitHub
|
||||
{
|
||||
public class GitHubApiClient : IGitHubApiClient
|
||||
{
|
||||
public async Task<Either<BaseError, string>> GetLatestReleaseNotes()
|
||||
{
|
||||
try
|
||||
{
|
||||
IGitHubApi service = RestService.For<IGitHubApi>("https://api.github.com");
|
||||
return await service.GetReleases().Map(releases => releases.Head().Body);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BaseError.New(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<Either<BaseError, string>> GetReleaseNotes(string tag)
|
||||
{
|
||||
try
|
||||
{
|
||||
IGitHubApi service = RestService.For<IGitHubApi>("https://api.github.com");
|
||||
return await service.GetTag(tag).Map(t => t.Body);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return BaseError.New(ex.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using ErsatzTV.Infrastructure.GitHub.Models;
|
||||
using Refit;
|
||||
|
||||
namespace ErsatzTV.Infrastructure.GitHub
|
||||
{
|
||||
[Headers("Accept: application/vnd.github.v3+json", "User-Agent: jasongdove/ErsatzTV")]
|
||||
public interface IGitHubApi
|
||||
{
|
||||
[Get("/repos/jasongdove/ErsatzTV/releases")]
|
||||
public Task<List<GitHubTag>> GetReleases();
|
||||
|
||||
[Get("/repos/jasongdove/ErsatzTV/releases/tags/{tag}")]
|
||||
public Task<GitHubTag> GetTag(string tag);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace ErsatzTV.Infrastructure.GitHub.Models
|
||||
{
|
||||
public class GitHubTag
|
||||
{
|
||||
public string Body { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user