feat(ynab): add new transactions trigger
This commit is contained in:
@@ -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,
|
||||
];
|
||||
|
@@ -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,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
@@ -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>
|
||||
|
Reference in New Issue
Block a user