Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Components] fullenrich #14282

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.",
},
michelle0927 marked this conversation as resolved.
Show resolved Hide resolved
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**.");
}
jcortes marked this conversation as resolved.
Show resolved Hide resolved

const response = await enrichContacts({
$,
data: {
name,
webhook_url: webhookUrl,
michelle0927 marked this conversation as resolved.
Show resolved Hide resolved
datas: [
{
firstname,
lastname,
domain,
company_name: companyName,
linkedin_url: linkedinUrl,
enrich_fields: enrichFields,
},
],
},
});
jcortes marked this conversation as resolved.
Show resolved Hide resolved

$.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}`;
},
michelle0927 marked this conversation as resolved.
Show resolved Hide resolved
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),
});
},
jcortes marked this conversation as resolved.
Show resolved Hide resolved
post(args) {
return this._makeRequest({
method: "POST",
...args,
});
jcortes marked this conversation as resolved.
Show resolved Hide resolved
michelle0927 marked this conversation as resolved.
Show resolved Hide resolved
},
},
};
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.

Loading