-
-
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
243 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
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 @@ | ||
{ | ||
"auth": { | ||
"type": "AID", | ||
"aid": "wf7mcf9bv3nv8g5f" | ||
}, | ||
"client": { | ||
"type": "WEB", | ||
"id": "VAO", | ||
"name": "webapp" | ||
}, | ||
"endpoint": "https://verkehrsauskunft.verbundlinie.at/bin/mgate.exe", | ||
"ext": "VAO.13", | ||
"ver": "1.32", | ||
"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 stvProfile = require('.') | ||
|
||
const client = createClient(stvProfile, 'hafas-client example') | ||
|
||
const grazSonnenhang = '460413500' | ||
const grazHΓΆdlweg = '460415400' | ||
|
||
// client.journeys(grazSonnenhang, grazHΓΆdlweg, { | ||
// 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(grazSonnenhang, {duration: 1}) | ||
// client.arrivals(grazSonnenhang, {duration: 10, linesOfStops: true}) | ||
|
||
client.locations('sonnenhang', {results: 3}) | ||
// client.stop(grazSonnenhang, {linesOfStops: true}) | ||
// client.nearby({ | ||
// type: 'location', | ||
// id: '980027564', | ||
// address: 'Eisengasse 10, 8020 Graz', | ||
// latitude: 47.076553, | ||
// longitude: 15.406064, | ||
// }, {distance: 1000}) | ||
// client.reachableFrom({ | ||
// type: 'location', | ||
// id: '980027564', | ||
// address: 'Eisengasse 10, 8020 Graz', | ||
// latitude: 47.076553, | ||
// longitude: 15.406064, | ||
// }, { | ||
// 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,91 @@ | ||
'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 stvProfile = { | ||
...baseProfile, | ||
locale: 'at-DE', | ||
timezone: 'Europe/Vienna', | ||
|
||
products, | ||
|
||
departuresGetPasslist: false, | ||
departuresStbFltrEquiv: false, | ||
refreshJourneyUseOutReconL: true, | ||
trip: true, | ||
reachableFrom: true, | ||
} | ||
|
||
module.exports = stvProfile |
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 @@ | ||
# STV profile for `hafas-client` | ||
|
||
[*Steirischer Verkehrsverbund (STV)*](https://de.wikipedia.org/wiki/Steirischer_Verkehrsverbund) is the local transport provider of [Styria](https://en.wikipedia.org/wiki/Styria) that runs its apps under the [*VerbundLinie*](https://www.verbundlinie.at) brand. This profile adds *STV*/*VerbundLinie* support to `hafas-client`. | ||
|
||
## Usage | ||
|
||
```js | ||
const createClient = require('hafas-client') | ||
const stvProfile = require('hafas-client/p/stv') | ||
|
||
// create a client with STV profile | ||
const client = createClient(stvProfile, '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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"ver":"1.32","ext":"VAO.13","lang":"deu","id":"urk4mgmgm6agg2wx","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":"prod_regbus","txtS":"421","fg":{"r":255,"g":255,"b":255},"bg":{"r":0,"g":121,"b":58},"zIdx":1000},{"res":"prod_bus","txtS":"53","fg":{"r":255,"g":255,"b":255},"bg":{"r":0,"g":121,"b":58},"zIdx":1000},{"res":"prod_regbus","txtS":"862","fg":{"r":255,"g":255,"b":255},"bg":{"r":0,"g":121,"b":58},"zIdx":1000},{"res":"prod_regbus","txtS":"265","fg":{"r":255,"g":255,"b":255},"bg":{"r":0,"g":121,"b":58},"zIdx":1000},{"res":"ADR"}]},"match":{"field":"S","state":"L","locL":[{"lid":"A=1@O=Graz Sonnenhang@X=15481555@Y=47067034@U=81@L=460413500@B=1@p=1628121247@","type":"S","name":"Graz Sonnenhang","nameFormatted":{"text":"Graz Sonnenhang"},"icoX":0,"extId":"460413500","state":"F","crd":{"x":15481555,"y":47067034,"floor":0},"meta":true,"pCls":192,"wt":191,"isMainMast":true,"gidL":["at:46:4135"]},{"lid":"A=1@O=Stattegg Sonnenhang@X=15418613@Y=47141626@U=81@L=460362700@B=1@p=1628121247@","type":"S","name":"Stattegg Sonnenhang","nameFormatted":{"text":"Stattegg Sonnenhang"},"icoX":1,"extId":"460362700","state":"F","crd":{"x":15418613,"y":47141626,"floor":0},"meta":true,"pCls":128,"wt":188,"isMainMast":true,"gidL":["at:46:3627"]},{"lid":"A=1@O=Mehrnbach Sonnenhang@X=13443674@Y=48207189@U=81@L=444079800@B=1@p=1628121247@","type":"S","name":"Mehrnbach Sonnenhang","nameFormatted":{"text":"Mehrnbach Sonnenhang"},"icoX":2,"extId":"444079800","state":"F","crd":{"x":13443674,"y":48207189,"floor":0},"meta":true,"pCls":64,"wt":10,"isMainMast":true,"gidL":["at:44:40798"]},{"lid":"A=1@O=Waxenberg Sonnenhang@X=14191927@Y=48481945@U=81@L=444569400@B=1@p=1628121247@","type":"S","name":"Waxenberg Sonnenhang","nameFormatted":{"text":"Waxenberg Sonnenhang"},"icoX":3,"extId":"444569400","state":"F","crd":{"x":14191927,"y":48481945,"floor":0},"meta":true,"pCls":64,"wt":2,"isMainMast":true,"gidL":["at:44:45694"]},{"lid":"A=2@O=Sonnenhang, 3262 Wang@X=15020723@Y=48049231@U=103@b=980111207@B=1@p=1626331592@","type":"A","name":"Sonnenhang, 3262 Wang","nameFormatted":{"text":"Sonnenhang, 3262 Wang","textInstructionIntervalL":[{"startIndex":0,"endIndex":10,"textInstructionX":0},{"startIndex":10,"endIndex":21,"textInstructionX":1}]},"icoX":4,"state":"F","crd":{"x":15020723,"y":48049231}}]}}}]} |
35 changes: 35 additions & 0 deletions
35
test/e2e/fixtures/9f33037cf954e62ae7ee72fbc9fbb8c4.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:17 GMT", | ||
"server": "Apache", | ||
"content-length": "841", | ||
"content-type": "application/json; charset=utf-8", | ||
"connection": "close" | ||
}, | ||
"url": "https://verkehrsauskunft.verbundlinie.at/bin/mgate.exe", | ||
"time": 266, | ||
"request": { | ||
"method": "POST", | ||
"headers": { | ||
"Content-Type": [ | ||
"application/json" | ||
], | ||
"Accept-Encoding": [ | ||
"gzip, br, deflate" | ||
], | ||
"Accept": [ | ||
"application/json" | ||
], | ||
"user-agent": [ | ||
"public-transc9279a930e0bport/hafas-client:test" | ||
], | ||
"Content-Length": [ | ||
"278" | ||
], | ||
"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 stvProfile = require('../../p/stv') | ||
const createValidate = require('./lib/validate-fptf-with') | ||
|
||
const when = createWhen(stvProfile.timezone, stvProfile.locale) | ||
const cfg = { | ||
when, | ||
stationCoordsOptional: false, | ||
products: stvProfile.products, | ||
maxLatitude: 47.9504, | ||
maxLongitude: 18.347, | ||
minLatitude: 46.127, | ||
minLongitude: 7.8635, | ||
} | ||
const validate = createValidate(cfg) | ||
|
||
const client = createClient(stvProfile, 'public-transport/hafas-client:test') | ||
|
||
const grazSonnenhang = '460413500' | ||
|
||
tap.test('locations named "sonnenhang"', async (t) => { | ||
const locations = await client.locations('sonnenhang') | ||
|
||
validate(t, locations, 'locations', 'locations') | ||
t.ok(locations.some((l) => { | ||
return l.station && l.station.id === grazSonnenhang || l.id === grazSonnenhang | ||
}), 'Graz Sonnenhang 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