Skip to content

Commit

Permalink
FullEnrich: new action components (#14282)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcortes authored Oct 14, 2024
1 parent 24bd15a commit fb808e1
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 7 deletions.
108 changes: 108 additions & 0 deletions components/fullenrich/actions/enrich-contact/enrich-contact.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import { ConfigurationError } from "@pipedream/platform";
import app from "../../fullenrich.app.mjs";

export default {
key: "fullenrich-enrich-contact",
name: "Enrich Contact",
description: "Starts the enrichment process for a specified contact. [See the documentation](https://docs.fullenrich.com/startbulk)",
version: "0.0.1",
type: "action",
props: {
app,
name: {
type: "string",
label: "Name",
description: "The name of the action.",
},
webhookUrl: {
type: "string",
label: "Webhook URL",
description: "The Webhook URL that will be triggered when the enrichment is done.",
optional: true,
},
firstname: {
type: "string",
label: "First Name",
description: "The first name of the contact to enrich.",
},
lastname: {
type: "string",
label: "Last Name",
description: "The last name of the contact to enrich.",
},
domain: {
type: "string",
label: "Domain",
description: "The domain of the contact's company (e.g., example.com). Optional if **Company Name** is provided.",
optional: true,
},
companyName: {
type: "string",
label: "Company Name",
description: "The name of the contact's company. Optional if a **Domain** is provided.",
optional: true,
},
linkedinUrl: {
type: "string",
label: "LinkedIn URL",
description: "The LinkedIn URL of the contact to increase the probability of finding emails and phones.",
optional: true,
},
enrichFields: {
type: "string[]",
label: "Enrich Fields",
description: "The fields to enrich. By default, the action enriches contact emails and phones.",
optional: true,
options: [
"contact.emails",
"contact.phones",
],
},
},
methods: {
enrichContacts(args = {}) {
return this.app.post({
path: "/contact/enrich/bulk",
...args,
});
},
},
async run({ $ }) {
const {
enrichContacts,
name,
webhookUrl,
firstname,
lastname,
domain,
companyName,
linkedinUrl,
enrichFields,
} = this;

if (!domain && !companyName) {
throw new ConfigurationError("You must provide either a **Domain** or a **Company Name**.");
}

const response = await enrichContacts({
$,
data: {
name,
webhook_url: webhookUrl,
datas: [
{
firstname,
lastname,
domain,
company_name: companyName,
linkedin_url: linkedinUrl,
enrich_fields: enrichFields,
},
],
},
});

$.export("$summary", `Successfully started the enrichment process with ID \`${response.enrichment_id}\`.`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import app from "../../fullenrich.app.mjs";

export default {
key: "fullenrich-get-enrichment-result",
name: "Get Enrichment Result",
description: "Get the enrichment result for a specified contact. [See the documentation](https://docs.fullenrich.com/getbulk).",
version: "0.0.1",
type: "action",
props: {
app,
enrichmentId: {
type: "string",
label: "Enrichment ID",
description: "The ID of the enrichment to get the result for.",
},
forceResults: {
type: "boolean",
label: "Force Results",
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.",
optional: true,
},
},
methods: {
getEnrichmentResult({
enrichmentId, ...args
} = {}) {
return this.app._makeRequest({
path: `/contact/enrich/bulk/${enrichmentId}`,
...args,
});
},
},
async run({ $ }) {
const {
getEnrichmentResult,
enrichmentId,
forceResults,
} = this;

const response = await getEnrichmentResult({
$,
enrichmentId,
params: {
forceResults,
},
});

$.export("$summary", `Successfully fetched enrichment result with ID \`${response.id}\`.`);
return response;
},
};
30 changes: 26 additions & 4 deletions components/fullenrich/fullenrich.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "fullenrich",
propDefinitions: {},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
getUrl(path) {
return `https://app.fullenrich.com/api/v1${path}`;
},
getHeaders(headers) {
return {
"Content-Type": "application/json",
"Authorization": `Bearer ${this.$auth.api_key}`,
...headers,
};
},
_makeRequest({
$ = this, path, headers, ...args
} = {}) {
return axios($, {
...args,
url: this.getUrl(path),
headers: this.getHeaders(headers),
});
},
post(args) {
return this._makeRequest({
method: "POST",
...args,
});
},
},
};
7 changes: 5 additions & 2 deletions components/fullenrich/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/fullenrich",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream FullEnrich Components",
"main": "fullenrich.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "3.0.3"
}
}
}
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fb808e1

Please sign in to comment.