-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* leadoku init * wip * new components * pnpm-lock.yaml
- Loading branch information
1 parent
8baf6c1
commit a654cca
Showing
6 changed files
with
151 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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 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/leadoku", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Pipedream Leadoku Components", | ||
"main": "leadoku.app.mjs", | ||
"keywords": [ | ||
|
@@ -11,5 +11,8 @@ | |
"author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@pipedream/platform": "^3.0.0" | ||
} | ||
} | ||
} |
This file contains 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 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 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"; | ||
}, | ||
}, | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.