[purchasing] add purchase status to json output

This commit is contained in:
Mark Spanbroek
2022-05-19 10:38:19 +02:00
committed by markspanbroek
parent 43c0a48245
commit 1848c0334d
2 changed files with 14 additions and 3 deletions
+9
View File
@@ -96,3 +96,12 @@ proc wait*(purchase: Purchase) {.async.} =
func id*(purchase: Purchase): array[32, byte] =
purchase.request.id
func finished*(purchase: Purchase): bool =
purchase.future.finished
func error*(purchase: Purchase): ?(ref CatchableError) =
if purchase.future.failed:
some purchase.future.error
else:
none (ref CatchableError)
+5 -3
View File
@@ -35,7 +35,9 @@ func `%`*(arr: openArray[byte]): JsonNode =
func `%`*(purchase: Purchase): JsonNode =
%*{
"request": %purchase.request,
"offers": %purchase.offers,
"selected": %purchase.selected
"finished": purchase.finished,
"error": purchase.error.?msg,
"request": purchase.request,
"offers": purchase.offers,
"selected": purchase.selected
}