-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
part of #207
- Loading branch information
Showing
9 changed files
with
251 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"auth": { | ||
"type": "AID", | ||
"aid": "and20201hf7mcf9bv3nv8g5f" | ||
}, | ||
"client": { | ||
"type": "AND", | ||
"id": "VAO" | ||
}, | ||
"endpoint": "https://app.verkehrsauskunft.at/bin/mgate.exe", | ||
"ext": "VAO.11", | ||
"ver": "1.27", | ||
"defaultLanguage": "de" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
'use strict' | ||
|
||
const createClient = require('../..') | ||
const vvvProfile = require('.') | ||
|
||
const client = createClient(vvvProfile, 'hafas-client example') | ||
|
||
const linzTheatergasse = '444670100' | ||
const amstettenStadtbad = '431507400' | ||
|
||
// client.journeys(linzTheatergasse, amstettenStadtbad, { | ||
// 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.find(l => !!l.line) | ||
// return client.trip(leg.tripId, leg.line.name, {polyline: true}) | ||
// }) | ||
|
||
client.departures(linzTheatergasse, {duration: 12 * 60}) | ||
// client.arrivals(linzTheatergasse, {duration: 10, linesOfStops: true}) | ||
|
||
// client.locations('theatergasse', {results: 3}) | ||
// client.stop(linzTheatergasse, {linesOfStops: true}) | ||
// client.nearby({ | ||
// type: 'location', | ||
// id: '980115190', | ||
// address: 'Steingasse 19, 4020 Linz', | ||
// latitude: 48.301181, | ||
// longitude: 14.284057, | ||
// }, {distance: 1000}) | ||
// client.reachableFrom({ | ||
// type: 'location', | ||
// id: '980115190', | ||
// address: 'Steingasse 19, 4020 Linz', | ||
// latitude: 48.301181, | ||
// longitude: 14.284057, | ||
// }, { | ||
// maxDuration: 30, | ||
// }) | ||
|
||
.then((data) => { | ||
console.log(require('util').inspect(data, {depth: null, colors: true})) | ||
}) | ||
.catch(console.error) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
'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: { | ||
type: 'USER', | ||
aid: 'and20201hf7mcf9bv3nv8g5f', | ||
user: 'mobile', | ||
pw: '87a6f8ZbnBih32', | ||
}, | ||
addMicMac: true, | ||
salt: '6633673735743766726667323938336A', | ||
|
||
locale: 'at-DE', | ||
timezone: 'Europe/Vienna', | ||
|
||
products, | ||
|
||
departuresGetPasslist: false, | ||
departuresStbFltrEquiv: false, | ||
refreshJourneyUseOutReconL: true, | ||
trip: true, | ||
reachableFrom: true, | ||
} | ||
|
||
module.exports = vosProfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# OÖVV profile for `hafas-client` | ||
|
||
[*Oberösterreichischer Verkehrsverbund (OÖVV)*](https://de.wikipedia.org/wiki/Oberösterreichischer_Verkehrsverbund) is the local transport provider of [Upper Austria](https://en.wikipedia.org/wiki/Upper_Austria). This profile adds *OÖVV* support to `hafas-client`. | ||
|
||
## Usage | ||
|
||
```js | ||
const createClient = require('hafas-client') | ||
const oövvProfile = require('hafas-client/p/ooevv') | ||
|
||
// create a client with OÖVV profile | ||
const client = createClient(oövvProfile, 'my-awesome-program') | ||
``` | ||
|
||
Check out the [code examples](example.js). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"ver":"1.27","ext":"VAO.11","lang":"deu","id":"u8ggsg6xk2ahxw8x","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":{"txtInstL":[{"id":"street","type":"NONE","mode":"ADD"},{"id":"city","type":"NONE","mode":"ADD"}],"icoL":[{"res":"ADR"},{"res":"prod_bus","txtS":"192","fg":{"r":255,"g":255,"b":255},"bg":{"r":0,"g":121,"b":58},"zIdx":1000}]},"match":{"field":"S","state":"L","locL":[{"lid":"A=2@O=Theatergasse, 4020 Linz@X=14284902@Y=48303994@U=103@b=980119291@B=1@p=1626331592@","type":"A","name":"Theatergasse, 4020 Linz","nameFormatted":{"text":"Theatergasse, 4020 Linz","textInstructionIntervalL":[{"startIndex":0,"endIndex":12,"textInstructionX":0},{"startIndex":12,"endIndex":23,"textInstructionX":1}]},"icoX":0,"state":"F","crd":{"x":14284902,"y":48303994}},{"lid":"A=1@O=Linz/Donau Theatergasse@X=14284111@Y=48303913@U=81@L=444670100@B=1@p=1628121247@","type":"S","name":"Linz/Donau Theatergasse","nameFormatted":{"text":"Linz/Donau Theatergasse"},"icoX":1,"extId":"444670100","state":"F","crd":{"x":14284111,"y":48303913,"floor":0},"meta":true,"pCls":128,"wt":9,"isMainMast":true,"gidL":["at:44:46701"]},{"lid":"A=2@O=Theatergasse, 4810 Gmunden@X=13799314@Y=47918510@U=103@b=980119292@B=1@p=1626331592@","type":"A","name":"Theatergasse, 4810 Gmunden","nameFormatted":{"text":"Theatergasse, 4810 Gmunden","textInstructionIntervalL":[{"startIndex":0,"endIndex":12,"textInstructionX":0},{"startIndex":12,"endIndex":26,"textInstructionX":1}]},"icoX":0,"state":"F","crd":{"x":13799314,"y":47918510}},{"lid":"A=2@O=Theatergasse, 5020 Salzburg@X=13043528@Y=47802441@U=103@b=980119293@B=1@p=1626331592@","type":"A","name":"Theatergasse, 5020 Salzburg","nameFormatted":{"text":"Theatergasse, 5020 Salzburg","textInstructionIntervalL":[{"startIndex":0,"endIndex":12,"textInstructionX":0},{"startIndex":12,"endIndex":27,"textInstructionX":1}]},"icoX":0,"state":"F","crd":{"x":13043528,"y":47802441}},{"lid":"A=2@O=Theatergasse, 6330 Kufstein@X=12170675@Y=47583787@U=103@b=980119295@B=1@p=1626331592@","type":"A","name":"Theatergasse, 6330 Kufstein","nameFormatted":{"text":"Theatergasse, 6330 Kufstein","textInstructionIntervalL":[{"startIndex":0,"endIndex":12,"textInstructionX":0},{"startIndex":12,"endIndex":27,"textInstructionX":1}]},"icoX":0,"state":"F","crd":{"x":12170675,"y":47583787}}]}}}]} |
35 changes: 35 additions & 0 deletions
35
test/e2e/fixtures/75f51a885c609c1376bbfefeb1fec20a.headers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"statusCode": 200, | ||
"headers": { | ||
"date": "Thu, 05 Aug 2021 18:10:27 GMT", | ||
"transfer-encoding": "chunked", | ||
"content-type": "application/json; charset=utf-8", | ||
"connection": "close", | ||
"strict-transport-security": "max-age=15552000; includeSubDomains" | ||
}, | ||
"url": "https://app.verkehrsauskunft.at/bin/mgate.exe?mic=252230314636b9e1ed51d8665c761a48&mac=874447bb7da6b7fee876ab7d61583ba6", | ||
"time": 282, | ||
"request": { | ||
"method": "POST", | ||
"headers": { | ||
"Content-Type": [ | ||
"application/json" | ||
], | ||
"Accept-Encoding": [ | ||
"gzip, br, deflate" | ||
], | ||
"Accept": [ | ||
"application/json" | ||
], | ||
"user-agent": [ | ||
"public-tr52c19d463253ansport/hafas-client:test" | ||
], | ||
"Content-Length": [ | ||
"311" | ||
], | ||
"Connection": [ | ||
"close" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict' | ||
|
||
const tap = require('tap') | ||
|
||
const {createWhen} = require('./lib/util') | ||
const createClient = require('../..') | ||
const oövvProfile = require('../../p/ooevv') | ||
const createValidate = require('./lib/validate-fptf-with') | ||
|
||
const when = createWhen(oövvProfile.timezone, oövvProfile.locale) | ||
const cfg = { | ||
when, | ||
stationCoordsOptional: false, | ||
products: oövvProfile.products, | ||
maxLatitude: 49.7921, | ||
maxLongitude: 17.0892, | ||
minLatitude: 45.7206, | ||
minLongitude: 7.8635, | ||
} | ||
const validate = createValidate(cfg) | ||
|
||
const client = createClient(oövvProfile, 'public-transport/hafas-client:test') | ||
|
||
const linzTheatergasse = '444670100' | ||
|
||
tap.test('locations named "theatergasse"', async (t) => { | ||
const locations = await client.locations('theatergasse') | ||
|
||
validate(t, locations, 'locations', 'locations') | ||
t.ok(locations.some((l) => { | ||
return l.station && l.station.id === linzTheatergasse || l.id === linzTheatergasse | ||
}), 'Linz Theatergasse not found') | ||
|
||
t.end() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters