Skip to content

Commit c197328

Browse files
committed
[Components] beekeeper #13273
Sources - New Chat Message (Instant) - New User Created (Instant) - New Comment Added (Instant) Actions - Send Message Group Chat - Create Post - Get Profile
1 parent bddac8c commit c197328

File tree

14 files changed

+331
-364
lines changed

14 files changed

+331
-364
lines changed
Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import beekeeper from "../../beekeeper.app.mjs";
2-
import { axios } from "@pipedream/platform";
2+
import { parseObject } from "../../common/utils.mjs";
33

44
export default {
55
key: "beekeeper-create-post",
@@ -15,10 +15,15 @@ export default {
1515
"streamId",
1616
],
1717
},
18+
text: {
19+
type: "string",
20+
label: "Text",
21+
description: "The text content of the post",
22+
},
1823
files: {
1924
type: "string[]",
2025
label: "Files",
21-
description: "Array of files to be attached to the post",
26+
description: "List of file objects to be attached. E.g. [{\"name\": \"fair_play_rules.pdf\", \"url\": \"https://mytenant.beekeeper.io/file/665987/original/fair_play_rules.pdf\", \"userid\": \"5cb9v45d-8i78-4v65-b5fd-81cgfac3ef17\", \"height\": 619, \"width\": 700, \"key\": \"f4fdaab0-d198-49b4-b1cc-dd85572d72f1\", \"media_type\": \"image/png\", \"usage_type\": \"attachment_image\" }]. [See the documentation](https://beekeeper.stoplight.io/docs/beekeeper-api/18408b41927b9-creates-a-new-post) for further details.",
2227
optional: true,
2328
},
2429
locked: {
@@ -34,71 +39,63 @@ export default {
3439
optional: true,
3540
},
3641
media: {
37-
type: "string",
42+
type: "string[]",
3843
label: "Media",
39-
description: "Media attachment for the post",
44+
description: "List of Photo or Video objects. E.g. [{\"name\": \"fair_play_rules.pdf\", \"url\": \"https://mytenant.beekeeper.io/file/665987/original/fair_play_rules.pdf\", \"userid\": \"5cb9v45d-8i78-4v65-b5fd-81cgfac3ef17\", \"height\": 619, \"width\": 700, \"key\": \"f4fdaab0-d198-49b4-b1cc-dd85572d72f1\", \"media_type\": \"image/png\", \"usage_type\": \"attachment_image\" }]. [See the documentation](https://beekeeper.stoplight.io/docs/beekeeper-api/18408b41927b9-creates-a-new-post) for further details.",
4045
optional: true,
4146
},
4247
labels: {
4348
type: "string[]",
4449
label: "Labels",
45-
description: "Array of labels for the post",
50+
description: "List of labels attached to the post",
4651
optional: true,
4752
},
4853
sticky: {
4954
type: "boolean",
5055
label: "Sticky",
51-
description: "Make the post sticky",
52-
optional: true,
53-
},
54-
photos: {
55-
type: "string[]",
56-
label: "Photos",
57-
description: "Array of photos to be attached to the post",
56+
description: "Flag that pins a post to the top of the stream",
5857
optional: true,
5958
},
6059
reactionsDisabled: {
6160
type: "boolean",
6261
label: "Reactions Disabled",
63-
description: "Disable reactions for the post",
64-
optional: true,
65-
},
66-
text: {
67-
type: "string",
68-
label: "Text",
69-
description: "The text content of the post",
62+
description: "Flag that disables the ability to add reaction to the post and to see reactions that have been added",
7063
optional: true,
7164
},
7265
options: {
7366
type: "object",
7467
label: "Options",
75-
description: "Additional options for the post",
68+
description: "List of poll options in a post. E.g. [\"This Friday\", \"Monday next week\"]",
7669
optional: true,
7770
},
7871
scheduledAt: {
7972
type: "string",
8073
label: "Scheduled At",
81-
description: "The scheduled time for the post in the format (UTC, yyyy-mm-ddTHH:MM:SS)",
74+
description: "Date and time when the post is scheduled to be published (UTC timezone, yyyy-mm-ddTHH:MM:SS format)",
8275
optional: true,
8376
},
8477
},
8578
async run({ $ }) {
8679
const response = await this.beekeeper.createPost({
87-
streamId: this.streamId,
88-
files: this.files,
89-
locked: this.locked,
90-
title: this.title,
91-
media: this.media,
92-
labels: this.labels,
93-
sticky: this.sticky,
94-
photos: this.photos,
95-
reactionsDisabled: this.reactionsDisabled,
96-
text: this.text,
97-
options: this.options,
98-
scheduledAt: this.scheduledAt,
80+
$,
81+
data: {
82+
streamid: this.streamId,
83+
files: parseObject(this.files),
84+
locked: this.locked,
85+
title: this.title,
86+
media: parseObject(this.media),
87+
labels: parseObject(this.labels),
88+
sticky: this.sticky,
89+
reactions_disabled: this.reactionsDisabled,
90+
text: this.text,
91+
options: parseObject(this.options)?.map((item) => ({
92+
text: item,
93+
})),
94+
scheduled_at: this.scheduledAt,
95+
},
9996
});
10097

101-
$.export("$summary", `Successfully created post with title: ${this.title || "Untitled"}`);
98+
$.export("$summary", `Successfully created post with UUID: ${response.uuid}`);
10299
return response;
103100
},
104101
};

