From 8e9e0df276f87ca1cf0ae822a3ff5d3e86694de4 Mon Sep 17 00:00:00 2001 From: Vladislav Hristov Date: Wed, 20 Jun 2018 12:22:16 +0300 Subject: [PATCH] code cleaning --- lib/ISO20022OrderBuilder.js | 101 ------------------------------------ lib/OrderBuilder.js | 52 ------------------- 2 files changed, 153 deletions(-) delete mode 100644 lib/ISO20022OrderBuilder.js delete mode 100644 lib/OrderBuilder.js diff --git a/lib/ISO20022OrderBuilder.js b/lib/ISO20022OrderBuilder.js deleted file mode 100644 index 02e637f..0000000 --- a/lib/ISO20022OrderBuilder.js +++ /dev/null @@ -1,101 +0,0 @@ -'use strict'; - -const OrderBuilder = require('./OrderBuilder'); - -module.exports = class ISO20022OrderBuilder extends OrderBuilder { - get document() { return this._document; } - get ebicsData() { return this._ebicsData; } - - use(dataToUse) { - if (Object.prototype.hasOwnProperty.call(dataToUse, 'ebicsData')) this._ebicsData = dataToUse.ebicsData; - if (Object.prototype.hasOwnProperty.call(dataToUse, 'document')) this._document = dataToUse.document; - - return this; - } - - static h004() { - const builder = new ISO20022OrderBuilder(); - - builder._version = 'H004'; - - return builder; - } - - INI() { - return this.details({ - ebicsData: this.ebicsData, - orderDetails: { OrderType: 'INI', OrderAttribute: 'DZNNN' }, - }); - } - - HIA() { - return this.details({ - ebicsData: this.ebicsData, - orderDetails: { OrderType: 'HIA', OrderAttribute: 'DZNNN' }, - }); - } - - HPB() { - return this.details({ - ebicsData: this.ebicsData, - orderDetails: { OrderType: 'HPB', OrderAttribute: 'DZHNN' }, - }); - } - - HKD() { - return this.details({ - ebicsData: this.ebicsData, - orderDetails: { OrderType: 'HKD', OrderAttribute: 'DZHNN', StandardOrderParams: {} }, - }); - } - - HPD() { - return this.details({ - ebicsData: this.ebicsData, - orderDetails: { OrderType: 'HPD', OrderAttribute: 'DZHNN', StandardOrderParams: {} }, - }); - } - - HTD() { - return this.details({ - ebicsData: this.ebicsData, - orderDetails: { OrderType: 'HTD', OrderAttribute: 'DZHNN', StandardOrderParams: {} }, - }); - } - - HAA() { - return this.details({ - ebicsData: this.ebicsData, - orderDetails: { OrderType: 'HAA', OrderAttribute: 'DZHNN', StandardOrderParams: {} }, - }); - } - - HAC(start = null, end = null) { - const params = start && end - ? { DateRange: { Start: start, End: end } } - : {}; - - return this.details({ - ebicsData: this.ebicsData, - orderDetails: { OrderType: 'HAC', OrderAttribute: 'DZHNN', StandardOrderParams: params }, - }); - } - - PTK(start = null, end = null) { - const params = start && end - ? { DateRange: { Start: start, End: end } } - : {}; - - return this.details({ - ebicsData: this.ebicsData, - orderDetails: { OrderType: 'PTK', OrderAttribute: 'DZHNN', StandardOrderParams: params }, - }); - } - - Z52() { - return this.details({ - ebicsData: this.ebicsData, - orderDetails: { OrderType: 'Z52', OrderAttribute: 'DZHNN', StandardOrderParams: {} }, - }); - } -}; diff --git a/lib/OrderBuilder.js b/lib/OrderBuilder.js deleted file mode 100644 index 4b0bc29..0000000 --- a/lib/OrderBuilder.js +++ /dev/null @@ -1,52 +0,0 @@ -'use strict'; - -const crypto = require('crypto'); - -const constants = require('./consts'); - -module.exports = class OrderBuilder { - constructor() { - this._productString = constants.productString; - this._transactionKey = crypto.randomBytes(16); - } - - details(data) { - this._data = data; - this._data.transactionId = null; - - return this; - } - - static h004() { - const builder = new OrderBuilder(); - - builder._version = 'H004'; - - return builder; - } - - /** - * Getters - */ - get data() { return this._data; } - get orderDetails() { return this._data.orderDetails; } - get transactionId() { return this._data.transactionId; } - get document() { return this._data.document; } - get transactionKey() { return this._transactionKey; } - get ebicsData() { return this._data.ebicsData; } - get hostId() { return this._data.ebicsData.hostId; } - get partnerId() { return this._data.ebicsData.partnerId; } - get userId() { return this._data.ebicsData.userId; } - get keys() { return this._data.ebicsData.keysManager.keys(); } - get version() { return this._version; } - get productString() { return this._productString; } - get orderType() { return this.orderDetails.OrderType; } - - set transactionId(tid) { - this._data.transactionId = tid === '' ? null : tid; - } - - hasTransactionId() { - return this.transactionId !== null; - } -};