mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 07:09:35 +02:00
25 lines
933 B
JavaScript
25 lines
933 B
JavaScript
import slugg from 'slugg';
|
|
|
|
const parseLine = (ctx, p) => {
|
|
const profile = ctx.profile;
|
|
const res = {
|
|
type: 'line',
|
|
id: slugg(p.verkehrsmittel?.langText || p.transport?.journeyDescription || p.train?.no), // TODO terrible
|
|
fahrtNr: p.verkehrsmittel?.nummer || p.transport?.number || p.train?.no,
|
|
name: p.verkehrsmittel?.name || p.zugName || p.transport?.journeyDescription || p.train && p.train.category + ' ' + p.train.lineName,
|
|
public: true,
|
|
};
|
|
|
|
// TODO res.adminCode
|
|
res.productName = p.verkehrsmittel?.kurzText || p.transport?.category || p.train?.category;
|
|
const foundProduct = profile.products.find(pp => pp.vendo == p.verkehrsmittel?.produktGattung || pp.ris == p.transport?.type || pp.ris == p.train?.type);
|
|
res.mode = foundProduct?.mode;
|
|
res.product = foundProduct?.id;
|
|
|
|
res.operator = profile.parseOperator(ctx, p.verkehrsmittel?.zugattribute || p.zugattribute);
|
|
return res;
|
|
};
|
|
|
|
export {
|
|
parseLine,
|
|
};
|