ctucx.git: oeffisearch

[nimlang] fast and simple tripplanner

commit da59b69e9dd4a9fee76f25451e5395a827c10937
parent 8fc01cf9860339565457f34cd970393a31542db4
Author: Milan Pässler <milan@petabyte.dev>
Date: Sun, 20 Sep 2020 20:02:44 +0200

backend: parse tariff information
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/backend/hafas/parse/journey.nim b/src/backend/hafas/parse/journey.nim
@@ -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
diff --git a/src/types.nim b/src/types.nim
@@ -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]