From 29344451d6a7e662ae98fc384ef60359c2c737ff Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 2 Apr 2024 14:53:45 +0200 Subject: [PATCH] workaround for getpurchases api call --- ProjectPlugins/CodexPlugin/CodexAccess.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ProjectPlugins/CodexPlugin/CodexAccess.cs b/ProjectPlugins/CodexPlugin/CodexAccess.cs index bd2582e..697ff2c 100644 --- a/ProjectPlugins/CodexPlugin/CodexAccess.cs +++ b/ProjectPlugins/CodexPlugin/CodexAccess.cs @@ -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(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()