33 lines
808 B
Nim
33 lines
808 B
Nim
|
import ../../../types
|
||
|
import json
|
||
|
|
||
|
proc parseRemark*(rem: JsonNode): Remark =
|
||
|
let typeStr = rem{"type"}.getStr()
|
||
|
if typeStr == "M" or typeStr == "P":
|
||
|
return (%* {
|
||
|
"type": %* "status",
|
||
|
"summary": rem{"txtS"},
|
||
|
"code": rem{"code"},
|
||
|
"text": rem{"txtN"},
|
||
|
}).to(Remark)
|
||
|
elif typeStr == "L":
|
||
|
return (%* {
|
||
|
"type": %* "status",
|
||
|
"code": %* "alternative-trip",
|
||
|
"text": rem{"txtN"},
|
||
|
"tripId": rem{"jid"},
|
||
|
}).to(Remark)
|
||
|
elif typeStr == "A" or typeStr == "I" or typeStr == "H":
|
||
|
return (%* {
|
||
|
"type": %* "hint",
|
||
|
"code": rem{"code"},
|
||
|
"text": rem{"txtN"},
|
||
|
}).to(Remark)
|
||
|
else:
|
||
|
# TODO: parse more accurately
|
||
|
return (%* {
|
||
|
"type": %* "status",
|
||
|
"code": rem{"code"},
|
||
|
"text": rem{"txtN"},
|
||
|
}).to(Remark)
|