UNPKG

node-suitetalk

Version:
55 lines (41 loc) 1.15 kB
"use strict"; const BaseObject = require("../../../baseObject"); class List extends BaseObject { constructor() { super(); this.replaceAll = false; this.list = []; this._listName = undefined; } _getSoapType() { return `${this._type}:${this._listName}`; } _getAttributes() { return { "replaceAll": this.replaceAll, "xsi:type": `${this._type}:${this._name}`, }; } getNode() { const attributes = this._getAttributes(); const type = this._getSoapType(); if (!type) { throw new Error(`Invalid SOAP type ${type}`); } const node = {}; node[type] = []; if (attributes) { node[type]["$attributes"] = attributes; } let xml = ""; this.list.forEach((el) => { if (!el._type) { el._type = this._type; } node[type].push(el.getNode()); }); node[type].$xml = xml; return node; } } module.exports = List;