add Irish Rail profile

This commit is contained in:
Jannis R 2018-04-12 21:49:55 +02:00 committed by Jannis Redmann
parent de86391dcd
commit 8ed218f4d6
5 changed files with 128 additions and 0 deletions

35
p/irish-rail/example.js Normal file
View file

@ -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)

36
p/irish-rail/index.js Normal file
View file

@ -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;

38
p/irish-rail/products.js Normal file
View file

@ -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
}
]

18
p/irish-rail/readme.md Normal file
View file

@ -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*)

View file

@ -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)