From 911a6d371e94f874c6cf77091c5c14a0c4ce3248 Mon Sep 17 00:00:00 2001 From: Traines Date: Tue, 14 Jan 2025 21:12:23 +0000 Subject: [PATCH] db: support for polylines --- p/db/base.json | 3 ++- p/db/journeys-req.js | 37 ++++++++++++++++++++++++------------- readme.md | 6 +++--- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/p/db/base.json b/p/db/base.json index c04b7285..a8b54809 100644 --- a/p/db/base.json +++ b/p/db/base.json @@ -1,6 +1,7 @@ { "journeysEndpoint": "https://int.bahn.de/web/api/angebote/fahrplan", - "refreshJourneysEndpoint": "https://int.bahn.de/web/api/angebote/recon", + "refreshJourneysEndpointTickets": "https://int.bahn.de/web/api/angebote/recon", + "refreshJourneysEndpointPolyline": "https://int.bahn.de/web/api/reiseloesung/verbindung", "locationsEndpoint": "https://int.bahn.de/web/api/reiseloesung/orte", "nearbyEndpoint": "https://int.bahn.de/web/api/reiseloesung/orte/nearby", "tripEndpoint": "https://int.bahn.de/web/api/reiseloesung/fahrt", diff --git a/p/db/journeys-req.js b/p/db/journeys-req.js index 0d0fc399..a896c7dc 100644 --- a/p/db/journeys-req.js +++ b/p/db/journeys-req.js @@ -44,19 +44,30 @@ const formatJourneysReq = (ctx, from, to, when, outFrwd, journeysRef) => { }; // TODO poly conditional other endpoint const formatRefreshJourneyReq = (ctx, refreshToken) => { - const {profile} = ctx; - let query = { - ctxRecon: refreshToken, - deutschlandTicketVorhanden: false, - nurDeutschlandTicketVerbindungen: false, - reservierungsKontingenteVorhanden: false, - }; - query = Object.assign(query, profile.formatTravellers(ctx)); - return { - endpoint: profile.refreshJourneysEndpoint, - body: query, - method: 'post', - }; + const {profile, opt} = ctx; + if (opt.tickets) { + let query = { + ctxRecon: refreshToken, + deutschlandTicketVorhanden: false, + nurDeutschlandTicketVerbindungen: false, + reservierungsKontingenteVorhanden: false, + }; + query = Object.assign(query, profile.formatTravellers(ctx)); + return { + endpoint: profile.refreshJourneysEndpointTickets, + body: query, + method: 'post', + }; + } else { + return { + endpoint: profile.refreshJourneysEndpointPolyline, + body: { + ctxRecon: refreshToken, + poly: true, + }, + method: 'post', + }; + } }; export { diff --git a/readme.md b/readme.md index 9dddbc7a..0855db5e 100644 --- a/readme.md +++ b/readme.md @@ -8,7 +8,7 @@ This is a very early version. What works: * `journeys()`, `refreshJourney()` including tickets -* `locations()`, `nearby()` +* `locations()`, `nearby()`, `stop()` * `departures()`, `arrivals()` boards * `trip()` @@ -28,8 +28,8 @@ Depending on the configured profile, db-vendo-client will use multiple different | max duration boards | 12h | 1h | | remarks | not for boards | ✅ (still no `remarks()` endpoint) | | cancelled trips | not contained in boards | contained with cancelled flag | -| tickets | only for `refreshJourney()` | only for `refreshJourney()`, mutually exclusive with polylines | -| polylines | only for `trip()` | only for `refreshJourney()/trip()`, mutually exclusive with tickets | +| tickets | only for `refreshJourney()`, mutually exclusive with polylines | only for `refreshJourney()`, mutually exclusive with polylines | +| polylines | only for `refreshJourney()` (mutually exclusive with tickets) and for `trip()` (only for HAFAS trip ids) | only for `refreshJourney()/trip()`, mutually exclusive with tickets | | trip ids used | HAFAS trip ids for journeys, RIS trip ids for boards (static on train splits?) | HAFAS trip ids | | line.id/fahrtNr used | unreliable/route id for journeys/`trip()`, actual fahrtNr for boards | actual fahrtNr for journeys, unreliable/route id for boards and `trip()` | | adminCode/operator | adminCode only for boards | only for journeys |