node-ebics-client/examples/bankLetter.js
Herman van Hazendonk d192e61d29 Add additional bank configuration items
For prettier generation of bank letters and other bits used in examples:

Expand the bank config to include:

* "bankFullName" used in the INI letter's which are sent to the bank.
* "bankShortName" used in the filename for the generated letters and in other places if needed.
* "languageCode" used for determining which template to use for the bank (currently "en" and "de" are supported).
* "storageLocation" can be used to specify a local or network path where to store downloaded files.

* In bankLetter.js: Use the current script folder as output for the bank's letter in HTML format instead of the user/os homedir folder.

Signed-off-by: Herman van Hazendonk <github.com@herrie.org>
2021-03-30 11:02:36 +02:00

26 lines
742 B
JavaScript
Executable File

#! /usr/bin/env node
'use strict';
const ebics = require('../index');
const path = require('path');
const fs = require('fs');
const os = require('os');
const config = require('./loadConfig')();
const client = require('./getClient')(config);
const bankName = client.bankName;
const template = fs.readFileSync("../templates/ini_"+client.languageCode+".hbs", { encoding: 'utf8'});
const bankLetterFile = path.join("./", "bankLetter_"+client.bankShortName+"_"+client.languageCode+".html");
const letter = new ebics.BankLetter({ client, bankName, template });
letter.serialize(bankLetterFile)
.then(() => {
console.log('Send your bank the letter (%s)', bankLetterFile);
})
.catch((err) => {
console.error(err);
process.exit(1);
});