Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions components/botcake/actions/create-keyword/create-keyword.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import app from "../../botcake.app.mjs";

export default {
key: "botcake-create-keyword",
name: "Create Keyword",
description: "Create a new Keyword. [See the documentation](https://docs.botcake.io/english/api-reference#create-keyword)",
version: "0.0.1",
type: "action",
props: {
app,
},

async run({ $ }) {
const response = await this.app.createKeyword({
$,
});
$.export("$summary", "Successfully created new Keyword");
return response;
},
};
20 changes: 20 additions & 0 deletions components/botcake/actions/get-tools/get-tools.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import app from "../../botcake.app.mjs";

export default {
key: "botcake-get-tools",
name: "Get Tools",
description: "Get a list of tools associated with the specified page. [See the documentation](https://docs.botcake.io/english/api-reference#get-tools)",
version: "0.0.1",
type: "action",
props: {
app,
},

async run({ $ }) {
const response = await this.app.getTools({
$,
});
$.export("$summary", `Successfully retrieved ${response.data.length} tools`);
return response;
},
};
38 changes: 38 additions & 0 deletions components/botcake/actions/update-keyword/update-keyword.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import app from "../../botcake.app.mjs";

export default {
key: "botcake-update-keyword",
name: "Update Keyword",
description: "Update the Keyword with the specified ID. [See the documentation](https://docs.botcake.io/english/api-reference#update-keyword)",
version: "0.0.1",
type: "action",
props: {
app,
keywordId: {
propDefinition: [
app,
"keywordId",
],
},
flowId: {
propDefinition: [
app,
"flowId",
],
},
},

async run({ $ }) {
const response = await this.app.updateKeyword({
$,
data: {
keyword_id: this.keywordId,
update: {
flow_id: this.flowId,
},
},
});
$.export("$summary", `Successfully updated Keyword with ID: '${this.keywordId}'`);
return response;
},
};
87 changes: 82 additions & 5 deletions components/botcake/botcake.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,88 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "botcake",
propDefinitions: {},
propDefinitions: {
flowId: {
type: "integer",
label: "Flow ID",
description: "ID of the Flow",
async options() {
const response = await this.getFlow();
const flowsIds = response.data.flows;
return flowsIds.map(({
id, name,
}) => ({
label: name,
value: id,
}));
},
},
keywordId: {
type: "integer",
label: "Keyword ID",
description: "ID of the Keyword",
async options() {
const response = await this.getKeyword();
const keywordIds = response.data;
return keywordIds.map(({ id }) => ({
value: id,
}));
},
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://botcake.io/api/public_api/v1/";
},
async _makeRequest(opts = {}) {
const {
$ = this,
path,
headers,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
headers: {
...headers,
"access-token": `${this.$auth.api_key}`,
},
});
},
async createKeyword(args = {}) {
return this._makeRequest({
path: `/pages/${this.$auth.page_id}/keywords/create`,
method: "post",
...args,
});
},
async updateKeyword(args = {}) {
return this._makeRequest({
path: `/pages/${this.$auth.page_id}/keywords/update`,
method: "post",
...args,
});
},
async getTools(args = {}) {
return this._makeRequest({
path: `/pages/${this.$auth.page_id}/tools`,
...args,
});
},
async getKeyword(args = {}) {
return this._makeRequest({
path: `/pages/${this.$auth.page_id}/keywords`,
...args,
});
},
async getFlow(args = {}) {
return this._makeRequest({
path: `/pages/${this.$auth.page_id}/flows`,
...args,
});
},
},
};
};
7 changes: 5 additions & 2 deletions components/botcake/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/botcake",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Botcake Components",
"main": "botcake.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
}
6 changes: 5 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading