mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
add VSN profile
This commit is contained in:
parent
c1beb28b85
commit
542a9eea02
5 changed files with 183 additions and 0 deletions
47
p/vsn/example.js
Normal file
47
p/vsn/example.js
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const createClient = require('../..')
|
||||||
|
const vsnProfile = require('.')
|
||||||
|
|
||||||
|
const client = createClient(vsnProfile, 'hafas-client-example')
|
||||||
|
|
||||||
|
// client.journeys('9033961', '9033962', {results: 1, polylines: true})
|
||||||
|
// client.departures('9033961', {duration: 1})
|
||||||
|
// client.arrivals('9033961', {duration: 10, linesOfStops: true})
|
||||||
|
client.locations('jugendherberge', {results: 2})
|
||||||
|
// client.stop('9033961', {linesOfStops: true})
|
||||||
|
// client.nearby({
|
||||||
|
// type: 'location',
|
||||||
|
// latitude: 53.554422,
|
||||||
|
// longitude: 9.977934
|
||||||
|
// }, {distance: 60})
|
||||||
|
// client.radar({
|
||||||
|
// north: 53.55,
|
||||||
|
// west: 9.95,
|
||||||
|
// south: 52.51,
|
||||||
|
// east: 10
|
||||||
|
// }, {results: 10})
|
||||||
|
// client.reachableFrom({
|
||||||
|
// type: 'location',
|
||||||
|
// address: 'Hamburg, Holstenwall 9',
|
||||||
|
// latitude: 53.553766,
|
||||||
|
// longitude: 9.977514
|
||||||
|
// }, {
|
||||||
|
// when: new Date('2019-05-16T10:00:00+0200'),
|
||||||
|
// maxDuration: 8
|
||||||
|
// })
|
||||||
|
|
||||||
|
// .then(({journeys}) => {
|
||||||
|
// const [journey] = journeys
|
||||||
|
// const leg = journey.legs[0]
|
||||||
|
// return client.trip(leg.tripId, leg.line.name, {polyline: true})
|
||||||
|
// })
|
||||||
|
|
||||||
|
// .then(({journeys}) => {
|
||||||
|
// const [journey] = journeys
|
||||||
|
// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true})
|
||||||
|
// })
|
||||||
|
.then((data) => {
|
||||||
|
console.log(require('util').inspect(data, {depth: null, colors: true}))
|
||||||
|
})
|
||||||
|
.catch(console.error)
|
37
p/vsn/index.js
Normal file
37
p/vsn/index.js
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const products = require('./products')
|
||||||
|
|
||||||
|
const transformReqBody = (ctx, body) => {
|
||||||
|
body.client = {type: 'IPA', id: 'VSN', name: 'vsn', v: '5030100', os: 'iOS 13.3'}
|
||||||
|
body.ver = '1.24'
|
||||||
|
body.auth = {type: 'AID', aid: 'Mpf5UPC0DmzV8jkg'}
|
||||||
|
body.lang = 'de'
|
||||||
|
|
||||||
|
return body
|
||||||
|
}
|
||||||
|
|
||||||
|
const vsnProfile = {
|
||||||
|
locale: 'de-DE',
|
||||||
|
timezone: 'Europe/Berlin',
|
||||||
|
endpoint: 'https://fahrplaner.vsninfo.de/hafas/mgate.exe',
|
||||||
|
|
||||||
|
// https://gist.github.com/n0emis/3b6887572793f4f54da9d83b30548332#file-haf_config_base-properties-L31
|
||||||
|
// https://runkit.com/derhuerst/hafas-decrypt-encrypted-mac-salt
|
||||||
|
salt: Buffer.from('535033316d4275665379434c6d4e7870', 'hex'),
|
||||||
|
addMicMac: true,
|
||||||
|
|
||||||
|
transformReqBody,
|
||||||
|
|
||||||
|
products: products,
|
||||||
|
|
||||||
|
trip: true,
|
||||||
|
radar: true,
|
||||||
|
refreshJourney: true,
|
||||||
|
reachableFrom: true,
|
||||||
|
|
||||||
|
departuresGetPasslist: false,
|
||||||
|
departuresStbFltrEquiv: false
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = vsnProfile
|
84
p/vsn/products.js
Normal file
84
p/vsn/products.js
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
module.exports = [
|
||||||
|
{
|
||||||
|
id: 'nationalExpress',
|
||||||
|
mode: 'train',
|
||||||
|
bitmasks: [1],
|
||||||
|
name: 'InterCityExpress',
|
||||||
|
short: 'ICE',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'national',
|
||||||
|
mode: 'train',
|
||||||
|
bitmasks: [2],
|
||||||
|
name: 'Fernzug',
|
||||||
|
short: 'IC/EC/CNL',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'regionalExpress',
|
||||||
|
mode: 'train',
|
||||||
|
bitmasks: [4],
|
||||||
|
name: 'RegionalExpress & InterRegio',
|
||||||
|
short: 'RE/IR',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'regional',
|
||||||
|
mode: 'train',
|
||||||
|
bitmasks: [8],
|
||||||
|
name: 'Nahverhehr',
|
||||||
|
short: 'NV',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'suburban',
|
||||||
|
mode: 'train',
|
||||||
|
bitmasks: [16],
|
||||||
|
name: 'S-Bahn',
|
||||||
|
short: 'S',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'bus',
|
||||||
|
mode: 'bus',
|
||||||
|
bitmasks: [32],
|
||||||
|
name: 'Bus',
|
||||||
|
short: 'Bus',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'ferry',
|
||||||
|
mode: 'watercraft',
|
||||||
|
bitmasks: [64],
|
||||||
|
name: 'Schiff',
|
||||||
|
short: 'F',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'subway',
|
||||||
|
mode: 'train',
|
||||||
|
bitmasks: [128],
|
||||||
|
name: 'U-Bahn',
|
||||||
|
short: 'U',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'tram',
|
||||||
|
mode: 'train',
|
||||||
|
bitmasks: [256],
|
||||||
|
name: 'Straßen-/Stadtbahn',
|
||||||
|
short: 'T',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'anrufSammelTaxi',
|
||||||
|
mode: 'taxi',
|
||||||
|
bitmasks: [512],
|
||||||
|
name: 'Anruf-Sammel-Taxi',
|
||||||
|
short: 'AST',
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
]
|
14
p/vsn/readme.md
Normal file
14
p/vsn/readme.md
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# VSN profile for `hafas-client`
|
||||||
|
[*Verkehrsverbund Süd-Niedersachsen (VSN)*](https://de.wikipedia.org/wiki/Verkehrsverbund_S%C3%BCd-Niedersachsen) is the local transport provider south [Lower Saxony](https://en.wikipedia.org/wiki/Lower_Saxony). This profile adds *VSN*-specific customizations to `hafas-client`.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
```js
|
||||||
|
const createClient = require('hafas-client')
|
||||||
|
const vsnProfile = require('hafas-client/p/vsn')
|
||||||
|
|
||||||
|
// create a client with VSN profile
|
||||||
|
const client = createClient(vsnProfile, 'my-awesome-program')
|
||||||
|
```
|
||||||
|
|
||||||
|
## Customisations
|
||||||
|
- parses *VSN*-specific products
|
|
@ -206,6 +206,7 @@ HAFAS endpoint | wrapper library | docs | example code | source code
|
||||||
[Hamburg public transport (HVV)](https://en.wikipedia.org/wiki/Hamburger_Verkehrsverbund) | - | [docs](p/hvv/readme.md) | [example code](p/hvv/example.js) | [src](p/hvv/index.js)
|
[Hamburg public transport (HVV)](https://en.wikipedia.org/wiki/Hamburger_Verkehrsverbund) | - | [docs](p/hvv/readme.md) | [example code](p/hvv/example.js) | [src](p/hvv/index.js)
|
||||||
[*Nordhessischer Verkehrsverbund (NVV)*](https://en.wikipedia.org/wiki/Nordhessischer_Verkehrsverbund) ([Hesse](https://en.wikipedia.org/wiki/Hesse)) | - | [docs](p/nvv/readme.md) | [example code](p/nvv/example.js) | [src](p/nvv/index.js)
|
[*Nordhessischer Verkehrsverbund (NVV)*](https://en.wikipedia.org/wiki/Nordhessischer_Verkehrsverbund) ([Hesse](https://en.wikipedia.org/wiki/Hesse)) | - | [docs](p/nvv/readme.md) | [example code](p/nvv/example.js) | [src](p/nvv/index.js)
|
||||||
*DB Busradar NRW* ([DB Regio Bus](https://en.wikipedia.org/wiki/DB_Regio#Bus_division_(DB_Regio_Bus))) | - | [docs](p/db-busradar-nrw/readme.md) | [example code](p/db-busradar-nrw/example.js) | [src](p/db-busradar-nrw/index.js)
|
*DB Busradar NRW* ([DB Regio Bus](https://en.wikipedia.org/wiki/DB_Regio#Bus_division_(DB_Regio_Bus))) | - | [docs](p/db-busradar-nrw/readme.md) | [example code](p/db-busradar-nrw/example.js) | [src](p/db-busradar-nrw/index.js)
|
||||||
|
[Verkehrsverbund Süd-Niedersachsen (VSN)](https://de.wikipedia.org/wiki/Verkehrsverbund_S%C3%BCd-Niedersachsen) | - | [docs](p/vsn/readme.md) | [example code](p/vsn/example.js) | [src](p/vsn/index.js)
|
||||||
|
|
||||||
There are also libraries that use `hafas-client` and pass their own profile in:
|
There are also libraries that use `hafas-client` and pass their own profile in:
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue