mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
parent
fcc53b5d2a
commit
b2b2d11dfe
8 changed files with 131 additions and 115 deletions
|
@ -95,11 +95,11 @@ client.journeys('900000003201', '900000100008', {
|
|||
.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
|
||||
[
|
||||
{
|
||||
{
|
||||
journeys: [ {
|
||||
legs: [ {
|
||||
tripId: '1|32615|6|86|10072018',
|
||||
origin: {
|
||||
|
@ -226,10 +226,10 @@ The response may look like this:
|
|||
public: true,
|
||||
distance: 558
|
||||
} ]
|
||||
},
|
||||
} ],
|
||||
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:
|
||||
|
@ -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`.
|
||||
|
||||
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
|
||||
const hbf = '900000003201'
|
||||
const heinrichHeineStr = '900000100008'
|
||||
|
||||
client.journeys(hbf, heinrichHeineStr)
|
||||
.then((journeys) => {
|
||||
const lastJourney = journeys[journeys.length - 1]
|
||||
.then((res) => {
|
||||
const lastJourney = res.journeys[res.journeys.length - 1]
|
||||
console.log('departure of last journey', lastJourney.legs[0].departure)
|
||||
|
||||
// get later journeys
|
||||
return client.journeys(hbf, heinrichHeineStr, {
|
||||
laterThan: journeys.laterRef
|
||||
laterThan: res.laterRef
|
||||
})
|
||||
})
|
||||
.then((laterJourneys) => {
|
||||
const firstJourney = laterJourneys[laterJourneys.length - 1]
|
||||
console.log('departure of first (later) journey', firstJourney.legs[0].departure)
|
||||
.then((laterRes) => {
|
||||
const firstLaterJourney = laterRes.journeys[laterRes.journeys.length - 1]
|
||||
console.log('departure of first (later) journey', firstLaterJourney.legs[0].departure)
|
||||
})
|
||||
.catch(console.error)
|
||||
```
|
||||
|
|
|
@ -32,12 +32,14 @@ client.journeys('900000003201', '900000024101', {results: 1, polylines: true})
|
|||
// maxDuration: 10
|
||||
// })
|
||||
|
||||
// .then(([journey]) => {
|
||||
// .then(({journeys}) => {
|
||||
// const [journey] = journeys
|
||||
// const leg = journey.legs[0]
|
||||
// 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})
|
||||
// })
|
||||
.then((data) => {
|
||||
|
|
|
@ -32,11 +32,13 @@ client.journeys('000002370', '000005919', {results: 1, polylines: true})
|
|||
// maxDuration: 15
|
||||
// })
|
||||
|
||||
// .then(([journey]) => {
|
||||
// .then(({journeys}) => {
|
||||
// const [journey] = journeys
|
||||
// const leg = journey.legs[0]
|
||||
// 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})
|
||||
// })
|
||||
|
||||
|
|
|
@ -24,12 +24,14 @@ client.journeys('008010226', '008013456', {results: 1})
|
|||
// east: 11.651451
|
||||
// }, {results: 10})
|
||||
|
||||
// .then(([journey]) => {
|
||||
// .then(({journeys}) => {
|
||||
// const [journey] = journeys
|
||||
// const leg = journey.legs[0]
|
||||
// return client.trip(leg.tripId, leg.line.name)
|
||||
// })
|
||||
|
||||
// .then(([journey]) => {
|
||||
// .then(({journeys}) => {
|
||||
// const [journey] = journeys
|
||||
// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true})
|
||||
// })
|
||||
|
||||
|
|
|
@ -6,11 +6,13 @@ const saarfahrplanProfile = require('.')
|
|||
const client = createClient(saarfahrplanProfile, 'hafas-client-example')
|
||||
|
||||
client.journeys('15541', '10609', {results: 1})
|
||||
// .then(([journey]) => {
|
||||
// .then(({journeys}) => {
|
||||
// const [journey] = journeys
|
||||
// const leg = journey.legs[0]
|
||||
// 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})
|
||||
// })
|
||||
|
||||
|
|
|
@ -32,12 +32,14 @@ client.departures('8004154', {duration: 5})
|
|||
// maxDuration: 20
|
||||
// })
|
||||
|
||||
// .then(([journey]) => {
|
||||
// .then(({journeys}) => {
|
||||
// const [journey] = journeys
|
||||
// const leg = journey.legs.find(leg => leg.line)
|
||||
// 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
|
||||
// })
|
||||
|
|
|
@ -32,12 +32,14 @@ client.journeys('900000003201', '900000024101', {results: 1, polylines: true})
|
|||
// maxDuration: 10
|
||||
// })
|
||||
|
||||
// .then(([journey]) => {
|
||||
// .then(({journeys}) => {
|
||||
// const [journey] = journeys
|
||||
// const leg = journey.legs[0]
|
||||
// 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})
|
||||
// })
|
||||
.then((data) => {
|
||||
|
|
10
readme.md
10
readme.md
|
@ -60,10 +60,11 @@ client.journeys('8011167', '8000261', {results: 1})
|
|||
.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
|
||||
[ {
|
||||
{
|
||||
journeys: [ {
|
||||
legs: [ {
|
||||
id: '1|100067|48|81|17122017',
|
||||
origin: {
|
||||
|
@ -168,7 +169,10 @@ The returned [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript
|
|||
amount: null,
|
||||
hint: 'No pricing information available.'
|
||||
}
|
||||
} ]
|
||||
} ],
|
||||
earlierRef: /* … */,
|
||||
laterRef: /* … */
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue