mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-04-20 23:23:56 +03:00
serverInfo: add opt.versionInfo 📝✅
Thanks to @alexander-albers! see also https://github.com/alexander-albers/tripkit/issues/69#issuecomment-1048105228
This commit is contained in:
parent
cbc7f63dcc
commit
2edcd49e99
5 changed files with 58 additions and 1 deletions
|
@ -6,6 +6,7 @@ With `opt`, you can override the default options, which look like this:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
{
|
{
|
||||||
|
versionInfo: true, // query HAFAS versions?
|
||||||
language: 'en', // depends on the profile
|
language: 'en', // depends on the profile
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -25,6 +26,9 @@ console.log(await client.serverInfo())
|
||||||
|
|
||||||
```js
|
```js
|
||||||
{
|
{
|
||||||
|
// version of the HAFAS Connection Interface (HCI), the API that hafas-client uses
|
||||||
|
hciVersion: '1.23',
|
||||||
|
|
||||||
timetableStart: '20200517',
|
timetableStart: '20200517',
|
||||||
timetableEnd: '20201212',
|
timetableEnd: '20201212',
|
||||||
serverTime: '2020-07-19T21:32:12+02:00',
|
serverTime: '2020-07-19T21:32:12+02:00',
|
||||||
|
|
11
index.js
11
index.js
|
@ -731,13 +731,22 @@ const createClient = (profile, userAgent, opt = {}) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const serverInfo = async (opt = {}) => {
|
const serverInfo = async (opt = {}) => {
|
||||||
|
opt = {
|
||||||
|
versionInfo: true, // query HAFAS versions?
|
||||||
|
...opt
|
||||||
|
}
|
||||||
|
|
||||||
const {res, common} = await profile.request({profile, opt}, userAgent, {
|
const {res, common} = await profile.request({profile, opt}, userAgent, {
|
||||||
meth: 'ServerInfo',
|
meth: 'ServerInfo',
|
||||||
req: {}
|
req: {
|
||||||
|
getVersionInfo: opt.versionInfo,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const ctx = {profile, opt, common, res}
|
const ctx = {profile, opt, common, res}
|
||||||
return {
|
return {
|
||||||
|
// todo: what are .serverVersion & .clientVersion?
|
||||||
|
hciVersion: res.hciVersion || null,
|
||||||
timetableStart: res.fpB || null,
|
timetableStart: res.fpB || null,
|
||||||
timetableEnd: res.fpE || null,
|
timetableEnd: res.fpE || null,
|
||||||
serverTime: res.sD && res.sT
|
serverTime: res.sD && res.sT
|
||||||
|
|
1
test/e2e/fixtures/ec7d38b24537d986a55c1608474cda45
vendored
Normal file
1
test/e2e/fixtures/ec7d38b24537d986a55c1608474cda45
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"ver":"1.34","ext":"DB.R20.12.b","lang":"eng","id":"ta2gikk4gaxhxkwg","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":"ServerInfo","err":"OK","res":{"fpB":"20211212","fpE":"20221210","sD":"20220222","sT":"202539","enc":"ISO-8859-1","planrtTS":"1645557831","serverVersion":"5.45.DB.R21.12.1.a (customer/hcudb/release/21.12.1.a.0) [Dec 17 2021]","clientVersion":"5.45.DB.R21.12.1.a (customer/hcudb/release/21.12.1.a.0) [Dec 17 2021]","hciVersion":"1.46"}}]}
|
40
test/e2e/fixtures/ec7d38b24537d986a55c1608474cda45.headers
vendored
Normal file
40
test/e2e/fixtures/ec7d38b24537d986a55c1608474cda45.headers
vendored
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
{
|
||||||
|
"statusCode": 200,
|
||||||
|
"headers": {
|
||||||
|
"date": "Tue, 22 Feb 2022 19:25:40 GMT",
|
||||||
|
"content-type": "application/json; charset=utf-8",
|
||||||
|
"content-length": "345",
|
||||||
|
"connection": "keep-alive",
|
||||||
|
"set-cookie": [
|
||||||
|
"AWSALB=ofa5BiXycld9XQJtZ8QTD823tDszyjr2sYpdBYbJCeWk4P+8+TUzu7oywsmVX9wivfMEDtEJyBipYc+SA33F2pYyStBnxkBIWvzo5mOIS+tGZWBlyN3csusXBpFd; Expires=Tue, 01 Mar 2022 19:25:39 GMT; Path=/",
|
||||||
|
"AWSALBCORS=ofa5BiXycld9XQJtZ8QTD823tDszyjr2sYpdBYbJCeWk4P+8+TUzu7oywsmVX9wivfMEDtEJyBipYc+SA33F2pYyStBnxkBIWvzo5mOIS+tGZWBlyN3csusXBpFd; Expires=Tue, 01 Mar 2022 19:25:39 GMT; Path=/; SameSite=None; Secure"
|
||||||
|
],
|
||||||
|
"server": "Apache",
|
||||||
|
"strict-transport-security": "max-age=16070400; includeSubDomains"
|
||||||
|
},
|
||||||
|
"url": "https://reiseauskunft.bahn.de/bin/mgate.exe?checksum=ee1ddec720dddfcac82fb7f78649d72c",
|
||||||
|
"time": 304,
|
||||||
|
"request": {
|
||||||
|
"method": "POST",
|
||||||
|
"headers": {
|
||||||
|
"Content-Type": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"Accept-Encoding": [
|
||||||
|
"gzip, br, deflate"
|
||||||
|
],
|
||||||
|
"Accept": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"user-agent": [
|
||||||
|
"public-1dd0bdtranspor1dd0bdt/haf1dd0bdas-clien1dd0bdt:test"
|
||||||
|
],
|
||||||
|
"connection": [
|
||||||
|
"keep-alive"
|
||||||
|
],
|
||||||
|
"Content-Length": [
|
||||||
|
"252"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,6 +9,9 @@ const testServerInfo = async (cfg) => {
|
||||||
const info = await fetchServerInfo()
|
const info = await fetchServerInfo()
|
||||||
t.ok(info, 'invalid info')
|
t.ok(info, 'invalid info')
|
||||||
|
|
||||||
|
t.equal(typeof info.hciVersion, 'string', 'invalid info.hciVersion')
|
||||||
|
t.ok(info.hciVersion, 'invalid info.hciVersion')
|
||||||
|
|
||||||
t.equal(typeof info.timetableStart, 'string', 'invalid info.timetableStart')
|
t.equal(typeof info.timetableStart, 'string', 'invalid info.timetableStart')
|
||||||
t.ok(info.timetableStart, 'invalid info.timetableStart')
|
t.ok(info.timetableStart, 'invalid info.timetableStart')
|
||||||
t.equal(typeof info.timetableEnd, 'string', 'invalid info.timetableEnd')
|
t.equal(typeof info.timetableEnd, 'string', 'invalid info.timetableEnd')
|
||||||
|
|
Loading…
Add table
Reference in a new issue