Compare commits

...

1 Commits

Author SHA1 Message Date
Rıdvan Akca
2846dd2bdd feat(trello): add new cards trigger 2023-10-26 15:13:10 +03:00
9 changed files with 213 additions and 1 deletions

View File

@@ -0,0 +1,4 @@
import listBoardLists from './list-board-lists';
import listBoards from './list-boards';
export default [listBoardLists, listBoards];

View File

@@ -0,0 +1,33 @@
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
export default {
name: 'List board lists',
key: 'listBoardLists',
async run($: IGlobalVariable) {
const boards: {
data: IJSONObject[];
} = {
data: [],
};
const boardId = $.step.parameters.boardId;
if (!boardId) {
return { data: [] };
}
const { data } = await $.http.get(`/1/boards/${boardId}/lists`);
if (data) {
for (const list of data) {
boards.data.push({
value: list.id,
name: list.name,
});
}
}
return boards;
},
};

View File

@@ -0,0 +1,29 @@
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
export default {
name: 'List boards',
key: 'listBoards',
async run($: IGlobalVariable) {
const boards: {
data: IJSONObject[];
} = {
data: [],
};
const { data } = await $.http.get(`/1/members/me/boards`);
if (data) {
for (const board of data) {
boards.data.push({
value: board.id,
name: board.name,
});
}
} else {
return { data: [] };
}
return boards;
},
};

View File

@@ -1,6 +1,8 @@
import defineApp from '../../helpers/define-app';
import addAuthHeader from './common/add-auth-header';
import auth from './auth';
import triggers from './triggers';
import dynamicData from './dynamic-data';
export default defineApp({
name: 'Trello',
@@ -13,4 +15,6 @@ export default defineApp({
primaryColor: '0079bf',
beforeRequest: [addAuthHeader],
auth,
triggers,
dynamicData,
});

View File

@@ -0,0 +1,3 @@
import newCards from './new-cards';
export default [newCards];

View File

@@ -0,0 +1,123 @@
import defineTrigger from '../../../../helpers/define-trigger';
export default defineTrigger({
name: 'New cards',
key: 'newCards',
pollInterval: 15,
description: 'Triggers upon the addition of a new card.',
arguments: [
{
label: 'Board',
key: 'boardId',
type: 'dropdown' as const,
required: false,
description:
'Selecting a board initiates the trigger for newly added cards on that board.',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listBoards',
},
],
},
},
{
label: 'List',
key: 'listId',
type: 'dropdown' as const,
required: false,
dependsOn: ['parameters.boardId'],
description: 'Requires to opt for a board.',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listBoardLists',
},
{
name: 'parameters.boardId',
value: '{parameters.boardId}',
},
],
},
},
{
label: 'Filter',
key: 'filter',
type: 'dropdown' as const,
required: false,
description: 'Default is open.',
variables: true,
options: [
{
label: 'open',
value: 'open',
},
{
label: 'closed',
value: 'closed',
},
{
label: 'all',
value: 'all',
},
],
},
],
async run($) {
const { boardId, listId, filter } = $.step.parameters;
if (boardId && !listId) {
const cardFilter = filter || 'open';
const { data } = await $.http.get(
`/1/boards/${boardId}/cards/${cardFilter}`
);
if (data) {
for (const card of data) {
$.pushTriggerItem({
raw: card,
meta: {
internalId: card.id,
},
});
}
}
} else if (listId) {
const { data } = await $.http.get(`1/lists/${listId}/cards`);
if (data) {
for (const card of data) {
$.pushTriggerItem({
raw: card,
meta: {
internalId: card.id,
},
});
}
}
} else {
const { data } = await $.http.get(`/1/members/me/cards`);
if (data) {
for (const card of data) {
$.pushTriggerItem({
raw: card,
meta: {
internalId: card.id,
},
});
}
}
}
},
});

View File

@@ -377,7 +377,10 @@ export default defineConfig({
text: 'Trello',
collapsible: true,
collapsed: true,
items: [{ text: 'Connection', link: '/apps/trello/connection' }],
items: [
{ text: 'Triggers', link: '/apps/trello/triggers' },
{ text: 'Connection', link: '/apps/trello/connection' },
],
},
{
text: 'Twilio',

View File

@@ -0,0 +1,12 @@
---
favicon: /favicons/trello.svg
items:
- name: New cards
desc: Triggers upon the addition of a new card.
---
<script setup>
import CustomListing from '../../components/CustomListing.vue'
</script>
<CustomListing />

View File

@@ -39,6 +39,7 @@ The following integrations are currently supported by Automatisch.
- [Stripe](/apps/stripe/triggers)
- [Telegram](/apps/telegram-bot/actions)
- [Todoist](/apps/todoist/triggers)
- [Trello](/apps/trello/triggers)
- [Twilio](/apps/twilio/triggers)
- [Twitter](/apps/twitter/triggers)
- [Typeform](/apps/typeform/triggers)