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

50 lines
1.5 KiB
JavaScript
Raw Permalink Normal View History

2019-10-31 20:08:56 +01:00
const formatStationBoardReq = (ctx, station, type) => {
const {profile, opt} = ctx;
2019-10-31 20:08:56 +01:00
2024-12-10 17:51:20 +00:00
return {
endpoint: profile.boardEndpoint,
path: (type == 'departures' ? 'departure' : 'arrival') + '/' + station,
query: {
// TODO direction, fields below
modeOfTransport: profile.formatProductsFilter(ctx, opt.products || {}, 'ris'),
timeStart: profile.formatTime(profile, opt.when, true),
timeEnd: profile.formatTime(profile, opt.when.getTime() + opt.duration * 60 * 1000, true),
expandTimeFrame: 'TIME_END', // TODO impact?
},
method: 'get',
};
};
/*
TODO separate RIS::Boards profile?
const formatRisStationBoardReq = (ctx, station, type) => {
const {profile, opt} = ctx;
2019-10-31 20:08:56 +01:00
return {
2024-12-07 22:46:04 +00:00
endpoint: profile.boardEndpoint,
2024-12-08 21:42:57 +00:00
path: type + '/' + station,
2024-12-07 22:46:04 +00:00
query: {
// TODO direction
filterTransports: profile.formatProductsFilter(ctx, opt.products || {}, 'ris'),
timeStart: profile.formatTime(profile, opt.when, true),
2024-12-08 21:42:57 +00:00
timeEnd: profile.formatTime(profile, opt.when.getTime() + opt.duration * 60 * 1000, true),
2024-12-07 22:46:04 +00:00
maxViaStops: opt.stopovers ? undefined : 0,
includeStationGroup: opt.includeRelatedStations,
maxTransportsPerType: opt.results === Infinity ? undefined : opt.results,
includeMessagesDisruptions: opt.remarks,
2024-12-08 21:42:57 +00:00
sortBy: 'TIME_SCHEDULE',
2024-12-07 22:46:04 +00:00
},
method: 'get',
headers: {
'Db-Client-Id': process.env.DB_CLIENT_ID,
'Db-Api-Key': process.env.DB_API_KEY,
2024-12-08 21:42:57 +00:00
'Accept': 'application/vnd.de.db.ris+json',
},
};
};
2024-12-10 17:51:20 +00:00
*/
2019-10-31 20:08:56 +01:00
2022-05-07 16:17:37 +02:00
export {
formatStationBoardReq,
};