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