mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-22 22:59:35 +02:00
docs: remove "migrating to 4" guide, fix profile examples, minor tweaks 📝
This commit is contained in:
parent
33ea6242bd
commit
86bf3b46f0
4 changed files with 9 additions and 127 deletions
|
@ -1,117 +0,0 @@
|
|||
# Migrating to `hafas-client@4`
|
||||
|
||||
## If you use Node `6`…
|
||||
|
||||
…migrate to Node `8`, sorry. bf3c4c5
|
||||
|
||||
## If you use the `journeys()` method…
|
||||
|
||||
…use the `journeys` entry from the returned object. fcc53b5
|
||||
…rename `leg.id` to `leg.tripId`. 96ff59d
|
||||
…use `leg.walking === true` to check for walking legs. 0e1fcb0
|
||||
…explicitly pass a value for `opt.transfers` if you want to limit the nr of transfers. 61e7d14
|
||||
|
||||
## If you use the `departures()`/`arrivals()` method…
|
||||
|
||||
…rename `opt.stationLines` to `opt.linesOfStops`. a972dad
|
||||
|
||||
## If you use the `station()` method…
|
||||
|
||||
…change the `station(id)` call to `stop(id)`. bad0af8
|
||||
|
||||
## If you use the `locations()` method…
|
||||
|
||||
…pass `opt.results` if you want more than 5 results. 3bc2eff
|
||||
…rename `opt.stationLines` to `opt.linesOfStops`. a972dad
|
||||
|
||||
## If you use the `trip()` method…
|
||||
|
||||
…rename `leg.nextStops` to `leg.nextStopovers`. bbff1f4
|
||||
|
||||
## If you use the `nearby()` method…
|
||||
|
||||
…rename `opt.stations` to `opt.stops`. 8f9b22e
|
||||
…rename `opt.stationLines` to `opt.linesOfStops`. a972dad
|
||||
|
||||
## If you use the `radar()` method…
|
||||
|
||||
…rename `movement.nextStops` to `movement.nextStopovers`. bbff1f4
|
||||
|
||||
## If you use the DB/INSA/Nah.SH/ÖBB profile…
|
||||
|
||||
…rename the product identifier `nationalExp` to `nationalExpress`. 567cc98
|
||||
|
||||
## If you use POIs…
|
||||
|
||||
…use the `poi: true` flag to check if a location is a POI. eb3ffba
|
||||
…add `poi: true` to a location to make it a POI. eb3ffba
|
||||
|
||||
## If you use `arrival.trip`/`departure.trip` or `movement.trip`…
|
||||
|
||||
…[let us know](https://github.com/public-transport/hafas-client/issues) why you need it. We removed it because it is not reliable. 9c44995
|
||||
|
||||
## If you use `hafas-client/throttle`…
|
||||
|
||||
…check out the [new and slightly different throttling API](readme.md#throttling-requests). 748f8ce
|
||||
|
||||
## If you use `hafas-client/retry`…
|
||||
|
||||
…check out the [new and slightly different retrying API](readme.md#retrying-failed-requests). fbde6a1
|
||||
|
||||
## If you use `arrival.formerScheduledPlatform`/`departure.formerScheduledPlatform`…
|
||||
|
||||
…rename to `arrival.scheduledPlatform`/`departure.scheduledPlatform`. 7e39a2f
|
||||
|
||||
## If you use `arrival.formerScheduledWhen`/`departure.formerScheduledWhen`…
|
||||
|
||||
…rename to `arrival.scheduledWhen`/`departure.scheduledWhen`. 7e39a2f
|
||||
|
||||
## If you use `leg.formerScheduledArrival`/`leg.formerScheduledDeparture`…
|
||||
|
||||
…rename to `leg.scheduledArrival`/`leg.scheduledDeparture`. 7e39a2f
|
||||
|
||||
## If you use `stopover.formerScheduledArrival`/`stopover.formerScheduledDeparture`…
|
||||
|
||||
…rename to `stopover.scheduledArrival`/`stopover.scheduledDeparture`. 7e39a2f
|
||||
|
||||
## If you use `stopover.formerScheduledArrivalPlatform`/`stopover.formerScheduledDeparturePlatform`…
|
||||
|
||||
…rename to `stopover.scheduledArrivalPlatform`/`stopover.scheduledDeparturePlatform`. 7e39a2f
|
||||
|
||||
## If you use `line.class` or `line.productCode`…
|
||||
|
||||
…write a custom `parseLine` implementation that exposes them. a1ffad3
|
||||
|
||||
An example with the VBB profile:
|
||||
|
||||
```js
|
||||
const createOrigParseLine = require('hafas-client/parse/line')
|
||||
|
||||
const createParseLine = (profile, opt, data) => {
|
||||
const origParseLine = createOrigParseLine(profile, opt, data)
|
||||
|
||||
const parseLine = (p) => {
|
||||
const res = origParseLine(p)
|
||||
res.class = p.cls
|
||||
return res
|
||||
}
|
||||
}
|
||||
|
||||
const customVbbProfile = Object.assign({}, vbbProfile)
|
||||
customVbbProfile.parseLine = createParseLine
|
||||
|
||||
const hafas = createHafas(customVbbProfile, 'my-awesome-program')
|
||||
```
|
||||
|
||||
## If you use `hafas-client` with custom parse functions…
|
||||
|
||||
…change the `parseDateTime` to
|
||||
|
||||
- return an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) string. a9fd9ff
|
||||
- have accept an optional `tzOffset`. ca1105f
|
||||
|
||||
…change the `parseLocation` to strip leading zeros from stop/station IDs. 1e13cf1
|
||||
|
||||
## If you inspect errors thrown by `hafas-client`…
|
||||
|
||||
…adapt your code to 1646173.
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
## Migrating from an old `hafas-client` version
|
||||
|
||||
- [`3` → `4` migration guide](migrating-to-4.md)
|
||||
- [`4` → `5` migration guide](migrating-to-5.md)
|
||||
|
||||
## Throttling requests
|
||||
|
|
|
@ -22,9 +22,9 @@ client.departures('009864348', { duration: 5 })
|
|||
// east: 6.13
|
||||
// }, {results: 10})
|
||||
|
||||
// .then(([journey]) => {
|
||||
// const leg = journey.legs[0]
|
||||
// return client.trip(leg.id, leg.line.name)
|
||||
// .then(({journeys}) => {
|
||||
// const leg = journeys[0].legs[0]
|
||||
// return client.trip(leg.tripId, leg.line.name)
|
||||
// })
|
||||
|
||||
.then(data => {
|
||||
|
|
12
readme.md
12
readme.md
|
@ -5,8 +5,8 @@
|
|||
[](https://www.npmjs.com/package/hafas-client)
|
||||
[](https://travis-ci.org/public-transport/hafas-client)
|
||||

|
||||
[](https://gitter.im/public-transport/Lobby)
|
||||
[](https://github.com/sponsors/derhuerst)
|
||||
[](https://twitter.com/derhuerst)
|
||||
|
||||
|
||||
## Background
|
||||
|
@ -31,6 +31,11 @@ npm install hafas-client
|
|||
`hafas-client` as well its dependencies use [Node-builtin modules](https://nodejs.org/dist/latest/docs/api/) and [Node globals](https://nodejs.org/api/globals.html). To be able to use it within react-native, follow [the instructions at `node-libs-react-native`](https://github.com/parshap/node-libs-react-native/blob/3/README.md#usage).
|
||||
|
||||
|
||||
## API
|
||||
|
||||
[API documentation](docs/readme.md)
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
Pick the [profile](p) for a HAFAS endpoint that covers the area you want to get data for. Pass the profile and an expressive name for your program into the `createClient` entry point of this library:
|
||||
|
@ -194,11 +199,6 @@ client.journeys('8011167', '8000261', {results: 1})
|
|||
Each of the [profiles](p) has more detailed example code.
|
||||
|
||||
|
||||
## API
|
||||
|
||||
[API documentation](docs/readme.md)
|
||||
|
||||
|
||||
## supported networks/endpoints
|
||||
|
||||
`hafas-client` has [built-in customisations called *profiles*](p) for these public transportation networks:
|
||||
|
|
Loading…
Add table
Reference in a new issue