From 86bf3b46f0cd3e4bc3d62e597d6b055b1c53d24c Mon Sep 17 00:00:00 2001 From: Jannis R Date: Sun, 10 Jan 2021 20:47:29 +0100 Subject: [PATCH] =?UTF-8?q?docs:=20remove=20"migrating=20to=204"=20guide,?= =?UTF-8?q?=20fix=20profile=20examples,=20minor=20tweaks=20=F0=9F=93=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/migrating-to-4.md | 117 ----------------------------------------- docs/readme.md | 1 - p/cfl/example.js | 6 +-- readme.md | 12 ++--- 4 files changed, 9 insertions(+), 127 deletions(-) delete mode 100644 docs/migrating-to-4.md diff --git a/docs/migrating-to-4.md b/docs/migrating-to-4.md deleted file mode 100644 index 6e7bcd3a..00000000 --- a/docs/migrating-to-4.md +++ /dev/null @@ -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. diff --git a/docs/readme.md b/docs/readme.md index e6fed89e..83eab905 100644 --- a/docs/readme.md +++ b/docs/readme.md @@ -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 diff --git a/p/cfl/example.js b/p/cfl/example.js index 43ba94a4..e91a6345 100644 --- a/p/cfl/example.js +++ b/p/cfl/example.js @@ -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 => { diff --git a/readme.md b/readme.md index 3c8cd676..01a6815f 100644 --- a/readme.md +++ b/readme.md @@ -5,8 +5,8 @@ [![npm version](https://img.shields.io/npm/v/hafas-client.svg)](https://www.npmjs.com/package/hafas-client) [![build status](https://img.shields.io/travis/public-transport/hafas-client.svg?branch=5)](https://travis-ci.org/public-transport/hafas-client) ![ISC-licensed](https://img.shields.io/github/license/public-transport/hafas-client.svg) -[![chat on gitter](https://badges.gitter.im/public-transport/Lobby.svg)](https://gitter.im/public-transport/Lobby) [![support Jannis via GitHub Sponsors](https://img.shields.io/badge/support%20Jannis-donate-fa7664.svg)](https://github.com/sponsors/derhuerst) +[![chat with Jannis on Twitter](https://img.shields.io/badge/chat%20with%20Jannis-on%20Twitter-1da1f2.svg)](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: