Skip to content

Commit 9a6b1bb

Browse files
committed
notiff_io init
1 parent 759d1f6 commit 9a6b1bb

File tree

3 files changed

+118
-3
lines changed

3 files changed

+118
-3
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import notiff_io from "../../notiff_io.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "notiff_io-create-notification",
6+
name: "Create Notification",
7+
description: "Send a new notification to a user or system via notiff.io. [See the documentation](https://notiff.io/articles/welcome-to-notiff-getting-started-with-your-notification-center)",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
notiff_io,
12+
idNotificationSource: {
13+
propDefinition: [
14+
notiff_io,
15+
"idNotificationSource",
16+
],
17+
},
18+
title: {
19+
propDefinition: [
20+
notiff_io,
21+
"title",
22+
],
23+
},
24+
description: {
25+
propDefinition: [
26+
notiff_io,
27+
"description",
28+
],
29+
},
30+
url: {
31+
propDefinition: [
32+
notiff_io,
33+
"url",
34+
],
35+
},
36+
},
37+
async run({ $ }) {
38+
const response = await this.notiff_io.sendNotification({
39+
idNotificationSource: this.idNotificationSource,
40+
title: this.title,
41+
description: this.description,
42+
url: this.url,
43+
});
44+
45+
$.export("$summary", `Notification titled "${this.title}" created successfully`);
46+
return response;
47+
},
48+
};
Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,78 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "notiff_io",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
idNotificationSource: {
8+
type: "string",
9+
label: "Notification Source ID",
10+
description: "The unique identifier for the notification source.",
11+
async options() {
12+
const sources = await this.listNotificationSources();
13+
return sources.map((source) => ({
14+
label: source.title,
15+
value: source.id,
16+
}));
17+
},
18+
},
19+
title: {
20+
type: "string",
21+
label: "Title",
22+
description: "The title of the notification.",
23+
},
24+
description: {
25+
type: "string",
26+
label: "Description",
27+
description: "The content/description of the notification.",
28+
},
29+
url: {
30+
type: "string",
31+
label: "URL",
32+
description: "The URL associated with the notification.",
33+
},
34+
},
535
methods: {
6-
// this.$auth contains connected account data
736
authKeys() {
837
console.log(Object.keys(this.$auth));
938
},
39+
_baseUrl() {
40+
return "https://notiff.io/api/1.1/wf";
41+
},
42+
async _makeRequest(opts = {}) {
43+
const {
44+
$ = this, method = "GET", path = "/", headers, ...otherOpts
45+
} = opts;
46+
return axios($, {
47+
...otherOpts,
48+
method,
49+
url: this._baseUrl() + path,
50+
headers: {
51+
"Authorization": `Bearer ${this.$auth.api_key}`,
52+
...headers,
53+
},
54+
});
55+
},
56+
async listNotificationSources(opts = {}) {
57+
return this._makeRequest({
58+
path: "/list_notification_sources",
59+
...opts,
60+
});
61+
},
62+
async sendNotification({
63+
idNotificationSource, title, description, url,
64+
}, opts = {}) {
65+
return this._makeRequest({
66+
method: "POST",
67+
path: "/create_notification",
68+
data: {
69+
id_notification_source: idNotificationSource,
70+
title,
71+
description,
72+
url,
73+
},
74+
...opts,
75+
});
76+
},
1077
},
1178
};

components/notiff_io/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
"publishConfig": {
1313
"access": "public"
1414
}
15-
}
15+
}

0 commit comments

Comments
 (0)