Skip to content

Commit ea8a408

Browse files
Merge branch 'master' into danny/connect-react/adding-pagination
2 parents 1999db2 + 650445a commit ea8a408

File tree

174 files changed

+6675
-302
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+6675
-302
lines changed

components/aftership/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/aftership",
3-
"version": "0.2.0",
3+
"version": "0.3.0",
44
"description": "Pipedream AfterShip Components",
55
"main": "aftership.app.mjs",
66
"keywords": [
@@ -13,7 +13,7 @@
1313
"access": "public"
1414
},
1515
"dependencies": {
16-
"@pipedream/platform": "^1.5.1"
16+
"@pipedream/platform": "^3.1.0",
17+
"crypto": "^1.0.1"
1718
}
1819
}
19-
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import { createHmac } from "crypto";
2+
import { ConfigurationError } from "@pipedream/platform";
3+
import app from "../../aftership.app.mjs";
4+
5+
export default {
6+
props: {
7+
app,
8+
http: {
9+
type: "$.interface.http",
10+
customResponse: true,
11+
},
12+
webhookSecret: {
13+
type: "string",
14+
label: "Secret",
15+
description: "The secret for the webhook. You can find it in `Tracking -> Settings -> Webhooks -> Webhook secret`",
16+
},
17+
},
18+
hooks: {
19+
async deploy() {
20+
if (!this.webhookSecret) {
21+
console.log("No webhook secret was provided, skipping deployment");
22+
throw new ConfigurationError("No webhook secret was provided, skipping deployment");
23+
}
24+
25+
const { data: { trackings } } = await this.app.listTrackings({
26+
params: {
27+
page: 1,
28+
limit: 25,
29+
},
30+
});
31+
32+
trackings
33+
.slice(0, 25)
34+
.reverse()
35+
.forEach((tracking) => {
36+
this.processResource({
37+
event: this.getEventName(),
38+
event_id: tracking.id,
39+
msg: tracking,
40+
ts: Date.parse(tracking.updated_at) / 1000,
41+
});
42+
});
43+
},
44+
},
45+
methods: {
46+
generateMeta() {
47+
throw new ConfigurationError("generateMeta is not implemented");
48+
},
49+
getEventName() {
50+
throw new ConfigurationError("getEventName is not implemented");
51+
},
52+
isSignatureValid(bodyRaw, signature) {
53+
const { webhookSecret } = this;
54+
if (!webhookSecret) {
55+
console.log("No webhook secret found, skipping signature verification");
56+
return true;
57+
}
58+
const hash = createHmac("sha256", webhookSecret)
59+
.update(bodyRaw)
60+
.digest("base64");
61+
return hash === signature;
62+
},
63+
processResource(resource) {
64+
this.$emit(resource, this.generateMeta(resource));
65+
},
66+
},
67+
async run({
68+
body, bodyRaw, headers,
69+
}) {
70+
const signature = headers["aftership-hmac-sha256"];
71+
72+
if (!this.isSignatureValid(bodyRaw, signature)) {
73+
console.log("Could not verify incoming webhook signature");
74+
return this.http.respond({
75+
status: 401,
76+
});
77+
}
78+
79+
this.http.respond({
80+
status: 200,
81+
});
82+
83+
this.processResource(body);
84+
},
85+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import common from "../common/webhook.mjs";
2+
3+
export default {
4+
...common,
5+
key: "aftership-shipment-status-updated",
6+
name: "Shipment Status Updated",
7+
description: "Emit new event when a shipment tracking status is updated. [See the documentation](https://www.aftership.com/docs/shipping/webhook/webhook-overview)",
8+
version: "0.0.1",
9+
type: "source",
10+
dedupe: "unique",
11+
methods: {
12+
...common.methods,
13+
getEventName() {
14+
return "tracking_update";
15+
},
16+
generateMeta(resource) {
17+
const {
18+
event_id: eventId,
19+
msg: tracking,
20+
} = resource;
21+
22+
return {
23+
id: eventId || tracking.id,
24+
summary: `Tracking Updated: ${tracking.tracking_number || tracking.title}`,
25+
ts: Date.parse(tracking.updated_at) || Date.now(),
26+
};
27+
},
28+
},
29+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export default {
2+
type: "app",
3+
app: "airweave",
4+
propDefinitions: {},
5+
methods: {
6+
// this.$auth contains connected account data
7+
authKeys() {
8+
console.log(Object.keys(this.$auth));
9+
},
10+
},
11+
};

components/airweave/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "@pipedream/airweave",
3+
"version": "0.0.1",
4+
"description": "Pipedream Airweave Components",
5+
"main": "airweave.app.mjs",
6+
"keywords": [
7+
"pipedream",
8+
"airweave"
9+
],
10+
"homepage": "https://pipedream.com/apps/airweave",
11+
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
12+
"publishConfig": {
13+
"access": "public"
14+
}
15+
}

components/aweber/actions/add-subscriber/add-subscriber.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
name: "Add Subscriber",
77
description: "Add subscribers to the specified account and list. [See the docs here](https://api.aweber.com/#tag/Subscribers/paths/~1accounts~1{accountId}~1lists~1{listId}~1subscribers/post).",
88
type: "action",
9-
version: "0.0.4",
9+
version: "0.0.5",
1010
annotations: {
1111
destructiveHint: false,
1212
openWorldHint: true,
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
import aweberApp from "../../aweber.app.mjs";
2+
3+
export default {
4+
key: "aweber-create-broadcast",
5+
name: "Create Broadcast",
6+
description: "Create a broadcast under the specified account and list. [See the documentation](https://api.aweber.com/#tag/Broadcasts/paths/~1accounts~1%7BaccountId%7D~1lists~1%7BlistId%7D~1broadcasts/post).",
7+
type: "action",
8+
version: "0.0.1",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: false,
13+
},
14+
props: {
15+
aweberApp,
16+
accountId: {
17+
propDefinition: [
18+
aweberApp,
19+
"accountId",
20+
],
21+
},
22+
listId: {
23+
propDefinition: [
24+
aweberApp,
25+
"listId",
26+
({ accountId }) => ({
27+
accountId,
28+
}),
29+
],
30+
},
31+
bodyHTML: {
32+
type: "string",
33+
label: "Body HTML",
34+
description: "The content of the message in HTML format. If `Body Text` is not provided, it will be auto-generated. If `Body Text` is not provided, `Body HTML` must be provided.",
35+
optional: true,
36+
},
37+
bodyText: {
38+
type: "string",
39+
label: "Body Text",
40+
description: "The content of the message in plain text, used when HTML is not supported. If `Body HTML` is not provided, the broadcast will be sent using only the `Body Text`. If `Body Text` is not provided, `Body HTML` must be provided.",
41+
optional: true,
42+
},
43+
bodyAmp: {
44+
type: "string",
45+
label: "Body AMP",
46+
description: "The content of the message in AMP format. [Read Aweber KB article before using this field](https://help.aweber.com/hc/en-us/articles/360025741194)",
47+
optional: true,
48+
},
49+
clickTrackingEnabled: {
50+
type: "boolean",
51+
label: "Click Tracking Enabled",
52+
description: "Enables links in the email message to be tracked.",
53+
optional: true,
54+
},
55+
excludeLists: {
56+
propDefinition: [
57+
aweberApp,
58+
"listSelfLink",
59+
({ accountId }) => ({
60+
accountId,
61+
}),
62+
],
63+
type: "string[]",
64+
label: "Exclude Lists",
65+
description: "List of [Lists](https://api.aweber.com/#tag/Lists) URLs to exclude in the delivery of this broadcast. **e.g. `https://api.aweber.com/1.0/accounts/<account_id>/lists/<list_id>`**",
66+
optional: true,
67+
},
68+
includeLists: {
69+
propDefinition: [
70+
aweberApp,
71+
"listSelfLink",
72+
({ accountId }) => ({
73+
accountId,
74+
}),
75+
],
76+
type: "string[]",
77+
label: "Include Lists",
78+
description: "List of [Lists](https://api.aweber.com/#tag/Lists) URLs to include in the delivery of this broadcast. **e.g. `https://api.aweber.com/1.0/accounts/<account_id>/lists/<list_id>`**",
79+
optional: true,
80+
},
81+
facebookIntegration: {
82+
propDefinition: [
83+
aweberApp,
84+
"integrations",
85+
({ accountId }) => ({
86+
accountId,
87+
serviceName: "facebook",
88+
}),
89+
],
90+
label: "Facebook Integration",
91+
description: "URL to the [Facebook broadcast integration](https://api.aweber.com/#tag/Integrations) to use for this broadcast. When the broadcast is sent, the subject of the broadcast will be posted to this Facebook integration - **e.g. `https://api.aweber.com/1.0/accounts/<account_id>/integrations/<integration_id>`**.",
92+
optional: true,
93+
},
94+
isArchived: {
95+
type: "boolean",
96+
label: "Is Archived",
97+
description: "Whether the broadcast enabled sharing via an archive URL.",
98+
optional: true,
99+
},
100+
notifyOnSend: {
101+
type: "boolean",
102+
label: "Notify on Send",
103+
description: "If true, notify when stats are available on a sent broadcast message.",
104+
optional: true,
105+
},
106+
segmentLink: {
107+
propDefinition: [
108+
aweberApp,
109+
"segmentSelfLink",
110+
({
111+
accountId, listId,
112+
}) => ({
113+
accountId,
114+
listId,
115+
}),
116+
],
117+
optional: true,
118+
},
119+
subject: {
120+
type: "string",
121+
label: "Subject",
122+
description: "The broadcast subject line. Subject must not be empty nor contain only whitespace.",
123+
},
124+
twitterIntegration: {
125+
propDefinition: [
126+
aweberApp,
127+
"integrations",
128+
({ accountId }) => ({
129+
accountId,
130+
serviceName: "twitter",
131+
}),
132+
],
133+
label: "Twitter Integration",
134+
description: "URL to the [Twitter broadcast integration](https://api.aweber.com/#tag/Integrations) to use for this broadcast. When the broadcast is sent, the subject of the broadcast will be tweeted - **e.g. `https://api.aweber.com/1.0/accounts/<account_id>/integrations/<integration_id>`**.",
135+
optional: true,
136+
},
137+
},
138+
async run({ $ }) {
139+
const response = await this.aweberApp.createBroadcast({
140+
$,
141+
accountId: this.accountId,
142+
listId: this.listId,
143+
data: {
144+
body_html: this.bodyHTML,
145+
body_text: this.bodyText,
146+
body_amp: this.bodyAmp,
147+
click_tracking_enabled: this.clickTrackingEnabled,
148+
exclude_lists: this.excludeLists,
149+
include_lists: this.includeLists,
150+
facebook_integration: this.facebookIntegration,
151+
is_archived: this.isArchived,
152+
notify_on_send: this.notifyOnSend,
153+
segment_link: this.segmentLink,
154+
subject: this.subject,
155+
twitter_integration: this.twitterIntegration,
156+
},
157+
headers: {
158+
"Content-Type": "application/x-www-form-urlencoded",
159+
},
160+
});
161+
162+
$.export("$summary", `Successfully created broadcast with **UUID: ${response.uuid}**.`);
163+
return response;
164+
},
165+
};

components/aweber/actions/create-or-update-subscriber/create-or-update-subscriber.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
name: "Create Or Update Subscriber",
66
description: "Create subscriber if the subscriber email is not existing or update the information for the specified subscriber by email. [See the docs here](https://api.aweber.com/#tag/Subscribers/paths/~1accounts~1{accountId}~1lists~1{listId}~1subscribers/patch).",
77
type: "action",
8-
version: "0.0.2",
8+
version: "0.0.3",
99
annotations: {
1010
destructiveHint: true,
1111
openWorldHint: true,

components/aweber/actions/get-accounts/get-accounts.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
name: "Get Accounts",
88
description: "Get a paginated collection of accounts. [See the docs here](https://api.aweber.com/#tag/Accounts/paths/~1accounts/get).",
99
type: "action",
10-
version: "0.0.4",
10+
version: "0.0.5",
1111
annotations: {
1212
destructiveHint: false,
1313
openWorldHint: true,

components/aweber/actions/get-lists/get-lists.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
name: "Get Lists",
88
description: "Get a paginated collection of subscriber lists. [See the docs here](https://api.aweber.com/#tag/Lists/paths/~1accounts~1{accountId}~1lists/get).",
99
type: "action",
10-
version: "0.0.4",
10+
version: "0.0.5",
1111
annotations: {
1212
destructiveHint: false,
1313
openWorldHint: true,

0 commit comments

Comments
 (0)