-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FullEnrich: new action components (#14282)
- Loading branch information
Showing
5 changed files
with
194 additions
and
7 deletions.
There are no files selected for viewing
108 changes: 108 additions & 0 deletions
108
components/fullenrich/actions/enrich-contact/enrich-contact.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}, | ||
}; |
51 changes: 51 additions & 0 deletions
51
components/fullenrich/actions/get-enrichment-result/get-enrichment-result.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}); | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": [ | ||
|
@@ -11,5 +11,8 @@ | |
"author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@pipedream/platform": "3.0.3" | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.