Skip to content

Commit a4d7535

Browse files
committed
[ACTION] Lusha: Prospecting APIs #14992
Actions - Contact Search - Company Search - Contact Enrich - Company Enrich
1 parent 5ac9a44 commit a4d7535

File tree

9 files changed

+250
-451
lines changed

9 files changed

+250
-451
lines changed
Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
11
import lusha from "../../lusha.app.mjs";
2-
import { axios } from "@pipedream/platform";
32

43
export default {
54
key: "lusha-company-enrich",
65
name: "Enrich Companies",
7-
description: "Enriches company information based on provided company IDs. [See the documentation]()",
8-
version: "0.0.{{ts}}",
6+
description: "Enriches company information based on provided company IDs. [See the documentation](https://www.lusha.com/docs/#company-enrich)",
7+
version: "0.0.1",
98
type: "action",
109
props: {
1110
lusha,
12-
enrichCompanyRequestId: {
11+
requestId: {
1312
propDefinition: [
1413
lusha,
15-
"enrichCompanyRequestId",
14+
"requestId",
1615
],
16+
label: "Company Request ID",
17+
description: "The request ID generated from the company search response.",
1718
},
18-
enrichCompanyIds: {
19+
companiesIds: {
1920
propDefinition: [
2021
lusha,
21-
"enrichCompanyIds",
22+
"companiesIds",
2223
],
2324
},
2425
},
2526
async run({ $ }) {
2627
const response = await this.lusha.enrichCompanies({
27-
enrichCompanyRequestId: this.enrichCompanyRequestId,
28-
enrichCompanyIds: this.enrichCompanyIds,
28+
$,
29+
params: {
30+
requestId: this.requestId,
31+
companiesIds: this.companiesIds,
32+
},
2933
});
30-
$.export("$summary", `Successfully enriched ${this.enrichCompanyIds.length} companies`);
34+
$.export("$summary", `Successfully enriched ${this.companiesIds.length} companies`);
3135
return response;
3236
},
3337
};

components/lusha/actions/company-search/company-search.mjs

Lines changed: 58 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,102 @@
1+
import { parseObject } from "../../common/utils.mjs";
12
import lusha from "../../lusha.app.mjs";
2-
import { axios } from "@pipedream/platform";
33

44
export default {
55
key: "lusha-company-search",
66
name: "Search Companies",
7-
description: "Search for companies using various filters. [See the documentation](https://www.lusha.com/docs/)",
8-
version: "0.0.{{ts}}",
7+
description: "Search for companies using various filters. [See the documentation](https://www.lusha.com/docs/#contactcompany-search)",
8+
version: "0.0.1",
99
type: "action",
1010
props: {
1111
lusha,
12-
searchCompanyNames: {
12+
names: {
1313
propDefinition: [
1414
lusha,
15-
"searchCompanyNames",
15+
"companyNames",
1616
],
17+
optional: true,
1718
},
18-
searchCompanyDomains: {
19+
domains: {
1920
propDefinition: [
2021
lusha,
21-
"searchCompanyDomains",
22+
"domains",
2223
],
24+
optional: true,
2325
},
24-
searchCompanyLocations: {
26+
locations: {
2527
propDefinition: [
2628
lusha,
27-
"searchCompanyLocations",
29+
"locations",
2830
],
31+
optional: true,
2932
},
30-
searchCompanySizes: {
33+
sizes: {
3134
propDefinition: [
3235
lusha,
33-
"searchCompanySizes",
36+
"sizes",
3437
],
38+
optional: true,
3539
},
36-
searchCompanyRevenues: {
40+
revenues: {
3741
propDefinition: [
3842
lusha,
39-
"searchCompanyRevenues",
43+
"revenues",
4044
],
45+
optional: true,
4146
},
42-
searchCompanySicCodes: {
47+
sicCodes: {
4348
propDefinition: [
4449
lusha,
45-
"searchCompanySicCodes",
50+
"sicCodes",
4651
],
52+
optional: true,
4753
},
48-
searchCompanyNaicsCodes: {
54+
naicsCodes: {
4955
propDefinition: [
5056
lusha,
51-
"searchCompanyNaicsCodes",
57+
"naicsCodes",
5258
],
59+
optional: true,
60+
},
61+
limit: {
62+
type: "string",
63+
label: "Limit",
64+
description: "The maximum number of results to return. **This feature is used to avoid timeouts due to very long returns.**",
5365
},
5466
},
5567
async run({ $ }) {
5668
try {
57-
const response = await this.lusha.searchCompanies({
58-
searchCompanyNames: this.searchCompanyNames,
59-
searchCompanyDomains: this.searchCompanyDomains,
60-
searchCompanyLocations: this.searchCompanyLocations,
61-
searchCompanySizes: this.searchCompanySizes,
62-
searchCompanyRevenues: this.searchCompanyRevenues,
63-
searchCompanySicCodes: this.searchCompanySicCodes,
64-
searchCompanyNaicsCodes: this.searchCompanyNaicsCodes,
69+
const include = {};
70+
71+
if (this.names) include.names = parseObject(this.names);
72+
if (this.domains) include.domains = parseObject(this.domains);
73+
if (this.locations) include.locations = parseObject(this.locations);
74+
if (this.sizes) include.sizes = parseObject(this.sizes);
75+
if (this.revenues) include.revenues = parseObject(this.revenues);
76+
if (this.sicCodes) include.sicCodes = parseObject(this.sicCodes);
77+
if (this.naicsCodes) include.naicsCodes = parseObject(this.naicsCodes);
78+
79+
const response = this.lusha.paginate({
80+
$,
81+
maxResults: this.limit,
82+
fn: this.lusha.searchCompanies,
83+
data: {
84+
filters: {
85+
companies: {
86+
include,
87+
},
88+
},
89+
},
6590
});
6691

67-
const totalResults = response.totalResults;
68-
$.export("$summary", `Successfully retrieved ${totalResults} companies`);
69-
return response;
92+
const responseArray = [];
93+
94+
for await (const item of response) {
95+
responseArray.push(item);
96+
}
97+
98+
$.export("$summary", `Successfully retrieved ${responseArray.length} companies`);
99+
return responseArray;
70100
} catch (error) {
71101
$.export("$summary", "Failed to search companies");
72102
throw error;

components/lusha/actions/contact-enrich/contact-enrich.mjs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,35 @@ import lusha from "../../lusha.app.mjs";
33
export default {
44
key: "lusha-contact-enrich",
55
name: "Enrich Contacts",
6-
description: "Enriches contacts based on provided IDs. [See the documentation](https://www.lusha.com/docs/)",
7-
version: "0.0.{{ts}}",
6+
description: "Enriches contacts based on provided IDs. [See the documentation](https://www.lusha.com/docs/#contact-enrich)",
7+
version: "0.0.1",
88
type: "action",
99
props: {
10-
lusha: {
11-
type: "app",
12-
app: "lusha",
13-
},
14-
enrichContactRequestId: {
10+
lusha,
11+
requestId: {
1512
propDefinition: [
16-
"lusha",
17-
"enrichContactRequestId",
13+
lusha,
14+
"requestId",
1815
],
16+
label: "Company Request ID",
17+
description: "The request ID generated from the company search response.",
1918
},
20-
enrichContactIds: {
19+
contactIds: {
2120
propDefinition: [
22-
"lusha",
23-
"enrichContactIds",
21+
lusha,
22+
"contactIds",
2423
],
2524
},
2625
},
2726
async run({ $ }) {
2827
const response = await this.lusha.enrichContacts({
29-
enrichContactRequestId: this.enrichContactRequestId,
30-
enrichContactIds: this.enrichContactIds,
28+
$,
29+
params: {
30+
requestId: this.requestId,
31+
contactIds: this.contactIds,
32+
},
3133
});
32-
$.export("$summary", `Successfully enriched ${this.enrichContactIds.length} contacts`);
34+
$.export("$summary", `Successfully enriched ${this.contactIds.length} contacts`);
3335
return response;
3436
},
3537
};
Lines changed: 47 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,98 @@
1+
import { parseObject } from "../../common/utils.mjs";
12
import lusha from "../../lusha.app.mjs";
2-
import { axios } from "@pipedream/platform";
33

44
export default {
55
key: "lusha-contact-search",
66
name: "Search Contacts",
7-
description: "Search for contacts using various filters. [See the documentation](https://www.lusha.com/docs/)",
8-
version: "0.0.{{ts}}",
7+
description: "Search for contacts using various filters. [See the documentation](https://www.lusha.com/docs/#contactcompany-search)",
8+
version: "0.0.1",
99
type: "action",
1010
props: {
1111
lusha,
12-
searchContactNames: {
12+
names: {
1313
propDefinition: [
1414
lusha,
15-
"searchContactNames",
15+
"contactNames",
1616
],
17+
label: "Contact Names",
18+
description: "Names of contacts to search.",
1719
},
18-
searchContactJobTitles: {
20+
jobTitles: {
1921
propDefinition: [
2022
lusha,
21-
"searchContactJobTitles",
23+
"jobTitles",
2224
],
2325
},
24-
searchContactJobTitlesExactMatch: {
26+
jobTitlesExactMatch: {
2527
propDefinition: [
2628
lusha,
27-
"searchContactJobTitlesExactMatch",
29+
"jobTitlesExactMatch",
2830
],
2931
},
30-
searchContactCountries: {
32+
countries: {
3133
propDefinition: [
3234
lusha,
33-
"searchContactCountries",
35+
"countries",
3436
],
3537
},
36-
searchContactSeniority: {
38+
seniority: {
3739
propDefinition: [
3840
lusha,
39-
"searchContactSeniority",
41+
"seniority",
4042
],
4143
},
42-
searchContactDepartments: {
44+
departments: {
4345
propDefinition: [
4446
lusha,
45-
"searchContactDepartments",
47+
"departments",
4648
],
4749
},
48-
searchContactExistingDataPoints: {
50+
existingDataPoints: {
4951
propDefinition: [
5052
lusha,
51-
"searchContactExistingDataPoints",
53+
"existingDataPoints",
5254
],
5355
},
54-
searchContactLocation: {
56+
location: {
5557
propDefinition: [
5658
lusha,
57-
"searchContactLocation",
59+
"location",
5860
],
5961
},
6062
},
6163
async run({ $ }) {
62-
const args = {};
64+
const include = {};
6365

64-
if (this.searchContactNames && this.searchContactNames.length > 0) {
65-
args.searchContactNames = this.searchContactNames;
66-
}
67-
68-
if (this.searchContactJobTitles && this.searchContactJobTitles.length > 0) {
69-
args.searchContactJobTitles = this.searchContactJobTitles;
70-
}
71-
72-
if (
73-
this.searchContactJobTitlesExactMatch &&
74-
this.searchContactJobTitlesExactMatch.length > 0
75-
) {
76-
args.searchContactJobTitlesExactMatch = this.searchContactJobTitlesExactMatch;
77-
}
78-
79-
if (this.searchContactCountries && this.searchContactCountries.length > 0) {
80-
args.searchContactCountries = this.searchContactCountries;
81-
}
82-
83-
if (this.searchContactSeniority && this.searchContactSeniority.length > 0) {
84-
args.searchContactSeniority = this.searchContactSeniority;
85-
}
66+
if (this.names) include.names = parseObject(this.names);
67+
if (this.jobTitles) include.jobTitles = parseObject(this.jobTitles);
68+
if (this.jobTitlesExactMatch)
69+
include.jobTitlesExactMatch = parseObject(this.jobTitlesExactMatch);
70+
if (this.countries) include.countries = parseObject(this.countries);
71+
if (this.seniority) include.seniority = parseObject(this.seniority);
72+
if (this.departments) include.departments = parseObject(this.departments);
73+
if (this.existingDataPoints) include.existingDataPoints = parseObject(this.existingDataPoints);
74+
if (this.location) include.location = parseObject(this.location);
8675

87-
if (this.searchContactDepartments && this.searchContactDepartments.length > 0) {
88-
args.searchContactDepartments = this.searchContactDepartments;
89-
}
76+
const response = this.lusha.paginate({
77+
$,
78+
maxResults: this.limit,
79+
fn: this.lusha.searchContacts,
80+
data: {
81+
filters: {
82+
contacts: {
83+
include,
84+
},
85+
},
86+
},
87+
});
9088

91-
if (
92-
this.searchContactExistingDataPoints &&
93-
this.searchContactExistingDataPoints.length > 0
94-
) {
95-
args.searchContactExistingDataPoints = this.searchContactExistingDataPoints;
96-
}
89+
const responseArray = [];
9790

98-
if (this.searchContactLocation && this.searchContactLocation.length > 0) {
99-
args.searchContactLocation = this.searchContactLocation;
91+
for await (const item of response) {
92+
responseArray.push(item);
10093
}
10194

102-
const response = await this.lusha.searchContacts(args);
103-
104-
$.export("$summary", `Found ${response.totalResults} contacts`);
95+
$.export("$summary", `Found ${responseArray.length} contacts`);
10596
return response;
10697
},
10798
};

0 commit comments

Comments
 (0)