Skip to content

Commit 70c3710

Browse files
authored
Added actions (#14553)
1 parent a529aa1 commit 70c3710

File tree

5 files changed

+87
-6
lines changed

5 files changed

+87
-6
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import app from "../../autoblogger.app.mjs";
2+
3+
export default {
4+
key: "autoblogger-get-blogposts",
5+
name: "Get Blogposts",
6+
description: "Retrieves blogposts using the API key. [See the documentation](https://u.pcloud.link/publink/show?code=XZdjuv0ZtabS8BN58thUiE8FGjznajoMc6Qy)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
},
12+
13+
async run({ $ }) {
14+
const response = await this.app.getBlogposts({
15+
$,
16+
});
17+
18+
$.export("$summary", `Successfully retrieved ${response.length} blogposts`);
19+
20+
return response;
21+
},
22+
};
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import app from "../../autoblogger.app.mjs";
2+
3+
export default {
4+
key: "autoblogger-validate-api-key",
5+
name: "Validate API Key",
6+
description: "Validates the provided API key. [See the documentation](https://u.pcloud.link/publink/show?code=XZdjuv0ZtabS8BN58thUiE8FGjznajoMc6Qy)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
},
12+
async run({ $ }) {
13+
const response = await this.app.validateKey({
14+
$,
15+
});
16+
17+
$.export("$summary", `API Key ${response.is_valid
18+
? "is"
19+
: "isn't"} valid`);
20+
21+
return response;
22+
},
23+
};
Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,41 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "autoblogger",
46
propDefinitions: {},
57
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
8+
_baseUrl() {
9+
return "https://autoblogger-api.otherweb.com";
10+
},
11+
async _makeRequest(opts = {}) {
12+
const {
13+
$ = this,
14+
path,
15+
headers,
16+
...otherOpts
17+
} = opts;
18+
return axios($, {
19+
...otherOpts,
20+
url: this._baseUrl() + path,
21+
headers: {
22+
...headers,
23+
"x-api-key": `${this.$auth.api_key}`,
24+
"Accept": "application/json",
25+
},
26+
});
27+
},
28+
async validateKey(args = {}) {
29+
return this._makeRequest({
30+
path: "/api/v1/site/validate/apikey",
31+
...args,
32+
});
33+
},
34+
async getBlogposts(args = {}) {
35+
return this._makeRequest({
36+
path: "/api/v1/blogposts",
37+
...args,
38+
});
939
},
1040
},
1141
};

components/autoblogger/package.json

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