db-vendo-client/format/station-board-req.js

35 lines
853 B
JavaScript
Raw Permalink Normal View History

2019-10-31 20:08:56 +01:00
'use strict'
const formatStationBoardReq = (ctx, station, type) => {
const {profile, opt} = ctx
2020-03-09 21:59:17 +01:00
const jnyFltrL = [
profile.formatProductsFilter(ctx, opt.products || {})
]
if (opt.line !== null) {
jnyFltrL.push({type: 'LINEID', mode: 'INC', value: opt.line})
}
2019-10-31 20:08:56 +01:00
const req = {
type,
date: profile.formatDate(profile, opt.when),
time: profile.formatTime(profile, opt.when),
stbLoc: station,
dirLoc: opt.direction ? profile.formatStation(opt.direction) : undefined,
2020-03-09 21:59:17 +01:00
jnyFltrL,
2019-10-31 20:08:56 +01:00
dur: opt.duration
}
if (opt.results !== null) {
req.maxJny = opt.results === Infinity ? 10000 : opt.results
}
2019-10-31 20:08:56 +01:00
if (profile.departuresGetPasslist) req.getPasslist = !!opt.stopovers
if (profile.departuresStbFltrEquiv) req.stbFltrEquiv = !opt.includeRelatedStations
return {
meth: 'StationBoard',
req
}
}
module.exports = formatStationBoardReq