feat(ynab): add new transactions trigger

This commit is contained in:
Rıdvan Akca
2024-01-18 18:08:42 +03:00
parent ab811daba7
commit 0f39007f92
3 changed files with 33 additions and 1 deletions

View File

@@ -1,5 +1,11 @@
import categoryOverspent from './category-overspent/index.js';
import goalCompleted from './goal-completed/index.js';
import lowAccountBalance from './low-account-balance/index.js';
import newTransactions from './new-transactions/index.js';
export default [categoryOverspent, goalCompleted, lowAccountBalance];
export default [
categoryOverspent,
goalCompleted,
lowAccountBalance,
newTransactions,
];

View File

@@ -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,
},
});
}
}
},
});

View File

@@ -7,6 +7,8 @@ items:
desc: Triggers when a goal is completed.
- name: Low account balance
desc: Triggers when the balance of a Checking or Savings account falls below a specified amount within a given month.
- name: New transactions
desc: Triggers when a new transaction is created.
---
<script setup>