feat(pipedrive): add new deals trigger

This commit is contained in:
Rıdvan Akca
2023-09-21 18:51:18 +03:00
committed by Faruk AYDIN
parent f53909355f
commit 251885d4be
8 changed files with 101 additions and 0 deletions

View File

@@ -24,6 +24,7 @@ const refreshToken = async ($: IGlobalVariable) => {
await $.auth.set({
accessToken: response.data.access_token,
refreshToken: response.data.refresh_token,
tokenType: response.data.token_type,
expiresIn: response.data.expires_in,
});

View File

@@ -1,6 +1,7 @@
import defineApp from '../../helpers/define-app';
import addAuthHeader from './common/add-auth-header';
import auth from './auth';
import triggers from './triggers';
export default defineApp({
name: 'Pipedrive',
@@ -13,4 +14,5 @@ export default defineApp({
supportsConnections: true,
beforeRequest: [addAuthHeader],
auth,
triggers,
});

View File

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

View File

@@ -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 deals',
key: 'newDeals',
pollInterval: 15,
description: 'Triggers when a new deal 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/deals`,
{ params }
);
if (!data.data.length) {
return;
}
params.start = data.additional_data?.pagination?.next_start;
for (const deal of data.data) {
$.pushTriggerItem({
raw: deal,
meta: {
internalId: deal.id.toString(),
},
});
}
} while (params.start);
},
});

View File

@@ -215,6 +215,15 @@ export default defineConfig({
{ text: 'Connection', link: '/apps/openai/connection' },
],
},
{
text: 'Pipedrive',
collapsible: true,
collapsed: true,
items: [
{ text: 'Triggers', link: '/apps/pipedrive/triggers' },
{ text: 'Connection', link: '/apps/pipedrive/connection' },
],
},
{
text: 'PostgreSQL',
collapsible: true,

View File

@@ -0,0 +1,17 @@
# Pipedrive
:::info
This page explains the steps you need to follow to set up the Pipedrive
connection in Automatisch. If any of the steps are outdated, please let us know!
:::
1. Go to [Pipedrive developers page](https://developers.pipedrive.com/).
2. Sign up for a **Sandbox account** in order to create an app.
3. Click create an app button and then choose **Create private app** option.
4. Write any app name to be displayed in Automatisch.
5. Copy **OAuth Redirect URL** from Automatisch to **Callback URL** field, and click on the **Save** button.
6. Check all options in **OAuth & Access scopes** with full access.
7. Click on the **Save** button.
8. Copy the **Client ID** value to the `Client ID` field on Automatisch.
9. Copy the **Client Secret** value to the `Client Secret` field on Automatisch.
10. Start using Pipedrive integration with Automatisch!

View File

@@ -0,0 +1,12 @@
---
favicon: /favicons/pipedrive.svg
items:
- name: New deals
desc: Triggers when a new deal is created.
---
<script setup>
import CustomListing from '../../components/CustomListing.vue'
</script>
<CustomListing />

View File

@@ -0,0 +1 @@
<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32" viewBox="0 0 32 32" fill="#FFFFFF" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_503_588)" fill="#017737"><path d="M32 16C32 24.8366 24.8366 32 16 32C7.16344 32 0 24.8366 0 16C0 7.16344 7.16344 0 16 0C24.8366 0 32 7.16344 32 16Z" fill="#017737"></path><path d="M24.9842 13.4564C24.9842 17.8851 22.1247 20.914 18.036 20.914C16.0923 20.914 14.4903 20.1136 13.8906 19.1134L13.9189 20.142V26.4847H9.74512V10.0846C9.74512 9.85644 9.68836 9.79843 9.4304 9.79843H8V6.31321H11.4889C13.0896 6.31321 13.4907 7.68461 13.6042 8.28525C14.2337 7.22834 15.8911 6 18.2359 6C22.2679 5.99871 24.9842 8.99802 24.9842 13.4564ZM20.724 13.4847C20.724 11.1131 19.1801 9.48523 17.2351 9.48523C15.6344 9.48523 13.8325 10.5421 13.8325 13.5144C13.8325 15.4568 14.9186 17.4855 17.1783 17.4855C18.837 17.4842 20.724 16.2843 20.724 13.4847Z" fill="#FFFFFF"></path></g></svg>

After

Width:  |  Height:  |  Size: 929 B