2018-06-11 08:38:32 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const crypto = require('crypto');
|
|
|
|
|
2018-06-15 06:33:41 +00:00
|
|
|
const constants = require('./consts');
|
2018-06-11 08:38:32 +00:00
|
|
|
|
|
|
|
module.exports = class OrderBuilder {
|
|
|
|
constructor() {
|
2018-06-15 06:33:41 +00:00
|
|
|
this._productString = constants.productString;
|
2018-06-11 08:38:32 +00:00
|
|
|
this._transactionKey = crypto.randomBytes(16);
|
|
|
|
}
|
|
|
|
|
|
|
|
details(data) {
|
|
|
|
this._data = data;
|
|
|
|
this._data.transactionId = null;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2018-06-11 12:25:07 +00:00
|
|
|
static h004() {
|
2018-06-11 08:38:32 +00:00
|
|
|
const builder = new OrderBuilder();
|
|
|
|
|
2018-06-11 12:25:07 +00:00
|
|
|
builder._version = 'H004';
|
2018-06-11 08:38:32 +00:00
|
|
|
|
|
|
|
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(); }
|
2018-06-11 12:25:07 +00:00
|
|
|
get version() { return this._version; }
|
2018-06-15 06:33:41 +00:00
|
|
|
get productString() { return this._productString; }
|
|
|
|
get orderType() { return this.orderDetails.OrderType; }
|
2018-06-11 08:38:32 +00:00
|
|
|
|
|
|
|
set transactionId(tid) {
|
|
|
|
this._data.transactionId = tid === '' ? null : tid;
|
|
|
|
}
|
|
|
|
|
|
|
|
hasTransactionId() {
|
|
|
|
return this.transactionId !== null;
|
|
|
|
}
|
|
|
|
};
|