From f20931b6ded6db5bef27b591747a96997a6e457c Mon Sep 17 00:00:00 2001 From: Jannis R Date: Thu, 19 Jul 2018 21:55:03 +0200 Subject: [PATCH] adapt docs & examples to 0a0cddc :memo: --- docs/changelog.md | 1 + docs/departures.md | 2 +- docs/journeys.md | 2 +- docs/locations.md | 2 +- docs/migrating-to-3.md | 13 +++++++++++++ docs/nearby.md | 2 +- docs/radar.md | 2 +- docs/station.md | 2 +- docs/trip.md | 2 +- p/db/example.js | 2 +- p/insa/example.js | 2 +- p/nahsh/example.js | 2 +- p/oebb/example.js | 2 +- p/vbb/example.js | 2 +- readme.md | 2 +- 15 files changed, 27 insertions(+), 13 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 3eee4338..34450707 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -19,6 +19,7 @@ This version is not fully backwords-compatible. Check out [the migration guide]( ### breaking changes 💥 +- c4935bc new mandatory `User-Agent` parameter - b7c1ee3 profiles: new products markup ([guide](https://github.com/public-transport/hafas-client/blob/ebe4fa64d871f711ced99d528c0171b180edc135/docs/writing-a-profile.md#3-products)) - 40b559f change `radar(n, w, s, e)` signature to `radar({north, west, south, east})` - 005f3f8 remove `journey.departure`, `journey.arrival`, … diff --git a/docs/departures.md b/docs/departures.md index 07212022..33651a1d 100644 --- a/docs/departures.md +++ b/docs/departures.md @@ -48,7 +48,7 @@ As an example, we're going to use the [VBB profile](../p/vbb): const createClient = require('hafas-client') const vbbProfile = require('hafas-client/p/vbb') -const client = createClient(vbbProfile) +const client = createClient(vbbProfile, 'my-awesome-program') // S Charlottenburg client.departures('900000024101', {duration: 3}) diff --git a/docs/journeys.md b/docs/journeys.md index 2fa65400..f7be35c1 100644 --- a/docs/journeys.md +++ b/docs/journeys.md @@ -82,7 +82,7 @@ As an example, we're going to use the [VBB profile](../p/vbb): const createClient = require('hafas-client') const vbbProfile = require('hafas-client/p/vbb') -const client = createClient(vbbProfile) +const client = createClient(vbbProfile, 'my-awesome-program') // Hauptbahnhof to Heinrich-Heine-Str. client.journeys('900000003201', '900000100008', { diff --git a/docs/locations.md b/docs/locations.md index 9d8cfd65..169dd342 100644 --- a/docs/locations.md +++ b/docs/locations.md @@ -24,7 +24,7 @@ As an example, we're going to use the [VBB profile](../p/vbb): const createClient = require('hafas-client') const vbbProfile = require('hafas-client/p/vbb') -const client = createClient(vbbProfile) +const client = createClient(vbbProfile, 'my-awesome-program') client.locations('Alexanderplatz', {results: 3}) .then(console.log) diff --git a/docs/migrating-to-3.md b/docs/migrating-to-3.md index eb2c7ba2..0855dd02 100644 --- a/docs/migrating-to-3.md +++ b/docs/migrating-to-3.md @@ -1,5 +1,18 @@ # Migrating to `hafas-client@3` +## New `User-Agent` parameter + +Pass an additional `User-Agent` string into `createClient`: + +```js +const createClient = require('hafas-client') +const dbProfile = require('hafas-client/p/db') + +const client = createClient(dbProfile, 'my-awesome-program') +``` + +Pick a name that describes your program and – if possible – the website/repo of it. + ## If you use the `journeyLeg()` method… …change the `journeyLeg(id, lineName)` call to `trip(id, lineName)`. c8ff217 diff --git a/docs/nearby.md b/docs/nearby.md index 33352922..20186c46 100644 --- a/docs/nearby.md +++ b/docs/nearby.md @@ -24,7 +24,7 @@ As an example, we're going to use the [VBB profile](../p/vbb): const createClient = require('hafas-client') const vbbProfile = require('hafas-client/p/vbb') -const client = createClient(vbbProfile) +const client = createClient(vbbProfile, 'my-awesome-program') client.nearby({ type: 'location', diff --git a/docs/radar.md b/docs/radar.md index 6d0bd2a5..f5502308 100644 --- a/docs/radar.md +++ b/docs/radar.md @@ -26,7 +26,7 @@ As an example, we're going to use the [VBB profile](../p/vbb): const createClient = require('hafas-client') const vbbProfile = require('hafas-client/p/vbb') -const client = createClient(vbbProfile) +const client = createClient(vbbProfile, 'my-awesome-program') client.radar({ north: 52.52411, diff --git a/docs/station.md b/docs/station.md index d31feb6f..615dad93 100644 --- a/docs/station.md +++ b/docs/station.md @@ -35,7 +35,7 @@ As an example, we're going to use the [VBB profile](../p/vbb): const createClient = require('hafas-client') const vbbProfile = require('hafas-client/p/vbb') -const client = createClient(vbbProfile) +const client = createClient(vbbProfile, 'my-awesome-program') client.station('900000042101') // U Spichernstr. .then(console.log) diff --git a/docs/trip.md b/docs/trip.md index 000359d4..9d1b34fe 100644 --- a/docs/trip.md +++ b/docs/trip.md @@ -10,7 +10,7 @@ Let's say you used [`journeys`](journeys.md) and now want to get more up-to-date const createClient = require('hafas-client') const vbbProfile = require('hafas-client/p/vbb') -const client = createClient(vbbProfile) +const client = createClient(vbbProfile, 'my-awesome-program') // Hauptbahnhof to Heinrich-Heine-Str. client.journeys('900000003201', '900000100008', {results: 1}) diff --git a/p/db/example.js b/p/db/example.js index 9d7ef481..1ca575b9 100644 --- a/p/db/example.js +++ b/p/db/example.js @@ -3,7 +3,7 @@ const createClient = require('../../') const dbProfile = require('.') -const client = createClient(dbProfile) +const client = createClient(dbProfile, 'hafas-client-example') // Berlin Jungfernheide to München Hbf client.journeys('8011167', '8000261', {results: 1, tickets: true}) diff --git a/p/insa/example.js b/p/insa/example.js index 01ebdaf0..a697f110 100644 --- a/p/insa/example.js +++ b/p/insa/example.js @@ -3,7 +3,7 @@ const createClient = require('../..') const insaProfile = require('.') -const client = createClient(insaProfile) +const client = createClient(insaProfile, 'hafas-client-example') // from Magdeburg-Neustadt to Magdeburg-Buckau client.journeys('008010226', '008013456', {results: 1}) diff --git a/p/nahsh/example.js b/p/nahsh/example.js index fad4fbf4..57a9aec5 100644 --- a/p/nahsh/example.js +++ b/p/nahsh/example.js @@ -3,7 +3,7 @@ const createClient = require('../..') const nahshProfile = require('.') -const client = createClient(nahshProfile) +const client = createClient(nahshProfile, 'hafas-client-example') // Flensburg Hbf to Kiel Hbf client.journeys('8000103', '8000199', {results: 10, tickets: true}) diff --git a/p/oebb/example.js b/p/oebb/example.js index ff6d5b40..f2c3ccdb 100644 --- a/p/oebb/example.js +++ b/p/oebb/example.js @@ -3,7 +3,7 @@ const createClient = require('../..') const oebbProfile = require('.') -const client = createClient(oebbProfile) +const client = createClient(oebbProfile, 'hafas-client-example') // Wien Westbahnhof to Salzburg Hbf client.journeys('1291501', '8100002', {results: 1}) diff --git a/p/vbb/example.js b/p/vbb/example.js index 270379ba..6a1968c2 100644 --- a/p/vbb/example.js +++ b/p/vbb/example.js @@ -3,7 +3,7 @@ const createClient = require('../..') const vbbProfile = require('.') -const client = createClient(vbbProfile) +const client = createClient(vbbProfile, 'hafas-client-example') // Hauptbahnhof to Charlottenburg client.journeys('900000003201', '900000024101', {results: 1, polylines: true}) diff --git a/readme.md b/readme.md index a74d03ab..bad03961 100644 --- a/readme.md +++ b/readme.md @@ -47,7 +47,7 @@ const createClient = require('hafas-client') const dbProfile = require('hafas-client/p/db') // create a client with Deutsche Bahn profile -const client = createClient(dbProfile) +const client = createClient(dbProfile, 'my-awesome-program') // Berlin Jungfernheide to München Hbf client.journeys('8011167', '8000261', {results: 1})