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
41 changes: 37 additions & 4 deletions components/leadoku/leadoku.app.mjs
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,
});
},
},
};
};
7 changes: 5 additions & 2 deletions components/leadoku/package.json
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": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.0"
}
}
}
55 changes: 55 additions & 0 deletions components/leadoku/sources/common/base.mjs
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 components/leadoku/sources/new-connection/new-connection.mjs
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 components/leadoku/sources/new-responder/new-responder.mjs
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";
},
},
};
Loading