2017-11-11 22:35:41 +01:00
|
|
|
'use strict'
|
|
|
|
|
2018-06-11 11:29:32 +02:00
|
|
|
const findRemark = require('./find-remark')
|
2017-11-11 23:56:09 +01:00
|
|
|
|
2018-06-13 19:59:44 +02:00
|
|
|
const createParseJourney = (profile, opt, data) => {
|
|
|
|
const parseLeg = profile.parseJourneyLeg(profile, opt, data)
|
2018-06-26 12:52:33 +02:00
|
|
|
const {hints, warnings} = data
|
2017-11-11 22:35:41 +01:00
|
|
|
|
|
|
|
// todo: c.sDays
|
|
|
|
// todo: c.conSubscr
|
|
|
|
// todo: c.trfRes x vbb-parse-ticket
|
2018-06-11 19:50:44 +02:00
|
|
|
// todo: c.sotRating, c.isSotCon, c.sotCtxt
|
|
|
|
// todo: c.showARSLink
|
|
|
|
// todo: c.useableTime
|
|
|
|
// todo: c.cksum
|
|
|
|
// todo: c.isNotRdbl
|
|
|
|
// todo: c.badSecRefX
|
|
|
|
// todo: c.bfATS, c.bfIOSTS
|
2017-11-12 01:23:34 +01:00
|
|
|
const parseJourney = (j) => {
|
2017-12-28 16:56:27 +01:00
|
|
|
const legs = j.secL.map(leg => parseLeg(j, leg))
|
2017-12-07 20:21:14 +01:00
|
|
|
const res = {
|
2018-03-02 00:35:54 +01:00
|
|
|
type: 'journey',
|
2018-07-24 17:37:36 +02:00
|
|
|
legs,
|
|
|
|
refreshToken: j.ctxRecon || null
|
2017-12-07 20:21:14 +01:00
|
|
|
}
|
|
|
|
|
2018-06-28 13:45:56 +02:00
|
|
|
if (opt.remarks && Array.isArray(j.msgL)) {
|
2018-06-11 11:29:32 +02:00
|
|
|
res.remarks = []
|
|
|
|
for (let ref of j.msgL) {
|
|
|
|
const remark = findRemark(hints, warnings, ref)
|
|
|
|
if (remark) res.remarks.push(remark)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-07 20:21:14 +01:00
|
|
|
return res
|
2017-11-11 22:35:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return parseJourney
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = createParseJourney
|