Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import app from "../../predictleads.app.mjs";

export default {
key: "predictleads-get-technologies",
name: "Get Technologies",
description: "Retrieve a list of technologies that PredictLeads tracks. [See the documentation](https://docs.predictleads.com/v3/api_endpoints/technologies_dataset/retrieve_all_tracked_technologies)",
version: "0.0.1",
type: "action",
props: {
app,
},
async run({ $ }) {
const response = await this.app.retrieveTechnologies({
$,
params: {
limit: 1000,
},
});
$.export("$summary", "Successfully retrieved the first page of technologies.");
return response;
},
};
36 changes: 36 additions & 0 deletions components/predictleads/actions/lookup-company/lookup-company.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import app from "../../predictleads.app.mjs";

export default {
key: "predictleads-lookup-company",
name: "Lookup Company By Domain",
description: "Lookup a company by their domain. [See the documentation](https://docs.predictleads.com/v3/api_endpoints/companies_dataset/retrieve_company)",
version: "0.0.1",
type: "action",
props: {
app,
domain: {
propDefinition: [
app,
"domain",
],
},
},
async run({ $ }) {
const {
app,
domain,
} = this;

const response = await app.retrieveCompany({
$,
domain,
});

if (response.data.length > 0) {
$.export("$summary", `Successfully found company for domain \`${domain}\`.`);
} else {
$.export("$summary", `No company found for domain \`${domain}\`.`);
}
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import app from "../../predictleads.app.mjs";

export default {
key: "predictleads-retrieve-companies-by-technology",
name: "Retrieve Companies By Technology",
description: "Retrieve companies that use a specific technology. [See the documentation](https://docs.predictleads.com/v3/api_endpoints/technologies_dataset/retrieve_a_single_technology_by_id)",
version: "0.0.1",
type: "action",
props: {
app,
technologyId: {
propDefinition: [
app,
"technologyId",
],
},
},
async run({ $ }) {
const {
app,
technologyId,
} = this;
const response = await app.retrieveCompaniesByTechnology({
$,
technologyId,
});
$.export("$summary", "Successfully retrieved the first page of companies.");
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import app from "../../predictleads.app.mjs";

export default {
key: "predictleads-retrieve-news-events-by-domain",
name: "Retrieve News Events By Domain",
description: "Retrieve news events for a company by domain. [See the documentation](https://docs.predictleads.com/v3/api_endpoints/news_events_dataset/retrieve_company_s_news_events)",
version: "0.0.1",
type: "action",
props: {
app,
domain: {
description: "The domain of the company to retrieve news events for (e.g., `google.com`).",
propDefinition: [
app,
"domain",
],
},
},
async run({ $ }) {
const {
app,
domain,
} = this;
const response = await app.retrieveNewsEvents({
$,
domain,
});
$.export("$summary", "Successfully retrieved the first page of news events.");
return response;
},
};
7 changes: 5 additions & 2 deletions components/predictleads/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/predictleads",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream PredictLeads Components",
"main": "predictleads.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.0"
}
}
}
155 changes: 151 additions & 4 deletions components/predictleads/predictleads.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,158 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "predictleads",
propDefinitions: {},
propDefinitions: {
domain: {
type: "string",
label: "Domain",
description: "The domain of the company to lookup (e.g., `google.com`).",
},
technologyId: {
type: "string",
label: "Technology",
description: "Select a technology to search for.",
async options({ page }) {
const { data: technologies } = await this.retrieveTechnologies({
params: {
page,
limit: 100,
},
});
return technologies.map(({
id: value,
name: label,
}) => ({
label,
value,
}));
},
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
getUrl(path) {
return `https://predictleads.com/api/v3${path}`;
},
getHeaders(headers) {
return {
"X-Api-Key": this.$auth.api_key,
"X-Api-Token": this.$auth.api_token,
...headers,
};
},
_makeRequest({
$ = this, path, headers, ...args
}) {
return axios($, {
url: this.getUrl(path),
headers: this.getHeaders(headers),
...args,
});
},
retrieveCompany({
domain, ...args
} = {}) {
return this._makeRequest({
path: `/companies/${domain}`,
...args,
});
},
retrieveTechnologies(args = {}) {
return this._makeRequest({
path: "/technologies",
...args,
});
},
retrieveCompaniesByTechnology({
technologyId, ...args
} = {}) {
return this._makeRequest({
path: `/discover/technologies/${technologyId}/technology_detections`,
...args,
});
},
retrieveJobOpenings({
domain, ...args
} = {}) {
return this._makeRequest({
path: `/companies/${domain}/job_openings`,
...args,
});
},
retrieveNewsEvents({
domain, ...args
} = {}) {
return this._makeRequest({
path: `/companies/${domain}/news_events`,
...args,
});
},
retrieveTechnologyDetections({
domain, ...args
} = {}) {
return this._makeRequest({
path: `/companies/${domain}/technology_detections`,
...args,
});
},
retrieveFinancingEvents({
domain, ...args
} = {}) {
return this._makeRequest({
path: `/companies/${domain}/financing_events`,
...args,
});
},
async *getIterations({
resourceFn,
resourceFnArgs,
max = 300,
}) {
let page = 1;
let resourcesCount = 0;
const limit = 100;

while (true) {
const response = await resourceFn({
...resourceFnArgs,
params: {
...resourceFnArgs?.params,
page,
limit,
},
});

const resources = response.data;

if (!resources?.length) {
console.log("No resources found");
return;
}

for (const resource of resources) {
yield resource;
resourcesCount += 1;
if (resourcesCount >= max) {
console.log("Max resources reached");
return;
}
}

if (page * limit > response.meta.count) {
console.log("Page limit reached");
return;
}

page += 1;
}
},
async paginate(args) {
const resources = [];
for await (const resource of this.getIterations(args)) {
resources.push(resource);
}
return resources;
},
},
};
Loading
Loading