Skip to content

Commit 1f8110c

Browse files
committed
new actions
1 parent 7a48a21 commit 1f8110c

File tree

5 files changed

+111
-1
lines changed

5 files changed

+111
-1
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import pipedriveApp from "../../pipedrive.app.mjs";
2+
3+
export default {
4+
key: "pipedrive-get-lead-by-id",
5+
name: "Get Lead by ID",
6+
description: "Get a lead by its ID. [See the documentation](https://developers.pipedrive.com/docs/api/v1/Leads#getLead)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
pipedriveApp,
11+
leadId: {
12+
propDefinition: [
13+
pipedriveApp,
14+
"leadId",
15+
],
16+
description: "The ID of the lead to get",
17+
optional: false,
18+
},
19+
},
20+
async run({ $ }) {
21+
const { data } = await this.pipedriveApp.getLead(this.leadId);
22+
$.export("$summary", `Successfully retrieved lead with ID: ${this.leadId}`);
23+
return data;
24+
},
25+
};
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import pipedriveApp from "../../pipedrive.app.mjs";
2+
import constants from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "pipedrive-search-leads",
6+
name: "Search Leads",
7+
description: "Search for leads by name or email. [See the documentation](https://developers.pipedrive.com/docs/api/v1/Leads#searchLeads)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
pipedriveApp,
12+
term: {
13+
type: "string",
14+
label: "Search Term",
15+
description: "The search term to look for. Minimum 2 characters (or 1 if using exact_match).",
16+
},
17+
exactMatch: {
18+
type: "boolean",
19+
label: "Exact Match",
20+
description: "When enabled, only full exact matches against the given term are returned. It is not case sensitive.",
21+
optional: true,
22+
},
23+
fields: {
24+
type: "string[]",
25+
label: "Search Fields",
26+
description: "An array containing fields to perform the search from. Defaults to all of them.",
27+
optional: true,
28+
options: constants.LEAD_FIELD_OPTIONS,
29+
},
30+
personId: {
31+
propDefinition: [
32+
pipedriveApp,
33+
"personId",
34+
],
35+
description: "Will filter Deals by the provided Person ID",
36+
},
37+
organizationId: {
38+
propDefinition: [
39+
pipedriveApp,
40+
"organizationId",
41+
],
42+
description: "Will filter Deals by the provided Organization ID",
43+
},
44+
includeFields: {
45+
type: "string",
46+
label: "Include fields",
47+
description: "Supports including optional fields in the results which are not provided by default.",
48+
optional: true,
49+
options: [
50+
"lead.was_seen",
51+
],
52+
},
53+
},
54+
async run({ $ }) {
55+
const { data: { items = [] } } = await this.pipedriveApp.searchLeads({
56+
term: this.term,
57+
exact_match: this.exactMatch,
58+
fields: this.fields,
59+
person_id: this.personId,
60+
organization_id: this.organizationId,
61+
include_fields: this.includeFields,
62+
});
63+
$.export("$summary", `Successfully found ${items.length} lead${items.length === 1
64+
? ""
65+
: "s"}`);
66+
return items;
67+
},
68+
};

components/pipedrive/common/constants.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,18 @@ const FIELD = {
3535
UPDATE_TIME: "update_time",
3636
};
3737

38+
const LEAD_FIELD_OPTIONS = [
39+
"custom_fields",
40+
"notes",
41+
"title",
42+
];
43+
3844
export default {
3945
STATUS_OPTIONS,
4046
FIELD_OPTIONS,
4147
VISIBLE_TO_OPTIONS,
4248
INCLUDE_FIELDS_OPTIONS,
4349
DEFAULT_PAGE_LIMIT,
4450
FIELD,
51+
LEAD_FIELD_OPTIONS,
4552
};

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.8.0",
3+
"version": "0.9.0",
44
"description": "Pipedream Pipedrive Components",
55
"main": "pipedrive.app.mjs",
66
"keywords": [

components/pipedrive/pipedrive.app.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,16 @@ export default {
449449
id: personId,
450450
});
451451
},
452+
getLead(leadId) {
453+
const leadApi = this.api("LeadsApi");
454+
return leadApi.getLead({
455+
id: leadId,
456+
});
457+
},
458+
searchLeads(opts = {}) {
459+
const leadApi = this.api("LeadsApi", "v2");
460+
return leadApi.searchLeads(opts);
461+
},
452462
async *paginate({
453463
fn, params, max,
454464
}) {

0 commit comments

Comments
 (0)