mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
earlierThan/laterThan: docs 📝
This commit is contained in:
parent
c835467d85
commit
1aac40079a
1 changed files with 138 additions and 104 deletions
|
@ -41,6 +41,8 @@ With `opt`, you can override the default options, which look like this:
|
||||||
```js
|
```js
|
||||||
{
|
{
|
||||||
when: new Date(),
|
when: new Date(),
|
||||||
|
earlierThan: null, // ref to get journeys earlier than the last query
|
||||||
|
laterThan: null, // ref to get journeys later than the last query
|
||||||
results: 5, // how many journeys?
|
results: 5, // how many journeys?
|
||||||
via: null, // let journeys pass this station
|
via: null, // let journeys pass this station
|
||||||
passedStations: false, // return stations on the way?
|
passedStations: false, // return stations on the way?
|
||||||
|
@ -85,7 +87,8 @@ client.journeys('900000003201', '900000100008', {
|
||||||
The response may look like this:
|
The response may look like this:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
[ {
|
[
|
||||||
|
{
|
||||||
legs: [ {
|
legs: [ {
|
||||||
id: '1|31041|35|86|17122017',
|
id: '1|31041|35|86|17122017',
|
||||||
origin: {
|
origin: {
|
||||||
|
@ -201,7 +204,10 @@ The response may look like this:
|
||||||
},
|
},
|
||||||
arrival: '2017-12-17T19:47:00.000+01:00',
|
arrival: '2017-12-17T19:47:00.000+01:00',
|
||||||
arrivalDelay: 30
|
arrivalDelay: 30
|
||||||
} ]
|
},
|
||||||
|
earlierRef: '…', // use with the `earlierThan` 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:
|
||||||
|
@ -242,3 +248,31 @@ 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, use `journey.earlierRef`/`journey.laterRef` as follows:
|
||||||
|
|
||||||
|
```js
|
||||||
|
const hbf = '900000003201'
|
||||||
|
const heinrichHeineStr = '900000100008'
|
||||||
|
|
||||||
|
client.journeys(hbf, heinrichHeineStr)
|
||||||
|
.then((journeys) => {
|
||||||
|
const lastJourney = journeys[journeys.length - 1]
|
||||||
|
console.log('departure of last journey', lastJourney.departure)
|
||||||
|
|
||||||
|
// get later journeys
|
||||||
|
return client.journeys(hbf, heinrichHeineStr, {
|
||||||
|
laterThan: journeys.laterRef
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.then((laterourneys) => {
|
||||||
|
const firstJourney = laterourneys[laterourneys.length - 1]
|
||||||
|
console.log('departure of first (later) journey', firstJourney.departure)
|
||||||
|
})
|
||||||
|
.catch(console.error)
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
departure of last journey 2017-12-17T19:07:00.000+01:00
|
||||||
|
departure of first (later) journey 2017-12-17T19:19:00.000+01:00
|
||||||
|
```
|
||||||
|
|
Loading…
Add table
Reference in a new issue