-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Components] predictleads #17228
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
Merged
Merged
[Components] predictleads #17228
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
components/predictleads/actions/get-technologies/get-technologies.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| }, | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
36 changes: 36 additions & 0 deletions
36
components/predictleads/actions/lookup-company/lookup-company.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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}\`.`); | ||
| } | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return response; | ||
| }, | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
30 changes: 30 additions & 0 deletions
30
...redictleads/actions/retrieve-companies-by-technology/retrieve-companies-by-technology.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| }, | ||
| }; |
31 changes: 31 additions & 0 deletions
31
...ts/predictleads/actions/retrieve-news-events-by-domain/retrieve-news-events-by-domain.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| }, | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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": [ | ||
|
|
@@ -11,5 +11,8 @@ | |
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.1.0" | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| }, | ||
| }, | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.