workaround for getpurchases api call

This commit is contained in:
Ben 2024-04-02 14:53:45 +02:00
parent 5511f8ed32
commit 29344451d6
No known key found for this signature in database
GPG Key ID: 541B9D8C9F1426A1
1 changed files with 11 additions and 1 deletions

View File

@ -2,6 +2,7 @@
using Core;
using KubernetesWorkflow;
using KubernetesWorkflow.Types;
using Newtonsoft.Json;
using Utils;
namespace CodexPlugin
@ -90,7 +91,16 @@ namespace CodexPlugin
public StoragePurchase GetPurchaseStatus(string purchaseId)
{
return mapper.Map(OnCodex(api => api.GetPurchaseAsync(purchaseId)));
var endpoint = GetEndpoint();
return Time.Retry(() =>
{
var str = endpoint.HttpGetString($"storage/purchases/{purchaseId}");
if (string.IsNullOrEmpty(str)) throw new Exception("Empty response.");
return JsonConvert.DeserializeObject<StoragePurchase>(str)!;
}, nameof(GetPurchaseStatus));
// TODO: current getpurchase api does not line up with its openapi spec.
// return mapper.Map(OnCodex(api => api.GetPurchaseAsync(purchaseId)));
}
public string GetName()