[purchasing] add purchase status to json output
This commit is contained in:
parent
43c0a48245
commit
1848c0334d
|
@ -96,3 +96,12 @@ proc wait*(purchase: Purchase) {.async.} =
|
||||||
|
|
||||||
func id*(purchase: Purchase): array[32, byte] =
|
func id*(purchase: Purchase): array[32, byte] =
|
||||||
purchase.request.id
|
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)
|
||||||
|
|
|
@ -35,7 +35,9 @@ func `%`*(arr: openArray[byte]): JsonNode =
|
||||||
|
|
||||||
func `%`*(purchase: Purchase): JsonNode =
|
func `%`*(purchase: Purchase): JsonNode =
|
||||||
%*{
|
%*{
|
||||||
"request": %purchase.request,
|
"finished": purchase.finished,
|
||||||
"offers": %purchase.offers,
|
"error": purchase.error.?msg,
|
||||||
"selected": %purchase.selected
|
"request": purchase.request,
|
||||||
|
"offers": purchase.offers,
|
||||||
|
"selected": purchase.selected
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue