db-vendo-client/parse/journey.js

36 lines
645 B
JavaScript
Raw Normal View History

2024-12-07 16:16:31 +00:00
import {parseRemarks} from './remarks.js';
2024-12-07 16:16:31 +00:00
const parseJourney = (ctx, j) => { // j = raw journey
const {profile, opt} = ctx;
const legs = [];
2024-12-07 16:16:31 +00:00
for (const l of j.verbindungsAbschnitte) {
const leg = profile.parseJourneyLeg(ctx, l, null);
legs.push(leg);
}
const res = {
type: 'journey',
legs,
2024-12-07 16:16:31 +00:00
refreshToken: j.ctxRecon || null,
};
2018-12-02 01:05:19 +01:00
2024-12-07 16:16:31 +00:00
// TODO freq
2024-12-07 16:16:31 +00:00
if (opt.remarks) {
res.remarks = parseRemarks(ctx, j);
}
2018-07-23 20:42:22 +02:00
2024-12-07 16:16:31 +00:00
// TODO
if (opt.scheduledDays && j.serviceDays) {
2022-11-16 15:18:12 +01:00
// todo [breaking]: rename to scheduledDates
2024-12-08 21:42:57 +00:00
// res.scheduledDays = profile.parseScheduledDays(ctx, j.serviceDays);
2017-11-11 22:35:41 +01:00
}
return res;
};
2017-11-11 22:35:41 +01:00
2022-05-07 16:17:37 +02:00
export {
parseJourney,
};