afip.ts-fork-ssl-fix
Version:
Afip typescript SDK
36 lines • 1.49 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Parser = void 0;
const xml2js_1 = require("xml2js");
/**
* Parser based on node-xml2js package (https://github.com/Leonidas-from-XIV/node-xml2js).
*/
class Parser {
static xmlToJson(xml) {
return __awaiter(this, void 0, void 0, function* () {
const parser = new xml2js_1.Parser(Parser.options);
return parser.parseStringPromise(xml);
});
}
static jsonToXml(obj) {
return new xml2js_1.Builder().buildObject(obj);
}
}
exports.Parser = Parser;
Parser.options = {
normalizeTags: true,
normalize: true,
explicitArray: false,
attrkey: "header",
tagNameProcessors: [(key) => key.replace("soapenv:", "")],
};
//# sourceMappingURL=parser.js.map