show release notes on home page (#165)

This commit is contained in:
Jason Dove
2021-04-11 12:34:41 -05:00
committed by GitHub
parent 34fbfce0a5
commit a2700e087c
11 changed files with 226 additions and 66 deletions
@@ -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());
}
}
}
}