db-vendo-client/format/remarks-req.js

39 lines
1 KiB
JavaScript
Raw Permalink Normal View History

2020-03-09 20:54:43 +01:00
const formatRemarksReq = (ctx) => {
const {profile, opt} = ctx;
2020-03-09 20:54:43 +01:00
const himFltrL = [];
2020-03-09 20:54:43 +01:00
// todo: https://github.com/marudor/BahnhofsAbfahrten/blob/95fef0217d01344642dd423457473fe9b8b6056e/src/types/HAFAS/index.ts#L76-L91
if (opt.products) {
himFltrL.push(profile.formatProductsFilter(ctx, opt.products));
2020-03-09 20:54:43 +01:00
}
const req = {
himFltrL,
};
if (profile.remarksGetPolyline) {
req.getPolyline = Boolean(opt.polylines);
2020-03-09 20:54:43 +01:00
}
// todo: stLoc, dirLoc
// todo: comp, dept, onlyHimId, onlyToday
// todo: dailyB, dailyE
// see https://github.com/marudor/BahnhofsAbfahrten/blob/46a74957d68edc15713112df44e1a25150f5a178/src/types/HAFAS/HimSearch.ts#L3-L18
if (opt.results !== null) {
req.maxNum = opt.results;
}
2020-03-09 20:54:43 +01:00
if (opt.from !== null) {
req.dateB = profile.formatDate(profile, opt.from);
req.timeB = profile.formatTime(profile, opt.from);
2020-03-09 20:54:43 +01:00
}
if (opt.to !== null) {
req.dateE = profile.formatDate(profile, opt.to);
req.timeE = profile.formatTime(profile, opt.to);
2020-03-09 20:54:43 +01:00
}
return {meth: 'HimSearch', req};
};
2020-03-09 20:54:43 +01:00
2022-05-07 16:17:37 +02:00
export {
formatRemarksReq,
};