mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19: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)
|
.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)
|
||||||
```
|
```
|
||||||
|
|
|
@ -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) => {
|
||||||
|
|
|
@ -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})
|
||||||
// })
|
// })
|
||||||
|
|
||||||
|
|
|
@ -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})
|
||||||
// })
|
// })
|
||||||
|
|
||||||
|
|
|
@ -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})
|
||||||
// })
|
// })
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
// })
|
// })
|
||||||
|
|
|
@ -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) => {
|
||||||
|
|
186
readme.md
186
readme.md
|
@ -60,82 +60,103 @@ 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
|
||||||
[ {
|
{
|
||||||
legs: [ {
|
journeys: [ {
|
||||||
id: '1|100067|48|81|17122017',
|
legs: [ {
|
||||||
|
id: '1|100067|48|81|17122017',
|
||||||
|
origin: {
|
||||||
|
type: 'station',
|
||||||
|
id: '8089100',
|
||||||
|
name: 'Berlin Jungfernheide (S)',
|
||||||
|
location: {
|
||||||
|
type: 'location',
|
||||||
|
latitude: 52.530291,
|
||||||
|
longitude: 13.299451
|
||||||
|
},
|
||||||
|
products: { /* … */ }
|
||||||
|
},
|
||||||
|
departure: '2017-12-17T17:05:00.000+01:00',
|
||||||
|
departurePlatform: '5',
|
||||||
|
destination: {
|
||||||
|
type: 'station',
|
||||||
|
id: '8089118',
|
||||||
|
name: 'Berlin Beusselstraße',
|
||||||
|
location: { /* … */ },
|
||||||
|
products: { /* … */ }
|
||||||
|
},
|
||||||
|
arrival: '2017-12-17T17:08:00.000+01:00',
|
||||||
|
arrivalPlatform: '1',
|
||||||
|
line: {
|
||||||
|
type: 'line',
|
||||||
|
id: '41172',
|
||||||
|
name: 'S 41',
|
||||||
|
public: true,
|
||||||
|
mode: 'train',
|
||||||
|
product: 'suburban',
|
||||||
|
operator: {
|
||||||
|
type: 'operator',
|
||||||
|
id: 's-bahn-berlin-gmbh',
|
||||||
|
name: 'S-Bahn Berlin GmbH'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
direction: 'Ringbahn ->'
|
||||||
|
}, /* … */ {
|
||||||
|
origin: {
|
||||||
|
type: 'station',
|
||||||
|
id: '730749',
|
||||||
|
name: 'Berlin Hauptbahnhof (S+U), Berlin',
|
||||||
|
location: {
|
||||||
|
type: 'location',
|
||||||
|
latitude: 52.526461,
|
||||||
|
longitude: 13.369378
|
||||||
|
},
|
||||||
|
products: { /* … */ }
|
||||||
|
},
|
||||||
|
departure: '2017-12-17T17:25:00.000+01:00',
|
||||||
|
destination: {
|
||||||
|
type: 'station',
|
||||||
|
id: '8098160',
|
||||||
|
name: 'Berlin Hbf (tief)',
|
||||||
|
location: { /* … */ },
|
||||||
|
products: { /* … */ }
|
||||||
|
},
|
||||||
|
arrival: '2017-12-17T17:33:00.000+01:00',
|
||||||
|
mode: 'walking',
|
||||||
|
public: true
|
||||||
|
}, {
|
||||||
|
id: '1|70906|0|81|17122017',
|
||||||
|
origin: {
|
||||||
|
type: 'station',
|
||||||
|
id: '8098160',
|
||||||
|
name: 'Berlin Hbf (tief)',
|
||||||
|
location: { /* … */ },
|
||||||
|
products: { /* … */ }
|
||||||
|
},
|
||||||
|
departure: '2017-12-17T17:37:00.000+01:00',
|
||||||
|
departurePlatform: '1',
|
||||||
|
destination: {
|
||||||
|
type: 'station',
|
||||||
|
id: '8000261',
|
||||||
|
name: 'München Hbf',
|
||||||
|
location: { /* … */ },
|
||||||
|
products: { /* … */ }
|
||||||
|
},
|
||||||
|
arrival: '2017-12-17T22:45:00.000+01:00',
|
||||||
|
arrivalPlatform: '13',
|
||||||
|
line: { /* … */ },
|
||||||
|
direction: 'München Hbf'
|
||||||
|
} ],
|
||||||
origin: {
|
origin: {
|
||||||
type: 'station',
|
type: 'station',
|
||||||
id: '8089100',
|
id: '8089100',
|
||||||
name: 'Berlin Jungfernheide (S)',
|
name: 'Berlin Jungfernheide (S)',
|
||||||
location: {
|
location: { /* … */ },
|
||||||
type: 'location',
|
|
||||||
latitude: 52.530291,
|
|
||||||
longitude: 13.299451
|
|
||||||
},
|
|
||||||
products: { /* … */ }
|
products: { /* … */ }
|
||||||
},
|
},
|
||||||
departure: '2017-12-17T17:05:00.000+01:00',
|
departure: '2017-12-17T17:05:00.000+01:00',
|
||||||
departurePlatform: '5',
|
|
||||||
destination: {
|
|
||||||
type: 'station',
|
|
||||||
id: '8089118',
|
|
||||||
name: 'Berlin Beusselstraße',
|
|
||||||
location: { /* … */ },
|
|
||||||
products: { /* … */ }
|
|
||||||
},
|
|
||||||
arrival: '2017-12-17T17:08:00.000+01:00',
|
|
||||||
arrivalPlatform: '1',
|
|
||||||
line: {
|
|
||||||
type: 'line',
|
|
||||||
id: '41172',
|
|
||||||
name: 'S 41',
|
|
||||||
public: true,
|
|
||||||
mode: 'train',
|
|
||||||
product: 'suburban',
|
|
||||||
operator: {
|
|
||||||
type: 'operator',
|
|
||||||
id: 's-bahn-berlin-gmbh',
|
|
||||||
name: 'S-Bahn Berlin GmbH'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
direction: 'Ringbahn ->'
|
|
||||||
}, /* … */ {
|
|
||||||
origin: {
|
|
||||||
type: 'station',
|
|
||||||
id: '730749',
|
|
||||||
name: 'Berlin Hauptbahnhof (S+U), Berlin',
|
|
||||||
location: {
|
|
||||||
type: 'location',
|
|
||||||
latitude: 52.526461,
|
|
||||||
longitude: 13.369378
|
|
||||||
},
|
|
||||||
products: { /* … */ }
|
|
||||||
},
|
|
||||||
departure: '2017-12-17T17:25:00.000+01:00',
|
|
||||||
destination: {
|
|
||||||
type: 'station',
|
|
||||||
id: '8098160',
|
|
||||||
name: 'Berlin Hbf (tief)',
|
|
||||||
location: { /* … */ },
|
|
||||||
products: { /* … */ }
|
|
||||||
},
|
|
||||||
arrival: '2017-12-17T17:33:00.000+01:00',
|
|
||||||
mode: 'walking',
|
|
||||||
public: true
|
|
||||||
}, {
|
|
||||||
id: '1|70906|0|81|17122017',
|
|
||||||
origin: {
|
|
||||||
type: 'station',
|
|
||||||
id: '8098160',
|
|
||||||
name: 'Berlin Hbf (tief)',
|
|
||||||
location: { /* … */ },
|
|
||||||
products: { /* … */ }
|
|
||||||
},
|
|
||||||
departure: '2017-12-17T17:37:00.000+01:00',
|
|
||||||
departurePlatform: '1',
|
|
||||||
destination: {
|
destination: {
|
||||||
type: 'station',
|
type: 'station',
|
||||||
id: '8000261',
|
id: '8000261',
|
||||||
|
@ -144,31 +165,14 @@ The returned [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript
|
||||||
products: { /* … */ }
|
products: { /* … */ }
|
||||||
},
|
},
|
||||||
arrival: '2017-12-17T22:45:00.000+01:00',
|
arrival: '2017-12-17T22:45:00.000+01:00',
|
||||||
arrivalPlatform: '13',
|
price: {
|
||||||
line: { /* … */ },
|
amount: null,
|
||||||
direction: 'München Hbf'
|
hint: 'No pricing information available.'
|
||||||
|
}
|
||||||
} ],
|
} ],
|
||||||
origin: {
|
earlierRef: /* … */,
|
||||||
type: 'station',
|
laterRef: /* … */
|
||||||
id: '8089100',
|
}
|
||||||
name: 'Berlin Jungfernheide (S)',
|
|
||||||
location: { /* … */ },
|
|
||||||
products: { /* … */ }
|
|
||||||
},
|
|
||||||
departure: '2017-12-17T17:05:00.000+01:00',
|
|
||||||
destination: {
|
|
||||||
type: 'station',
|
|
||||||
id: '8000261',
|
|
||||||
name: 'München Hbf',
|
|
||||||
location: { /* … */ },
|
|
||||||
products: { /* … */ }
|
|
||||||
},
|
|
||||||
arrival: '2017-12-17T22:45:00.000+01:00',
|
|
||||||
price: {
|
|
||||||
amount: null,
|
|
||||||
hint: 'No pricing information available.'
|
|
||||||
}
|
|
||||||
} ]
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue