diff --git a/p/hvv/index.js b/p/hvv/index.js new file mode 100644 index 00000000..cafb3337 --- /dev/null +++ b/p/hvv/index.js @@ -0,0 +1,33 @@ +'use strict' + +const products = require('./products') + +const transformReqBody = (body) => { + body.client = {type: 'AND', id: 'HVV', name: 'HVVPROD_ADHOC', v: '4020100'} + body.ext = 'HVV.1' + body.ver = '1.16' + body.auth = {type: 'AID', aid: 'andcXUmC9Mq6hjrwDIGd2l3oiaMrTUzyH'} + + return body +} + +const hvvProfile = { + locale: 'de-DE', + timezone: 'Europe/Berlin', + endpoint: 'https://hvv-app.hafas.de/bin/mgate.exe', + + // https://runkit.com/derhuerst/hafas-decrypt-encrypted-mac-salt + salt: Buffer.from('pqjM3iKEGOAhYbX76k9R5zutv', 'utf-8'), + addMicMac: true, + + transformReqBody, + + products, + + trip: true, + radar: true, + refreshJourney: true, + reachableFrom: true +} + +module.exports = hvvProfile diff --git a/p/hvv/products.js b/p/hvv/products.js new file mode 100644 index 00000000..c7dc5aa8 --- /dev/null +++ b/p/hvv/products.js @@ -0,0 +1,92 @@ +'use strict' + +module.exports = [ // todo: what is `512`? + { + id: 'subway', + mode: 'train', + bitmasks: [1], + name: 'U-Bahn', + short: 'U', + default: true + }, + { + id: 'suburban', + mode: 'train', + bitmasks: [2], + name: 'S-Bahn', + short: 'S', + default: true + }, + { + id: 'akn', + mode: 'train', + bitmasks: [4], + name: 'AKN', + short: 'A', + default: true + }, + { + id: 'regional-express-train', + mode: 'train', + bitmasks: [8], + name: 'RegionalExpress', + short: 'RE', + default: true + }, + { + id: 'regional-train', + mode: 'train', + bitmasks: [16], + name: 'Regionalbahn', + short: 'RB', + default: true + }, + { + id: 'ferry', + mode: 'watercraft', + bitmasks: [32], + name: 'Fähre', + short: 'F', + default: true + }, + { + id: 'bus', + mode: 'bus', + bitmasks: [128], + name: 'Bus', + short: 'Bus', + default: true + }, + { + id: 'express-bus', + mode: 'bus', + bitmasks: [256], + name: 'Schnellbus', + short: 'Schnellbus', + default: true + }, + { + id: 'anruf-sammel-taxi', + mode: null, // todo + bitmasks: [1024], + name: 'Anruf-Sammel-Taxi', + short: 'AST', + default: true + }, + { + id: 'long-distance-train', + mode: 'train', + bitmasks: [4096, 64], + name: 'Fernzug', + short: 'ICE/IC/EC/EN', + default: false + }, + { + id: 'long-distance-bus', + mode: 'bus', + bitmasks: [2048], + name: 'Fernbus', + short: 'Fernbus', + default: false + } +] diff --git a/p/hvv/readme.md b/p/hvv/readme.md new file mode 100644 index 00000000..566e7fa5 --- /dev/null +++ b/p/hvv/readme.md @@ -0,0 +1,18 @@ +# HVV profile for `hafas-client` + +[*Hamburger Verkehrsverbund (HVV)*](https://en.wikipedia.org/wiki/Hamburger_Verkehrsverbund) is the major local transport provider in [Hamburg](https://en.wikipedia.org/wiki/Hamburg). This profile adds *HVV*-specific customizations to `hafas-client`. + +## Usage + +```js +const createClient = require('hafas-client') +const hvvProfile = require('hafas-client/p/hvv') + +// create a client with HVV profile +const client = createClient(hvvProfile, 'my-awesome-program') +``` + + +## Customisations + +- parses *HVV*-specific products (such as *AKN*) diff --git a/readme.md b/readme.md index a15d3df6..ce89096d 100644 --- a/readme.md +++ b/readme.md @@ -14,6 +14,7 @@ HAFAS endpoint | wrapper library | docs | example code | source code [*S-Bahn München*](https://en.wikipedia.org/wiki/Munich_S-Bahn) | - | [docs](p/sbahn-muenchen/readme.md) | [example code](p/sbahn-muenchen/example.js) | [src](p/sbahn-muenchen/index.js) *Saarfahrplan*/VGS ([Saarland](https://en.wikipedia.org/wiki/Saarland)) | - | [docs](p/saarfahrplan/readme.md) | [example code](p/saarfahrplan/example.js) | [src](p/saarfahrplan/index.js) [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) There are also client libraries that use the library, but contain their own customisations: