Skip to content

Commit 17c27f2

Browse files
committed
Added actions
1 parent 572351b commit 17c27f2

File tree

4 files changed

+98
-7
lines changed

4 files changed

+98
-7
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import app from "../../noor.app.mjs";
2+
3+
export default {
4+
key: "noor-send-text-message",
5+
name: "Send Text Message",
6+
description: "Send a message in a thread. [See the documentation](https://usenoor.notion.site/v0-e812ae5e5976420f81232fa1c0316e84)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
spaceId: {
12+
propDefinition: [
13+
app,
14+
"spaceId",
15+
],
16+
},
17+
thread: {
18+
propDefinition: [
19+
app,
20+
"thread",
21+
],
22+
},
23+
text: {
24+
propDefinition: [
25+
app,
26+
"text",
27+
],
28+
},
29+
},
30+
async run({ $ }) {
31+
const response = await this.app.sendMessage({
32+
$,
33+
data: {
34+
spaceId: this.spaceId,
35+
thread: this.thread,
36+
text: this.text,
37+
},
38+
});
39+
40+
$.export("$summary", `Successfully sent message to '${this.thread}' thread`);
41+
42+
return response;
43+
},
44+
};

components/noor/noor.app.mjs

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,52 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "noor",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
thread: {
8+
type: "string",
9+
label: "Thread",
10+
description: "Thread to where the message will be sent",
11+
},
12+
text: {
13+
type: "string",
14+
label: "Text",
15+
description: "Text of the message",
16+
},
17+
spaceId: {
18+
type: "string",
19+
label: "Space ID",
20+
description: "ID of the space, can be viewed in your space settings",
21+
},
22+
},
523
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
24+
_baseUrl() {
25+
return "https://sun.noor.to/api/v0";
26+
},
27+
async _makeRequest(opts = {}) {
28+
const {
29+
$ = this,
30+
path,
31+
headers,
32+
...otherOpts
33+
} = opts;
34+
return axios($, {
35+
...otherOpts,
36+
url: this._baseUrl() + path,
37+
headers: {
38+
...headers,
39+
"Authorization": `Bearer ${this.$auth.api_key}`,
40+
"Content-Type": "application/json",
41+
},
42+
});
43+
},
44+
async sendMessage(args = {}) {
45+
return this._makeRequest({
46+
method: "post",
47+
path: "/sendMessage",
48+
...args,
49+
});
950
},
1051
},
1152
};

components/noor/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/noor",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Noor Components",
55
"main": "noor.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.0"
1417
}
15-
}
18+
}

pnpm-lock.yaml

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)