31 lines
1.1 KiB
C#
31 lines
1.1 KiB
C#
namespace ThreadPilot.Services
|
|
{
|
|
using System;
|
|
using System.Net.Http;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using ThreadPilot.Services.Abstractions;
|
|
|
|
public sealed class GitHubReleaseClient : IGitHubReleaseClient
|
|
{
|
|
private readonly HttpClient httpClient;
|
|
|
|
public GitHubReleaseClient(HttpClient httpClient)
|
|
{
|
|
this.httpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
|
|
}
|
|
|
|
public Task<string> GetLatestReleaseJsonAsync(string owner, string repo, CancellationToken cancellationToken = default)
|
|
{
|
|
var url = $"https://api.github.com/repos/{owner}/{repo}/releases/latest";
|
|
return this.httpClient.GetStringAsync(url, cancellationToken);
|
|
}
|
|
|
|
public Task<string> GetReleasesJsonAsync(string owner, string repo, CancellationToken cancellationToken = default)
|
|
{
|
|
var url = $"https://api.github.com/repos/{owner}/{repo}/releases";
|
|
return this.httpClient.GetStringAsync(url, cancellationToken);
|
|
}
|
|
}
|
|
}
|