-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (32 loc) · 1.12 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const mbank = require('./mbank');
const citibank = require('./citibank');
const revolut = require('./revolut');
const {sendToYnab} = require('./ynab');
async function run() {
const account = process.argv[2];
const notificationTitle = process.argv[3];
const notificationMessage = process.argv[4];
const dryRun = process.argv[5];
console.log(`Account: ${account}`)
console.log(`Title: ${notificationTitle}`)
console.log(`Message: ${notificationMessage}`)
let transaction;
if (account === 'mbank') {
transaction = mbank.parse(notificationTitle, notificationMessage);
} else if (account === 'citibank') {
transaction = citibank.parse(notificationTitle, notificationMessage);
} else if (account === 'revolut') {
transaction = revolut.parse(notificationTitle, notificationMessage);
} else {
throw new Error(`Unsupported account: ${account}`);
}
if (transaction === null) {
console.log('Ignoring notification');
return;
}
await sendToYnab(account, transaction, dryRun === '1');
}
run().catch((e) => {
console.log(e);
throw e;
});