mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
deal with some todos, add more
This commit is contained in:
parent
040ed41de7
commit
024aa0e948
7 changed files with 13 additions and 10 deletions
|
@ -3,8 +3,9 @@
|
|||
const formatCoord = require('./coord')
|
||||
|
||||
const formatAddress = (a) => {
|
||||
// todo: type-checking, better error msgs
|
||||
if (!a.latitude || !a.longitude || !a.name) throw new Error('invalid address.')
|
||||
if (!a.type !== 'location' || !a.latitude || !a.longitude || !a.address) {
|
||||
throw new Error('invalid address')
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'A',
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
const formatCoord = require('./coord')
|
||||
|
||||
const formatPoi = (p) => {
|
||||
// todo: type-checking, better error msgs
|
||||
if (!p.latitude || !p.longitude || !p.id || !p.name) throw new Error('invalid poi.')
|
||||
if (!p.type !== 'location' || !p.latitude || !p.longitude || !p.id || !p.name) {
|
||||
throw new Error('invalid POI')
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'P',
|
||||
|
|
|
@ -42,7 +42,7 @@ const transformJourneysQuery = (query, opt) => {
|
|||
if (opt.bike) filters.push(bike)
|
||||
|
||||
query.trfReq = {
|
||||
jnyCl: 2, // todo
|
||||
jnyCl: opt.firstClass === true ? 1 : 2,
|
||||
tvlrProf: [{
|
||||
type: 'E',
|
||||
redtnCard: opt.loyaltyCard
|
||||
|
|
|
@ -11,7 +11,6 @@ const createParseJourney = (profile, stations, lines, remarks) => {
|
|||
// todo: c.dep.dProgType, c.arr.dProgType
|
||||
// todo: c.conSubscr
|
||||
// todo: c.trfRes x vbb-parse-ticket
|
||||
// todo: use computed information from part
|
||||
const parseJourney = (j) => {
|
||||
const parts = j.secL.map(part => parsePart(j, part))
|
||||
const res = {
|
||||
|
|
|
@ -16,7 +16,7 @@ const {
|
|||
assertValidLocation,
|
||||
assertValidLine,
|
||||
assertValidStopover,
|
||||
when, isValidWhen // todo: timezone
|
||||
when, isValidWhen
|
||||
} = require('./util.js')
|
||||
|
||||
const assertValidStationProducts = (t, p) => {
|
||||
|
|
|
@ -89,8 +89,10 @@ const hour = 60 * 60 * 1000
|
|||
const week = 7 * 24 * hour
|
||||
|
||||
// next Monday 10 am
|
||||
const dt = DateTime.local().startOf('week').plus({weeks: 1, hours: 10})
|
||||
const when = new Date(dt.toISO())
|
||||
const when = DateTime.fromMillis(Date.now(), {
|
||||
zone: 'Europe/Berlin',
|
||||
locale: 'de-DE'
|
||||
}).startOf('week').plus({weeks: 1, hours: 10}).toJSDate()
|
||||
const isValidWhen = (w) => {
|
||||
const ts = +new Date(w)
|
||||
if (Number.isNaN(ts)) return false
|
||||
|
|
|
@ -19,7 +19,7 @@ const {
|
|||
assertValidLine: _assertValidLine,
|
||||
assertValidStopover,
|
||||
hour, when,
|
||||
assertValidWhen, // todo: timezone
|
||||
assertValidWhen,
|
||||
assertValidTicket
|
||||
} = require('./util')
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue