@pipedream/vestaboard 0.0.2 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/create-message/create-message.mjs +63 -0
- package/actions/get-current-message/get-current-message.mjs +23 -0
- package/actions/get-subscriptions/get-subscriptions.mjs +25 -0
- package/package.json +5 -5
- package/sources/new-current-message/new-current-message.mjs +60 -0
- package/vestaboard.app.mjs +70 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import vestaboard from "../../vestaboard.app.mjs";
|
|
2
|
+
import { ConfigurationError } from "@pipedream/platform";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "vestaboard-create-message",
|
|
6
|
+
name: "Create Message",
|
|
7
|
+
description: "Creates a new message for a subscription. [See the docs](https://swagger.vestaboard.com/docs/vestaboard/b3A6MTYwMTA4OTc-post-v2-0-subscriptions-with-id-message)",
|
|
8
|
+
version: "0.0.2",
|
|
9
|
+
type: "action",
|
|
10
|
+
props: {
|
|
11
|
+
vestaboard,
|
|
12
|
+
subscriptionId: {
|
|
13
|
+
propDefinition: [
|
|
14
|
+
vestaboard,
|
|
15
|
+
"subscriptionId",
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
text: {
|
|
19
|
+
type: "string",
|
|
20
|
+
label: "Text",
|
|
21
|
+
description: "The message to send to the specified Subscription. If text is specified, lines will be centered horizontally and vertically if possible. Character codes will be inferred for alphanumeric and punctuation, or can be explicitly specified in-line in the message with curly braces containing the character code. Either `text` or `characters` must be entered.",
|
|
22
|
+
optional: true,
|
|
23
|
+
},
|
|
24
|
+
characters: {
|
|
25
|
+
type: "string",
|
|
26
|
+
label: "Characters",
|
|
27
|
+
description: "A 6x22 two-dimensional array of character codes to send to the specified Subscription. If characters are specified, the characters will be shown in the exact position in the array. [See Character Code Reference](https://docs.vestaboard.com/characters). Either `text` or `characters` must be entered.",
|
|
28
|
+
optional: true,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
async run({ $ }) {
|
|
32
|
+
const {
|
|
33
|
+
subscriptionId,
|
|
34
|
+
text,
|
|
35
|
+
characters,
|
|
36
|
+
} = this;
|
|
37
|
+
|
|
38
|
+
if (!text && !characters) {
|
|
39
|
+
throw new ConfigurationError("Either `text` or `characters` must be entered");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const data = {};
|
|
43
|
+
if (text) {
|
|
44
|
+
data.text = text;
|
|
45
|
+
} else {
|
|
46
|
+
data.characters = Array.isArray(characters)
|
|
47
|
+
? characters
|
|
48
|
+
: JSON.parse(characters);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const response = await this.vestaboard.createMessage({
|
|
52
|
+
subscriptionId,
|
|
53
|
+
data,
|
|
54
|
+
$,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
if (response) {
|
|
58
|
+
$.export("$summary", `Successfully created message with ID ${response.message.id}`);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return response;
|
|
62
|
+
},
|
|
63
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import vestaboard from "../../vestaboard.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "vestaboard-get-current-message",
|
|
5
|
+
name: "Get Current Message",
|
|
6
|
+
description: "Retrieves the current message. [See the docs](https://docs.vestaboard.com/read-write)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
vestaboard,
|
|
11
|
+
},
|
|
12
|
+
async run({ $ }) {
|
|
13
|
+
const response = await this.vestaboard.getCurrentMessage({
|
|
14
|
+
$,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
if (response) {
|
|
18
|
+
$.export("$summary", "Successfully retrieved current message.");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return response;
|
|
22
|
+
},
|
|
23
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import vestaboard from "../../vestaboard.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "vestaboard-get-subscriptions",
|
|
5
|
+
name: "Get Subscriptions",
|
|
6
|
+
description: "Get the list of subscriptions available to the viewer. [See the docs](https://swagger.vestaboard.com/docs/vestaboard/b3A6MTYwMTA4OTQ-get-v2-0-subscriptions)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
vestaboard,
|
|
11
|
+
},
|
|
12
|
+
async run({ $ }) {
|
|
13
|
+
const response = await this.vestaboard.listSubscriptions({
|
|
14
|
+
$,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
if (response) {
|
|
18
|
+
$.export("$summary", `Successfully retrieved ${response.subscriptions.length} subscription${response.subscriptions.length === 1
|
|
19
|
+
? "s"
|
|
20
|
+
: ""}`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return response;
|
|
24
|
+
},
|
|
25
|
+
};
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/vestaboard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Pipedream Vestaboard Components",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "vestaboard.app.mjs",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"pipedream",
|
|
8
8
|
"vestaboard"
|
|
9
9
|
],
|
|
10
|
-
"files": [
|
|
11
|
-
"dist"
|
|
12
|
-
],
|
|
13
10
|
"homepage": "https://pipedream.com/apps/vestaboard",
|
|
14
11
|
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
|
|
15
12
|
"publishConfig": {
|
|
16
13
|
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@pipedream/platform": "^1.5.1"
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import vestaboard from "../../vestaboard.app.mjs";
|
|
2
|
+
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "vestaboard-new-current-message",
|
|
6
|
+
name: "New Current Message",
|
|
7
|
+
description: "Emit new event when a new message is displayed on a board. [See the docs](https://docs.vestaboard.com/read-write)",
|
|
8
|
+
version: "0.0.1",
|
|
9
|
+
type: "source",
|
|
10
|
+
dedupe: "unique",
|
|
11
|
+
props: {
|
|
12
|
+
vestaboard,
|
|
13
|
+
db: "$.service.db",
|
|
14
|
+
timer: {
|
|
15
|
+
type: "$.interface.timer",
|
|
16
|
+
default: {
|
|
17
|
+
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
hooks: {
|
|
22
|
+
async deploy() {
|
|
23
|
+
const { currentMessage } = await this.vestaboard.getCurrentMessage();
|
|
24
|
+
if (!currentMessage) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
this.emitEvent(currentMessage);
|
|
28
|
+
this._setPreviousId(currentMessage.id);
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
methods: {
|
|
32
|
+
_getPreviousId() {
|
|
33
|
+
return this.db.get("previousId");
|
|
34
|
+
},
|
|
35
|
+
_setPreviousId(previousId) {
|
|
36
|
+
this.db.set("previousId", previousId);
|
|
37
|
+
},
|
|
38
|
+
generateMeta({ id }) {
|
|
39
|
+
const ts = Date.now();
|
|
40
|
+
return {
|
|
41
|
+
id: `${id}${ts}`,
|
|
42
|
+
summary: `New Message with ID ${id}`,
|
|
43
|
+
ts,
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
emitEvent(message) {
|
|
47
|
+
const meta = this.generateMeta(message);
|
|
48
|
+
this.$emit(message, meta);
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
async run() {
|
|
52
|
+
const previousId = this._getPreviousId();
|
|
53
|
+
const { currentMessage } = await this.vestaboard.getCurrentMessage();
|
|
54
|
+
if (!currentMessage || currentMessage.id === previousId) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
this.emitEvent(currentMessage);
|
|
58
|
+
this._setPreviousId(currentMessage.id);
|
|
59
|
+
},
|
|
60
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { axios } from "@pipedream/platform";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
type: "app",
|
|
5
|
+
app: "vestaboard",
|
|
6
|
+
propDefinitions: {
|
|
7
|
+
subscriptionId: {
|
|
8
|
+
type: "string",
|
|
9
|
+
label: "Subscription",
|
|
10
|
+
description: "The ID of the Subscription to which to post",
|
|
11
|
+
async options() {
|
|
12
|
+
const { subscriptions } = await this.listSubscriptions();
|
|
13
|
+
return subscriptions?.map(({
|
|
14
|
+
_id, title,
|
|
15
|
+
}) => ({
|
|
16
|
+
label: title || _id,
|
|
17
|
+
value: _id,
|
|
18
|
+
})) || [];
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
methods: {
|
|
23
|
+
_baseUrl() {
|
|
24
|
+
return "https://platform.vestaboard.com/v2.0";
|
|
25
|
+
},
|
|
26
|
+
_headers() {
|
|
27
|
+
return {
|
|
28
|
+
"X-Vestaboard-Api-Key": this.$auth.api_key,
|
|
29
|
+
"X-Vestaboard-Api-Secret": this.$auth.api_secret,
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
async _makeRequest({
|
|
33
|
+
$ = this,
|
|
34
|
+
url,
|
|
35
|
+
headers,
|
|
36
|
+
path,
|
|
37
|
+
...args
|
|
38
|
+
}) {
|
|
39
|
+
return axios($, {
|
|
40
|
+
url: url || `${this._baseUrl()}${path}`,
|
|
41
|
+
headers: headers || this._headers(),
|
|
42
|
+
...args,
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
async getCurrentMessage(args = {}) {
|
|
46
|
+
return this._makeRequest({
|
|
47
|
+
url: "https://rw.vestaboard.com",
|
|
48
|
+
headers: {
|
|
49
|
+
"X-Vestaboard-Read-Write-Key": this.$auth.readwrite_api_key,
|
|
50
|
+
},
|
|
51
|
+
...args,
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
listSubscriptions(args = {}) {
|
|
55
|
+
return this._makeRequest({
|
|
56
|
+
path: "/subscriptions",
|
|
57
|
+
...args,
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
createMessage({
|
|
61
|
+
subscriptionId, ...args
|
|
62
|
+
} = {}) {
|
|
63
|
+
return this._makeRequest({
|
|
64
|
+
path: `/subscriptions/${subscriptionId}/message`,
|
|
65
|
+
method: "POST",
|
|
66
|
+
...args,
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
};
|