diff --git a/p/irish-rail/example.js b/p/irish-rail/example.js new file mode 100644 index 00000000..ddea918d --- /dev/null +++ b/p/irish-rail/example.js @@ -0,0 +1,35 @@ +'use strict' + +const createClient = require('../..') +const irishProfile = require('.') + +const client = createClient(irishProfile) + +// from Dublin to Belfast Central +client.journeys('9909002', '9990840', {results: 1}) +// .then(({journeys}) => { +// const leg = journeys[0].legs[0] +// return client.trip(leg.tripId, leg.line && leg.line.name) +// }) + +// client.departures('9909002', {duration: 5}) +// client.arrivals('9909002', {duration: 10, linesOfStops: true}) +// client.locations('Dublin', {results: 2}) +// client.locations('Hochschule Dublin', {poi: true, addressses: false, fuzzy: false}) +// client.stop('9909002') // Dublin +// client.nearby({ +// type: 'location', +// latitude: 53.353, +// longitude: -6.247 +// }, {distance: 200}) +// client.radar({ +// north: 53.35, +// west: -6.245, +// south: 53.34, +// east: -6.244 +// }, {results: 10}) + +.then(data => { + console.log(require('util').inspect(data, { depth: null })) +}) +.catch(console.error) diff --git a/p/irish-rail/index.js b/p/irish-rail/index.js new file mode 100644 index 00000000..b63c3c9d --- /dev/null +++ b/p/irish-rail/index.js @@ -0,0 +1,36 @@ +'use strict' + +const products = require('./products') + +const transformReqBody = (ctx, body) => { + body.client = { + type: 'IPA', + id: 'IRISHRAIL', + v: '4000100', + name: 'IrishRailPROD-APPSTORE', + os: 'iOS 12.4.8', + } + body.ver = '1.18' + + body.auth = {type: 'AID', aid: 'P9bplgVCGnozdgQE'} + body.lang = 'ga' + + return body +} + +const irishRailProfile = { + locale: 'en-IE', + timezone: 'Europe/Dublin', + endpoint: 'https://journeyplanner.irishrail.ie/bin/mgate.exe', + transformReqBody, + + salt: Buffer.from('i5s7m3q9z6b4k1c2', 'utf8'), + addMicMac: true, + + products: products, + + trip: true, + radar: true, +} + +module.exports = irishRailProfile; diff --git a/p/irish-rail/products.js b/p/irish-rail/products.js new file mode 100644 index 00000000..a3e2cc43 --- /dev/null +++ b/p/irish-rail/products.js @@ -0,0 +1,38 @@ +'use strict' + +module.exports = [ + { + id: 'national-train', + mode: 'train', + bitmasks: [2], + name: 'InterCity', + short: 'IC', + default: true + }, + // todo: 4 + { + id: 'local-train', + mode: 'train', + bitmasks: [8], + name: 'Commuter', + short: 'Commuter', + default: true + }, + { + id: 'suburban', + mode: 'train', + bitmasks: [16], + name: 'Dublin Area Rapid Transit', + short: 'DART', + default: true + }, + // todo: 32 + { + id: 'luas', + mode: 'train', + bitmasks: [64], + name: 'LUAS Tram', + short: 'LUAS', + default: true + } +] diff --git a/p/irish-rail/readme.md b/p/irish-rail/readme.md new file mode 100644 index 00000000..5a629cf9 --- /dev/null +++ b/p/irish-rail/readme.md @@ -0,0 +1,18 @@ +# Irish Rail profile for `hafas-client` + +The [*Iarnród Éireann* (Irish Rail)](https://en.wikipedia.org/wiki/Iarnród_Éireann) is the national railway company of Ireland. This profile adds *Iarnród Éireann*-specific customizations to `hafas-client`. + +## Usage + +```js +const createClient = require('hafas-client') +const irishProfile = require('hafas-client/p/irish-rail') + +// create a client with Irish Rail profile +const client = createClient(irishProfile, 'my-awesome-program') +``` + + +## Customisations + +- parses *Irish Rail*-specific products (such as *LUAS* or *DART*) diff --git a/readme.md b/readme.md index c5d8aa14..8cb18198 100644 --- a/readme.md +++ b/readme.md @@ -208,6 +208,7 @@ HAFAS endpoint | wrapper library | docs | example code | source code [Deutsche Bahn (DB)](https://en.wikipedia.org/wiki/Deutsche_Bahn) | [`db-hafas`](https://github.com/public-transport/db-hafas) | [docs](p/db/readme.md) | [example code](p/db/example.js) | [src](p/db/index.js) [Polskie Koleje Państwowe (PKP)](https://en.wikipedia.org/wiki/Polish_State_Railways) | [`pkp-hafas`](https://github.com/juliuste/pkp-hafas) | [docs](p/pkp/readme.md) | [example code](p/pkp/example.js) | [src](p/pkp/index.js) [Belgian National Railways (SNCB/NMBS)](https://en.wikipedia.org/wiki/National_Railway_Company_of_Belgium) | - | [docs](p/sncb/readme.md) | [example code](p/sncb/example.js) | [src](p/sncb/index.js) +[*Iarnród Éireann* (Irish Rail)](https://en.wikipedia.org/wiki/Iarnród_Éireann) | - | [docs](p/irish-rail/readme.md) | [example code](p/irish-rail/example.js) | [src](p/irish-rail/index.js) [Berlin & Brandenburg public transport (VBB)](https://en.wikipedia.org/wiki/Verkehrsverbund_Berlin-Brandenburg) | [`vbb-hafas`](https://github.com/public-transport/vbb-hafas) | [docs](p/vbb/readme.md) | [example code](p/vbb/example.js) | [src](p/vbb/index.js) [Berlin public transport (BVG)](https://en.wikipedia.org/wiki/Berliner_Verkehrsbetriebe) | [`bvg-hafas`](https://github.com/public-transport/bvg-hafas) | [docs](p/bvg/readme.md) | [example code](p/bvg/example.js) | [src](p/bvg/index.js) [Österreichische Bundesbahnen (ÖBB)](https://en.wikipedia.org/wiki/Austrian_Federal_Railways) | [`oebb-hafas`](https://github.com/juliuste/oebb-hafas) | [docs](p/oebb/readme.md) | [example code](p/oebb/example.js) | [src](p/oebb/index.js)