diff --git a/components/leadiq/actions/find-contact/find-contact.mjs b/components/leadiq/actions/find-contact/find-contact.mjs new file mode 100644 index 0000000000000..cb3698b04e284 --- /dev/null +++ b/components/leadiq/actions/find-contact/find-contact.mjs @@ -0,0 +1,88 @@ +import app from "../../leadiq.app.mjs"; +import queries from "../../common/queries.mjs"; + +export default { + key: "leadiq-find-contact", + name: "Find Contact", + description: "Searches for contact information based on user-defined props which may include identifiers such as name, email, or company. Returns the contact data if a match is found within the LeadIQ database. [See the documentation](https://developer.leadiq.com/#query-searchPeople)", + version: "0.0.1", + type: "action", + props: { + app, + fullName: { + type: "string", + label: "Full Name", + description: "The full name of the contact.", + optional: true, + }, + email: { + type: "string", + label: "Email", + description: "The email of the contact", + optional: true, + }, + companyName: { + type: "string", + label: "Company Name", + description: "The name of the company.", + optional: true, + }, + searchInPastCompanies: { + type: "boolean", + label: "Search in Past Companies", + description: "If enabled, the search will include past companies.", + optional: true, + }, + }, + methods: { + searchContact({ + data, ...args + } = {}) { + return this.app.post({ + ...args, + data: { + ...data, + query: queries.searchPeople, + }, + }); + }, + }, + async run({ $ }) { + const { + searchContact, + fullName, + email, + companyName, + searchInPastCompanies, + } = this; + + const { data: { searchPeople: { results } } } = await searchContact({ + $, + data: { + variables: { + input: { + limit: 1, + fullName, + email, + ...(companyName && { + company: { + name: companyName, + searchInPastCompanies, + }, + }), + }, + }, + }, + }); + + if (!results.length) { + $.export("$summary", `No contact information found for \`${fullName || email || companyName}\``); + return { + success: false, + }; + } + + $.export("$summary", `Successfully found \`${results.length}\` contact(s)`); + return results; + }, +}; diff --git a/components/leadiq/common/queries.mjs b/components/leadiq/common/queries.mjs new file mode 100644 index 0000000000000..277865f3b2a64 --- /dev/null +++ b/components/leadiq/common/queries.mjs @@ -0,0 +1,59 @@ +export default { + searchPeople: ` + query SearchPeople($input: SearchPeopleInput!) { + searchPeople(input: $input) { + results { + _id + name { + first + fullName + last + middle + } + currentPositions { + companyId + title + updatedAt + emails { + type + status + updatedAt + value + } + companyInfo { + name + alternativeNames + domain + description + emailDomains + type + phones + country + } + } + pastPositions { + companyId + title + updatedAt + emails { + type + status + updatedAt + value + } + companyInfo { + name + alternativeNames + domain + description + emailDomains + type + phones + country + } + } + } + } + } + `, +}; diff --git a/components/leadiq/leadiq.app.mjs b/components/leadiq/leadiq.app.mjs index b814dda966b3a..25afabca1d7fe 100644 --- a/components/leadiq/leadiq.app.mjs +++ b/components/leadiq/leadiq.app.mjs @@ -1,11 +1,36 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "leadiq", - propDefinitions: {}, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://api.leadiq.com/graphql"; + }, + getAuth() { + return { + username: this.$auth.api_key, + password: "", + }; + }, + async _makeRequest({ + $ = this, ...args + } = {}) { + const response = await axios($, { + ...args, + url: this._baseUrl(), + auth: this.getAuth(), + }); + if (response?.errors?.length) { + throw new Error(JSON.stringify(response.errors)); + } + return response; + }, + post(args = {}) { + return this._makeRequest({ + method: "POST", + ...args, + }); }, }, }; diff --git a/components/leadiq/package.json b/components/leadiq/package.json index 76a5e2fe76489..930b0315c1a69 100644 --- a/components/leadiq/package.json +++ b/components/leadiq/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/leadiq", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream LeadIQ Components", "main": "leadiq.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "1.6.5" } -} \ No newline at end of file +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 756799c16b18e..ceb64e5e8e723 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4559,7 +4559,10 @@ importers: '@pipedream/platform': 1.5.1 components/leadiq: - specifiers: {} + specifiers: + '@pipedream/platform': 1.6.5 + dependencies: + '@pipedream/platform': 1.6.5 components/leap: specifiers: