diff --git a/components/prospeo/actions/extract-data/extract-data.mjs b/components/prospeo/actions/extract-data/extract-data.mjs new file mode 100644 index 0000000000000..495f9381f6767 --- /dev/null +++ b/components/prospeo/actions/extract-data/extract-data.mjs @@ -0,0 +1,46 @@ +import { ConfigurationError } from "@pipedream/platform"; +import prospeo from "../../prospeo.app.mjs"; + +export default { + name: "Extract Data", + version: "0.0.1", + key: "prospeo-extract-data", + description: "Extract data from any LinkedIn profile in real-time, as well as all the data from the company page, and also find a valid verified email from the lead. [See the documentation](https://prospeo.io/api/social-url-enrichment)", + type: "action", + props: { + prospeo, + linkedinUrl: { + type: "string", + label: "LinkedIn URL", + description: "The LinkedIn profile URL.This endpoint is only compatible with public LinkedIn URL, and will not work with special IDs starting in `ACw..`, or `ACo...`", + }, + profileOnly: { + type: "boolean", + label: "Profile Only", + description: "If true, only the profile data will be returned. If false, the company data will also be returned.", + optional: true, + }, + }, + async run({ $ }) { + try { + const response = await this.prospeo.extractData({ + $, + data: { + url: this.linkedinUrl, + profile_only: this.profileOnly, + }, + }); + + $.export("$summary", `Successfully extracted data for **${this.linkedinUrl}**`); + + return response; + } catch ({ response }) { + if (response.data.message === "NO_RESULT") { + $.export("$summary", `No data found for **${this.linkedinUrl}**`); + return {}; + } else { + throw new ConfigurationError(response.data.message); + } + } + }, +}; diff --git a/components/prospeo/actions/find-email/find-email.mjs b/components/prospeo/actions/find-email/find-email.mjs new file mode 100644 index 0000000000000..435802a29befc --- /dev/null +++ b/components/prospeo/actions/find-email/find-email.mjs @@ -0,0 +1,45 @@ +import { ConfigurationError } from "@pipedream/platform"; +import prospeo from "../../prospeo.app.mjs"; + +export default { + name: "Find Email", + version: "0.0.1", + key: "prospeo-find-email", + description: "Find an email address. [See the documentation](https://prospeo.io/api/email-finder)", + type: "action", + props: { + prospeo, + fullName: { + type: "string", + label: "Full Name", + description: "The person's full name. Prospeo advises you to submit the first and last name for higher accuracy.", + }, + company: { + type: "string", + label: "Company Domain/Name", + description: "The company domain, website, or name. Using a domain or website is recommended for better accuracy. If submitting a company name, it needs to be between 3 to 75 characters.", + }, + }, + async run({ $ }) { + try { + const response = await this.prospeo.findEmail({ + $, + data: { + company: this.company, + full_name: this.fullName, + }, + }); + + $.export("$summary", `Successfully found email for **${this.fullName}** at **${this.company}**`); + + return response; + } catch ({ response }) { + if (response.data.message === "NO_RESULT") { + $.export("$summary", `No results found for **${this.fullName}** at ${this.company}`); + return {}; + } else { + throw new ConfigurationError(response.data); + } + } + }, +}; diff --git a/components/prospeo/actions/find-mobile-number/find-mobile-number.mjs b/components/prospeo/actions/find-mobile-number/find-mobile-number.mjs new file mode 100644 index 0000000000000..a7e73dfe38a74 --- /dev/null +++ b/components/prospeo/actions/find-mobile-number/find-mobile-number.mjs @@ -0,0 +1,39 @@ +import { ConfigurationError } from "@pipedream/platform"; +import prospeo from "../../prospeo.app.mjs"; + +export default { + name: "Find Mobile Number", + version: "0.0.1", + key: "prospeo-find-mobile-number", + description: "Discover mobile numbers associated with a LinkedIn profile URL. [See the documentation](https://prospeo.io/api/mobile-finder)", + type: "action", + props: { + prospeo, + linkedinUrl: { + type: "string", + label: "LinkedIn URL", + description: "The LinkedIn profile URL.This endpoint is only compatible with public LinkedIn URL, and will not work with special IDs starting in `ACw..`, or `ACo...`", + }, + }, + async run({ $ }) { + try { + const response = await this.prospeo.findMobile({ + $, + data: { + url: this.linkedinUrl, + }, + }); + + $.export("$summary", `Successfully found mobile number for **${this.linkedinUrl}**`); + + return response; + } catch ({ response }) { + if (response.data.message === "NO_RESULT") { + $.export("$summary", `No results found for **${this.linkedinUrl}**`); + return {}; + } else { + throw new ConfigurationError(response.data.message); + } + } + }, +}; diff --git a/components/prospeo/actions/search-domain/search-domain.mjs b/components/prospeo/actions/search-domain/search-domain.mjs new file mode 100644 index 0000000000000..d3635778d3157 --- /dev/null +++ b/components/prospeo/actions/search-domain/search-domain.mjs @@ -0,0 +1,61 @@ +import { ConfigurationError } from "@pipedream/platform"; +import { EMAIL_TYPE_OPTIONS } from "../../common/constants.mjs"; +import prospeo from "../../prospeo.app.mjs"; + +export default { + name: "Search Domain", + version: "0.0.1", + key: "prospeo-search-domain", + description: "Discover email addresses associated with a domain name, website, or company name. [See the documentation](https://prospeo.io/api/domain-search)", + type: "action", + props: { + prospeo, + company: { + type: "string", + label: "Company Domain/Name", + description: "The company domain, website, or name. Using a domain or website is recommended for better accuracy. If submitting a company name, it needs to be between 3 to 75 characters.", + }, + limit: { + type: "integer", + label: "Limit", + description: "How many emails you need. The default value is `50`. You will be charged 1 credit every 50 emails. For example, 35 emails will be charged 1 credit while 65 emails will be charged 2 credits.", + optional: true, + }, + emailType: { + type: "string", + label: "Email Type", + description: "Indicates what type of email you want to get. `generic` refers to role-based emails such as `info@example.com`, while `professional` are emails of people working at the company.", + options: EMAIL_TYPE_OPTIONS, + optional: true, + }, + companyEnrichment: { + type: "boolean", + label: "Company Enrichment", + description: "Indicates if you want the company details in the response. It is `false` by default. Turning it to `true` might slow-down the response time as we gather the company details.", + }, + }, + async run({ $ }) { + try { + const response = await this.prospeo.searchDomain({ + $, + data: { + company: this.company, + limit: this.limit, + email_type: this.emailType, + enrich_company: this.companyEnrichment, + }, + }); + + $.export("$summary", `Successfully searched domain: ${this.company}`); + + return response; + } catch ({ response }) { + if (response.data.message === "NO_RESULT") { + $.export("$summary", `No results found for **${this.company}**`); + return {}; + } else { + throw new ConfigurationError(response.data.message); + } + } + }, +}; diff --git a/components/prospeo/actions/verify-email/verify-email.mjs b/components/prospeo/actions/verify-email/verify-email.mjs new file mode 100644 index 0000000000000..a156cd9278f2a --- /dev/null +++ b/components/prospeo/actions/verify-email/verify-email.mjs @@ -0,0 +1,50 @@ +import { ConfigurationError } from "@pipedream/platform"; +import prospeo from "../../prospeo.app.mjs"; + +export default { + name: "Verify Email", + version: "0.0.1", + key: "prospeo-verify-email", + description: "Verify the validity of an email address. [See the documentation](https://prospeo.io/api/email-verifier)", + type: "action", + props: { + prospeo, + email: { + type: "string", + label: "Email", + description: "The email address to verify", + optional: true, + }, + emailAnonId: { + type: "string", + label: "Email Anon ID", + description: "The ID of the email obtained from the `Search Domain` action.", + optional: true, + }, + }, + async run({ $ }) { + if (!this.email && !this.emailAnonId) { + throw new ConfigurationError("Either email or emailAnonId is required"); + } + try { + const response = await this.prospeo.verifyEmail({ + $, + data: { + email: this.email, + email_anon_id: this.emailAnonId, + }, + }); + + $.export("$summary", `Successfully verified: ${this.email || this.emailAnonId}`); + + return response; + } catch ({ response }) { + if (response.data.message === "NO_RESULT") { + $.export("$summary", `No results found for **${this.email || this.emailAnonId}**`); + return {}; + } else { + throw new ConfigurationError(response.data.message); + } + } + }, +}; diff --git a/components/prospeo/common/constants.mjs b/components/prospeo/common/constants.mjs new file mode 100644 index 0000000000000..f424dcf96f456 --- /dev/null +++ b/components/prospeo/common/constants.mjs @@ -0,0 +1,10 @@ +export const EMAIL_TYPE_OPTIONS = [ + { + label: "Generic", + value: "generic", + }, + { + label: "Professional", + value: "professional", + }, +]; diff --git a/components/prospeo/package.json b/components/prospeo/package.json index 742d7d5821d4f..34b8c1f64503e 100644 --- a/components/prospeo/package.json +++ b/components/prospeo/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/prospeo", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Prospeo Components", "main": "prospeo.app.mjs", "keywords": [ @@ -9,7 +9,10 @@ ], "homepage": "https://pipedream.com/apps/prospeo", "author": "Pipedream (https://pipedream.com/)", + "dependencies": { + "@pipedream/platform": "^3.0.3" + }, "publishConfig": { "access": "public" } -} \ No newline at end of file +} diff --git a/components/prospeo/prospeo.app.mjs b/components/prospeo/prospeo.app.mjs index 72dffa6297f91..88b40dd75ee9c 100644 --- a/components/prospeo/prospeo.app.mjs +++ b/components/prospeo/prospeo.app.mjs @@ -1,11 +1,61 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "prospeo", - propDefinitions: {}, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://api.prospeo.io"; + }, + _headers() { + return { + "x-key": `${this.$auth.api_key}`, + "Content-Type": "application/json", + }; + }, + _makeRequest({ + $ = this, path, ...opts + }) { + return axios($, { + url: this._baseUrl() + path, + headers: this._headers(), + ...opts, + }); + }, + findEmail(args = {}) { + return this._makeRequest({ + method: "POST", + path: "/email-finder", + ...args, + }); + }, + findMobile(args = {}) { + return this._makeRequest({ + method: "POST", + path: "/mobile-finder", + ...args, + }); + }, + extractData(args = {}) { + return this._makeRequest({ + method: "POST", + path: "/social-url-enrichment", + ...args, + }); + }, + searchDomain(args = {}) { + return this._makeRequest({ + method: "POST", + path: "/domain-search", + ...args, + }); + }, + verifyEmail(args = {}) { + return this._makeRequest({ + method: "POST", + path: "/email-verifier", + ...args, + }); }, }, -}; \ No newline at end of file +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 81a357245fbf5..d0353d6013238 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10498,7 +10498,11 @@ importers: components/proprofs_quiz_maker: {} - components/prospeo: {} + components/prospeo: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 components/provesource: {}