mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-20 02:28:31 +01:00
32 lines
1.2 KiB
C#
32 lines
1.2 KiB
C#
|
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; }
|
||
|
}
|
||
|
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();
|
||
|
}
|
||
|
}
|
||
|
}
|