mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-04-20 23:23:56 +03:00
31 lines
776 B
JavaScript
31 lines
776 B
JavaScript
|
import {stringify} from 'qs';
|
||
|
|
||
|
const formatStationBoardReq = (ctx, station, type) => {
|
||
|
const {profile, opt} = ctx;
|
||
|
|
||
|
if (opt.departure || opt.arrival) {
|
||
|
throw new Error('opt.departure/opt.arrival is not supported for profile dbbahnhof, can only query for current time.');
|
||
|
}
|
||
|
const evaNumbers = [station];
|
||
|
if (opt.moreStops) {
|
||
|
evaNumbers.push(...opt.moreStops);
|
||
|
}
|
||
|
const query = {
|
||
|
filterTransports: profile.formatProductsFilter(ctx, opt.products || {}, 'ris_alt'),
|
||
|
evaNumbers: evaNumbers,
|
||
|
duration: opt.duration,
|
||
|
sortBy: 'TIME_SCHEDULE',
|
||
|
locale: opt.language,
|
||
|
};
|
||
|
|
||
|
return {
|
||
|
endpoint: profile.boardEndpoint,
|
||
|
path: type + '?' + stringify(query, {arrayFormat: 'repeat', encodeValuesOnly: true}),
|
||
|
method: 'get',
|
||
|
};
|
||
|
};
|
||
|
|
||
|
export {
|
||
|
formatStationBoardReq,
|
||
|
};
|