2022-05-07 16:17:37 +02:00
|
|
|
import {inspect} from 'util'
|
|
|
|
import {createClient} from '../../index.js'
|
2022-11-22 21:08:08 +01:00
|
|
|
import {profile as nahshProfile} from './index.js'
|
2018-03-14 14:54:08 +01:00
|
|
|
|
2023-07-28 21:35:56 +02:00
|
|
|
// Pick a descriptive user agent! hafas-client won't work with this string.
|
2022-11-22 21:08:08 +01:00
|
|
|
const client = createClient(nahshProfile, 'hafas-client-example')
|
2018-03-14 14:54:08 +01:00
|
|
|
|
2023-07-28 21:35:56 +02:00
|
|
|
const flensburgHbf = '8000103'
|
|
|
|
const kielHbf = '8000199'
|
2021-04-18 19:18:41 +02:00
|
|
|
|
2023-07-28 21:35:56 +02:00
|
|
|
let data = await client.locations('Schleswig', {results: 1})
|
|
|
|
// let data = await client.nearby({
|
2018-06-28 12:08:54 +02:00
|
|
|
// type: 'location',
|
|
|
|
// latitude: 54.295691,
|
|
|
|
// longitude: 10.116424
|
|
|
|
// }, {distance: 60})
|
2023-07-28 21:35:56 +02:00
|
|
|
// let data = await client.reachableFrom({
|
2018-08-26 18:35:27 +02:00
|
|
|
// type: 'location',
|
|
|
|
// address: 'Husum, Berliner Straße 80',
|
|
|
|
// latitude: 54.488995,
|
|
|
|
// longitude: 9.056263
|
|
|
|
// }, {
|
|
|
|
// when: new Date('2018-08-27T10:00:00+0200'),
|
|
|
|
// maxDuration: 20
|
|
|
|
// })
|
2018-03-14 14:54:08 +01:00
|
|
|
|
2023-07-28 21:35:56 +02:00
|
|
|
// let data = await client.stop('706990') // Kiel Holunderbusch
|
|
|
|
|
|
|
|
// let data = await client.departures(kielHbf, {duration: 10})
|
|
|
|
// let data = await client.arrivals(kielHbf, {duration: 5, linesOfStops: true})
|
|
|
|
|
|
|
|
// let data = await client.journeys(flensburgHbf, kielHbf, {
|
|
|
|
// results: 10,
|
|
|
|
// tickets: true,
|
|
|
|
// })
|
|
|
|
// {
|
|
|
|
// const [journey] = data.journeys
|
|
|
|
// data = await client.refreshJourney(journey.refreshToken, {
|
|
|
|
// stopovers: true,
|
|
|
|
// remarks: true,
|
|
|
|
// })
|
|
|
|
// }
|
|
|
|
// {
|
|
|
|
// const [journey] = data.journeys
|
|
|
|
// const leg = journey.legs[0]
|
|
|
|
// data = await client.trip(leg.tripId, {polyline: true})
|
|
|
|
// }
|
|
|
|
|
|
|
|
// let data = await client.radar({
|
2021-04-18 19:18:41 +02:00
|
|
|
// north: 54.4,
|
|
|
|
// west: 10.0,
|
|
|
|
// south: 54.2,
|
|
|
|
// east: 10.2
|
|
|
|
// }, {
|
|
|
|
// results: 10,
|
|
|
|
// })
|
|
|
|
|
2023-07-28 21:35:56 +02:00
|
|
|
console.log(inspect(data, {depth: null, colors: true}))
|