From 140c2ccd692cf33872c587474e7c2544c7f88fd7 Mon Sep 17 00:00:00 2001 From: Vladislav Hristov Date: Thu, 31 May 2018 12:01:21 +0300 Subject: [PATCH] Update GenericOrder.js file Add toTransferXML method Add encryptedOrderData method Clean some lines --- lib/orders/GenericOrder.js | 45 ++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/lib/orders/GenericOrder.js b/lib/orders/GenericOrder.js index 0f07a44..b108102 100644 --- a/lib/orders/GenericOrder.js +++ b/lib/orders/GenericOrder.js @@ -1,9 +1,9 @@ 'use strict'; // const randHex = require('../../lib/utils').randHex; -const crypto = require("crypto"); +const crypto = require("crypto"); const js2xmlparser = require('js2xmlparser'); -const consts = require('../consts'); +const consts = require('../consts'); module.exports = class GenericOrder { constructor(client) { @@ -24,8 +24,6 @@ module.exports = class GenericOrder { doubleQuotes: true, indent: '', newline: '', - // indent: "\t", - // newline: "\r\n", pretty: true } }; @@ -137,6 +135,45 @@ module.exports = class GenericOrder { return js2xmlparser.parse(this.root(), xmlObj, this.xmlOptions); } + toTransferXML(){ + const xmlObj = { + "@": { + "xmlns:ds": "http://www.w3.org/2000/09/xmldsig#", + xmlns: "urn:org:ebics:H004", + Version: "H004", + Revision: "1" + }, + + header: { + "@": { authenticate: true }, + static: { + HostID: this.hostId, + TransactionID: this.transactionId + }, + mutable: { + TransactionPhase: 'Transfer', + SegmentNumber: { + "@": { lastSegment: true }, + "#": 1 + } + } + }, + + AuthSignature: this.authSignature(), + + body: { + DataTransfer: { + OrderData: this.encryptedOrderData() + } + } + }; + + return js2xmlparser.parse(this.root(), xmlObj, this.xmlOptions); + } + + encryptedOrderData() { + } + toXML() { return js2xmlparser.parse(this.root(), this._schema, this.xmlOptions); }