Skip to content

Commit acb8255

Browse files
authored
[Components] goodbits #13479 (#16351)
* Added actions * Done requested changes
1 parent 1d7ea34 commit acb8255

File tree

9 files changed

+260
-20
lines changed

9 files changed

+260
-20
lines changed

components/goodbits/.gitignore

-3
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import app from "../../goodbits.app.mjs";
2+
3+
export default {
4+
key: "goodbits-create-link",
5+
name: "Create Link",
6+
description: "Create a new link. [See the documentation](https://support.goodbits.io/article/115-goodbit-api)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
url: {
12+
propDefinition: [
13+
app,
14+
"url",
15+
],
16+
},
17+
title: {
18+
propDefinition: [
19+
app,
20+
"title",
21+
],
22+
},
23+
description: {
24+
propDefinition: [
25+
app,
26+
"description",
27+
],
28+
},
29+
fetchRemoteThumbnailUrl: {
30+
propDefinition: [
31+
app,
32+
"fetchRemoteThumbnailUrl",
33+
],
34+
},
35+
imageCandidates: {
36+
propDefinition: [
37+
app,
38+
"imageCandidates",
39+
],
40+
},
41+
},
42+
async run({ $ }) {
43+
const response = await this.app.createLink({
44+
$,
45+
data: {
46+
url: this.url,
47+
title: this.title,
48+
description: this.description,
49+
fetch_remote_thumbnail_url: this.fetchRemoteThumbnailUrl,
50+
image_candidates: this.imageCandidates,
51+
},
52+
});
53+
$.export("$summary", "Successfully created new link");
54+
return response;
55+
},
56+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import app from "../../goodbits.app.mjs";
2+
3+
export default {
4+
key: "goodbits-create-subscriber",
5+
name: "Create Subscriber",
6+
description: "Create a new subscriber. [See the documentation](https://support.goodbits.io/article/115-goodbit-api)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
email: {
12+
propDefinition: [
13+
app,
14+
"email",
15+
],
16+
},
17+
firstName: {
18+
propDefinition: [
19+
app,
20+
"firstName",
21+
],
22+
},
23+
lastName: {
24+
propDefinition: [
25+
app,
26+
"lastName",
27+
],
28+
},
29+
},
30+
async run({ $ }) {
31+
const response = await this.app.createSubscriber({
32+
$,
33+
data: {
34+
subscriber: {
35+
email: this.email,
36+
first_name: this.firstName,
37+
last_name: this.lastName,
38+
},
39+
},
40+
});
41+
$.export("$summary", "Successfully created new subscriber");
42+
return response;
43+
},
44+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import app from "../../goodbits.app.mjs";
2+
3+
export default {
4+
key: "goodbits-update-subscriber-status",
5+
name: "Update Subscriber Status",
6+
description: "Update the status of a subscriber. [See the documentation](https://support.goodbits.io/article/115-goodbit-api)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
email: {
12+
propDefinition: [
13+
app,
14+
"email",
15+
],
16+
},
17+
status: {
18+
propDefinition: [
19+
app,
20+
"status",
21+
],
22+
},
23+
},
24+
async run({ $ }) {
25+
const response = await this.app.updateSubscriberStatus({
26+
$,
27+
email: this.email,
28+
data: {
29+
subscriber: {
30+
status: this.status,
31+
},
32+
},
33+
});
34+
$.export("$summary", "Successfully uptated subscriber status");
35+
return response;
36+
},
37+
};

components/goodbits/app/goodbits.app.ts

-13
This file was deleted.
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default {
2+
STATUS_OPTIONS: [
3+
"unsubscribed",
4+
"cleaned",
5+
"pending",
6+
"deleted",
7+
],
8+
};

components/goodbits/goodbits.app.mjs

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
import { axios } from "@pipedream/platform";
2+
import constants from "./common/constants.mjs";
3+
4+
export default {
5+
type: "app",
6+
app: "goodbits",
7+
propDefinitions: {
8+
email: {
9+
type: "string",
10+
label: "Email",
11+
description: "Subscriber's email address",
12+
},
13+
firstName: {
14+
type: "string",
15+
label: "First Name",
16+
description: "Subscriber's first name",
17+
optional: true,
18+
},
19+
lastName: {
20+
type: "string",
21+
label: "Last Name",
22+
description: "Subscriber's last name",
23+
optional: true,
24+
},
25+
status: {
26+
type: "string",
27+
label: "Status",
28+
description: "New status of the subscriber",
29+
options: constants.STATUS_OPTIONS,
30+
},
31+
url: {
32+
type: "string",
33+
label: "URL",
34+
description: "URL of the new link",
35+
},
36+
title: {
37+
type: "string",
38+
label: "Title",
39+
description: "Title associated with the link",
40+
optional: true,
41+
},
42+
description: {
43+
type: "string",
44+
label: "Description",
45+
description: "Description of the link",
46+
optional: true,
47+
},
48+
fetchRemoteThumbnailUrl: {
49+
type: "string",
50+
label: "Fetch Remote Thumbnail URL",
51+
description: "URL to fetch a remote thumbnail image",
52+
optional: true,
53+
},
54+
imageCandidates: {
55+
type: "string[]",
56+
label: "Image Candidates",
57+
description: "List of candidate image URLs",
58+
optional: true,
59+
},
60+
},
61+
methods: {
62+
_baseUrl() {
63+
return "https://app.goodbits.io/api/v1";
64+
},
65+
async _makeRequest(opts = {}) {
66+
const {
67+
$ = this,
68+
path,
69+
headers,
70+
...otherOpts
71+
} = opts;
72+
return axios($, {
73+
...otherOpts,
74+
url: this._baseUrl() + path,
75+
headers: {
76+
"Authorization": `${this.$auth.api_key}`,
77+
...headers,
78+
},
79+
});
80+
},
81+
async createSubscriber(args = {}) {
82+
return this._makeRequest({
83+
path: "/subscribers",
84+
method: "post",
85+
...args,
86+
});
87+
},
88+
async updateSubscriberStatus({
89+
email, ...args
90+
}) {
91+
return this._makeRequest({
92+
path: `/subscribers/${email}`,
93+
method: "put",
94+
...args,
95+
});
96+
},
97+
async createLink(args = {}) {
98+
return this._makeRequest({
99+
path: "/links",
100+
method: "post",
101+
...args,
102+
});
103+
},
104+
},
105+
};

components/goodbits/package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
{
22
"name": "@pipedream/goodbits",
3-
"version": "0.0.2",
3+
"version": "0.0.1",
44
"description": "Pipedream Goodbits Components",
5-
"main": "dist/app/goodbits.app.mjs",
5+
"main": "goodbits.app.mjs",
66
"keywords": [
77
"pipedream",
88
"goodbits"
99
],
10-
"files": ["dist"],
1110
"homepage": "https://pipedream.com/apps/goodbits",
1211
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
1312
"publishConfig": {
1413
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1517
}
1618
}

pnpm-lock.yaml

+5-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)