backend: parse tariff information

This commit is contained in:
Milan Pässler 2020-09-20 20:02:44 +02:00
parent 8fc01cf986
commit da59b69e9d
2 changed files with 8 additions and 2 deletions

View file

@ -8,6 +8,12 @@ proc mkParseJourney*(common: CommonData): proc =
var common = common
common.dateStr = j{"date"}.getStr()
if j{"trfRes"}{"statusCode"}.getStr == "OK":
result.price = some(Price(
amount: j["trfRes"]["fareSetL"][0]["fareL"][0]["prc"].getInt / 100,
currency: some("Euro"),
))
result.refreshToken = j{"ctxRecon"}.getStr()
result.legs = j{"secL"}.getElems().map(mkParseLeg(common))
result.lastUpdated = common.timeStamp

View file

@ -100,10 +100,10 @@ type
max*: Option[int]
nr*: Option[int]
# TODO: Make this unnecessary :3
Price* = object
amount*: Option[float]
amount*: float
currency*: Option[string]
hint*: Option[string]
StopoverPart* = object
plannedTime*: Option[int64]