Skip to content

Commit 5935fa8

Browse files
jcorteslcaresia
authored andcommitted
[Components] bippybox: Action component (#14463)
1 parent 3977be7 commit 5935fa8

File tree

4 files changed

+88
-8
lines changed

4 files changed

+88
-8
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import app from "../../bippybox.app.mjs";
2+
3+
export default {
4+
key: "bippybox-activate-box",
5+
name: "Activate Box",
6+
description: "Triggers the BippyBox to play an audio file. [See the documentation](https://bippybox.io/docs/).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
device: {
12+
type: "string",
13+
label: "Device",
14+
description: "The device identifier. Eg. `DEVICE123`.",
15+
},
16+
url: {
17+
type: "string",
18+
label: "URL",
19+
description: "The URL of the audio file to play. Eg. `https://storage.example.com/users/exampleUserUID67890/audio/SampleAudioFile.wav?alt=media&token=exampleToken123456`.",
20+
},
21+
},
22+
async run({ $ }) {
23+
const {
24+
app,
25+
device,
26+
url,
27+
} = this;
28+
29+
const response = await app.activateBox({
30+
$,
31+
data: {
32+
device,
33+
URL: url,
34+
},
35+
});
36+
$.export("$summary", "Successfully activated BippyBox.");
37+
return response;
38+
},
39+
};
Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,46 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "bippybox",
4-
propDefinitions: {},
56
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
7+
getUrl(path) {
8+
return `https://websocket.bippybox.io${path}`;
9+
},
10+
getHeaders(headers) {
11+
return {
12+
...headers,
13+
"Content-Type": "application/json",
14+
"x-api-key": this.$auth.api_key,
15+
};
16+
},
17+
_makeRequest({
18+
$ = this, path, headers, ...args
19+
} = {}) {
20+
return axios($, {
21+
...args,
22+
url: this.getUrl(path),
23+
headers: this.getHeaders(headers),
24+
});
25+
},
26+
post(args = {}) {
27+
return this._makeRequest({
28+
method: "POST",
29+
...args,
30+
});
31+
},
32+
activateBox({
33+
data, ...args
34+
} = {}) {
35+
const { uid } = this.$auth;
36+
return this.post({
37+
path: "/send",
38+
data: {
39+
...data,
40+
uid,
41+
},
42+
...args,
43+
});
944
},
1045
},
11-
};
46+
};

components/bippybox/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/bippybox",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream BippyBox Components",
55
"main": "bippybox.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "3.0.3"
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)