Add optional automatic Verbundticket price fetching#31
Add optional automatic Verbundticket price fetching#31mariusangelmann wants to merge 4 commits intopublic-transport:mainfrom
Conversation
Introduces the `autoFetchVerbundtickets` option to automatically fetch Verbundticket prices via the recon API, updates documentation, and enhances journey and ticket parsing to handle Verbundticket price retrieval and parsing. Also adds a helper for manual price fetching and improves ticket extraction logic for DB Navigator mobile API responses.
|
These are more philosophical things, but at least so far one request to db-vendo-client would always equal one request to a DB backend (in order to not inundate the APIs with requests and not become another bahn.expert, aggregating information from many different sources and APIs), and while we have added features/flags before that go beyond hafas-client, I think we should strive to stay close as possible to hafas-client. In some sense this is the only reason of existence of db-vendo-client, since the new DB APIs are usually at least much more readable/usable than their HAFAS counterparts... That said and you apparently seeing the need, I think we can nonetheless add the Verbundticket feature. I'm not so fond of Also, is it really the case that DB Navigator et al do a separate request for each journey with a Verbundticket? Or do they only do that in the detail view, meaning we should also only add it in |
This PR adds support for automatically fetching prices for Verbundtickets (local transport network tickets) which require a two-step API process.
Problem
Verbundtickets don't include prices in the initial journey response. Instead, they return an empty
angebotsClusterand require a subsequent/angebote/reconrequest to fetch the actual ticket prices.Solution
autoFetchVerbundticketsparameter tojourneys()andrefreshJourney()methodsUsage
Changes
lib/fetch-verbundticket-prices.jsto handle recon requestsparse/journey.jsto detect and fetch Verbundticket prices when enabledjourneys()andrefreshJourney()methods