components/beekeeper/actions/get-profile/get-profile.mjs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import beekeeper from "../../beekeeper.app.mjs";
2-
import { axios } from "@pipedream/platform";
32

43
export default {
54
key: "beekeeper-get-profile",
65
name: "Get User Profile",
76
description: "Retrieve the profile details of a specific user. [See the documentation](https://beekeeper.stoplight.io/docs/beekeeper-api/05bcd13b38a67-get-profile-of-the-given-user)",
8-
version: "0.0.{{ts}}",
7+
version: "0.0.1",
98
type: "action",
109
props: {
1110
beekeeper,
@@ -18,23 +17,24 @@ export default {
1817
includeActivities: {
1918
type: "boolean",
2019
label: "Include Activities",
21-
description: "Whether to include the user's activities. True by default.",
22-
optional: true,
20+
description: "Whether to include the user's activities.",
2321
default: true,
2422
},
2523
includeTotals: {
2624
type: "boolean",
2725
label: "Include Totals",
28-
description: "Whether to include the user's total number of posts, comments, and likes received. True by default.",
29-
optional: true,
26+
description: "Whether to include the user's total number of posts, comments, and likes received.",
3027
default: true,
3128
},
3229
},
3330
async run({ $ }) {
3431
const response = await this.beekeeper.getUserProfile({
32+
$,
3533
userId: this.userId,
36-
includeActivities: this.includeActivities,
37-
includeTotals: this.includeTotals,
34+
params: {
35+
include_activities: this.includeActivities,
36+
include_totals: this.includeTotals,
37+
},
3838
});
3939

4040
$.export("$summary", `Successfully retrieved profile for user ID ${this.userId}`);

components/beekeeper/actions/send-message-group-chat/send-message-group-chat.mjs

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import { ConfigurationError } from "@pipedream/platform";
12
import beekeeper from "../../beekeeper.app.mjs";
2-
import { axios } from "@pipedream/platform";
3+
import { parseObject } from "../../common/utils.mjs";
34

45
export default {
56
key: "beekeeper-send-message-group-chat",
67
name: "Send Message to Group Chat",
78
description: "Send a precomposed message to a defined group chat. [See the documentation](https://beekeeper.stoplight.io/docs/beekeeper-api/9075b32d36db4-send-a-message-to-a-group-chat)",
8-
version: "0.0.{{ts}}",
9+
version: "0.0.1",
910
type: "action",
1011
props: {
1112
beekeeper,
@@ -45,35 +46,38 @@ export default {
4546
description: "Array of objects containing type and data fields for message addons.",
4647
optional: true,
4748
},
48-
refersTo: {
49-
type: "string",
50-
label: "Refers To",
51-
description: "Field used by message deletion event. Marks the ID of the message the deletion message refers to.",
52-
optional: true,
53-
},
5449
mentions: {
55-
type: "string[]",
56-
label: "Mentions",
57-
description: "IDs of the users mentioned in the message body. Can also have value of 'all', which means all the chat members were mentioned.",
50+
propDefinition: [
51+
beekeeper,
52+
"mentions",
53+
({ chatId }) => ({
54+
chatId,
55+
}),
56+
],
5857
optional: true,
5958
},
6059
},
6160
async run({ $ }) {
62-
const data = {
63-
body: this.body,
64-
attachment: this.attachment,
65-
event: {
66-
type: this.eventType,
67-
},
68-
chat_state_addons: this.chatStateAddons?.map(JSON.parse),
69-
message_addons: this.messageAddons?.map(JSON.parse),
70-
refers_to: this.refersTo,
71-
mentions: this.mentions,
72-
};
73-
61+
if (!this.body && !this.event && !this.attachment && !this.chatStateAddons) {
62+
throw new ConfigurationError("You must provide at least **Body**, **Event**, **Attachment** or **Chat State Addons**");
63+
}
7464
const response = await this.beekeeper.sendMessage({
65+
$,
7566
chatId: this.chatId,
76-
...data,
67+
data: {
68+
body: this.body,
69+
attachment: parseObject(this.attachment),
70+
...this.eventType
71+
? {
72+
event: {
73+
type: this.eventType,
74+
},
75+
}
76+
: {},
77+
chat_state_addons: parseObject(this.chatStateAddons),
78+
message_addons: parseObject(this.messageAddons),
79+
mentions: parseObject(this.mentions),
80+
},
7781
});
7882

7983
$.export("$summary", `Message sent successfully to chat ID: ${this.chatId}`);

0 commit comments

Comments
 (0)