Skip to content

Commit 0cc715b

Browse files
Merging pull request #15288
* Added actions * Done requests changes * Update components/hypeauditor/actions/get-instagram-report/get-instagram-report.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent b2d3363 commit 0cc715b

File tree

6 files changed

+197
-7
lines changed

6 files changed

+197
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import app from "../../hypeauditor.app.mjs";
2+
import { ConfigurationError } from "@pipedream/platform";
3+
4+
export default {
5+
key: "hypeauditor-get-instagram-report",
6+
name: "Get Instagram Report",
7+
description: "Returns a report about the specified Instagram user. [See the documentation](https://hypeauditor.readme.io/reference/report_instagram#requests)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
username: {
13+
propDefinition: [
14+
app,
15+
"username",
16+
],
17+
},
18+
userId: {
19+
propDefinition: [
20+
app,
21+
"userId",
22+
],
23+
},
24+
},
25+
26+
async run({ $ }) {
27+
if (!this.userId && !this.username) {
28+
throw new ConfigurationError("You need to provide either a User ID or Username");
29+
}
30+
31+
const response = await this.app.getInstagramReport({
32+
$,
33+
params: {
34+
username: this.userId ?? this.username,
35+
v: "2",
36+
},
37+
38+
});
39+
40+
$.export("$summary", `Successfully sent the request. Report state: '${response.result.report_state}'`);
41+
42+
return response;
43+
},
44+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import app from "../../hypeauditor.app.mjs";
2+
3+
export default {
4+
key: "hypeauditor-get-tiktok-report",
5+
name: "Get Tiktok Report",
6+
description: "Returns a report about the specified Tiktok channel. [See the documentation](https://hypeauditor.readme.io/reference/get_report_tiktok)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
channelUsername: {
12+
propDefinition: [
13+
app,
14+
"channelUsername",
15+
],
16+
optional: false,
17+
},
18+
},
19+
20+
async run({ $ }) {
21+
const response = await this.app.getTiktokReport({
22+
$,
23+
data: {
24+
channel: this.channelUsername,
25+
},
26+
});
27+
$.export("$summary", `Successfully sent the request. Report state: '${response.result.report_state}'`);
28+
29+
return response;
30+
},
31+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import app from "../../hypeauditor.app.mjs";
2+
import { ConfigurationError } from "@pipedream/platform";
3+
4+
export default {
5+
key: "hypeauditor-get-youtube-report",
6+
name: "Get Youtube Report",
7+
description: "Returns a report about the specified Youtube channel. [See the documentation](https://hypeauditor.readme.io/reference/report_youtube)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
channelId: {
13+
propDefinition: [
14+
app,
15+
"channelId",
16+
],
17+
},
18+
channelUsername: {
19+
propDefinition: [
20+
app,
21+
"channelUsername",
22+
],
23+
},
24+
},
25+
26+
async run({ $ }) {
27+
if (!this.channelId && !this.channelUsername) {
28+
throw new ConfigurationError("You need to inform a Channel ID or Channel Username");
29+
}
30+
31+
const response = await this.app.getYoutubeReport({
32+
$,
33+
data: {
34+
channel: this.channelId ?? this.channelUsername,
35+
},
36+
});
37+
38+
$.export("$summary", `Successfully sent the request. Report state: '${response.result.report_state}'`);
39+
40+
return response;
41+
},
42+
};
+70-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,77 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "hypeauditor",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
username: {
8+
type: "string",
9+
label: "Username",
10+
description: "Username to request the report",
11+
optional: true,
12+
},
13+
userId: {
14+
type: "string",
15+
label: "User ID",
16+
description: "User ID to request the report",
17+
optional: true,
18+
},
19+
channelUsername: {
20+
type: "string",
21+
label: "Channel Username",
22+
description: "Identify the user by their Channel Username",
23+
optional: true,
24+
},
25+
channelId: {
26+
type: "string",
27+
label: "Channel ID",
28+
description: "Identify the user by their Channel ID",
29+
optional: true,
30+
},
31+
},
532
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
33+
_baseUrl() {
34+
return "https://hypeauditor.com/api/method";
35+
},
36+
async _makeRequest(opts = {}) {
37+
const {
38+
$ = this,
39+
path,
40+
headers,
41+
...otherOpts
42+
} = opts;
43+
return axios($, {
44+
...otherOpts,
45+
url: this._baseUrl() + path,
46+
headers: {
47+
...headers,
48+
"content-type": "application/x-www-form-urlencoded",
49+
"x-auth-id": `${this.$auth.client_id}`,
50+
"x-auth-token": `${this.$auth.api_token}`,
51+
"user-agent": "pipedream/1",
52+
},
53+
});
54+
},
55+
async getInstagramReport(args = {}) {
56+
return this._makeRequest({
57+
path: "/auditor.report/",
58+
method: "post",
59+
...args,
60+
});
61+
},
62+
async getYoutubeReport(args = {}) {
63+
return this._makeRequest({
64+
path: "/auditor.youtube/",
65+
method: "post",
66+
...args,
67+
});
68+
},
69+
async getTiktokReport(args = {}) {
70+
return this._makeRequest({
71+
path: "/auditor.tiktok",
72+
method: "post",
73+
...args,
74+
});
975
},
1076
},
1177
};

components/hypeauditor/package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/hypeauditor",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream HypeAuditor Components",
55
"main": "hypeauditor.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
15-
}
18+
}

pnpm-lock.yaml

+5-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)