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] leadiq #11923

Merged
merged 2 commits into from
May 16, 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
88 changes: 88 additions & 0 deletions components/leadiq/actions/find-contact/find-contact.mjs
Original file line number Diff line number Diff line change
@@ -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;
},
};
59 changes: 59 additions & 0 deletions components/leadiq/common/queries.mjs
Original file line number Diff line number Diff line change
@@ -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
}
}
}
}
}
`,
};
33 changes: 29 additions & 4 deletions components/leadiq/leadiq.app.mjs
Original file line number Diff line number Diff line change
@@ -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,
});
},
},
};
7 changes: 5 additions & 2 deletions components/leadiq/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/leadiq",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream LeadIQ Components",
"main": "leadiq.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "1.6.5"
}
}
}
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