Add returned codes errors and messages

This commit is contained in:
Vladislav Hristov
2018-07-03 12:48:00 +03:00
parent ab2853956c
commit 044bbba9e3
3 changed files with 384 additions and 14 deletions

View File

@@ -8,6 +8,7 @@ const Crypto = require('../../crypto/Crypto');
const { DOMParser, XMLSerializer } = require('xmldom');
const xpath = require('xpath');
const errors = require('./errors');
const DEFAULT_IV = Buffer.from(Array(16).fill(0, 0, 15));
@@ -69,21 +70,55 @@ module.exports = (xml, keys) => ({
return node.length ? node[0].textContent : '';
},
returnCode(where = 'header') {
businessCode() {
const select = xpath.useNamespaces({ xmlns: 'urn:org:ebics:H004' });
const node = select('//xmlns:body/xmlns:ReturnCode', this.doc)
return node.length ? node[0].textContent : '';
},
businessSymbol(code) {
return errors.business[code].symbol;
},
businessShortText(code) {
return errors.business[code].short_text;
},
businessMeaning(code) {
return errors.business[code].meaning;
},
technicalCode() {
const select = xpath.useNamespaces({ xmlns: 'urn:org:ebics:H004' });
const node = select('//xmlns:header/xmlns:mutable/xmlns:ReturnCode', this.doc);
return node.length ? node[0].textContent : '';
},
technicalSymbol() {
const select = xpath.useNamespaces({ xmlns: 'urn:org:ebics:H004' });
const node = select('//xmlns:header/xmlns:mutable/xmlns:ReportText', this.doc);
return node.length ? node[0].textContent : '';
},
technicalShortText(code) {
return errors.technical[code].short_text;
},
technicalMeaning(code) {
return errors.technical[code].meaning;
},
/* returnCode(where = 'header') {
const select = xpath.useNamespaces({ xmlns: 'urn:org:ebics:H004' });
const node = where === 'header'
? select('//xmlns:header/xmlns:mutable/xmlns:ReturnCode', this.doc)
: select('//xmlns:body/xmlns:ReturnCode', this.doc);
return node.length ? node[0].textContent : '';
},
reportText() {
const select = xpath.useNamespaces({ xmlns: 'urn:org:ebics:H004' });
const node = select('//xmlns:header/xmlns:mutable/xmlns:ReportText', this.doc);
return node.length ? node[0].textContent : '';
},
}, */
bankKeys() {
const orderData = this.orderData();