mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
parseWarning
This commit is contained in:
parent
b6e37595a5
commit
d909be3b65
5 changed files with 43 additions and 0 deletions
|
@ -11,6 +11,7 @@ const parseMovement = require('../parse/movement')
|
|||
const parseNearby = require('../parse/nearby')
|
||||
const parseOperator = require('../parse/operator')
|
||||
const parseHint = require('../parse/hint')
|
||||
const parseWarning = require('../parse/warning')
|
||||
const parseStopover = require('../parse/stopover')
|
||||
|
||||
const formatAddress = require('../format/address')
|
||||
|
@ -48,6 +49,7 @@ const defaultProfile = {
|
|||
parseNearby,
|
||||
parseOperator,
|
||||
parseHint,
|
||||
parseWarning,
|
||||
parseStopover,
|
||||
|
||||
formatAddress,
|
||||
|
|
|
@ -83,6 +83,10 @@ const request = (profile, data) => {
|
|||
if (Array.isArray(c.remL)) {
|
||||
d.hints = c.remL.map(hint => profile.parseHint(profile, hint))
|
||||
}
|
||||
d.warnings = []
|
||||
if (Array.isArray(c.himL)) {
|
||||
d.warnings = c.himL.map(w => profile.parseWarning(profile, w))
|
||||
}
|
||||
if (Array.isArray(c.opL)) {
|
||||
d.operators = c.opL.map(op => profile.parseOperator(profile, op))
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ const types = {
|
|||
parseNearby: 'function',
|
||||
parseOperator: 'function',
|
||||
parseHint: 'function',
|
||||
parseWarning: 'function',
|
||||
parseStopover: 'function',
|
||||
|
||||
formatAddress: 'function',
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@mapbox/polyline": "^1.0.0",
|
||||
"br2nl": "^1.0.0",
|
||||
"capture-stack-trace": "^1.0.0",
|
||||
"create-hash": "^1.2.0",
|
||||
"fetch-ponyfill": "^6.0.0",
|
||||
|
|
35
parse/warning.js
Normal file
35
parse/warning.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
'use strict'
|
||||
|
||||
const brToNewline = require('br2nl')
|
||||
|
||||
const parseDateTime = require('./date-time')
|
||||
|
||||
// todo: is passing in profile necessary?
|
||||
const parseWarning = (profile, w) => {
|
||||
// todo: hid, act, pub, lead, tckr, icoX, fLocX, tLocX, prod, comp,
|
||||
// todo: cat (1, 2), pubChL
|
||||
// pubChL:
|
||||
// [ { name: 'timetable',
|
||||
// fDate: '20180606',
|
||||
// fTime: '073000',
|
||||
// tDate: '20180713',
|
||||
// tTime: '030000' },
|
||||
// { name: 'export',
|
||||
// fDate: '20180606',
|
||||
// fTime: '073000',
|
||||
// tDate: '20180713',
|
||||
// tTime: '030000' } ]
|
||||
|
||||
return {
|
||||
type: 'warning',
|
||||
summary: brToNewline(w.head),
|
||||
text: brToNewline(w.text),
|
||||
priority: w.prio,
|
||||
category: w.cat, // todo: parse to sth meaningful
|
||||
validFrom: parseDateTime(profile, w.sDate, w.sTime).toISO(),
|
||||
validUntil: parseDateTime(profile, w.eDate, w.eTime).toISO(),
|
||||
modified: parseDateTime(profile, w.lModDate, w.lModTime).toISO()
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = parseWarning
|
Loading…
Add table
Reference in a new issue