db-vendo-client/parse/journey.js

41 lines
876 B
JavaScript
Raw Normal View History

2017-11-11 22:35:41 +01:00
'use strict'
const findRemark = require('./find-remark')
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))
const res = {
type: 'journey',
legs
}
2018-06-28 13:45:56 +02:00
if (opt.remarks && Array.isArray(j.msgL)) {
res.remarks = []
for (let ref of j.msgL) {
const remark = findRemark(hints, warnings, ref)
if (remark) res.remarks.push(remark)
}
}
return res
2017-11-11 22:35:41 +01:00
}
return parseJourney
}
module.exports = createParseJourney