ctucx.git: nimhafas

[nimlang] hafas-client library

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
import ../types
import json

proc mkParseMsg*(common: CommonData): proc =
  proc parseMsg(m: JsonNode): Remark =
    let typeStr = m{"type"}.getStr()
    if typeStr != "REM":
      raise newException(CatchableError, "Unimplemented hafas msg type: " & typeStr)
    return common.remarks[m{"remX"}.getInt()]

  return parseMsg