feat(ynab): add low account balance trigger
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import defineApp from '../../helpers/define-app.js';
|
||||
import addAuthHeader from './common/add-auth-header.js';
|
||||
import auth from './auth/index.js';
|
||||
import triggers from './triggers/index.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'You Need A Budget',
|
||||
@@ -13,4 +14,5 @@ export default defineApp({
|
||||
supportsConnections: true,
|
||||
beforeRequest: [addAuthHeader],
|
||||
auth,
|
||||
triggers,
|
||||
});
|
||||
|
@@ -0,0 +1,3 @@
|
||||
import lowAccountBalance from './low-account-balance/index.js';
|
||||
|
||||
export default [lowAccountBalance];
|
@@ -0,0 +1,39 @@
|
||||
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'Low account balance',
|
||||
key: 'lowAccountBalance',
|
||||
pollInterval: 15,
|
||||
description:
|
||||
'Triggers when the balance of a Checking or Savings account falls below a specified amount within a given month.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Balance Below Amount',
|
||||
key: 'balanceBelowAmount',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Account balance falls below this amount (e.g. "250.00")',
|
||||
variables: true,
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const balanceBelowAmount = $.step.parameters.balanceBelowAmount;
|
||||
const formattedBalance = balanceBelowAmount * 1000;
|
||||
|
||||
const response = await $.http.get('/budgets/last-used/accounts');
|
||||
|
||||
if (response.data?.data?.accounts?.length) {
|
||||
for (const account of response.data.data.accounts) {
|
||||
if (account.balance < formattedBalance) {
|
||||
$.pushTriggerItem({
|
||||
raw: account,
|
||||
meta: {
|
||||
internalId: account.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
@@ -480,6 +480,7 @@ export default defineConfig({
|
||||
collapsible: true,
|
||||
collapsed: true,
|
||||
items: [
|
||||
{ text: 'Triggers', link: '/apps/you-need-a-budget/triggers' },
|
||||
{ text: 'Connection', link: '/apps/you-need-a-budget/connection' },
|
||||
],
|
||||
},
|
||||
|
12
packages/docs/pages/apps/you-need-a-budget/triggers.md
Normal file
12
packages/docs/pages/apps/you-need-a-budget/triggers.md
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
favicon: /favicons/you-need-a-budget.svg
|
||||
items:
|
||||
- name: Low account balance
|
||||
desc: Triggers when the balance of a Checking or Savings account falls below a specified amount within a given month.
|
||||
---
|
||||
|
||||
<script setup>
|
||||
import CustomListing from '../../components/CustomListing.vue'
|
||||
</script>
|
||||
|
||||
<CustomListing />
|
@@ -50,5 +50,6 @@ The following integrations are currently supported by Automatisch.
|
||||
- [Webhooks](/apps/webhooks/triggers)
|
||||
- [WordPress](/apps/wordpress/triggers)
|
||||
- [Xero](/apps/xero/triggers)
|
||||
- [You Need A Budget](/apps/you-need-a-budget/triggers)
|
||||
- [Youtube](/apps/youtube/triggers)
|
||||
- [Zendesk](/apps/zendesk/actions)
|
||||
|
Reference in New Issue
Block a user