adapt docs to fcc53b5 📝

[ci skip]
This commit is contained in:
Jannis R 2019-01-16 21:40:45 +08:00
parent fcc53b5d2a
commit b2b2d11dfe
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
8 changed files with 131 additions and 115 deletions

View file

@ -95,11 +95,11 @@ client.journeys('900000003201', '900000100008', {
.catch(console.error) .catch(console.error)
``` ```
The response may look like this: The `Promise` returned by `journeys()` will resolve with an object with the `journeys` & `earlierRef`/`laterRef` fields. It might look like this:
```js ```js
[ {
{ journeys: [ {
legs: [ { legs: [ {
tripId: '1|32615|6|86|10072018', tripId: '1|32615|6|86|10072018',
origin: { origin: {
@ -226,10 +226,10 @@ The response may look like this:
public: true, public: true,
distance: 558 distance: 558
} ] } ]
}, } ],
earlierRef: '…', // use with the `earlierThan` option earlierRef: '…', // use with the `earlierThan` option
laterRef: '…' // use with the `laterThan` option laterRef: '…' // use with the `laterThan` option
] }
``` ```
Some [profiles](../p) are able to parse the ticket information, if returned by the API. For example, if you pass `tickets: true` with the [VBB profile](../p/vbb), each `journey` will have a tickets array that looks like this: Some [profiles](../p) are able to parse the ticket information, if returned by the API. For example, if you pass `tickets: true` with the [VBB profile](../p/vbb), each `journey` will have a tickets array that looks like this:
@ -271,25 +271,25 @@ Some [profiles](../p) are able to parse the ticket information, if returned by t
If a journey leg has been cancelled, a `cancelled: true` will be added. Also, `departure`/`departureDelay`/`departurePlatform` and `arrival`/`arrivalDelay`/`arrivalPlatform` will be `null`. If a journey leg has been cancelled, a `cancelled: true` will be added. Also, `departure`/`departureDelay`/`departurePlatform` and `arrival`/`arrivalDelay`/`arrivalPlatform` will be `null`.
To get more journeys earlier/later than the current set of results, pass `journeys.earlierRef`/`journeys.laterRef` into `opt.earlierThan`/`opt.laterThan`. For example, query *later* journeys as follows: To get more journeys earlier/later than the current set of results, pass `earlierRef`/`laterRef` into `opt.earlierThan`/`opt.laterThan`. For example, query *later* journeys as follows:
```js ```js
const hbf = '900000003201' const hbf = '900000003201'
const heinrichHeineStr = '900000100008' const heinrichHeineStr = '900000100008'
client.journeys(hbf, heinrichHeineStr) client.journeys(hbf, heinrichHeineStr)
.then((journeys) => { .then((res) => {
const lastJourney = journeys[journeys.length - 1] const lastJourney = res.journeys[res.journeys.length - 1]
console.log('departure of last journey', lastJourney.legs[0].departure) console.log('departure of last journey', lastJourney.legs[0].departure)
// get later journeys // get later journeys
return client.journeys(hbf, heinrichHeineStr, { return client.journeys(hbf, heinrichHeineStr, {
laterThan: journeys.laterRef laterThan: res.laterRef
}) })
}) })
.then((laterJourneys) => { .then((laterRes) => {
const firstJourney = laterJourneys[laterJourneys.length - 1] const firstLaterJourney = laterRes.journeys[laterRes.journeys.length - 1]
console.log('departure of first (later) journey', firstJourney.legs[0].departure) console.log('departure of first (later) journey', firstLaterJourney.legs[0].departure)
}) })
.catch(console.error) .catch(console.error)
``` ```

View file

@ -32,12 +32,14 @@ client.journeys('900000003201', '900000024101', {results: 1, polylines: true})
// maxDuration: 10 // maxDuration: 10
// }) // })
// .then(([journey]) => { // .then(({journeys}) => {
// const [journey] = journeys
// const leg = journey.legs[0] // const leg = journey.legs[0]
// return client.trip(leg.tripId, leg.line.name, {polyline: true}) // return client.trip(leg.tripId, leg.line.name, {polyline: true})
// }) // })
// .then(([journey]) => { // .then(({journeys}) => {
// const [journey] = journeys
// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) // return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true})
// }) // })
.then((data) => { .then((data) => {

View file

@ -32,11 +32,13 @@ client.journeys('000002370', '000005919', {results: 1, polylines: true})
// maxDuration: 15 // maxDuration: 15
// }) // })
// .then(([journey]) => { // .then(({journeys}) => {
// const [journey] = journeys
// const leg = journey.legs[0] // const leg = journey.legs[0]
// return client.trip(leg.tripId, leg.line.name, {polyline: true}) // return client.trip(leg.tripId, leg.line.name, {polyline: true})
// }) // })
// .then(([journey]) => { // .then(({journeys}) => {
// const [journey] = journeys
// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) // return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true})
// }) // })

View file

@ -24,12 +24,14 @@ client.journeys('008010226', '008013456', {results: 1})
// east: 11.651451 // east: 11.651451
// }, {results: 10}) // }, {results: 10})
// .then(([journey]) => { // .then(({journeys}) => {
// const [journey] = journeys
// const leg = journey.legs[0] // const leg = journey.legs[0]
// return client.trip(leg.tripId, leg.line.name) // return client.trip(leg.tripId, leg.line.name)
// }) // })
// .then(([journey]) => { // .then(({journeys}) => {
// const [journey] = journeys
// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) // return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true})
// }) // })

View file

@ -6,11 +6,13 @@ const saarfahrplanProfile = require('.')
const client = createClient(saarfahrplanProfile, 'hafas-client-example') const client = createClient(saarfahrplanProfile, 'hafas-client-example')
client.journeys('15541', '10609', {results: 1}) client.journeys('15541', '10609', {results: 1})
// .then(([journey]) => { // .then(({journeys}) => {
// const [journey] = journeys
// const leg = journey.legs[0] // const leg = journey.legs[0]
// return client.trip(leg.id, leg.line.name, {polyline: true}) // return client.trip(leg.id, leg.line.name, {polyline: true})
// }) // })
// .then(([journey]) => { // .then(({journeys}) => {
// const [journey] = journeys
// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) // return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true})
// }) // })

View file

@ -32,12 +32,14 @@ client.departures('8004154', {duration: 5})
// maxDuration: 20 // maxDuration: 20
// }) // })
// .then(([journey]) => { // .then(({journeys}) => {
// const [journey] = journeys
// const leg = journey.legs.find(leg => leg.line) // const leg = journey.legs.find(leg => leg.line)
// return client.trip(leg.tripId, leg.line.name, {polyline: true}) // return client.trip(leg.tripId, leg.line.name, {polyline: true})
// }) // })
// .then(([journey]) => { // .then(({journeys}) => {
// const [journey] = journeys
// return client.refreshJourney(journey.refreshToken, { // return client.refreshJourney(journey.refreshToken, {
// stopovers: true, remarks: true // stopovers: true, remarks: true
// }) // })

View file

@ -32,12 +32,14 @@ client.journeys('900000003201', '900000024101', {results: 1, polylines: true})
// maxDuration: 10 // maxDuration: 10
// }) // })
// .then(([journey]) => { // .then(({journeys}) => {
// const [journey] = journeys
// const leg = journey.legs[0] // const leg = journey.legs[0]
// return client.trip(leg.tripId, leg.line.name, {polyline: true}) // return client.trip(leg.tripId, leg.line.name, {polyline: true})
// }) // })
// .then(([journey]) => { // .then(({journeys}) => {
// const [journey] = journeys
// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) // return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true})
// }) // })
.then((data) => { .then((data) => {

View file

@ -60,10 +60,11 @@ client.journeys('8011167', '8000261', {results: 1})
.catch(console.error) .catch(console.error)
``` ```
The returned [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/promise) will resolve with an array of one [*FPTF* `journey`](https://github.com/public-transport/friendly-public-transport-format/blob/1.2.0/spec/readme.md#journey). The returned [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/promise) will resolve with an object with an array `journeys` that contains one [*FPTF* `journey`](https://github.com/public-transport/friendly-public-transport-format/blob/1.2.0/spec/readme.md#journey).
```js ```js
[ { {
journeys: [ {
legs: [ { legs: [ {
id: '1|100067|48|81|17122017', id: '1|100067|48|81|17122017',
origin: { origin: {
@ -168,7 +169,10 @@ The returned [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript
amount: null, amount: null,
hint: 'No pricing information available.' hint: 'No pricing information available.'
} }
} ] } ],
earlierRef: /* … */,
laterRef: /* … */
}
``` ```