[purchasing] add purchase status to json output

This commit is contained in:
Mark Spanbroek 2022-05-12 13:43:42 +02:00 committed by markspanbroek
parent 43c0a48245
commit 1848c0334d
2 changed files with 14 additions and 3 deletions

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)

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
}