mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
departures: profile flag for getPasslist & stbFilterEquiv
This commit is contained in:
parent
b55c2c1579
commit
5d0096c596
2 changed files with 21 additions and 11 deletions
20
index.js
20
index.js
|
@ -49,6 +49,13 @@ const createClient = (profile, userAgent, request = _request) => {
|
|||
throw new Error('type must be a non-empty string.')
|
||||
}
|
||||
|
||||
if (!profile.departuresGetPasslist && ('stopovers' in opt)) {
|
||||
throw new Error('opt.stopovers is not supported by this endpoint')
|
||||
}
|
||||
if (!profile.departuresStbFltrEquiv && ('includeRelatedStations' in opt)) {
|
||||
throw new Error('opt.includeRelatedStations is not supported by this endpoint')
|
||||
}
|
||||
|
||||
opt = Object.assign({
|
||||
direction: null, // only show departures heading to this station
|
||||
duration: 10, // show departures for the next n minutes
|
||||
|
@ -64,19 +71,20 @@ const createClient = (profile, userAgent, request = _request) => {
|
|||
const products = profile.formatProductsFilter(opt.products || {})
|
||||
|
||||
const dir = opt.direction ? profile.formatStation(opt.direction) : null
|
||||
return request(profile, userAgent, opt, {
|
||||
meth: 'StationBoard',
|
||||
req: {
|
||||
const req = {
|
||||
type,
|
||||
date: profile.formatDate(profile, opt.when),
|
||||
time: profile.formatTime(profile, opt.when),
|
||||
stbLoc: station,
|
||||
dirLoc: dir,
|
||||
jnyFltrL: [products],
|
||||
dur: opt.duration,
|
||||
getPasslist: !!opt.stopovers,
|
||||
stbFltrEquiv: !opt.includeRelatedStations
|
||||
dur: opt.duration
|
||||
}
|
||||
if (profile.departuresGetPasslist) req.getPasslist = !!opt.stopovers
|
||||
if (profile.departuresStbFltrEquiv) req.stbFltrEquiv = !opt.includeRelatedStations
|
||||
return request(profile, userAgent, opt, {
|
||||
meth: 'StationBoard',
|
||||
req
|
||||
})
|
||||
.then((d) => {
|
||||
if (!Array.isArray(d.jnyL)) return []
|
||||
|
|
|
@ -66,6 +66,8 @@ const defaultProfile = {
|
|||
filters,
|
||||
|
||||
journeysNumF: true, // `journeys()` method: support for `numF` field?
|
||||
departuresGetPasslist: true, // `departures()` method: support for `getPasslist` field?
|
||||
departuresStbFltrEquiv: true, // `departures()` method: support for `stbFltrEquiv` field?
|
||||
trip: false,
|
||||
radar: false,
|
||||
refreshJourney: true
|
||||
|
|
Loading…
Add table
Reference in a new issue