diff --git a/p/mobil-nrw/example.js b/p/mobil-nrw/example.js new file mode 100644 index 00000000..c66f69bd --- /dev/null +++ b/p/mobil-nrw/example.js @@ -0,0 +1,49 @@ +'use strict' + +const {inspect} = require('util') +const createClient = require('../..') +const cflProfile = require('.') + +const client = createClient(cflProfile, 'hafas-client-example') + +const soest = '8000076' +const aachenHbf = '8000001' + +client.journeys(soest, aachenHbf, {results: 1, stopovers: true}) +// .then(({journeys}) => { +// const leg = journeys[0].legs[0] +// return client.trip(leg.tripId, leg.line.name) +// }) + +// client.locations('soest', {results: 3}) +// client.reachableFrom({ +// type: 'location', +// id: '980301639', +// latitude: 51.387609, +// longitude: 6.684019, +// address: 'Duisburg, Am Mühlenberg 1', +// }, { +// maxDuration: 15, +// }) +// client.nearby({ +// type: 'location', +// latitude: 51.4503, +// longitude: 6.6581, +// }, {distance: 1200}) + +// client.station(soest) +// client.departures(soest, {duration: 20}) + +// client.radar({ +// north: 51.4358, +// west: 6.7625, +// south: 51.4214, +// east: 6.7900, +// }, {results: 10}) + +// client.remarks() + +.then(data => { + console.log(inspect(data, {depth: null, colors: true})) +}) +.catch(console.error) diff --git a/p/mobil-nrw/index.js b/p/mobil-nrw/index.js new file mode 100644 index 00000000..ef4f71d6 --- /dev/null +++ b/p/mobil-nrw/index.js @@ -0,0 +1,40 @@ +'use strict' + +const products = require('./products') + +const transformReqBody = (ctx, body) => { + body.client = { + id: 'DB-REGIO-NRW', + name: 'NRW', + os: 'iOS 12.4.9', + type: 'IPH', + v: '6000300', + } + body.ver = '1.24' + body.auth = { + type: 'AID', + aid: 'Kdf0LNRWYg5k3499' + } + body.lang = 'de' + // body.ext = 'DB.R19.04.a' + + return body +} + +const cflProfile = { + locale: 'de-DE', + timezone: 'Europe/Berlin', + endpoint: 'https://nrw.hafas.de/bin/mgate.exe', + transformReqBody, + + products, + + departuresGetPasslist: false, + departuresStbFltrEquiv: false, + trip: true, + radar: true, + reachableFrom: true, + remarks: true, +} + +module.exports = cflProfile; diff --git a/p/mobil-nrw/products.js b/p/mobil-nrw/products.js new file mode 100644 index 00000000..e2f45788 --- /dev/null +++ b/p/mobil-nrw/products.js @@ -0,0 +1,78 @@ +'use strict' + +module.exports = [ + { + id: 'regional-train', + mode: 'train', + bitmasks: [8], + // todo: specify explicitly which + name: 'regional train', + short: 'regional train', + default: true, + }, + { + id: 'urban-train', + mode: 'train', + bitmasks: [16], + name: 'urban train', + short: 'urban train', + default: true, + }, + { + id: 'subway', + mode: 'train', + bitmasks: [128], + name: 'subway', + short: 'subway', + default: true, + }, + { + id: 'tram', + mode: 'train', + bitmasks: [256], + name: 'tram', + short: 'tram', + default: true, + }, + { + id: 'bus', + mode: 'bus', + bitmasks: [32], + name: 'bus', + short: 'bus', + default: true, + }, + { + id: 'dial-a-ride', + mode: 'taxi', + bitmasks: [512], + name: 'dial-a-ride', + short: 'dial-a-ride', + default: true, + }, + { + id: 'long-distance-train', + mode: 'train', + bitmasks: [4], + // todo: specify explicitly which + name: 'long-distance train', + short: 'long-distance train', + default: true, + }, + { + id: 'express-train', + mode: 'train', + bitmasks: [1], + name: 'ICE', + short: 'ICE', + default: true, + }, + { + id: 'ec-ic', + mode: 'ec-ic', + bitmasks: [2], + name: 'EC/IC', + short: 'EC/IC', + default: true, + } +] diff --git a/p/mobil-nrw/readme.md b/p/mobil-nrw/readme.md new file mode 100644 index 00000000..a0809817 --- /dev/null +++ b/p/mobil-nrw/readme.md @@ -0,0 +1,18 @@ +# *mobil.nrw* profile for `hafas-client` + +[*mobil.nrw*](https://www.mobil.nrw) is the name of the travel planning service of the [*NRW-Tarif*](https://de.wikipedia.org/wiki/NRW-Tarif). This profile adds *mobil.nrw*-specific customisations to `hafas-client`. + +## Usage + +```js +const createClient = require('hafas-client') +const mobilNrwProfile = require('hafas-client/p/mobil-nrw') + +// create a client with mobil.nrw profile +const client = createClient(mobilNrwProfile) +``` + + +## Customisations + +- *mobil.nrw*-specific products diff --git a/readme.md b/readme.md index 01a6815f..a5f886c8 100644 --- a/readme.md +++ b/readme.md @@ -223,6 +223,7 @@ HAFAS endpoint | wrapper library | docs | example code | source code [Société Nationale des Chemins de Fer Luxembourgeois (CFL)](https://en.wikipedia.org/wiki/Société_Nationale_des_Chemins_de_Fer_Luxembourgeois) | - | [docs](p/cfl/readme.md) | [example code](p/cfl/example.js) | [src](p/cfl/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) +[*mobil.nrw*](https://www.mobil.nrw) | - | [docs](p/mobil-nrw/readme.md) | [example code](p/mobil-nrw/example.js) | [src](p/mobil-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) [Ingolstädter Verkehrsgesellschaft (INVG)](https://de.wikipedia.org/wiki/Ingolstädter_Verkehrsgesellschaft) | - | [docs](p/invg/readme.md) | [example code](p/invg/example.js) | [src](p/invg/index.js)