2022-11-21 10:23:25 +09:00
|
|
|
using System;
|
|
|
|
using System.Net.Http;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
|
|
|
namespace BTCPayServer.Plugins
|
|
|
|
{
|
|
|
|
public class PublishedVersion
|
|
|
|
{
|
|
|
|
public string ProjectSlug { get; set; }
|
|
|
|
public long BuildId { get; set; }
|
|
|
|
public JObject BuildInfo { get; set; }
|
|
|
|
public JObject ManifestInfo { get; set; }
|
2022-11-22 19:06:23 +09:00
|
|
|
public string Documentation { get; set; }
|
2022-11-21 10:23:25 +09:00
|
|
|
}
|
|
|
|
public class PluginBuilderClient
|
|
|
|
{
|
|
|
|
HttpClient httpClient;
|
|
|
|
public HttpClient HttpClient => httpClient;
|
|
|
|
public PluginBuilderClient(HttpClient httpClient)
|
|
|
|
{
|
|
|
|
this.httpClient = httpClient;
|
|
|
|
}
|
|
|
|
static JsonSerializerSettings serializerSettings = new JsonSerializerSettings() { ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver() };
|
|
|
|
public async Task<PublishedVersion[]> GetPublishedVersions(string btcpayVersion, bool includePreRelease)
|
|
|
|
{
|
|
|
|
var result = await httpClient.GetStringAsync($"api/v1/plugins?btcpayVersion={btcpayVersion}&includePreRelease={includePreRelease}");
|
|
|
|
return JsonConvert.DeserializeObject<PublishedVersion[]>(result, serializerSettings) ?? throw new InvalidOperationException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|