diff --git a/components/hunter/actions/account-information/account-information.mjs b/components/hunter/actions/account-information/account-information.mjs new file mode 100644 index 0000000000000..1fc0168e44ad1 --- /dev/null +++ b/components/hunter/actions/account-information/account-information.mjs @@ -0,0 +1,20 @@ +import app from "../../hunter.app.mjs"; + +export default { + key: "hunter-account-information", + name: "Account Information", + description: "Get information about your Hunter account. [See the documentation](https://hunter.io/api-documentation/v2#account).", + version: "0.0.1", + type: "action", + props: { + app, + }, + async run({ $ }) { + const response = await this.app.accountInformation({ + $, + }); + + $.export("$summary", "Successfully retrieved account information"); + return response; + }, +}; diff --git a/components/hunter/actions/combined-enrichment/combined-enrichment.mjs b/components/hunter/actions/combined-enrichment/combined-enrichment.mjs new file mode 100644 index 0000000000000..91a3237724160 --- /dev/null +++ b/components/hunter/actions/combined-enrichment/combined-enrichment.mjs @@ -0,0 +1,34 @@ +import app from "../../hunter.app.mjs"; + +export default { + key: "hunter-combined-enrichment", + name: "Combined Enrichment", + description: "Returns all the information associated with an email address and its domain name. [See the documentation](https://hunter.io/api-documentation/v2#combined-enrichment).", + version: "0.0.1", + type: "action", + props: { + app, + email: { + propDefinition: [ + app, + "email", + ], + }, + }, + async run({ $ }) { + const { + app, + email, + } = this; + + const response = await app.combinedEnrichment({ + $, + params: { + email, + }, + }); + + $.export("$summary", "Successfully retrieved combined enrichment data"); + return response; + }, +}; diff --git a/components/hunter/actions/create-lead/create-lead.mjs b/components/hunter/actions/create-lead/create-lead.mjs new file mode 100644 index 0000000000000..7601ac876dd18 --- /dev/null +++ b/components/hunter/actions/create-lead/create-lead.mjs @@ -0,0 +1,206 @@ +import app from "../../hunter.app.mjs"; + +export default { + key: "hunter-create-lead", + name: "Create Lead", + description: "Create a new lead in your Hunter account. [See the documentation](https://hunter.io/api-documentation/v2#create-lead).", + version: "0.0.1", + type: "action", + props: { + app, + email: { + propDefinition: [ + app, + "email", + ], + description: "The email address of the lead.", + }, + firstName: { + propDefinition: [ + app, + "firstName", + ], + description: "The first name of the lead.", + optional: true, + }, + lastName: { + propDefinition: [ + app, + "lastName", + ], + description: "The last name of the lead.", + optional: true, + }, + position: { + propDefinition: [ + app, + "position", + ], + description: "The job title of the lead.", + optional: true, + }, + company: { + propDefinition: [ + app, + "company", + ], + description: "The name of the company the lead is working in.", + optional: true, + }, + companyIndustry: { + type: "string", + label: "Company Industry", + description: "The sector of the company.", + options: [ + "Animal", + "Art & Entertainment", + "Automotive", + "Beauty & Fitness", + "Books & Literature", + "Education & Career", + "Finance", + "Food & Drink", + "Game", + "Health", + "Hobby & Leisure", + "Home & Garden", + "Industry", + "Internet & Telecom", + "Law & Government", + "Manufacturing", + "News", + "Real Estate", + "Science", + "Retail", + "Sport", + "Technology", + "Travel", + ], + optional: true, + }, + companySize: { + propDefinition: [ + app, + "companySize", + ], + description: "The size of the company the lead is working in.", + optional: true, + }, + confidenceScore: { + type: "integer", + label: "Confidence Score", + description: "Estimation of the probability the email address returned is correct, between 0 and 100.", + min: 0, + max: 100, + optional: true, + }, + website: { + propDefinition: [ + app, + "website", + ], + description: "The domain name of the company.", + optional: true, + }, + countryCode: { + propDefinition: [ + app, + "countryCode", + ], + description: "The country of the lead (ISO 3166-1 alpha-2 standard).", + optional: true, + }, + linkedinUrl: { + propDefinition: [ + app, + "linkedinUrl", + ], + description: "The address of the public profile on LinkedIn.", + optional: true, + }, + phoneNumber: { + propDefinition: [ + app, + "phoneNumber", + ], + description: "The phone number of the lead.", + optional: true, + }, + twitter: { + propDefinition: [ + app, + "twitter", + ], + description: "The Twitter handle of the lead.", + optional: true, + }, + notes: { + type: "string", + label: "Notes", + description: "Some personal notes about the lead.", + optional: true, + }, + source: { + propDefinition: [ + app, + "source", + ], + description: "The source where the lead has been found.", + optional: true, + }, + leadsListId: { + propDefinition: [ + app, + "leadsListId", + ], + description: "The identifier of the list the lead belongs to. If not specified, the lead is saved in the last list created.", + optional: true, + }, + }, + async run({ $ }) { + const { + app, + email, + firstName, + lastName, + position, + company, + companyIndustry, + companySize, + confidenceScore, + website, + countryCode, + linkedinUrl, + phoneNumber, + twitter, + notes, + source, + leadsListId, + } = this; + + const response = await app.createLead({ + $, + data: { + email, + first_name: firstName, + last_name: lastName, + position, + company, + company_industry: companyIndustry, + company_size: companySize, + confidence_score: confidenceScore, + website, + country_code: countryCode, + linkedin_url: linkedinUrl, + phone_number: phoneNumber, + twitter, + notes, + source, + leads_list_id: leadsListId, + }, + }); + + $.export("$summary", "Successfully created lead"); + return response; + }, +}; diff --git a/components/hunter/actions/delete-lead/delete-lead.mjs b/components/hunter/actions/delete-lead/delete-lead.mjs new file mode 100644 index 0000000000000..708e50312d868 --- /dev/null +++ b/components/hunter/actions/delete-lead/delete-lead.mjs @@ -0,0 +1,34 @@ +import app from "../../hunter.app.mjs"; + +export default { + key: "hunter-delete-lead", + name: "Delete Lead", + description: "Delete an existing lead from your Hunter account. [See the documentation](https://hunter.io/api-documentation/v2#delete-lead).", + version: "0.0.1", + type: "action", + props: { + app, + leadId: { + propDefinition: [ + app, + "leadId", + ], + }, + }, + async run({ $ }) { + const { + app, + leadId, + } = this; + + await app.deleteLead({ + $, + leadId, + }); + + $.export("$summary", "Successfully deleted lead"); + return { + success: true, + }; + }, +}; diff --git a/components/hunter/actions/domain-search/domain-search.mjs b/components/hunter/actions/domain-search/domain-search.mjs new file mode 100644 index 0000000000000..cf5d6c7347602 --- /dev/null +++ b/components/hunter/actions/domain-search/domain-search.mjs @@ -0,0 +1,106 @@ +import { ConfigurationError } from "@pipedream/platform"; +import app from "../../hunter.app.mjs"; + +export default { + key: "hunter-domain-search", + name: "Domain Search", + description: "Search all the email addresses corresponding to one website or company. [See the documentation](https://hunter.io/api-documentation/v2#domain-search).", + version: "0.0.1", + type: "action", + props: { + app, + domain: { + propDefinition: [ + app, + "domain", + ], + optional: true, + }, + company: { + propDefinition: [ + app, + "company", + ], + optional: true, + }, + limit: { + propDefinition: [ + app, + "limit", + ], + }, + type: { + propDefinition: [ + app, + "type", + ], + }, + seniority: { + type: "string[]", + label: "Seniority", + description: "Get only email addresses for people with the selected seniority level(s).", + options: [ + "junior", + "senior", + "executive", + ], + optional: true, + }, + department: { + type: "string[]", + label: "Department", + description: "Get only email addresses for people working in the selected department(s).", + options: [ + "executive", + "it", + "finance", + "management", + "sales", + "legal", + "support", + "hr", + "marketing", + "communication", + "education", + "design", + "health", + "operations", + ], + optional: true, + }, + }, + async run({ $ }) { + const { + app, + domain, + company, + type, + seniority, + department, + limit, + } = this; + + if (!domain && !company) { + throw new ConfigurationError("You must provide either a **Domain** or **Company** name"); + } + + const response = await app.domainSearch({ + $, + params: { + domain, + company, + type, + ...(Array.isArray(seniority) && seniority.length && { + seniority: seniority.join(","), + }), + ...(Array.isArray(department) && department.length && { + department: department.join(","), + }), + limit, + }, + }); + + $.export("$summary", "Successfully searched for email addresses"); + return response; + }, +}; diff --git a/components/hunter/actions/email-count/email-count.mjs b/components/hunter/actions/email-count/email-count.mjs new file mode 100644 index 0000000000000..8eeda688381a7 --- /dev/null +++ b/components/hunter/actions/email-count/email-count.mjs @@ -0,0 +1,57 @@ +import { ConfigurationError } from "@pipedream/platform"; +import app from "../../hunter.app.mjs"; + +export default { + key: "hunter-email-count", + name: "Email Count", + description: "Get the number of email addresses Hunter has for one domain or company. [See the documentation](https://hunter.io/api-documentation/v2#email-count).", + version: "0.0.1", + type: "action", + props: { + app, + domain: { + propDefinition: [ + app, + "domain", + ], + optional: true, + }, + company: { + propDefinition: [ + app, + "company", + ], + optional: true, + }, + type: { + propDefinition: [ + app, + "type", + ], + }, + }, + async run({ $ }) { + const { + app, + domain, + company, + type, + } = this; + + if (!domain && !company) { + throw new ConfigurationError("You must provide either a **Domain** or **Company** name"); + } + + const response = await app.emailCount({ + $, + params: { + domain, + company, + type, + }, + }); + + $.export("$summary", "Successfully retrieved email count"); + return response; + }, +}; diff --git a/components/hunter/actions/email-finder/email-finder.mjs b/components/hunter/actions/email-finder/email-finder.mjs new file mode 100644 index 0000000000000..d1be3fde92312 --- /dev/null +++ b/components/hunter/actions/email-finder/email-finder.mjs @@ -0,0 +1,65 @@ +import { ConfigurationError } from "@pipedream/platform"; +import app from "../../hunter.app.mjs"; + +export default { + key: "hunter-email-finder", + name: "Email Finder", + description: "Find the most likely email address from a domain name, a first name and a last name. [See the documentation](https://hunter.io/api-documentation/v2#email-finder).", + version: "0.0.1", + type: "action", + props: { + app, + domain: { + propDefinition: [ + app, + "domain", + ], + optional: true, + }, + company: { + propDefinition: [ + app, + "company", + ], + optional: true, + }, + firstName: { + propDefinition: [ + app, + "firstName", + ], + }, + lastName: { + propDefinition: [ + app, + "lastName", + ], + }, + }, + async run({ $ }) { + const { + app, + domain, + company, + firstName, + lastName, + } = this; + + if (!domain && !company) { + throw new ConfigurationError("You must provide either a **Domain** or **Company** name"); + } + + const response = await app.emailFinder({ + $, + params: { + domain, + company, + first_name: firstName, + last_name: lastName, + }, + }); + + $.export("$summary", "Successfully searched for email address"); + return response; + }, +}; diff --git a/components/hunter/actions/email-verifier/email-verifier.mjs b/components/hunter/actions/email-verifier/email-verifier.mjs new file mode 100644 index 0000000000000..24339f3b633a7 --- /dev/null +++ b/components/hunter/actions/email-verifier/email-verifier.mjs @@ -0,0 +1,34 @@ +import app from "../../hunter.app.mjs"; + +export default { + key: "hunter-email-verifier", + name: "Email Verifier", + description: "Check the deliverability of a given email address, verify if it has been found in Hunter's database, and return their sources. [See the documentation](https://hunter.io/api-documentation/v2#email-verifier).", + version: "0.0.1", + type: "action", + props: { + app, + email: { + propDefinition: [ + app, + "email", + ], + }, + }, + async run({ $ }) { + const { + app, + email, + } = this; + + const response = await app.emailVerifier({ + $, + params: { + email, + }, + }); + + $.export("$summary", "Successfully verified email address"); + return response; + }, +}; diff --git a/components/hunter/actions/get-lead/get-lead.mjs b/components/hunter/actions/get-lead/get-lead.mjs new file mode 100644 index 0000000000000..1767754b8ce8c --- /dev/null +++ b/components/hunter/actions/get-lead/get-lead.mjs @@ -0,0 +1,32 @@ +import app from "../../hunter.app.mjs"; + +export default { + key: "hunter-get-lead", + name: "Get Lead", + description: "Retrieve one of your leads by ID. [See the documentation](https://hunter.io/api-documentation/v2#leads).", + version: "0.0.1", + type: "action", + props: { + app, + leadId: { + propDefinition: [ + app, + "leadId", + ], + }, + }, + async run({ $ }) { + const { + app, + leadId, + } = this; + + const response = await app.getLead({ + $, + leadId, + }); + + $.export("$summary", `Successfully retrieved lead with ID \`${response.data.id}\`.`); + return response; + }, +}; diff --git a/components/hunter/actions/get-leads-list/get-leads-list.mjs b/components/hunter/actions/get-leads-list/get-leads-list.mjs new file mode 100644 index 0000000000000..33b519c6e4d40 --- /dev/null +++ b/components/hunter/actions/get-leads-list/get-leads-list.mjs @@ -0,0 +1,44 @@ +import app from "../../hunter.app.mjs"; + +export default { + key: "hunter-get-leads-list", + name: "Get Leads List", + description: "Retrieves all the fields of a leads list, including its leads. [See the documentation](https://hunter.io/api-documentation/v2#get-leads-list).", + version: "0.0.1", + type: "action", + props: { + app, + leadsListId: { + propDefinition: [ + app, + "leadsListId", + ], + description: "Identifier of the leads list to retrieve.", + }, + limit: { + propDefinition: [ + app, + "limit", + ], + description: "A limit on the number of leads to be returned. Limit can range between 1 and 100. Default is 20.", + }, + }, + async run({ $ }) { + const { + app, + leadsListId, + limit, + } = this; + + const response = await app.getLeadsList({ + $, + leadsListId, + params: { + limit, + }, + }); + + $.export("$summary", `Successfully retrieved leads list ${leadsListId}`); + return response; + }, +}; diff --git a/components/hunter/actions/list-leads-lists/list-leads-lists.mjs b/components/hunter/actions/list-leads-lists/list-leads-lists.mjs new file mode 100644 index 0000000000000..42bcc8a2c4939 --- /dev/null +++ b/components/hunter/actions/list-leads-lists/list-leads-lists.mjs @@ -0,0 +1,35 @@ +import app from "../../hunter.app.mjs"; + +export default { + key: "hunter-list-leads-lists", + name: "List Leads Lists", + description: "List all your leads lists. The leads lists are returned in sorted order, with the most recent leads lists appearing first. [See the documentation](https://hunter.io/api-documentation/v2#list-leads-lists).", + version: "0.0.1", + type: "action", + props: { + app, + limit: { + propDefinition: [ + app, + "limit", + ], + description: "A limit on the number of lists to be returned. Limit can range between 1 and 100 lists. Default is 20.", + }, + }, + async run({ $ }) { + const { + app, + limit, + } = this; + + const response = await app.listLeadsLists({ + $, + params: { + limit, + }, + }); + + $.export("$summary", "Successfully retrieved leads lists"); + return response; + }, +}; diff --git a/components/hunter/actions/list-leads/list-leads.mjs b/components/hunter/actions/list-leads/list-leads.mjs new file mode 100644 index 0000000000000..e972842716004 --- /dev/null +++ b/components/hunter/actions/list-leads/list-leads.mjs @@ -0,0 +1,277 @@ +import app from "../../hunter.app.mjs"; + +export default { + key: "hunter-list-leads", + name: "List Leads", + description: "List all your leads with comprehensive filtering options. The leads are returned in sorted order, with the most recent leads appearing first. [See the documentation](https://hunter.io/api-documentation/v2#leads).", + version: "0.0.1", + type: "action", + props: { + app, + leadsListId: { + propDefinition: [ + app, + "leadsListId", + ], + description: "Only returns the leads belonging to this list.", + optional: true, + }, + email: { + propDefinition: [ + app, + "email", + ], + description: "Filter leads by email. Use `*` for any value, `~` for empty, or specific email.", + optional: true, + }, + firstName: { + propDefinition: [ + app, + "firstName", + ], + description: "Filter leads by first name. Use `*` for any value, `~` for empty, or specific name.", + optional: true, + }, + lastName: { + propDefinition: [ + app, + "lastName", + ], + description: "Filter leads by last name. Use `*` for any value, `~` for empty, or specific name.", + optional: true, + }, + position: { + propDefinition: [ + app, + "position", + ], + description: "Filter leads by position. Use `*` for any value, `~` for empty, or specific position.", + optional: true, + }, + company: { + propDefinition: [ + app, + "company", + ], + description: "Filter leads by company. Use `*` for any value, `~` for empty, or specific company.", + optional: true, + }, + industry: { + propDefinition: [ + app, + "industry", + ], + description: "Filter leads by industry. Use `*` for any value, `~` for empty, or specific industry.", + optional: true, + }, + website: { + propDefinition: [ + app, + "website", + ], + description: "Filter leads by website. Use `*` for any value, `~` for empty, or specific website.", + optional: true, + }, + countryCode: { + propDefinition: [ + app, + "countryCode", + ], + description: "Filter leads by country code (ISO 3166-1 alpha-2). Use `*` for any value, `~` for empty.", + optional: true, + }, + companySize: { + propDefinition: [ + app, + "companySize", + ], + description: "Filter leads by company size. Use `*` for any value, `~` for empty, or specific size.", + optional: true, + }, + source: { + propDefinition: [ + app, + "source", + ], + description: "Filter leads by source. Use `*` for any value, `~` for empty, or specific source.", + optional: true, + }, + twitter: { + propDefinition: [ + app, + "twitter", + ], + description: "Filter leads by Twitter handle. Use `*` for any value, `~` for empty, or specific handle.", + optional: true, + }, + linkedinUrl: { + propDefinition: [ + app, + "linkedinUrl", + ], + description: "Filter leads by LinkedIn URL. Use `*` for any value, `~` for empty, or specific URL.", + optional: true, + }, + phoneNumber: { + propDefinition: [ + app, + "phoneNumber", + ], + description: "Filter leads by phone number. Use `*` for any value, `~` for empty, or specific number.", + optional: true, + }, + syncStatus: { + type: "string", + label: "Sync Status", + description: "Only returns the leads matching this synchronization status.", + options: [ + "pending", + "error", + "success", + ], + optional: true, + }, + sendingStatus: { + type: "string[]", + label: "Sending Status", + description: "Only returns the leads matching these sending status(es).", + options: [ + "clicked", + "opened", + "sent", + "pending", + "error", + "bounced", + "unsubscribed", + "replied", + { + value: "~", + label: "unset", + }, + ], + optional: true, + }, + verificationStatus: { + type: "string[]", + label: "Verification Status", + description: "Only returns the leads matching these verification status(es).", + options: [ + "accept_all", + "disposable", + "invalid", + "unknown", + "valid", + "webmail", + "pending", + ], + optional: true, + }, + lastActivityAt: { + type: "string", + label: "Last Activity", + description: "Only returns the leads matching this last activity.", + options: [ + { + value: "*", + label: "any", + }, + { + value: "~", + label: "unset", + }, + ], + optional: true, + }, + lastContactedAt: { + type: "string", + label: "Last Contacted", + description: "Only returns the leads matching this last contact date.", + options: [ + { + value: "*", + label: "any", + }, + { + value: "~", + label: "unset", + }, + ], + optional: true, + }, + query: { + type: "string", + label: "Query", + description: "Only returns the leads with **First Name**, **Last Name**, or **Email** matching the query.", + optional: true, + }, + limit: { + propDefinition: [ + app, + "limit", + ], + description: "A limit on the number of leads to be returned. Limit can range between `1` and `1,000`. Default is `20`.", + min: 1, + max: 1000, + }, + }, + async run({ $ }) { + const { + app, + leadsListId, + email, + firstName, + lastName, + position, + company, + industry, + website, + countryCode, + companySize, + source, + twitter, + linkedinUrl, + phoneNumber, + syncStatus, + sendingStatus, + verificationStatus, + lastActivityAt, + lastContactedAt, + query, + limit, + } = this; + + const response = await app.listLeads({ + $, + params: { + limit, + leads_list_id: leadsListId, + email, + first_name: firstName, + last_name: lastName, + position, + company, + industry, + website, + country_code: countryCode, + company_size: companySize, + source, + twitter, + linkedin_url: linkedinUrl, + phone_number: phoneNumber, + sync_status: syncStatus, + query, + last_activity_at: lastActivityAt, + last_contacted_at: lastContactedAt, + ...(Array.isArray(sendingStatus) && sendingStatus.length && { + ["sending_status[]"]: sendingStatus, + }), + ...(Array.isArray(verificationStatus) && verificationStatus.length && { + ["verification_status[]"]: verificationStatus, + }), + }, + }); + + $.export("$summary", "Successfully retrieved leads"); + return response; + }, +}; diff --git a/components/hunter/actions/update-lead/update-lead.mjs b/components/hunter/actions/update-lead/update-lead.mjs new file mode 100644 index 0000000000000..cfbfa7621bbfa --- /dev/null +++ b/components/hunter/actions/update-lead/update-lead.mjs @@ -0,0 +1,96 @@ +import app from "../../hunter.app.mjs"; + +export default { + key: "hunter-update-lead", + name: "Update Lead", + description: "Update an existing lead in your Hunter account. [See the documentation](https://hunter.io/api-documentation/v2#update-lead).", + version: "0.0.1", + type: "action", + props: { + app, + leadId: { + propDefinition: [ + app, + "leadId", + ], + }, + email: { + propDefinition: [ + app, + "email", + ], + optional: true, + }, + firstName: { + propDefinition: [ + app, + "firstName", + ], + optional: true, + }, + lastName: { + propDefinition: [ + app, + "lastName", + ], + optional: true, + }, + position: { + propDefinition: [ + app, + "position", + ], + }, + company: { + propDefinition: [ + app, + "company", + ], + optional: true, + }, + website: { + propDefinition: [ + app, + "website", + ], + }, + phoneNumber: { + propDefinition: [ + app, + "phoneNumber", + ], + }, + }, + async run({ $ }) { + const { + app, + leadId, + email, + firstName, + lastName, + position, + company, + website, + phoneNumber, + } = this; + + await app.updateLead({ + $, + leadId, + data: { + email, + first_name: firstName, + last_name: lastName, + position, + company, + website, + phone_number: phoneNumber, + }, + }); + + $.export("$summary", "Successfully updated lead"); + return { + success: true, + }; + }, +}; diff --git a/components/hunter/hunter.app.mjs b/components/hunter/hunter.app.mjs index 4eb07c086c14e..522467104f7cb 100644 --- a/components/hunter/hunter.app.mjs +++ b/components/hunter/hunter.app.mjs @@ -1,11 +1,293 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "hunter", - propDefinitions: {}, + propDefinitions: { + domain: { + type: "string", + label: "Domain", + description: "Domain name from which you want to find the email addresses. For example, 'stripe.com'.", + }, + company: { + type: "string", + label: "Company", + description: "The company name from which you want to find the email addresses. For example, 'stripe'.", + }, + type: { + type: "string", + label: "Type", + description: "Get only personal or generic email addresses.", + options: [ + "personal", + "generic", + ], + optional: true, + }, + email: { + type: "string", + label: "Email", + description: "The email address you want to verify or find information about.", + }, + firstName: { + type: "string", + label: "First Name", + description: "The person's first name.", + }, + lastName: { + type: "string", + label: "Last Name", + description: "The person's last name.", + }, + limit: { + type: "integer", + label: "Limit", + description: "Specifies the max number of email addresses to return. The default is `100`.", + default: 100, + min: 1, + max: 100, + }, + leadId: { + type: "string", + label: "Lead ID", + description: "The unique identifier of the lead.", + async options({ prevContext: { offset = 0 } }) { + const DEFAULT_LIMIT = 100; + if (offset === null) { + return []; + } + const { data: { leads } } = await this.listLeads({ + params: { + limit: DEFAULT_LIMIT, + offset, + }, + }); + const options = leads.map(({ + id: value, + email: label, + }) => ({ + label, + value, + })); + return { + options, + context: { + offset: leads.length === DEFAULT_LIMIT + ? offset + DEFAULT_LIMIT + : null, + }, + }; + }, + }, + position: { + type: "string", + label: "Position", + description: "The person's position in the company.", + optional: true, + }, + website: { + type: "string", + label: "Website", + description: "The website URL of the company.", + optional: true, + }, + phoneNumber: { + type: "string", + label: "Phone Number", + description: "The person's phone number.", + optional: true, + }, + industry: { + type: "string", + label: "Industry", + description: "The industry of the company.", + optional: true, + }, + countryCode: { + type: "string", + label: "Country Code", + description: "The country code (ISO 3166-1 alpha-2 standard).", + optional: true, + }, + companySize: { + type: "string", + label: "Company Size", + description: "The size of the company.", + optional: true, + }, + source: { + type: "string", + label: "Source", + description: "The source of the lead.", + optional: true, + }, + twitter: { + type: "string", + label: "Twitter", + description: "The Twitter handle.", + optional: true, + }, + linkedinUrl: { + type: "string", + label: "LinkedIn URL", + description: "The LinkedIn profile URL.", + optional: true, + }, + leadsListId: { + type: "string", + label: "Leads List ID", + description: "Only returns the leads belonging to this list.", + async options({ prevContext: { offset = 0 } }) { + const DEFAULT_LIMIT = 100; + if (offset === null) { + return []; + } + const { data: { leads_lists: leadsLists } } = await this.listLeadsLists({ + params: { + limit: DEFAULT_LIMIT, + offset, + }, + }); + const options = leadsLists.map(({ + id: value, + name: label, + }) => ({ + label, + value, + })); + return { + options, + context: { + offset: leadsLists.length === DEFAULT_LIMIT + ? offset + DEFAULT_LIMIT + : null, + }, + }; + }, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + getUrl(path) { + return `https://api.hunter.io/v2${path}`; + }, + getHeaders(headers) { + return { + ...headers, + "X-API-KEY": this.$auth.api_key, + }; + }, + _makeRequest({ + $ = this, path, headers, ...args + } = {}) { + return axios($, { + ...args, + url: this.getUrl(path), + headers: this.getHeaders(headers), + }); + }, + post(args = {}) { + return this._makeRequest({ + ...args, + method: "POST", + }); + }, + put(args = {}) { + return this._makeRequest({ + ...args, + method: "PUT", + }); + }, + delete(args = {}) { + return this._makeRequest({ + ...args, + method: "DELETE", + }); + }, + domainSearch(args = {}) { + return this._makeRequest({ + path: "/domain-search", + ...args, + }); + }, + emailFinder(args = {}) { + return this._makeRequest({ + path: "/email-finder", + ...args, + }); + }, + emailVerifier(args = {}) { + return this._makeRequest({ + path: "/email-verifier", + ...args, + }); + }, + combinedEnrichment(args = {}) { + return this._makeRequest({ + path: "/combined/find", + ...args, + }); + }, + emailCount(args = {}) { + return this._makeRequest({ + path: "/email-count", + ...args, + }); + }, + accountInformation(args = {}) { + return this._makeRequest({ + path: "/account", + ...args, + }); + }, + listLeadsLists(args = {}) { + return this._makeRequest({ + path: "/leads_lists", + ...args, + }); + }, + getLeadsList({ + leadsListId, ...args + } = {}) { + return this._makeRequest({ + path: `/leads_lists/${leadsListId}`, + ...args, + }); + }, + listLeads(args = {}) { + return this._makeRequest({ + path: "/leads", + ...args, + }); + }, + getLead({ + leadId, ...args + } = {}) { + return this._makeRequest({ + path: `/leads/${leadId}`, + ...args, + }); + }, + createLead(args = {}) { + return this.post({ + path: "/leads", + ...args, + }); + }, + updateLead({ + leadId, ...args + } = {}) { + return this.put({ + path: `/leads/${leadId}`, + ...args, + }); + }, + deleteLead({ + leadId, ...args + } = {}) { + return this.delete({ + path: `/leads/${leadId}`, + ...args, + }); }, }, }; diff --git a/components/hunter/package.json b/components/hunter/package.json index 0e80b6e334cbc..1751a77c9a0ab 100644 --- a/components/hunter/package.json +++ b/components/hunter/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/hunter", - "version": "0.6.0", + "version": "0.7.0", "description": "Pipedream hunter Components", "main": "hunter.app.mjs", "keywords": [ @@ -13,6 +13,6 @@ "access": "public" }, "dependencies": { - "@pipedream/platform": "^3.0.0" + "@pipedream/platform": "^3.0.3" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 62e32450448a9..7ec1b69a9a0c4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6377,7 +6377,7 @@ importers: components/hunter: dependencies: '@pipedream/platform': - specifier: ^3.0.0 + specifier: ^3.0.3 version: 3.0.3 components/hygraph: {} @@ -36105,8 +36105,6 @@ snapshots: '@putout/operator-filesystem': 5.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3)) '@putout/operator-json': 2.2.0 putout: 36.13.1(eslint@8.57.1)(typescript@5.6.3) - transitivePeerDependencies: - - supports-color '@putout/operator-regexp@1.0.0(putout@36.13.1(eslint@8.57.1)(typescript@5.6.3))': dependencies: