-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New Components - leadoku #12625
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
New Components - leadoku #12625
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
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,44 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| type: "app", | ||
| app: "leadoku", | ||
| propDefinitions: {}, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| _baseUrl() { | ||
| return "https://api.growth-x.com/growth/apis"; | ||
| }, | ||
| _makeRequest(opts = {}) { | ||
| const { | ||
| $ = this, | ||
| path, | ||
| params, | ||
| ...otherOpts | ||
| } = opts; | ||
| return axios($, { | ||
| url: `${this._baseUrl()}${path}`, | ||
| params: { | ||
| ...params, | ||
| analytics_code: `${this.$auth.analytics_code}`, | ||
| }, | ||
| ...otherOpts, | ||
| }); | ||
| }, | ||
| getNewConnections(opts = {}) { | ||
| return this._makeRequest({ | ||
| params: { | ||
| method: "new_connections", | ||
| }, | ||
| ...opts, | ||
| }); | ||
| }, | ||
| getNewResponders(opts = {}) { | ||
| return this._makeRequest({ | ||
| params: { | ||
| method: "new_responders", | ||
| }, | ||
| ...opts, | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
| }; |
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
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,55 @@ | ||
| import leadoku from "../../leadoku.app.mjs"; | ||
| import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| props: { | ||
| leadoku, | ||
| db: "$.service.db", | ||
| timer: { | ||
| type: "$.interface.timer", | ||
| default: { | ||
| intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, | ||
| }, | ||
| }, | ||
| }, | ||
| methods: { | ||
| _getLastScannedDate() { | ||
| return this.db.get("lastScannedDate") || 0; | ||
| }, | ||
| _setLastScannedDate(lastScannedDate) { | ||
| this.db.set("lastScannedDate", lastScannedDate); | ||
| }, | ||
| getResourceFn() { | ||
| throw new Error("getResourceFn is not implemented"); | ||
| }, | ||
| getTsField() { | ||
| throw new Error("getTsField is not implemented"); | ||
| }, | ||
| getSummary() { | ||
| throw new Error("getSummary is not implemented"); | ||
| }, | ||
| generateMeta(item) { | ||
| const ts = Date.parse(item[this.getTsField()]); | ||
| return { | ||
| id: `${item.receiver_id}-${ts}`, | ||
| summary: this.getSummary(), | ||
| ts, | ||
| }; | ||
| }, | ||
| }, | ||
| async run() { | ||
| const lastScannedDate = this._getLastScannedDate(); | ||
| let maxScannedDate = lastScannedDate; | ||
| const resourceFn = this.getResourceFn(); | ||
| const { data } = await resourceFn(); | ||
| for (const item of data) { | ||
| const ts = Date.parse(item[this.getTsField()]); | ||
| if (ts > lastScannedDate) { | ||
| maxScannedDate = Math.max(maxScannedDate, ts); | ||
| const meta = this.generateMeta(item); | ||
| this.$emit(item, meta); | ||
| } | ||
| } | ||
| this._setLastScannedDate(maxScannedDate); | ||
| }, | ||
| }; | ||
23 changes: 23 additions & 0 deletions
23
components/leadoku/sources/new-connection/new-connection.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,23 @@ | ||
| import common from "../common/base.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| key: "leadoku-new-connection", | ||
| name: "New Connection", | ||
| description: "Emit new event each time a new connection is made in Leadoku. [See the documentation](https://help.leadoku.io/en/articles/8261580-leadoku-api-for-custom-integrations)", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| methods: { | ||
| ...common.methods, | ||
| getResourceFn() { | ||
| return this.leadoku.getNewConnections; | ||
| }, | ||
| getTsField() { | ||
| return "connection_date"; | ||
| }, | ||
| getSummary() { | ||
| return "New Connection Made"; | ||
| }, | ||
| }, | ||
| }; |
23 changes: 23 additions & 0 deletions
23
components/leadoku/sources/new-responder/new-responder.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,23 @@ | ||
| import common from "../common/base.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| key: "leadoku-new-responder", | ||
| name: "New Responder", | ||
| description: "Emit new event when there is a new responder in Leadoku. [See the documentation](https://help.leadoku.io/en/articles/8261580-leadoku-api-for-custom-integrations)", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| methods: { | ||
| ...common.methods, | ||
| getResourceFn() { | ||
| return this.leadoku.getNewResponders; | ||
| }, | ||
| getTsField() { | ||
| return "message_scan_date"; | ||
| }, | ||
| getSummary() { | ||
| return "New Responder"; | ||
| }, | ||
| }, | ||
| }; |
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.