Skip to content

Commit 12a5f75

Browse files
committed
add-lead
1 parent aa6fd81 commit 12a5f75

File tree

14 files changed

+145
-12
lines changed

14 files changed

+145
-12
lines changed

components/pipedrive/actions/add-activity/add-activity.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
key: "pipedrive-add-activity",
88
name: "Add Activity",
99
description: "Adds a new activity. Includes `more_activities_scheduled_in_context` property in response's `additional_data` which indicates whether there are more undone activities scheduled with the same deal, person or organization (depending on the supplied data). See the Pipedrive API docs for Activities [here](https://developers.pipedrive.com/docs/api/v1/#!/Activities). For info on [adding an activity in Pipedrive](https://developers.pipedrive.com/docs/api/v1/Activities#addActivity)",
10-
version: "0.1.7",
10+
version: "0.1.8",
1111
type: "action",
1212
props: {
1313
pipedriveApp,

components/pipedrive/actions/add-deal/add-deal.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "pipedrive-add-deal",
66
name: "Add Deal",
77
description: "Adds a new deal. See the Pipedrive API docs for Deals [here](https://developers.pipedrive.com/docs/api/v1/Deals#addDeal)",
8-
version: "0.1.7",
8+
version: "0.1.8",
99
type: "action",
1010
props: {
1111
pipedriveApp,
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import pipedrive from "../../pipedrive.app.mjs";
2+
import { ConfigurationError } from "@pipedream/platform";
3+
import { parseObject } from "../../common/utils.mjs";
4+
5+
export default {
6+
key: "pipedrive-add-lead",
7+
name: "Add Lead",
8+
description: "Create a new lead in Pipedrive. [See the documentation](https://developers.pipedrive.com/docs/api/v1/Leads#addLead)",
9+
version: "0.0.1",
10+
type: "action",
11+
props: {
12+
pipedrive,
13+
title: {
14+
type: "string",
15+
label: "Title",
16+
description: "The name of the lead",
17+
},
18+
personId: {
19+
propDefinition: [
20+
pipedrive,
21+
"personId",
22+
],
23+
description: "The ID of a person which this lead will be linked to. If the person does not exist yet, it needs to be created first. This property is required unless organization_id is specified.",
24+
},
25+
organizationId: {
26+
propDefinition: [
27+
pipedrive,
28+
"organizationId",
29+
],
30+
description: "The ID of an organization which this lead will be linked to. If the organization does not exist yet, it needs to be created first. This property is required unless person_id is specified.",
31+
},
32+
ownerId: {
33+
propDefinition: [
34+
pipedrive,
35+
"userId",
36+
],
37+
description: "The ID of the user which will be the owner of the created lead. If not provided, the user making the request will be used.",
38+
},
39+
leadLabelIds: {
40+
propDefinition: [
41+
pipedrive,
42+
"leadLabelIds",
43+
],
44+
},
45+
value: {
46+
type: "object",
47+
label: "Value",
48+
description: "Potential value of the lead, e.g. `{ \"amount\": 200, \"currency\": \"EUR\" }`",
49+
optional: true,
50+
},
51+
expectedCloseDate: {
52+
type: "string",
53+
label: "Expected Close Date",
54+
description: "The date of when the deal which will be created from the lead is expected to be closed. In ISO 8601 format: YYYY-MM-DD.",
55+
optional: true,
56+
},
57+
visibleTo: {
58+
type: "string",
59+
label: "Visible To",
60+
description: "The visibility of the lead. If omitted, the visibility will be set to the default visibility setting of this item type for the authorized user. Read more about visibility groups [here](https://support.pipedrive.com/en/article/visibility-groups).",
61+
options: [
62+
{
63+
label: "Essential / Advanced plan - Owner & followers, Professional / Enterprise plan - Owner only",
64+
value: "1",
65+
},
66+
{
67+
label: "Essential / Advanced plan - Entire company, Professional / Enterprise plan - Owner's visibility group",
68+
value: "3",
69+
},
70+
{
71+
label: "Professional / Enterprise plan - Owner's visibility group and sub-groups",
72+
value: "5",
73+
},
74+
{
75+
label: "Professional / Enterprise plan - Entire company",
76+
value: "7",
77+
},
78+
],
79+
optional: true,
80+
},
81+
wasSeen: {
82+
type: "boolean",
83+
label: "Was Seen",
84+
description: "A flag indicating whether the lead was seen by someone in the Pipedrive UI",
85+
optional: true,
86+
},
87+
},
88+
async run({ $ }) {
89+
if (!this.organizationId && !this.personId) {
90+
throw new ConfigurationError("Either organizationId or personId is required");
91+
}
92+
93+
const response = await this.pipedrive.addLead({
94+
title: this.title,
95+
person_id: this.personId,
96+
organization_id: this.organizationId,
97+
owner_id: this.ownerId,
98+
label_ids: this.leadLabelIds,
99+
value: parseObject(this.value),
100+
expected_close_date: this.expectedCloseDate,
101+
visible_to: this.visibleTo,
102+
was_seen: this.wasSeen,
103+
});
104+
$.export("$summary", `Successfully created lead: ${response.data?.title || response.data?.id}`);
105+
return response;
106+
},
107+
};

components/pipedrive/actions/add-note/add-note.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "pipedrive-add-note",
66
name: "Add Note",
77
description: "Adds a new note. For info on [adding an note in Pipedrive](https://developers.pipedrive.com/docs/api/v1/Notes#addNote)",
8-
version: "0.0.5",
8+
version: "0.0.6",
99
type: "action",
1010
props: {
1111
pipedriveApp,

components/pipedrive/actions/add-organization/add-organization.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "pipedrive-add-organization",
66
name: "Add Organization",
77
description: "Adds a new organization. See the Pipedrive API docs for Organizations [here](https://developers.pipedrive.com/docs/api/v1/Organizations#addOrganization)",
8-
version: "0.1.7",
8+
version: "0.1.8",
99
type: "action",
1010
props: {
1111
pipedriveApp,

components/pipedrive/actions/add-person/add-person.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "pipedrive-add-person",
77
name: "Add Person",
88
description: "Adds a new person. See the Pipedrive API docs for People [here](https://developers.pipedrive.com/docs/api/v1/Persons#addPerson)",
9-
version: "0.1.7",
9+
version: "0.1.8",
1010
type: "action",
1111
props: {
1212
pipedriveApp,

components/pipedrive/actions/search-persons/search-persons.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
key: "pipedrive-search-persons",
88
name: "Search persons",
99
description: "Searches all Persons by `name`, `email`, `phone`, `notes` and/or custom fields. This endpoint is a wrapper of `/v1/itemSearch` with a narrower OAuth scope. Found Persons can be filtered by Organization ID. See the Pipedrive API docs [here](https://developers.pipedrive.com/docs/api/v1/Persons#searchPersons)",
10-
version: "0.1.7",
10+
version: "0.1.8",
1111
type: "action",
1212
props: {
1313
pipedriveApp,

components/pipedrive/actions/update-deal/update-deal.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "pipedrive-update-deal",
66
name: "Update Deal",
77
description: "Updates the properties of a deal. See the Pipedrive API docs for Deals [here](https://developers.pipedrive.com/docs/api/v1/Deals#updateDeal)",
8-
version: "0.1.8",
8+
version: "0.1.9",
99
type: "action",
1010
props: {
1111
pipedriveApp,

components/pipedrive/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/pipedrive",
3-
"version": "0.3.13",
3+
"version": "0.4.0",
44
"description": "Pipedream Pipedrive Components",
55
"main": "pipedrive.app.mjs",
66
"keywords": [

components/pipedrive/pipedrive.app.mjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,22 @@ export default {
278278
};
279279
},
280280
},
281+
leadLabelIds: {
282+
type: "string[]",
283+
label: "Lead Label IDs",
284+
description: "The IDs of the lead labels to associate with the lead",
285+
optional: true,
286+
async options() {
287+
const { data: leadLabels } = await this.getLeadLabels();
288+
289+
return leadLabels?.map(({
290+
id, name,
291+
}) => ({
292+
label: name,
293+
value: id,
294+
}));
295+
},
296+
},
281297
},
282298
methods: {
283299
api(model, version = "v1") {
@@ -323,6 +339,10 @@ export default {
323339
const stagesApi = this.api("StagesApi", "v2");
324340
return stagesApi.getStages(opts);
325341
},
342+
getLeadLabels(opts) {
343+
const leadLabelsApi = this.api("LeadLabelsApi");
344+
return leadLabelsApi.getLeadLabels(opts);
345+
},
326346
addActivity(opts = {}) {
327347
const activityApi = this.api("ActivitiesApi", "v2");
328348
return activityApi.addActivity({
@@ -353,6 +373,12 @@ export default {
353373
AddPersonRequest: opts,
354374
});
355375
},
376+
addLead(opts = {}) {
377+
const leadApi = this.api("LeadsApi");
378+
return leadApi.addLead({
379+
AddLeadRequest: opts,
380+
});
381+
},
356382
addWebhook(opts = {}) {
357383
const webhooksApi = this.api("WebhooksApi");
358384
return webhooksApi.addWebhook({

0 commit comments

Comments
 (0)