adapt to Friendly Public Transport Format, part 2

also added a user agent string
This commit is contained in:
Jannis R 2017-05-09 16:39:26 +02:00
parent 5abb2150fe
commit 44f6d3cd71
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
2 changed files with 8 additions and 7 deletions

View file

@ -12,7 +12,7 @@ const defaults = {
onLocation: parse.location,
onProduct: parse.product,
onRemark: parse.remark,
onAgency: parse.agency
onOperator: parse.operator
}
@ -26,7 +26,8 @@ const request = (opt) => {
json: true, body: JSON.stringify(body),
headers: {
'Content-Type': 'application/json',
'Accept-Encoding': 'gzip, deflate'
'Accept-Encoding': 'gzip, deflate',
'user-agent': 'https://github.com/derhuerst/hafas-client'
}
})
@ -43,7 +44,7 @@ const request = (opt) => {
if (Array.isArray(c.locL)) d.locations = c.locL.map(opt.onLocation)
if (Array.isArray(c.prodL)) d.products = c.prodL.map(opt.onProduct)
if (Array.isArray(c.remL)) d.remarks = c.remL.map(opt.onRemark)
if (Array.isArray(c.opL)) d.agencies = c.opL.map(opt.onAgency)
if (Array.isArray(c.opL)) d.operators = c.opL.map(opt.onOperator)
return d
}).catch((err) => {throw err})
}

View file

@ -127,10 +127,10 @@ const route = (tz, s, p, r) => (c) => {
const parts = c.secL.map(part(tz, s, p, r, c))
return {
parts
, from: parts[0].from
, start: parts[0].start
, to: parts[parts.length - 1].to
, end: parts[parts.length - 1].end
, origin: parts[0].origin
, destination: parts[0].destination
, departure: parts[parts.length - 1].departure
, arrival: parts[parts.length - 1].arrival
}
}