2020-02-27 13:46:34 +00:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Wabbajack.Common;
|
|
|
|
|
|
|
|
|
|
namespace Wabbajack.Lib
|
|
|
|
|
{
|
|
|
|
|
public class ClientAPI
|
|
|
|
|
{
|
|
|
|
|
public static Common.Http.Client GetClient()
|
|
|
|
|
{
|
|
|
|
|
var client = new Common.Http.Client();
|
2020-03-02 23:16:15 +00:00
|
|
|
|
if (Utils.HaveEncryptedJson(Consts.MetricsKeyHeader))
|
|
|
|
|
client.Headers.Add((Consts.MetricsKeyHeader, Utils.FromEncryptedJson<string>(Consts.MetricsKeyHeader)));
|
2020-02-27 13:46:34 +00:00
|
|
|
|
return client;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-22 15:50:53 +00:00
|
|
|
|
public static async Task<Archive> GetModUpgrade(Hash hash)
|
2020-02-27 13:46:34 +00:00
|
|
|
|
{
|
|
|
|
|
using var response = await GetClient()
|
2020-03-22 15:50:53 +00:00
|
|
|
|
.GetAsync($"https://{Consts.WabbajackCacheHostname}/alternative/{hash.ToHex()}");
|
2020-02-27 13:46:34 +00:00
|
|
|
|
return !response.IsSuccessStatusCode ? null : (await response.Content.ReadAsStringAsync()).FromJSONString<Archive>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|