forked from NangoHQ/nango
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into getguru-api-support
- Loading branch information
Showing
9 changed files
with
519 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
title: 'Pipedrive API Integration Template' | ||
sidebarTitle: 'Pipedrive' | ||
--- | ||
|
||
## Get started with the Pipedrive template | ||
|
||
<Card title="How to use integration templates" | ||
href="/integration-templates/overview#how-to-use-integration-templates" | ||
icon="book-open"> | ||
Learn how to use integration templates in Nango | ||
</Card> | ||
|
||
<Card title="Get the Pipedrive template" | ||
href="https://github.com/NangoHQ/nango/tree/master/integration-templates/pipedrive" | ||
icon="github"> | ||
Get the latest version of the Pipedrive integration template from GitHub | ||
</Card> | ||
|
||
## Need help with the template? | ||
Please reach out on the [Slack community](https://nango.dev/slack), we are very active there and happy to help! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
integrations: | ||
pipedrive: | ||
pipedrive-activities: | ||
runs: every hour | ||
returns: | ||
- PipeDriveActivity | ||
description: | | ||
Fetches activities from pipedrive. | ||
Details: full sync, doesn't track deletes, metadata is not required. | ||
Scope(s): activities:read | ||
pipedrive-deals: | ||
runs: every hour | ||
returns: | ||
- PipeDriveDeal | ||
description: | | ||
Fetches deals from pipedrive. | ||
Details: full sync, doesn't track deletes, metadata is not required. | ||
Scope(s): deals:read | ||
pipedrive-organizations: | ||
runs: every hour | ||
returns: | ||
- PipeDriveOrganization | ||
description: | | ||
Fetches organizations from pipedrive. | ||
Details: full sync, doesn't track deletes, metadata is not required. | ||
Scope(s): contacts:read | ||
pipedrive-persons: | ||
runs: every half hour | ||
returns: | ||
- PipeDrivePerson | ||
description: | | ||
Fetches persons from pipedrive. | ||
Details: full sync, doesn't track deletes, metadata is not required. | ||
Scope(s): contacts:read | ||
models: | ||
PipeDriveActivity: | ||
id: integer | ||
done: boolean | ||
type: string | ||
duration: date | ||
subject: string | ||
company_id: integer | ||
user_id: integer | ||
conference_meeting_client: string | ||
conference_meeting_url: string | ||
conference_meeting_id: string | ||
due_date: date | ||
due_time: date | ||
busy_flag: boolean | ||
add_time: date | ||
marked_as_done_time: date | ||
public_description: string | ||
location: string | ||
org_id: integer | ||
person_id: integer | ||
deal_id: integer | ||
active_flag: boolean | ||
update_time: date | ||
update_user_id: integer | ||
source_timezone: string | ||
lead_id: string | ||
location_subpremise: string | ||
location_street_number: string | ||
location_route: string | ||
location_sublocality: string | ||
location_locality: string | ||
location_admin_area_level_1: string | ||
location_admin_area_level_2: string | ||
location_country: string | ||
location_postal_code: string | ||
location_formatted_address: string | ||
project_id: integer | ||
PipeDriveDeal: | ||
id: integer | ||
creator_user_id: integer | ||
user_id: integer | ||
person_id: integer | ||
org_id: integer | ||
stage_id: integer | ||
title: string | ||
value: integer | ||
currency: string | ||
add_time: date | ||
update_time: date | ||
status: string | ||
probability: string | ||
lost_reason: string | ||
visible_to: string | ||
close_time: date | ||
pipeline_id: integer | ||
won_time: date | ||
lost_time: date | ||
expected_close_date: date | ||
label: string | ||
PipeDriveOrganization: | ||
id: integer | ||
owner_id: integer | ||
name: string | ||
active_flag: boolean | ||
update_time: date | ||
delete_time: date | ||
add_time: date | ||
visible_to: string | ||
label: integer | ||
address: integer | ||
address_subpremise: string | ||
address_street_number: string | ||
address_route: string | ||
address_sublocality: string | ||
address_locality: string | ||
address_admin_area_level_1: string | ||
address_admin_area_level_2: string | ||
address_country: string | ||
address_postal_code: string | ||
address_formatted_address: string | ||
cc_email: string | ||
PipeDrivePerson: | ||
id: integer | ||
active_flag: boolean | ||
owner_id: integer | ||
org_id: integer | ||
name: string | ||
phone: [] | ||
email: [] | ||
update_time: date | ||
delete_time: date | ||
add_time: date | ||
visible_to: string | ||
picture_id: integer | ||
label: integer | ||
cc_email: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import type { PipeDriveActivity, NangoSync } from './models'; | ||
|
||
export default async function fetchData(nango: NangoSync) { | ||
let totalRecords = 0; | ||
|
||
try { | ||
const endpoint = '/v1/activities/collection'; | ||
const config = { | ||
...(nango.lastSyncDate ? { params: { since: nango.lastSyncDate?.toISOString() } } : {}), | ||
paginate: { | ||
type: 'cursor', | ||
cursor_path_in_response: 'additional_data.next_cursor', | ||
cursor_name_in_request: 'cursor', | ||
limit_name_in_request: 'limit', | ||
response_path: 'data', | ||
limit: 100 | ||
} | ||
}; | ||
for await (const activity of nango.paginate({ ...config, endpoint })) { | ||
const mappedActivity: PipeDriveActivity[] = activity.map(mapActivity) || []; | ||
// Save Activitiy | ||
const batchSize: number = mappedActivity.length; | ||
totalRecords += batchSize; | ||
await nango.log(`Saving batch of ${batchSize} activities (total activities: ${totalRecords})`); | ||
await nango.batchSave(mappedActivity, 'PipeDriveActivity'); | ||
} | ||
} catch (error: any) { | ||
throw new Error(`Error in fetchData: ${error.message}`); | ||
} | ||
} | ||
|
||
function mapActivity(activity: any): PipeDriveActivity { | ||
return { | ||
id: activity.id, | ||
done: activity.done, | ||
type: activity.type, | ||
duration: activity.duration, | ||
subject: activity.subject, | ||
company_id: activity.company_id, | ||
user_id: activity.user_id, | ||
conference_meeting_client: activity.conference_meeting_client, | ||
conference_meeting_url: activity.conference_meeting_url, | ||
conference_meeting_id: activity.conference_meeting_id, | ||
due_date: activity.due_date, | ||
due_time: activity.due_time, | ||
busy_flag: activity.busy_flag, | ||
add_time: activity.add_time, | ||
marked_as_done_time: activity.marked_as_done_time, | ||
public_description: activity.public_description, | ||
location: activity.location, | ||
org_id: activity.org_id, | ||
person_id: activity.person_id, | ||
deal_id: activity.deal_id, | ||
active_flag: activity.active_flag, | ||
update_time: activity.update_time, | ||
update_user_id: activity.update_user_id, | ||
source_timezone: activity.source_timezone, | ||
lead_id: activity.lead_id, | ||
location_subpremise: activity.location_subpremise, | ||
location_street_number: activity.location_street_number, | ||
location_route: activity.location_route, | ||
location_sublocality: activity.location_sublocality, | ||
location_locality: activity.location_locality, | ||
location_admin_area_level_1: activity.location_admin_area_level_1, | ||
location_admin_area_level_2: activity.location_admin_area_level_2, | ||
location_country: activity.location_country, | ||
location_postal_code: activity.location_postal_code, | ||
location_formatted_address: activity.location_formatted_address, | ||
project_id: activity.project_id | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import type { PipeDriveDeal, NangoSync } from './models'; | ||
|
||
export default async function fetchData(nango: NangoSync) { | ||
let totalRecords = 0; | ||
|
||
try { | ||
const endpoint = '/v1/deals/collection'; | ||
const config = { | ||
...(nango.lastSyncDate ? { params: { since: nango.lastSyncDate?.toISOString() } } : {}), | ||
paginate: { | ||
type: 'cursor', | ||
cursor_path_in_response: 'additional_data.next_cursor', | ||
cursor_name_in_request: 'cursor', | ||
limit_name_in_request: 'limit', | ||
response_path: 'data', | ||
limit: 100 | ||
} | ||
}; | ||
for await (const deal of nango.paginate({ ...config, endpoint })) { | ||
const mappedDeal: PipeDriveDeal[] = deal.map(mapDeal) || []; | ||
// Save Deal | ||
const batchSize: number = mappedDeal.length; | ||
totalRecords += batchSize; | ||
await nango.log(`Saving batch of ${batchSize} deals (total deals: ${totalRecords})`); | ||
await nango.batchSave(mappedDeal, 'PipeDriveDeal'); | ||
} | ||
} catch (error: any) { | ||
throw new Error(`Error in fetchData: ${error.message}`); | ||
} | ||
} | ||
|
||
function mapDeal(deal: any): PipeDriveDeal { | ||
return { | ||
id: deal.id, | ||
creator_user_id: deal.creator_user_id, | ||
user_id: deal.user_id, | ||
person_id: deal.person_id, | ||
org_id: deal.org_id, | ||
stage_id: deal.stage_id, | ||
title: deal.title, | ||
value: deal.value, | ||
currency: deal.currency, | ||
add_time: deal.add_time, | ||
update_time: deal.update_time, | ||
status: deal.status, | ||
probability: deal.probability, | ||
lost_reason: deal.lost_reason, | ||
visible_to: deal.visible_to, | ||
close_time: deal.close_time, | ||
pipeline_id: deal.pipeline_id, | ||
won_time: deal.won_time, | ||
lost_time: deal.lost_time, | ||
expected_close_date: deal.expected_close_date, | ||
label: deal.label | ||
}; | ||
} |
56 changes: 56 additions & 0 deletions
56
integration-templates/pipedrive/pipedrive-organizations.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import type { PipeDriveOrganization, NangoSync } from './models'; | ||
|
||
export default async function fetchData(nango: NangoSync) { | ||
let totalRecords = 0; | ||
|
||
try { | ||
const endpoint = '/v1/organizations/collection'; | ||
const config = { | ||
...(nango.lastSyncDate ? { params: { since: nango.lastSyncDate?.toISOString() } } : {}), | ||
paginate: { | ||
type: 'cursor', | ||
cursor_path_in_response: 'additional_data.next_cursor', | ||
cursor_name_in_request: 'cursor', | ||
limit_name_in_request: 'limit', | ||
response_path: 'data', | ||
limit: 100 | ||
} | ||
}; | ||
for await (const organization of nango.paginate({ ...config, endpoint })) { | ||
const mappedOrganization: PipeDriveOrganization[] = organization.map(mapOrganization) || []; | ||
// Save Organization | ||
const batchSize: number = mappedOrganization.length; | ||
totalRecords += batchSize; | ||
await nango.log(`Saving batch of ${batchSize} organizations (total organizations: ${totalRecords})`); | ||
await nango.batchSave(mappedOrganization, 'PipeDriveOrganization'); | ||
} | ||
} catch (error: any) { | ||
throw new Error(`Error in fetchData: ${error.message}`); | ||
} | ||
} | ||
|
||
function mapOrganization(organization: any): PipeDriveOrganization { | ||
return { | ||
id: organization.id, | ||
owner_id: organization.owner_id, | ||
name: organization.name, | ||
active_flag: organization.active_flag, | ||
update_time: organization.update_time, | ||
delete_time: organization.delete_time, | ||
add_time: organization.add_time, | ||
visible_to: organization.visible_to, | ||
label: organization.label, | ||
address: organization.address, | ||
address_subpremise: organization.address_subpremise, | ||
address_street_number: organization.address_street_number, | ||
address_route: organization.address_route, | ||
address_sublocality: organization.address_sublocality, | ||
address_locality: organization.address_locality, | ||
address_admin_area_level_1: organization.address_admin_area_level_1, | ||
address_admin_area_level_2: organization.address_admin_area_level_2, | ||
address_country: organization.address_country, | ||
address_postal_code: organization.address_postal_code, | ||
address_formatted_address: organization.address_formatted_address, | ||
cc_email: organization.cc_email | ||
}; | ||
} |
Oops, something went wrong.