Skip to content

Commit d73162c

Browse files
authored
Ditlead new components (#16565)
* Package version * Base and generic webhook source * List Campaigns action * add newline * pnpm
1 parent 3d82722 commit d73162c

File tree

11 files changed

+162
-11
lines changed

11 files changed

+162
-11
lines changed

components/catch_all_verifier/catch_all_verifier.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import ditlead from "../../ditlead.app.mjs";
2+
3+
export default {
4+
key: "ditlead-list-campaigns",
5+
name: "List Campaigns",
6+
description: "List campaigns in Ditlead. [See the documentation](https://ditlead.com/developer/api#tag/Campaign/paths/~1v1~1campaign/get)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
ditlead,
11+
},
12+
async run({ $ }) {
13+
const { data } = await this.ditlead.listCampaigns({
14+
$,
15+
});
16+
17+
$.export("$summary", `Successfully listed ${data.length} campaigns`);
18+
return data;
19+
},
20+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export const WEBHOOK_EVENT_TYPES = [
2+
"email.bounced",
3+
"email.opened",
4+
"contact.replied",
5+
"contact.created",
6+
"contact.contacted",
7+
"contact.started_campaign",
8+
"contact.restarted_campaign",
9+
"contact.completed_campaign",
10+
"contact.unsubscribed",
11+
"campaign.scheduled",
12+
"campaign.started",
13+
"campaign.paused",
14+
"campaign.restarted",
15+
"campaign.completed",
16+
"campaign.limit",
17+
"campaign.errored",
18+
];

components/ditlead/ditlead.app.mjs

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,41 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "ditlead",
46
propDefinitions: {},
57
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
8+
_makeRequest({
9+
$, headers, ...args
10+
}) {
11+
return axios($, {
12+
baseURL: "https://api.ditlead.com/v1",
13+
headers: {
14+
...headers,
15+
Authorization: `Bearer ${this.$auth.api_key}`,
16+
},
17+
...args,
18+
});
19+
},
20+
createWebhook(args) {
21+
return this._makeRequest({
22+
method: "POST",
23+
url: "/webhook",
24+
...args,
25+
});
26+
},
27+
deleteWebhook(args) {
28+
return this._makeRequest({
29+
method: "DELETE",
30+
url: "/webhook",
31+
...args,
32+
});
33+
},
34+
listCampaigns(args) {
35+
return this._makeRequest({
36+
url: "/campaign",
37+
...args,
38+
});
939
},
1040
},
11-
};
41+
};

components/ditlead/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/ditlead",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream DitLead Components",
55
"main": "ditlead.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "3.0.3"
1417
}
15-
}
18+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import ditlead from "../../ditlead.app.mjs";
2+
3+
export default {
4+
props: {
5+
ditlead,
6+
db: "$.service.db",
7+
http: "$.interface.http",
8+
},
9+
hooks: {
10+
async activate() {
11+
const { id } = await this.ditlead.createWebhook({
12+
data: {
13+
url: this.http.endpoint,
14+
name: "Pipedream Source",
15+
eventId: this.getEventTypes(),
16+
},
17+
});
18+
this._setWebhookId(id);
19+
},
20+
async deactivate() {
21+
await this.ditlead.deleteWebhook({
22+
data: {
23+
subscriptionId: this._getWebhookId(),
24+
},
25+
});
26+
},
27+
},
28+
methods: {
29+
getEventTypes() {
30+
throw new Error("Event types not specified for this component");
31+
},
32+
_setWebhookId(value) {
33+
this.db.set("webhookId", value);
34+
},
35+
_getWebhookId() {
36+
return this.db.get("webhookId");
37+
},
38+
39+
},
40+
async run(event) {
41+
const { body } = event;
42+
const ts = Date.now();
43+
this.$emit(body, {
44+
id: ts,
45+
summary: "New event",
46+
ts,
47+
});
48+
},
49+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import common from "../common/base.mjs";
2+
import { WEBHOOK_EVENT_TYPES } from "../../common/constants.mjs";
3+
4+
export default {
5+
...common,
6+
key: "ditlead-new-webhook-event",
7+
name: "New Webhook Event",
8+
description: "Emit new events according to the selected event types. [See the documentation](https://ditlead.com/developer/api#tag/Webhook/paths/~1v1~1webhook/post)",
9+
version: "0.0.1",
10+
type: "source",
11+
dedupe: "unique",
12+
props: {
13+
...common.props,
14+
eventTypes: {
15+
type: "string[]",
16+
label: "Event Types",
17+
description: "Select one or more event types to listen for.",
18+
options: WEBHOOK_EVENT_TYPES,
19+
},
20+
},
21+
methods: {
22+
...common.methods,
23+
getEventTypes() {
24+
return this.eventTypes;
25+
},
26+
},
27+
};

components/membado/membado.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/planpoint/planpoint.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/szybkisms/szybkisms.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

0 commit comments

Comments
 (0)