const info = () => req(endpoints.get('info')) .then(res => res.body.toString()) .then(xml2Json) .then(json => { const flatJson = {}; json = json['device-info']; Object.entries(json).forEach(([key, value]) => { flatJson[key] = value[0]; }); return flatJson; })
const apps = () => req(endpoints.get('apps')) .then(res => res.body.toString()) .then(xml2Json) .then(({ apps }) => { // Tidy up json data return apps.app.map(a => { return { id: a.$.id, name: a._, type: a.$.type, version: a.$.version }; }); })
const active = () => req(endpoints.get('activeApp')) .then(res => res.body.toString()) .then(xml2Json) .then(json => { // Tidy up json data return json['active-app'].app.map(app => { // If no app is currently active, a single field is returned without // any properties if (!app.$ || !app.$.id) { return null; } return { id: app.$.id, name: app._, type: app.$.type, version: app.$.version }; }).filter(app => app !== null); })