mirror of
https://github.com/node-ebics/node-ebics-client.git
synced 2024-11-21 21:52:07 +00:00
code cleaning
This commit is contained in:
parent
945499290a
commit
8e9e0df276
@ -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: {} },
|
||||
});
|
||||
}
|
||||
};
|
@ -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;
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user