Skip to content

Commit 47944a0

Browse files
authored
12458 components gloww (#12521)
* [Components] gloww #12458 Actions - Create Live Session * pnpm update
1 parent 6633718 commit 47944a0

File tree

4 files changed

+126
-10
lines changed

4 files changed

+126
-10
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import gloww from "../../gloww.app.mjs";
3+
4+
export default {
5+
key: "gloww-create-live-session",
6+
name: "Create Live Session",
7+
version: "0.0.1",
8+
description: "Create a new Live Session [See the documentation](https://gloww.com/faq/)",
9+
type: "action",
10+
props: {
11+
gloww,
12+
sessionId: {
13+
propDefinition: [
14+
gloww,
15+
"sessionId",
16+
],
17+
optional: true,
18+
},
19+
templateId: {
20+
propDefinition: [
21+
gloww,
22+
"templateId",
23+
],
24+
optional: true,
25+
},
26+
name: {
27+
type: "string",
28+
label: "Name",
29+
description: "The name of the Live Session.",
30+
},
31+
},
32+
async run({ $ }) {
33+
if ((!this.sessionId && !this.templateId) || (this.sessionId && this.templateId)) {
34+
throw new ConfigurationError("You must provide either Session Id or Template Id.");
35+
}
36+
37+
const response = await this.gloww.createSession({
38+
$,
39+
data: {
40+
name: this.sessionName,
41+
},
42+
params: {
43+
fromTemplateId: this.templateId,
44+
fromSessionId: this.sessionId,
45+
},
46+
});
47+
48+
$.export("$summary", `A new live session with Id: ${response.id} was successfully created!`);
49+
return response;
50+
},
51+
};

components/gloww/gloww.app.mjs

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,70 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "gloww",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
sessionId: {
8+
type: "string",
9+
label: "Session Id",
10+
description: "The Id of the session on which the new session is based.",
11+
async options() {
12+
const { sessions } = await this.listSuggestions();
13+
14+
return sessions.map(({
15+
id: value, name: label,
16+
}) => ({
17+
label,
18+
value,
19+
}));
20+
},
21+
},
22+
templateId: {
23+
type: "string",
24+
label: "Template Id",
25+
description: "The Id of the template on which the new session is based.",
26+
async options() {
27+
const { templates } = await this.listSuggestions();
28+
29+
return templates.map(({
30+
id: value, name: label,
31+
}) => ({
32+
label,
33+
value,
34+
}));
35+
},
36+
},
37+
},
538
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
39+
_apiUrl() {
40+
return "https://api.gloww.com";
41+
},
42+
_getHeaders() {
43+
return {
44+
"Authorization": `Bearer ${this.$auth.oauth_access_token}`,
45+
};
46+
},
47+
_makeRequest({
48+
$ = this, path, ...opts
49+
}) {
50+
return axios($, {
51+
url: `${this._apiUrl()}${path}`,
52+
headers: this._getHeaders(),
53+
...opts,
54+
});
55+
},
56+
createSession(opts = {}) {
57+
return this._makeRequest({
58+
method: "POST",
59+
path: "/api/liveSessions",
60+
...opts,
61+
});
62+
},
63+
listSuggestions(opts = {}) {
64+
return this._makeRequest({
65+
path: "/integrations/suggestions/sessions",
66+
...opts,
67+
});
968
},
1069
},
11-
};
70+
};

components/gloww/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/gloww",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Gloww Components",
55
"main": "gloww.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": "^2.0.0"
1417
}
15-
}
18+
}

pnpm-lock.yaml

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)