Skip to content

Commit 7a1d134

Browse files
committed
Added actions
1 parent e86f52d commit 7a1d134

File tree

6 files changed

+177
-10
lines changed

6 files changed

+177
-10
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import app from "../../botcake.app.mjs";
2+
3+
export default {
4+
key: "botcake-create-keyword",
5+
name: "Create Keyword",
6+
description: "Create a new Keyword. [See the documentation](https://docs.botcake.io/english/api-reference#create-keyword)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
},
12+
13+
async run({ $ }) {
14+
const response = await this.app.createKeyword({
15+
$,
16+
});
17+
18+
$.export("$summary", "Successfully created new Keyword");
19+
20+
return response;
21+
},
22+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import app from "../../botcake.app.mjs";
2+
3+
export default {
4+
key: "botcake-get-tools",
5+
name: "Get Tools",
6+
description: "Get a list of tools associated with the specified page. [See the documentation](https://docs.botcake.io/english/api-reference#get-tools)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
},
12+
13+
async run({ $ }) {
14+
const response = await this.app.getTools({
15+
$,
16+
});
17+
18+
$.export("$summary", `Successfully retrieved ${response.data.length} tools`);
19+
20+
return response;
21+
},
22+
};
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import app from "../../botcake.app.mjs";
2+
3+
export default {
4+
key: "botcake-update-keyword",
5+
name: "Update Keyword",
6+
description: "Update the Keyword with the specified ID. [See the documentation](https://docs.botcake.io/english/api-reference#update-keyword)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
keywordId: {
12+
propDefinition: [
13+
app,
14+
"keywordId",
15+
],
16+
},
17+
flowId: {
18+
propDefinition: [
19+
app,
20+
"flowId",
21+
],
22+
},
23+
},
24+
25+
async run({ $ }) {
26+
const response = await this.app.updateKeyword({
27+
$,
28+
data: {
29+
keyword_id: this.keywordId,
30+
update: {
31+
flow_id: this.flowId,
32+
},
33+
},
34+
});
35+
36+
$.export("$summary", `Successfully updated Keyword with ID: '${this.keywordId}'`);
37+
38+
return response;
39+
},
40+
};

components/botcake/botcake.app.mjs

Lines changed: 82 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,88 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "botcake",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
flowId: {
8+
type: "integer",
9+
label: "Flow ID",
10+
description: "ID of the Flow",
11+
async options() {
12+
const response = await this.getFlow();
13+
const flowsIds = response.data.folders;
14+
return flowsIds.map(({
15+
id, name,
16+
}) => ({
17+
label: name,
18+
value: id,
19+
}));
20+
},
21+
},
22+
keywordId: {
23+
type: "integer",
24+
label: "Keyword ID",
25+
description: "ID of the Keyword",
26+
async options() {
27+
const response = await this.getKeyword();
28+
const datasourceIds = response.datasources;
29+
return datasourceIds.map(({ id }) => ({
30+
value: id,
31+
}));
32+
},
33+
},
34+
},
535
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
36+
_baseUrl() {
37+
return "https://botcake.io/api/public_api/v1/";
38+
},
39+
async _makeRequest(opts = {}) {
40+
const {
41+
$ = this,
42+
path,
43+
headers,
44+
...otherOpts
45+
} = opts;
46+
return axios($, {
47+
...otherOpts,
48+
url: this._baseUrl() + path,
49+
headers: {
50+
...headers,
51+
"access-token": `${this.$auth.api_key}`,
52+
},
53+
});
54+
},
55+
async createKeyword(args = {}) {
56+
return this._makeRequest({
57+
path: `/pages/${this.$auth.page_id}/keywords/create`,
58+
method: "post",
59+
...args,
60+
});
61+
},
62+
async updateKeyword(args = {}) {
63+
return this._makeRequest({
64+
path: `/pages/${this.$auth.page_id}/keywords/update`,
65+
method: "post",
66+
...args,
67+
});
68+
},
69+
async getTools(args = {}) {
70+
return this._makeRequest({
71+
path: `/pages/${this.$auth.page_id}/tools`,
72+
...args,
73+
});
74+
},
75+
async getKeyword(args = {}) {
76+
return this._makeRequest({
77+
path: `/pages/${this.$auth.page_id}/keywords`,
78+
...args,
79+
});
80+
},
81+
async getFlow(args = {}) {
82+
return this._makeRequest({
83+
path: `/pages/${this.$auth.page_id}/flows`,
84+
...args,
85+
});
986
},
1087
},
11-
};
88+
};

components/botcake/package.json

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