35 lines
1.1 KiB
Nim
35 lines
1.1 KiB
Nim
import ../types
|
|
import ../parse/remark
|
|
import ../parse/point
|
|
import ../parse/operator
|
|
import ../parse/journey
|
|
import ../parse/line
|
|
import ../util
|
|
import json
|
|
import asyncdispatch
|
|
import options
|
|
import sequtils
|
|
|
|
proc refreshJourney*(params: RefreshJourneyParams): Future[Journey] {.async.} =
|
|
let req = %* {
|
|
"cfg": {
|
|
},
|
|
"meth": "Reconstruction",
|
|
"req": {
|
|
"ctxRecon": params.refreshToken,
|
|
"getIST": true,
|
|
"getPasslist": params.stopovers.get(false),
|
|
"getPolyline": params.polylines.get(false),
|
|
"getTariff": params.tickets.get(false),
|
|
}
|
|
}
|
|
|
|
let data = await request(req)
|
|
let points = map(data["res"]["common"]["locL"].getElems(), parsePoint)
|
|
let operators = map(data["res"]["common"]["opL"].getElems(), parseOperator)
|
|
let remarks = map(data["res"]["common"]["remL"].getElems(), parseRemark)
|
|
let lines = map(data["res"]["common"]["prodL"].getElems(), mkParseLine(operators))
|
|
let common = CommonData(points: points, operators: operators, remarks: remarks, lines: lines)
|
|
|
|
return common.mkParseJourney()(data["res"]["outConL"][0])
|