Skip to content

Commit f1bb8ac

Browse files
authored
[Components] leadiq (#11923)
* Tested component * pnpm-lock.yaml
1 parent d5353ad commit f1bb8ac

File tree

5 files changed

+185
-7
lines changed

5 files changed

+185
-7
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import app from "../../leadiq.app.mjs";
2+
import queries from "../../common/queries.mjs";
3+
4+
export default {
5+
key: "leadiq-find-contact",
6+
name: "Find Contact",
7+
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)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
fullName: {
13+
type: "string",
14+
label: "Full Name",
15+
description: "The full name of the contact.",
16+
optional: true,
17+
},
18+
email: {
19+
type: "string",
20+
label: "Email",
21+
description: "The email of the contact",
22+
optional: true,
23+
},
24+
companyName: {
25+
type: "string",
26+
label: "Company Name",
27+
description: "The name of the company.",
28+
optional: true,
29+
},
30+
searchInPastCompanies: {
31+
type: "boolean",
32+
label: "Search in Past Companies",
33+
description: "If enabled, the search will include past companies.",
34+
optional: true,
35+
},
36+
},
37+
methods: {
38+
searchContact({
39+
data, ...args
40+
} = {}) {
41+
return this.app.post({
42+
...args,
43+
data: {
44+
...data,
45+
query: queries.searchPeople,
46+
},
47+
});
48+
},
49+
},
50+
async run({ $ }) {
51+
const {
52+
searchContact,
53+
fullName,
54+
email,
55+
companyName,
56+
searchInPastCompanies,
57+
} = this;
58+
59+
const { data: { searchPeople: { results } } } = await searchContact({
60+
$,
61+
data: {
62+
variables: {
63+
input: {
64+
limit: 1,
65+
fullName,
66+
email,
67+
...(companyName && {
68+
company: {
69+
name: companyName,
70+
searchInPastCompanies,
71+
},
72+
}),
73+
},
74+
},
75+
},
76+
});
77+
78+
if (!results.length) {
79+
$.export("$summary", `No contact information found for \`${fullName || email || companyName}\``);
80+
return {
81+
success: false,
82+
};
83+
}
84+
85+
$.export("$summary", `Successfully found \`${results.length}\` contact(s)`);
86+
return results;
87+
},
88+
};
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
export default {
2+
searchPeople: `
3+
query SearchPeople($input: SearchPeopleInput!) {
4+
searchPeople(input: $input) {
5+
results {
6+
_id
7+
name {
8+
first
9+
fullName
10+
last
11+
middle
12+
}
13+
currentPositions {
14+
companyId
15+
title
16+
updatedAt
17+
emails {
18+
type
19+
status
20+
updatedAt
21+
value
22+
}
23+
companyInfo {
24+
name
25+
alternativeNames
26+
domain
27+
description
28+
emailDomains
29+
type
30+
phones
31+
country
32+
}
33+
}
34+
pastPositions {
35+
companyId
36+
title
37+
updatedAt
38+
emails {
39+
type
40+
status
41+
updatedAt
42+
value
43+
}
44+
companyInfo {
45+
name
46+
alternativeNames
47+
domain
48+
description
49+
emailDomains
50+
type
51+
phones
52+
country
53+
}
54+
}
55+
}
56+
}
57+
}
58+
`,
59+
};

components/leadiq/leadiq.app.mjs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,36 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "leadiq",
4-
propDefinitions: {},
56
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
7+
_baseUrl() {
8+
return "https://api.leadiq.com/graphql";
9+
},
10+
getAuth() {
11+
return {
12+
username: this.$auth.api_key,
13+
password: "",
14+
};
15+
},
16+
async _makeRequest({
17+
$ = this, ...args
18+
} = {}) {
19+
const response = await axios($, {
20+
...args,
21+
url: this._baseUrl(),
22+
auth: this.getAuth(),
23+
});
24+
if (response?.errors?.length) {
25+
throw new Error(JSON.stringify(response.errors));
26+
}
27+
return response;
28+
},
29+
post(args = {}) {
30+
return this._makeRequest({
31+
method: "POST",
32+
...args,
33+
});
934
},
1035
},
1136
};

components/leadiq/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/leadiq",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream LeadIQ Components",
55
"main": "leadiq.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "1.6.5"
1417
}
15-
}
18+
}

pnpm-lock.yaml

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)