-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ad6c356
commit debc1ee
Showing
16 changed files
with
167 additions
and
34 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
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
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
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,10 @@ | ||
{ | ||
"journeysEndpoint": "https://app.vendo.noncd.db.de/mob/angebote/fahrplan", | ||
"refreshJourneysEndpointPrice": "https://app.vendo.noncd.db.de/mob/angebote/recon/autonomereservierung", | ||
"refreshJourneysEndpointPolyline": "https://app.vendo.noncd.db.de/mob/trip/recon", | ||
"locationsEndpoint": "https://app.vendo.noncd.db.de/mob/location/search", | ||
"nearbyEndpoint": "https://app.vendo.noncd.db.de/mob/location/nearby", | ||
"tripEndpoint": "https://app.vendo.noncd.db.de/mob/zuglauf", | ||
"boardEndpoint": "https://app.vendo.noncd.db.de/mob/bahnhofstafel/abfahrt", | ||
"defaultLanguage": "en" | ||
} |
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,11 @@ | ||
const getHeaders = (contentType) => { | ||
return { | ||
'X-Correlation-ID': 'null', | ||
'Accept': contentType, | ||
'Content-Type': contentType, | ||
}; | ||
}; | ||
|
||
export { | ||
getHeaders, | ||
}; |
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,33 @@ | ||
import {createRequire} from 'module'; | ||
const require = createRequire(import.meta.url); | ||
|
||
const baseProfile = require('./base.json'); | ||
import {products} from '../../lib/products.js'; | ||
// import {formatJourneysReq, formatRefreshJourneyReq} from './journeys-req.js'; | ||
import {formatLocationFilter} from './location-filter.js'; | ||
import {formatLocationsReq} from './locations-req.js'; | ||
import {formatNearbyReq} from './nearby-req.js'; | ||
import {formatStationBoardReq} from './station-board-req.js'; | ||
// import {formatTravellers} from './travellers.js'; | ||
// import {parseTickets, parsePrice} from './tickets.js'; | ||
|
||
const profile = { | ||
...baseProfile, | ||
locale: 'de-DE', | ||
timezone: 'Europe/Berlin', | ||
|
||
products, | ||
// formatJourneysReq, | ||
// formatRefreshJourneyReq, | ||
formatNearbyReq, | ||
formatLocationsReq, | ||
formatStationBoardReq, | ||
formatLocationFilter, | ||
// parsePrice, | ||
// parseTickets, | ||
// formatTravellers, | ||
}; | ||
|
||
export { | ||
profile, | ||
}; |
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,20 @@ | ||
const formatLocationFilter = (stops, addresses, poi) => { | ||
if (stops && addresses && poi) { | ||
return ['ALL']; | ||
} | ||
const types = []; | ||
if (stops) { | ||
types.push('ST'); | ||
} | ||
if (addresses) { | ||
types.push('ADR'); | ||
} | ||
if (poi) { | ||
types.push('POI'); | ||
} | ||
return types; | ||
}; | ||
|
||
export { | ||
formatLocationFilter, | ||
}; |
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,20 @@ | ||
import {getHeaders} from './header.js'; | ||
|
||
const formatLocationsReq = (ctx, query) => { | ||
const {profile, opt} = ctx; | ||
|
||
return { | ||
endpoint: profile.locationsEndpoint, | ||
body: { | ||
locationTypes: profile.formatLocationFilter(opt.stops, opt.addresses, opt.poi), | ||
searchTerm: query, | ||
maxResults: opt.results, | ||
}, | ||
headers: getHeaders('application/x.db.vendo.mob.location.v3+json'), | ||
method: 'post', | ||
}; | ||
}; | ||
|
||
export { | ||
formatLocationsReq, | ||
}; |
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,29 @@ | ||
import {getHeaders} from './header.js'; | ||
|
||
const formatNearbyReq = (ctx, location) => { | ||
const {profile, opt} = ctx; | ||
if (opt.distance > 10000) { | ||
throw new Error('maximum supported distance by this endpoint is 10000'); | ||
} | ||
// TODO location types | ||
return { | ||
endpoint: profile.nearbyEndpoint, | ||
body: { | ||
area: { | ||
coordinates: { | ||
longitude: location.longitude, | ||
latitude: location.latitude, | ||
}, | ||
radius: opt.distance || 10000, | ||
}, | ||
maxResults: opt.results, | ||
products: profile.formatProductsFilter(ctx, opt.products || {}, 'dbnav'), | ||
}, | ||
headers: getHeaders('application/x.db.vendo.mob.location.v3+json'), | ||
method: 'post', | ||
}; | ||
}; | ||
|
||
export { | ||
formatNearbyReq, | ||
}; |
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,17 @@ | ||
import {getHeaders} from './header.js'; | ||
|
||
const formatStationBoardReq = (ctx, station, type) => { | ||
const {profile, opt} = ctx; | ||
|
||
return { | ||
endpoint: profile.boardEndpoint, | ||
path: type == 'departures' ? 'abfahrt' : 'ankunft', | ||
body: {anfragezeit: profile.formatTimeOfDay(profile, opt.when), datum: profile.formatDate(profile, opt.when), ursprungsBahnhofId: profile.formatStation(station).lid, verkehrsmittel: profile.formatProductsFilter(ctx, opt.products || {}, 'dbnav')}, | ||
method: 'POST', | ||
header: getHeaders('application/x.db.vendo.mob.bahnhofstafeln.v2+json'), | ||
}; | ||
}; | ||
|
||
export { | ||
formatStationBoardReq, | ||
}; |
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
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