@pipedream/reachmail 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/opt-out-recipient-from-list/opt-out-recipient-from-list.mjs +36 -0
- package/package.json +4 -1
- package/reachmail.app.mjs +74 -5
- package/sources/common/base.mjs +49 -0
- package/sources/new-bounce-instant/new-bounce-instant.mjs +22 -0
- package/sources/new-bounce-instant/test-event.mjs +39 -0
- package/sources/new-click-instant/new-click-instant.mjs +22 -0
- package/sources/new-click-instant/test-event.mjs +39 -0
- package/sources/new-open-instant/new-open-instant.mjs +22 -0
- package/sources/new-open-instant/test-event.mjs +39 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import reachmail from "../../reachmail.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "reachmail-opt-out-recipient-from-list",
|
|
5
|
+
name: "Opt Out Recipient From List",
|
|
6
|
+
description: "The action will remove the recipient from the specified list. [See the documentation](https://services.reachmail.net/)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
reachmail,
|
|
11
|
+
recipient: {
|
|
12
|
+
type: "string",
|
|
13
|
+
label: "Recipient Email",
|
|
14
|
+
description: "The email address of the recipient.",
|
|
15
|
+
},
|
|
16
|
+
listId: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
reachmail,
|
|
19
|
+
"listId",
|
|
20
|
+
],
|
|
21
|
+
type: "string",
|
|
22
|
+
description: "The ID of the list from which the recipient should be opted out.",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
async run({ $ }) {
|
|
26
|
+
const response = await this.reachmail.optOutRecipient({
|
|
27
|
+
$,
|
|
28
|
+
listId: this.listId,
|
|
29
|
+
data: {
|
|
30
|
+
Email: this.recipient,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
$.export("$summary", `Successfully opted out ${this.recipient} from list ${this.listId}`);
|
|
34
|
+
return response;
|
|
35
|
+
},
|
|
36
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/reachmail",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Pipedream ReachMail Components",
|
|
5
5
|
"main": "reachmail.app.mjs",
|
|
6
6
|
"keywords": [
|
|
@@ -11,5 +11,8 @@
|
|
|
11
11
|
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
|
|
12
12
|
"publishConfig": {
|
|
13
13
|
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@pipedream/platform": "^1.5.1"
|
|
14
17
|
}
|
|
15
18
|
}
|
package/reachmail.app.mjs
CHANGED
|
@@ -1,11 +1,80 @@
|
|
|
1
|
+
import { axios } from "@pipedream/platform";
|
|
2
|
+
|
|
1
3
|
export default {
|
|
2
4
|
type: "app",
|
|
3
5
|
app: "reachmail",
|
|
4
|
-
propDefinitions: {
|
|
6
|
+
propDefinitions: {
|
|
7
|
+
listId: {
|
|
8
|
+
type: "string[]",
|
|
9
|
+
label: "List ID",
|
|
10
|
+
description: "The list ID related to the new campaign.",
|
|
11
|
+
async options() {
|
|
12
|
+
const data = await this.listLists();
|
|
13
|
+
|
|
14
|
+
return data.map(({
|
|
15
|
+
Id: value, Name: label,
|
|
16
|
+
}) => ({
|
|
17
|
+
label,
|
|
18
|
+
value,
|
|
19
|
+
}));
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
5
23
|
methods: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
24
|
+
_baseUrl() {
|
|
25
|
+
return "https://services.reachmail.net";
|
|
26
|
+
},
|
|
27
|
+
_headers() {
|
|
28
|
+
return {
|
|
29
|
+
"Authorization": `Bearer ${this.$auth.api_token}`,
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
_makeRequest({
|
|
33
|
+
$ = this, path, ...opts
|
|
34
|
+
}) {
|
|
35
|
+
return axios($, {
|
|
36
|
+
url: this._baseUrl() + path,
|
|
37
|
+
headers: this._headers(),
|
|
38
|
+
...opts,
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
createWebhook({
|
|
42
|
+
action, ...opts
|
|
43
|
+
}) {
|
|
44
|
+
return this._makeRequest({
|
|
45
|
+
method: "POST",
|
|
46
|
+
path: `/Webhooks/${action}`,
|
|
47
|
+
...opts,
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
deleteWebhook(action) {
|
|
51
|
+
return this._makeRequest({
|
|
52
|
+
method: "DELETE",
|
|
53
|
+
path: `/Webhooks/${action}`,
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
updateWebhook({
|
|
57
|
+
hookId, ...opts
|
|
58
|
+
}) {
|
|
59
|
+
return this._makeRequest({
|
|
60
|
+
method: "PUT",
|
|
61
|
+
path: `/Webhooks/${hookId}`,
|
|
62
|
+
...opts,
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
listLists() {
|
|
66
|
+
return this._makeRequest({
|
|
67
|
+
path: "/Lists",
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
optOutRecipient({
|
|
71
|
+
listId, ...opts
|
|
72
|
+
}) {
|
|
73
|
+
return this._makeRequest({
|
|
74
|
+
method: "POST",
|
|
75
|
+
path: `/Lists/OptOut/${listId}`,
|
|
76
|
+
...opts,
|
|
77
|
+
});
|
|
9
78
|
},
|
|
10
79
|
},
|
|
11
|
-
};
|
|
80
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import reachmail from "../../reachmail.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
props: {
|
|
5
|
+
reachmail,
|
|
6
|
+
http: "$.interface.http",
|
|
7
|
+
db: "$.service.db",
|
|
8
|
+
},
|
|
9
|
+
methods: {
|
|
10
|
+
_setHookId(Id) {
|
|
11
|
+
this.db.set("hookId", Id);
|
|
12
|
+
},
|
|
13
|
+
_getHookId() {
|
|
14
|
+
return this.db.get("hookId");
|
|
15
|
+
},
|
|
16
|
+
emitData(body) {
|
|
17
|
+
this.$emit(body, {
|
|
18
|
+
id: body.Signature,
|
|
19
|
+
summary: this.getSummary(body),
|
|
20
|
+
ts: Date.parse(body.Timestamp),
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
hooks: {
|
|
25
|
+
async activate() {
|
|
26
|
+
const response = await this.reachmail.createWebhook({
|
|
27
|
+
action: this.getAction(),
|
|
28
|
+
data: {
|
|
29
|
+
Url: this.http.endpoint,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
this._setHookId(response.Id);
|
|
33
|
+
},
|
|
34
|
+
async deactivate() {
|
|
35
|
+
const hookId = this._getHookId();
|
|
36
|
+
|
|
37
|
+
await this.reachmail.updateWebhook({
|
|
38
|
+
hookId,
|
|
39
|
+
data: {
|
|
40
|
+
Url: this.http.endpoint,
|
|
41
|
+
Active: false,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
async run({ body }) {
|
|
47
|
+
this.emitData(body);
|
|
48
|
+
},
|
|
49
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import common from "../common/base.mjs";
|
|
2
|
+
import sampleEmit from "./test-event.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
...common,
|
|
6
|
+
key: "reachmail-new-bounce-instant",
|
|
7
|
+
name: "New Bounce Instant",
|
|
8
|
+
description: "Emit new event when a recipient's email address bounces.",
|
|
9
|
+
version: "0.0.1",
|
|
10
|
+
type: "source",
|
|
11
|
+
dedupe: "unique",
|
|
12
|
+
methods: {
|
|
13
|
+
...common.methods,
|
|
14
|
+
getAction() {
|
|
15
|
+
return "Bounce";
|
|
16
|
+
},
|
|
17
|
+
getSummary(body) {
|
|
18
|
+
return `New bounce: ${body.Email}`;
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
sampleEmit,
|
|
22
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"body": {
|
|
3
|
+
"Device": {
|
|
4
|
+
"ClientName": null,
|
|
5
|
+
"ClientOs": "Unknown",
|
|
6
|
+
"ClientType": "Other",
|
|
7
|
+
"DeviceType": "Desktop"
|
|
8
|
+
},
|
|
9
|
+
"Email": "webhook@reachmail.net",
|
|
10
|
+
"EventId": "9d2360cd-e094-4586-9125-ffcc9c713f58",
|
|
11
|
+
"EventType": "bounce",
|
|
12
|
+
"IpAddress": "123.11.32.1",
|
|
13
|
+
"Location": {
|
|
14
|
+
"City": "Chicago",
|
|
15
|
+
"CountryCode": "US",
|
|
16
|
+
"Region": "IL"
|
|
17
|
+
},
|
|
18
|
+
"RecipientId": "20b64129-c0a1-42bc-9453-209a28f7bd51",
|
|
19
|
+
"Signature": "816fb208ea0cb491f81b171d6d5d91d0de850b37156e1322fabccd2e2ed5cd64",
|
|
20
|
+
"Timestamp": 1710169299,
|
|
21
|
+
"Token": "xeeggtwycyqgcpemxduirulpdpmjbksejmkocvkjffwjefpnph",
|
|
22
|
+
"Url": null,
|
|
23
|
+
"UserAgent": "Mozilla/firefox",
|
|
24
|
+
"XCampaign": "Campaign Name"
|
|
25
|
+
},
|
|
26
|
+
"client_ip": "123.11.32.1",
|
|
27
|
+
"headers": {
|
|
28
|
+
"accept": "text/html, application/xhtml+xml, application/xml; q=0.9, image/webp, */*; q=0.8",
|
|
29
|
+
"accept-encoding": "gzip, deflate, sdch, br",
|
|
30
|
+
"content-length": "569",
|
|
31
|
+
"content-type": "application/json; charset=utf-8",
|
|
32
|
+
"host": "urltest.com",
|
|
33
|
+
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15"
|
|
34
|
+
},
|
|
35
|
+
"method": "POST",
|
|
36
|
+
"path": "/",
|
|
37
|
+
"query": {},
|
|
38
|
+
"url": "https://urltest.com/"
|
|
39
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import common from "../common/base.mjs";
|
|
2
|
+
import sampleEmit from "./test-event.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
...common,
|
|
6
|
+
key: "reachmail-new-click-instant",
|
|
7
|
+
name: "New Click Instant",
|
|
8
|
+
description: "Emit new event when a recipient clicks on an email.",
|
|
9
|
+
version: "0.0.1",
|
|
10
|
+
type: "source",
|
|
11
|
+
dedupe: "unique",
|
|
12
|
+
methods: {
|
|
13
|
+
...common.methods,
|
|
14
|
+
getAction() {
|
|
15
|
+
return "Click";
|
|
16
|
+
},
|
|
17
|
+
getSummary(body) {
|
|
18
|
+
return `New click from ${body.Email}`;
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
sampleEmit,
|
|
22
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"body": {
|
|
3
|
+
"Device": {
|
|
4
|
+
"ClientName": null,
|
|
5
|
+
"ClientOs": "Unknown",
|
|
6
|
+
"ClientType": "Other",
|
|
7
|
+
"DeviceType": "Desktop"
|
|
8
|
+
},
|
|
9
|
+
"Email": "webhook@reachmail.net",
|
|
10
|
+
"EventId": "9d2360cd-e094-4586-9125-ffcc9c713f58",
|
|
11
|
+
"EventType": "click",
|
|
12
|
+
"IpAddress": "123.11.32.1",
|
|
13
|
+
"Location": {
|
|
14
|
+
"City": "Chicago",
|
|
15
|
+
"CountryCode": "US",
|
|
16
|
+
"Region": "IL"
|
|
17
|
+
},
|
|
18
|
+
"RecipientId": "20b64129-c0a1-42bc-9453-209a28f7bd51",
|
|
19
|
+
"Signature": "816fb208ea0cb491f81b171d6d5d91d0de850b37156e1322fabccd2e2ed5cd64",
|
|
20
|
+
"Timestamp": 1710169299,
|
|
21
|
+
"Token": "xeeggtwycyqgcpemxduirulpdpmjbksejmkocvkjffwjefpnph",
|
|
22
|
+
"Url": null,
|
|
23
|
+
"UserAgent": "Mozilla/firefox",
|
|
24
|
+
"XCampaign": "Campaign Name"
|
|
25
|
+
},
|
|
26
|
+
"client_ip": "123.11.32.1",
|
|
27
|
+
"headers": {
|
|
28
|
+
"accept": "text/html, application/xhtml+xml, application/xml; q=0.9, image/webp, */*; q=0.8",
|
|
29
|
+
"accept-encoding": "gzip, deflate, sdch, br",
|
|
30
|
+
"content-length": "569",
|
|
31
|
+
"content-type": "application/json; charset=utf-8",
|
|
32
|
+
"host": "urltest.com",
|
|
33
|
+
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15"
|
|
34
|
+
},
|
|
35
|
+
"method": "POST",
|
|
36
|
+
"path": "/",
|
|
37
|
+
"query": {},
|
|
38
|
+
"url": "https://urltest.com/"
|
|
39
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import common from "../common/base.mjs";
|
|
2
|
+
import sampleEmit from "./test-event.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
...common,
|
|
6
|
+
key: "reachmail-new-open-instant",
|
|
7
|
+
name: "New Email Open Instant",
|
|
8
|
+
description: "Emit new event when a recipient opens an email.",
|
|
9
|
+
version: "0.0.1",
|
|
10
|
+
type: "source",
|
|
11
|
+
dedupe: "unique",
|
|
12
|
+
methods: {
|
|
13
|
+
...common.methods,
|
|
14
|
+
getAction() {
|
|
15
|
+
return "Open";
|
|
16
|
+
},
|
|
17
|
+
getSummary(body) {
|
|
18
|
+
return `Email opened by ${body.Email}`;
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
sampleEmit,
|
|
22
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"body": {
|
|
3
|
+
"Device": {
|
|
4
|
+
"ClientName": null,
|
|
5
|
+
"ClientOs": "Unknown",
|
|
6
|
+
"ClientType": "Other",
|
|
7
|
+
"DeviceType": "Desktop"
|
|
8
|
+
},
|
|
9
|
+
"Email": "webhook@reachmail.net",
|
|
10
|
+
"EventId": "9d2360cd-e094-4586-9125-ffcc9c713f58",
|
|
11
|
+
"EventType": "open",
|
|
12
|
+
"IpAddress": "123.11.32.1",
|
|
13
|
+
"Location": {
|
|
14
|
+
"City": "Chicago",
|
|
15
|
+
"CountryCode": "US",
|
|
16
|
+
"Region": "IL"
|
|
17
|
+
},
|
|
18
|
+
"RecipientId": "20b64129-c0a1-42bc-9453-209a28f7bd51",
|
|
19
|
+
"Signature": "816fb208ea0cb491f81b171d6d5d91d0de850b37156e1322fabccd2e2ed5cd64",
|
|
20
|
+
"Timestamp": 1710169299,
|
|
21
|
+
"Token": "xeeggtwycyqgcpemxduirulpdpmjbksejmkocvkjffwjefpnph",
|
|
22
|
+
"Url": null,
|
|
23
|
+
"UserAgent": "Mozilla/firefox",
|
|
24
|
+
"XCampaign": "Campaign Name"
|
|
25
|
+
},
|
|
26
|
+
"client_ip": "123.11.32.1",
|
|
27
|
+
"headers": {
|
|
28
|
+
"accept": "text/html, application/xhtml+xml, application/xml; q=0.9, image/webp, */*; q=0.8",
|
|
29
|
+
"accept-encoding": "gzip, deflate, sdch, br",
|
|
30
|
+
"content-length": "569",
|
|
31
|
+
"content-type": "application/json; charset=utf-8",
|
|
32
|
+
"host": "urltest.com",
|
|
33
|
+
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15"
|
|
34
|
+
},
|
|
35
|
+
"method": "POST",
|
|
36
|
+
"path": "/",
|
|
37
|
+
"query": {},
|
|
38
|
+
"url": "https://urltest.com/"
|
|
39
|
+
}
|