diff --git a/p/readme.md b/p/readme.md index 3081e5d3..cbf78af4 100644 --- a/p/readme.md +++ b/p/readme.md @@ -41,6 +41,7 @@ HAFAS endpoint | wrapper library | docs | example code | profile name [Salzburg public transport (SVV)](https://de.wikipedia.org/wiki/Salzburger_Verkehrsverbund) | - | [docs](svv/readme.md) | [example](svv/example.js) | [`svv`](svv) [Verkehrsverbund Tirol (VVT)](https://de.wikipedia.org/wiki/Verkehrsverbund_Tirol) | - | [docs](vvt/readme.md) | [example](vvt/example.js) | [`vvt`](vvt) [*Kärntner Linien/Verkehrsverbund Kärnten (VKG/VVK)*](https://de.wikipedia.org/wiki/Verkehrsverbund_Kärnten) | - | [docs](vkg/readme.md) | [example](vkg/example.js) | [`vkg`](vkg) +[Verkehrsverbund Vorarlberg (VVV)](https://de.wikipedia.org/wiki/Verkehrsverbund_Vorarlberg) | - | [docs](vvv/readme.md) | [example](vvv/example.js) | [`vvv`](vvv) [*Transports publics genevois (TPG)*](https://en.wikipedia.org/wiki/Geneva_Public_Transport) (Geneva) | - | [docs](tpg/readme.md) | [example](tpg/example.js) | [`tpg`](tpg) [*BLS AG*](https://en.wikipedia.org/wiki/BLS_AG) (Bern) | - | [docs](bls/readme.md) | [example](bls/example.js) | [`bls`](bls) [Zürich public transport (ZVV)](https://en.wikipedia.org/wiki/Zürcher_Verkehrsverbund) | - | [docs](zvv/readme.md) | [example](zvv/example.js) | [`zvv`](zvv) diff --git a/p/vvv/base.json b/p/vvv/base.json new file mode 100644 index 00000000..11e0fe94 --- /dev/null +++ b/p/vvv/base.json @@ -0,0 +1,14 @@ +{ + "auth": { + "type": "AID", + "aid": "and20201hf7mcf9bv3nv8g5f" + }, + "client": { + "type": "AND", + "id": "VAO" + }, + "endpoint": "https://fahrplan.vmobil.at/bin/mgate.exe", + "ext": "VAO.11", + "ver": "1.27", + "defaultLanguage": "de" +} diff --git a/p/vvv/example.js b/p/vvv/example.js new file mode 100644 index 00000000..ae4a4079 --- /dev/null +++ b/p/vvv/example.js @@ -0,0 +1,49 @@ +'use strict' + +const createClient = require('../..') +const vvvProfile = require('.') + +const client = createClient(vvvProfile, 'hafas-client example') + +const bregenzLandeskrankenhaus = '480195700' +const bludenzGymnasium = '480031300' + +// client.journeys(bregenzLandeskrankenhaus, bludenzGymnasium, { +// results: 1, stopovers: true, +// }) +// .then(({journeys}) => { +// const [journey] = journeys +// return client.refreshJourney(journey.refreshToken, {stopovers: true, remarks: true}) +// }) +// .then(({journeys}) => { +// const [journey] = journeys +// const leg = journey.legs[0] +// return client.trip(leg.tripId, leg.line.name, {polyline: true}) +// }) + +// client.departures(bregenzLandeskrankenhaus, {duration: 1}) +// client.arrivals(bregenzLandeskrankenhaus, {duration: 10, linesOfStops: true}) + +client.locations('krankenhaus', {results: 3}) +// client.stop(bregenzLandeskrankenhaus, {linesOfStops: true}) +// client.nearby({ +// type: 'location', +// id: '980010311', +// address: 'Austraße 37, 6700 Bludenz', +// latitude: 47.149626, +// longitude: 9.822693, +// }, {distance: 1000}) +// client.reachableFrom({ +// type: 'location', +// id: '980010311', +// address: 'Austraße 37, 6700 Bludenz', +// latitude: 47.149626, +// longitude: 9.822693, +// }, { +// maxDuration: 30, +// }) + +.then((data) => { + console.log(require('util').inspect(data, {depth: null, colors: true})) +}) +.catch(console.error) diff --git a/p/vvv/index.js b/p/vvv/index.js new file mode 100644 index 00000000..64176c89 --- /dev/null +++ b/p/vvv/index.js @@ -0,0 +1,98 @@ +'use strict' + +const baseProfile = require('./base.json') + +const products = [{ + id: 'train-and-s-bahn', + mode: 'train', + bitmasks: [1, 2], + name: 'Bahn & S-Bahn', + short: 'Bahn & S-Bahn', + default: true, +}, { + id: 'u-bahn', + mode: 'train', + bitmasks: [4], + name: 'U-Bahn', + short: 'U-Bahn', + default: true, +}, { + id: 'tram', + mode: 'train', + bitmasks: [16], + name: 'Straßenbahn', + short: 'Straßenbahn', + default: true, +}, { + id: 'city-bus', + mode: 'bus', + bitmasks: [128], + name: 'Stadtbus', + short: 'Stadtbus', + default: true, +}, { + id: 'regional-bus', + mode: 'bus', + bitmasks: [64], + name: 'Regionalbus', + short: 'Regionalbus', + default: true, +}, { + id: 'long-distance-bus', + mode: 'bus', + bitmasks: [32], + name: 'Fernbus', + short: 'Fernbus', + default: true, +}, { + id: 'other-bus', + mode: 'bus', + bitmasks: [2048], + name: 'sonstige Busse', + short: 'sonstige Busse', + default: true, +}, { + id: 'aerial-lift', + mode: 'gondola', + bitmasks: [256], + name: 'Seil-/Zahnradbahn', + short: 'Seil-/Zahnradbahn', + default: true, +}, { + id: 'ferry', + mode: 'watercraft', + bitmasks: [512], + name: 'Schiff', + short: 'Schiff', + default: true, +}, { + id: 'on-call', + mode: 'taxi', + bitmasks: [1024], + name: 'Anrufsammeltaxi', + short: 'AST', + default: true, +}] + +const vosProfile = { + ...baseProfile, + auth: { + aid: 'and20201hf7mcf9bv3nv8g5f', + type: 'USER', + user: 'mobile', + }, + addMicMac: true, + salt: '6633673735743766726667323938336A', + locale: 'at-DE', + timezone: 'Europe/Vienna', + + products, + + departuresGetPasslist: false, + departuresStbFltrEquiv: false, + refreshJourneyUseOutReconL: true, + trip: true, + reachableFrom: true, +} + +module.exports = vosProfile diff --git a/p/vvv/readme.md b/p/vvv/readme.md new file mode 100644 index 00000000..0eeaf061 --- /dev/null +++ b/p/vvv/readme.md @@ -0,0 +1,15 @@ +# VVV profile for `hafas-client` + +[*Verkehrsverbund Vorarlberg (VVV)*](https://de.wikipedia.org/wiki/Verkehrsverbund_Vorarlberg) is the local transport provider of [Vorarlberg](https://en.wikipedia.org/wiki/Vorarlberg) that runs its apps under the [*VMOBIL*](https://www.vmobil.at) brand. This profile adds *VVV*/*VMOBIL* support to `hafas-client`. + +## Usage + +```js +const createClient = require('hafas-client') +const vvvProfile = require('hafas-client/p/vvv') + +// create a client with VVV profile +const client = createClient(vvvProfile, 'my-awesome-program') +``` + +Check out the [code examples](example.js). diff --git a/test/e2e/fixtures/fb997e87e2c2921529ca6a49c7d9859d b/test/e2e/fixtures/fb997e87e2c2921529ca6a49c7d9859d new file mode 100644 index 00000000..6d4f51d2 --- /dev/null +++ b/test/e2e/fixtures/fb997e87e2c2921529ca6a49c7d9859d @@ -0,0 +1 @@ +{"ver":"1.27","ext":"VAO.11","lang":"deu","id":"zv4scgiqm2qcyg8x","err":"OK","cInfo":{"code":"OK","url":"","msg":""},"graph":{"id":"standard","index":0},"subGraph":{"id":"global","index":0},"view":{"id":"standard","index":0,"type":"WGS84"},"svcResL":[{"meth":"LocMatch","err":"OK","res":{"common":{"remL":[{"type":"W","code":"WW","txtN":"WEBVIEW","url":"https://app.verkehrsauskunft.at/bin/query.exe/dn?tpl=webview_poi&performLocating=128&look_station=960076303&look_nv=get_infotext|yes|get_attributes|yes&look_stationpool=130"}],"icoL":[{"res":"prod_bus","txtS":"4","fg":{"r":255,"g":255,"b":255},"bg":{"r":0,"g":121,"b":58},"zIdx":1000},{"res":"PCAT_KRANKENANSTALT","zIdx":900},{"res":"prod_ic_bus","txtS":"11","fg":{"r":255,"g":255,"b":255},"bg":{"r":0,"g":121,"b":58},"zIdx":1000},{"res":"prod_bus","txtS":"1","fg":{"r":255,"g":255,"b":255},"bg":{"r":0,"g":121,"b":58},"zIdx":1000},{"res":"prod_ic_bus","txtS":"878","fg":{"r":255,"g":255,"b":255},"bg":{"r":0,"g":121,"b":58},"zIdx":1000}]},"match":{"field":"S","state":"L","locL":[{"lid":"A=1@O=Bregenz Landeskrankenhaus@X=9743201@Y=47497806@U=81@L=480195700@B=1@p=1628121247@","type":"S","name":"Bregenz Landeskrankenhaus","nameFormatted":{"text":"Bregenz Landeskrankenhaus"},"icoX":0,"extId":"480195700","state":"F","crd":{"x":9743201,"y":47497806,"floor":0},"meta":true,"pCls":192,"wt":191,"isMainMast":true,"gidL":["at:48:1957"]},{"lid":"A=4@O=Landeskrankenhaus Bregenz@X=9745287@Y=47496736@U=130@L=960076303@B=1@p=1628123037@","type":"P","name":"Landeskrankenhaus Bregenz","nameFormatted":{"text":"Landeskrankenhaus Bregenz"},"icoX":1,"extId":"960076303","state":"F","crd":{"x":9745287,"y":47496736,"floor":0},"mcpData":{"type":"P","occupancy":"N","mcpid":"0","externalId":"vao-betrieb_K803"},"msgL":[{"type":"REM","remX":0,"sty":"I","dspl":"U","tagL":["RES_LOC_WEB","RES_LOC_FLY_WEB"],"sort":684195840}]},{"lid":"A=1@O=Bregenz Gebietskrankenkasse@X=9731335@Y=47499819@U=81@L=480046500@B=1@p=1628121247@","type":"S","name":"Bregenz Gebietskrankenkasse","nameFormatted":{"text":"Bregenz Gebietskrankenkasse"},"icoX":2,"extId":"480046500","state":"F","crd":{"x":9731335,"y":47499819,"floor":0},"meta":true,"pCls":192,"wt":88,"isMainMast":true,"gidL":["at:48:465"]},{"lid":"A=1@O=Bludenz Krankenhaus@X=9821371@Y=47158993@U=81@L=480038800@B=1@p=1628121247@","type":"S","name":"Bludenz Krankenhaus","nameFormatted":{"text":"Bludenz Krankenhaus"},"icoX":3,"extId":"480038800","state":"F","crd":{"x":9821371,"y":47158993,"floor":0},"meta":true,"pCls":128,"wt":58,"isMainMast":true,"gidL":["at:48:388"]},{"lid":"A=1@O=Eggenburg Krankenhaus@X=15821365@Y=48646079@U=81@L=431557000@B=1@p=1628121247@","type":"S","name":"Eggenburg Krankenhaus","nameFormatted":{"text":"Eggenburg Krankenhaus"},"icoX":4,"extId":"431557000","state":"F","crd":{"x":15821365,"y":48646079,"floor":0},"meta":true,"pCls":64,"wt":10,"isMainMast":true,"gidL":["at:43:15570"]}]}}}]} \ No newline at end of file diff --git a/test/e2e/fixtures/fb997e87e2c2921529ca6a49c7d9859d.headers b/test/e2e/fixtures/fb997e87e2c2921529ca6a49c7d9859d.headers new file mode 100644 index 00000000..450d4f9c --- /dev/null +++ b/test/e2e/fixtures/fb997e87e2c2921529ca6a49c7d9859d.headers @@ -0,0 +1,35 @@ +{ + "statusCode": 200, + "headers": { + "date": "Thu, 05 Aug 2021 18:09:48 GMT", + "server": "Apache", + "content-length": "1039", + "content-type": "application/json; charset=utf-8", + "connection": "close" + }, + "url": "https://fahrplan.vmobil.at/bin/mgate.exe?mic=b612903e01707306710b6fbabc65bcee&mac=2287c0d8d5f08f184f1e71f246aee38c", + "time": 266, + "request": { + "method": "POST", + "headers": { + "Content-Type": [ + "application/json" + ], + "Accept-Encoding": [ + "gzip, br, deflate" + ], + "Accept": [ + "application/json" + ], + "user-agent": [ + "pb8f7fad7961dublic-transport/hafas-client:test" + ], + "Content-Length": [ + "296" + ], + "Connection": [ + "close" + ] + } + } +} \ No newline at end of file diff --git a/test/e2e/vvv.js b/test/e2e/vvv.js new file mode 100644 index 00000000..eac982c9 --- /dev/null +++ b/test/e2e/vvv.js @@ -0,0 +1,35 @@ +'use strict' + +const tap = require('tap') + +const {createWhen} = require('./lib/util') +const createClient = require('../..') +const vvvProfile = require('../../p/vvv') +const createValidate = require('./lib/validate-fptf-with') + +const when = createWhen(vvvProfile.timezone, vvvProfile.locale) +const cfg = { + when, + stationCoordsOptional: false, + products: vvvProfile.products, + maxLatitude: 47.9504, + maxLongitude: 17.0892, + minLatitude: 45.7206, + minLongitude: 7.8635, +} +const validate = createValidate(cfg) + +const client = createClient(vvvProfile, 'public-transport/hafas-client:test') + +const bregenzLandeskrankenhaus = '480195700' + +tap.test('locations named "bregenz krankenhaus"', async (t) => { + const locations = await client.locations('bregenz krankenhaus') + + validate(t, locations, 'locations', 'locations') + t.ok(locations.some((l) => { + return l.station && l.station.id === bregenzLandeskrankenhaus || l.id === bregenzLandeskrankenhaus + }), 'Bregenz Landeskrankenhaus not found') + + t.end() +}) diff --git a/tools/pull-profile-base-data.sh b/tools/pull-profile-base-data.sh index b210517d..8bbc09ca 100755 --- a/tools/pull-profile-base-data.sh +++ b/tools/pull-profile-base-data.sh @@ -61,6 +61,7 @@ node -p "$query" "$src/de/vos-hafas-mgate.json" >../p/vos/base.json node -p "$query" "$src/de/vrn-hafas-mgate.json" >../p/vrn/base.json node -p "$query" "$src/de/vsn-hafas-mgate.json" >../p/vsn/base.json node -p "$query" "$src/at/vvt-hafas-mgate.json" >../p/vvt/base.json +node -p "$query" "$src/at/vvv-hafas-mgate.json" >../p/vvv/base.json node -p "$query" "$src/ch/bls-hafas-mgate.json" >../p/bls/base.json node -p "$query" "$src/ch/tpg-hafas-mgate.json" >../p/tpg/base.json node -p "$query" "$src/ch/zvv-hafas-mgate.json" >../p/zvv/base.json diff --git a/tools/transport-apis b/tools/transport-apis index 14ba39a4..f297b865 160000 --- a/tools/transport-apis +++ b/tools/transport-apis @@ -1 +1 @@ -Subproject commit 14ba39a48a441e6819a7e0627d5e8701c5a0f60d +Subproject commit f297b865747394b3d797e8eaa06b11006ad5d987