Skip to content

Commit 853628a

Browse files
committed
FullEnrich: new action components
1 parent 58ff60b commit 853628a

File tree

5 files changed

+194
-7
lines changed

5 files changed

+194
-7
lines changed
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import app from "../../fullenrich.app.mjs";
3+
4+
export default {
5+
key: "fullenrich-enrich-contact",
6+
name: "Enrich Contact",
7+
description: "Starts the enrichment process for a specified contact. [See the documentation](https://docs.fullenrich.com/startbulk)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
name: {
13+
type: "string",
14+
label: "Name",
15+
description: "The name of the action.",
16+
},
17+
webhookUrl: {
18+
type: "string",
19+
label: "Webhook URL",
20+
description: "The Webhook URL that will be triggered when the enrichment is done.",
21+
optional: true,
22+
},
23+
firstname: {
24+
type: "string",
25+
label: "First Name",
26+
description: "The first name of the contact to enrich.",
27+
},
28+
lastname: {
29+
type: "string",
30+
label: "Last Name",
31+
description: "The last name of the contact to enrich.",
32+
},
33+
domain: {
34+
type: "string",
35+
label: "Domain",
36+
description: "The domain of the contact's company (e.g., example.com). Optional if **Company Name** is provided.",
37+
optional: true,
38+
},
39+
companyName: {
40+
type: "string",
41+
label: "Company Name",
42+
description: "The name of the contact's company. Optional if a **Domain** is provided.",
43+
optional: true,
44+
},
45+
linkedinUrl: {
46+
type: "string",
47+
label: "LinkedIn URL",
48+
description: "The LinkedIn URL of the contact to increase the probability of finding emails and phones.",
49+
optional: true,
50+
},
51+
enrichFields: {
52+
type: "string[]",
53+
label: "Enrich Fields",
54+
description: "The fields to enrich. By default, the action enriches contact emails and phones.",
55+
optional: true,
56+
options: [
57+
"contact.emails",
58+
"contact.phones",
59+
],
60+
},
61+
},
62+
methods: {
63+
enrichContacts(args = {}) {
64+
return this.app.post({
65+
path: "/contact/enrich/bulk",
66+
...args,
67+
});
68+
},
69+
},
70+
async run({ $ }) {
71+
const {
72+
enrichContacts,
73+
name,
74+
webhookUrl,
75+
firstname,
76+
lastname,
77+
domain,
78+
companyName,
79+
linkedinUrl,
80+
enrichFields,
81+
} = this;
82+
83+
if (!domain && !companyName) {
84+
throw new ConfigurationError("You must provide either a **Domain** or a **Company Name**.");
85+
}
86+
87+
const response = await enrichContacts({
88+
$,
89+
data: {
90+
name,
91+
webhook_url: webhookUrl,
92+
datas: [
93+
{
94+
firstname,
95+
lastname,
96+
domain,
97+
company_name: companyName,
98+
linkedin_url: linkedinUrl,
99+
enrich_fields: enrichFields,
100+
},
101+
],
102+
},
103+
});
104+
105+
$.export("$summary", `Successfully started the enrichment process with ID \`${response.enrichment_id}\`.`);
106+
return response;
107+
},
108+
};
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import app from "../../fullenrich.app.mjs";
2+
3+
export default {
4+
key: "fullenrich-get-enrichment-result",
5+
name: "Get Enrichment Result",
6+
description: "Get the enrichment result for a specified contact. [See the documentation](https://docs.fullenrich.com/getbulk).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
enrichmentId: {
12+
type: "string",
13+
label: "Enrichment ID",
14+
description: "The ID of the enrichment to get the result for.",
15+
},
16+
forceResults: {
17+
type: "boolean",
18+
label: "Force Results",
19+
description: "This parameter forces the API to return what has been found so far, even if the enrichment is not finished. This may result in missing information and is not recommended for regular use.",
20+
optional: true,
21+
},
22+
},
23+
methods: {
24+
getEnrichmentResult({
25+
enrichmentId, ...args
26+
} = {}) {
27+
return this.app._makeRequest({
28+
path: `/contact/enrich/bulk/${enrichmentId}`,
29+
...args,
30+
});
31+
},
32+
},
33+
async run({ $ }) {
34+
const {
35+
getEnrichmentResult,
36+
enrichmentId,
37+
forceResults,
38+
} = this;
39+
40+
const response = await getEnrichmentResult({
41+
$,
42+
enrichmentId,
43+
params: {
44+
forceResults,
45+
},
46+
});
47+
48+
$.export("$summary", `Successfully fetched enrichment result with ID \`${response.id}\`.`);
49+
return response;
50+
},
51+
};
Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,33 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "fullenrich",
4-
propDefinitions: {},
56
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
7+
getUrl(path) {
8+
return `https://app.fullenrich.com/api/v1${path}`;
9+
},
10+
getHeaders(headers) {
11+
return {
12+
"Content-Type": "application/json",
13+
"Authorization": `Bearer ${this.$auth.api_key}`,
14+
...headers,
15+
};
16+
},
17+
_makeRequest({
18+
$ = this, path, headers, ...args
19+
} = {}) {
20+
return axios($, {
21+
...args,
22+
url: this.getUrl(path),
23+
headers: this.getHeaders(headers),
24+
});
25+
},
26+
post(args) {
27+
return this._makeRequest({
28+
method: "POST",
29+
...args,
30+
});
931
},
1032
},
1133
};

components/fullenrich/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/fullenrich",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream FullEnrich Components",
55
"main": "fullenrich.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "3.0.3"
1417
}
15-
}
18+
}

pnpm-lock.yaml

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)