diff --git a/p/cmta/index.js b/p/cmta/index.js index 7318a9ee..f277fde3 100644 --- a/p/cmta/index.js +++ b/p/cmta/index.js @@ -1,11 +1,6 @@ 'use strict' -const createParseBitmask = require('../../parse/products-bitmask') -const createFormatBitmask = require('../../format/products-bitmask') - -const modes = require('./modes') - -const formatBitmask = createFormatBitmask(modes) +const products = require('./products') const transformReqBody = (body) => { body.client = {type: 'WEB', id: 'CMTA', name: 'webapp', l: ''} @@ -16,29 +11,14 @@ const transformReqBody = (body) => { return body } -const defaultProducts = { - bus: true, - rapid: true, - rail: true -} - -const formatProducts = (products) => { - products = Object.assign(Object.create(null), defaultProducts, products) - return { - type: 'PROD', - mode: 'INC', - value: formatBitmask(products) + '' - } -} - const cmtaProfile = { endpoint: 'https://capmetro.hafas.de/bin/mgate.exe', locale: 'en-US', timezone: 'America/Chicago', - products: modes.allProducts, transformReqBody, - formatProducts, - parseProducts: createParseBitmask(modes.allProducts, defaultProducts), + + products, + journeyLeg: true, radar: true } diff --git a/p/cmta/modes.js b/p/cmta/modes.js deleted file mode 100644 index d66647f0..00000000 --- a/p/cmta/modes.js +++ /dev/null @@ -1,56 +0,0 @@ -'use strict' - -const m = { - bus: { - category: 1, - bitmask: 32, - name: 'Bus', - mode: 'bus', - short: 'B', - product: 'bus' - }, - rapid: { - category: 2, - bitmask: 4096, - name: 'MetroRapid', - mode: 'bus', - short: 'R', - product: 'rapid' - }, - rail: { - category: 3, - bitmask: 8, - name: 'MetroRail', - mode: 'train', - short: 'M', - product: 'rail' - }, - unknown: { - category: null, - bitmask: 0, - name: 'unknown', - mode: null, - short: '?', - product: 'unknown' - } -} - -m.bitmasks = [] -m.bitmasks[8] = m.rail -m.bitmasks[32] = m.bus -m.bitmasks[4096] = m.rapid - -m.categories = [ - m.bus, - m.rapid, - m.rail, - m.unknown -] - -m.allProducts = [ - m.bus, - m.rapid, - m.rail -] - -module.exports = m diff --git a/p/cmta/products.js b/p/cmta/products.js new file mode 100644 index 00000000..37cea896 --- /dev/null +++ b/p/cmta/products.js @@ -0,0 +1,28 @@ +'use strict' + +module.exports = [ + { + id: 'bus', + mode: 'bus', + bitmasks: [32], + name: 'MetroBus', + short: 'B', + default: true + }, + { + id: 'rapid', + mode: 'bus', + bitmasks: [4096], + name: 'MetroRapid', + short: 'R', + default: true + }, + { + id: 'rail', + mode: 'train', + bitmasks: [8], + name: 'MetroRail', + short: 'M', + default: true + } +]