Merge pull request #1549 from automatisch/AUT-586
feat(ynab): add new transactions trigger
This commit is contained in:
@@ -10,7 +10,7 @@ export default defineTrigger({
|
|||||||
async run($) {
|
async run($) {
|
||||||
const categoryWithNegativeBalance = [];
|
const categoryWithNegativeBalance = [];
|
||||||
|
|
||||||
const response = await $.http.get('/budgets/last-used/categories');
|
const response = await $.http.get('/budgets/default/categories');
|
||||||
const categoryGroups = response.data.data.category_groups;
|
const categoryGroups = response.data.data.category_groups;
|
||||||
|
|
||||||
categoryGroups.forEach((group) => {
|
categoryGroups.forEach((group) => {
|
||||||
|
@@ -9,7 +9,7 @@ export default defineTrigger({
|
|||||||
async run($) {
|
async run($) {
|
||||||
const goalCompletedCategories = [];
|
const goalCompletedCategories = [];
|
||||||
|
|
||||||
const response = await $.http.get('/budgets/last-used/categories');
|
const response = await $.http.get('/budgets/default/categories');
|
||||||
const categoryGroups = response.data.data.category_groups;
|
const categoryGroups = response.data.data.category_groups;
|
||||||
|
|
||||||
categoryGroups.forEach((group) => {
|
categoryGroups.forEach((group) => {
|
||||||
|
@@ -1,5 +1,11 @@
|
|||||||
import categoryOverspent from './category-overspent/index.js';
|
import categoryOverspent from './category-overspent/index.js';
|
||||||
import goalCompleted from './goal-completed/index.js';
|
import goalCompleted from './goal-completed/index.js';
|
||||||
import lowAccountBalance from './low-account-balance/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,
|
||||||
|
];
|
||||||
|
@@ -21,7 +21,7 @@ export default defineTrigger({
|
|||||||
const balanceBelowAmount = $.step.parameters.balanceBelowAmount;
|
const balanceBelowAmount = $.step.parameters.balanceBelowAmount;
|
||||||
const formattedBalance = balanceBelowAmount * 1000;
|
const formattedBalance = balanceBelowAmount * 1000;
|
||||||
|
|
||||||
const response = await $.http.get('/budgets/last-used/accounts');
|
const response = await $.http.get('/budgets/default/accounts');
|
||||||
|
|
||||||
if (response.data?.data?.accounts?.length) {
|
if (response.data?.data?.accounts?.length) {
|
||||||
for (const account of response.data.data.accounts) {
|
for (const account of response.data.data.accounts) {
|
||||||
|
@@ -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/default/transactions');
|
||||||
|
const transactions = response.data.data?.transactions;
|
||||||
|
|
||||||
|
if (transactions?.length) {
|
||||||
|
for (const transaction of transactions) {
|
||||||
|
$.pushTriggerItem({
|
||||||
|
raw: transaction,
|
||||||
|
meta: {
|
||||||
|
internalId: transaction.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
@@ -11,8 +11,9 @@ connection in Automatisch. If any of the steps are outdated, please let us know!
|
|||||||
4. Click on the **New Application** under the **OAuth Applications** section.
|
4. Click on the **New Application** under the **OAuth Applications** section.
|
||||||
5. Fill the new application form.
|
5. Fill the new application form.
|
||||||
6. Copy **OAuth Redirect URL** from Automatisch and paste it in **Redirect URI(s)** section.
|
6. Copy **OAuth Redirect URL** from Automatisch and paste it in **Redirect URI(s)** section.
|
||||||
7. Click on the **Save Application** button.
|
7. Enable the option **Enable default budget selection when users authorize this application**.
|
||||||
8. Copy the **Client ID** value to the **Client ID** field on Automatisch.
|
8. Click on the **Save Application** button.
|
||||||
9. Copy the **Client Secret** value to the **Client Secret** field on Automatisch.
|
9. Copy the **Client ID** value to the **Client ID** field on Automatisch.
|
||||||
10. Fill the **Screen Name** field on Automatisch.
|
10. Copy the **Client Secret** value to the **Client Secret** field on Automatisch.
|
||||||
11. Congrats! Start using your new You Need A Budget connection within the flows.
|
11. Fill the **Screen Name** field on Automatisch.
|
||||||
|
12. Congrats! Start using your new You Need A Budget connection within the flows.
|
||||||
|
@@ -7,6 +7,8 @@ items:
|
|||||||
desc: Triggers when a goal is completed.
|
desc: Triggers when a goal is completed.
|
||||||
- name: Low account balance
|
- name: Low account balance
|
||||||
desc: Triggers when the balance of a Checking or Savings account falls below a specified amount within a given month.
|
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>
|
<script setup>
|
||||||
|
Reference in New Issue
Block a user