From ab2853956c8f45307ba8891e180a497fff1a8385 Mon Sep 17 00:00:00 2001 From: Vladislav Hristov Date: Tue, 3 Jul 2018 12:03:37 +0300 Subject: [PATCH] Return body error code --- lib/Client.js | 5 +++-- lib/orders/H004/response.js | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Client.js b/lib/Client.js index 36c1696..7fce499 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -94,8 +94,9 @@ module.exports = class Client { return { orderData: res.orderData(), orderId: res.orderId(), - returnCode: res.returnCode(), - reportText: res.reportText(), + returnAuthCode: res.returnCode(), + reportAuthText: res.reportText(), + returnBodyCode: res.returnCode('body'), }; } diff --git a/lib/orders/H004/response.js b/lib/orders/H004/response.js index c8051a6..e1900e1 100644 --- a/lib/orders/H004/response.js +++ b/lib/orders/H004/response.js @@ -69,9 +69,11 @@ module.exports = (xml, keys) => ({ return node.length ? node[0].textContent : ''; }, - returnCode() { + returnCode(where = 'header') { const select = xpath.useNamespaces({ xmlns: 'urn:org:ebics:H004' }); - const node = select('//xmlns:header/xmlns:mutable/xmlns:ReturnCode', this.doc); + 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 : ''; },