node-ebics-client/lib/orders/H004/serializer.js

20 lines
640 B
JavaScript
Raw Normal View History

2018-06-15 06:33:41 +00:00
'use strict';
const orders = require('../orders');
const iniSerializer = require('./serializers/ini');
const downloadSerializer = require('./serializers/download');
const uploadSerializer = require('./serializers/upload');
module.exports = {
use(order) {
const { version, orderType } = order;
if (orders.version(version).isIni(orderType)) return iniSerializer.use(order);
if (orders.version(version).isDownload(orderType)) return downloadSerializer.use(order);
if (orders.version(version).isUpload(orderType)) return uploadSerializer.use(order);
throw Error('Error from orders/orders.js: Wrong order version/type.');
},
};