feat(pipedrive): add new activities trigger
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import newActivities from './new-activities';
|
||||
import newDeals from './new-deals';
|
||||
import newNotes from './new-notes';
|
||||
|
||||
export default [newDeals, newNotes];
|
||||
export default [newActivities, newDeals, newNotes];
|
||||
|
@@ -0,0 +1,56 @@
|
||||
import defineTrigger from '../../../../helpers/define-trigger';
|
||||
|
||||
type Payload = {
|
||||
start: number;
|
||||
limit: number;
|
||||
sort: string;
|
||||
};
|
||||
|
||||
type ResponseData = {
|
||||
data: {
|
||||
id: number;
|
||||
}[];
|
||||
additional_data: {
|
||||
pagination: {
|
||||
next_start: number;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'New activities',
|
||||
key: 'newActivities',
|
||||
pollInterval: 15,
|
||||
description: 'Triggers when a new activity is created.',
|
||||
arguments: [],
|
||||
|
||||
async run($) {
|
||||
const params: Payload = {
|
||||
start: 0,
|
||||
limit: 100,
|
||||
sort: 'add_time DESC',
|
||||
};
|
||||
|
||||
do {
|
||||
const { data } = await $.http.get<ResponseData>(
|
||||
`${$.auth.data.apiDomain}/api/v1/activities`,
|
||||
{ params }
|
||||
);
|
||||
|
||||
if (!data?.data?.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
params.start = data.additional_data?.pagination?.next_start;
|
||||
|
||||
for (const activity of data.data) {
|
||||
$.pushTriggerItem({
|
||||
raw: activity,
|
||||
meta: {
|
||||
internalId: activity.id.toString(),
|
||||
},
|
||||
});
|
||||
}
|
||||
} while (params.start);
|
||||
},
|
||||
});
|
@@ -1,6 +1,8 @@
|
||||
---
|
||||
favicon: /favicons/pipedrive.svg
|
||||
items:
|
||||
- name: New activities
|
||||
desc: Triggers when a new activity is created.
|
||||
- name: New deals
|
||||
desc: Triggers when a new deal is created.
|
||||
- name: New notes
|
||||
|
Reference in New Issue
Block a user