feat(ynab): add new transactions trigger
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'New transactions',
|
||||
key: 'newTransactions',
|
||||
pollInterval: 15,
|
||||
description: 'Triggers when a new transaction is created.',
|
||||
|
||||
async run($) {
|
||||
const response = await $.http.get('/budgets/last-used/transactions');
|
||||
const transactions = response.data.data?.transactions;
|
||||
|
||||
if (transactions?.length) {
|
||||
for (const transaction of transactions) {
|
||||
$.pushTriggerItem({
|
||||
raw: transaction,
|
||||
meta: {
|
||||
internalId: transaction.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user