From e28f3a4b0854ea06cfddbac4099183e7695670f4 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Mon, 13 Jan 2025 18:11:55 -0300 Subject: [PATCH 1/3] Added actions --- .../get-instagram-report.mjs | 44 +++++++++++ .../get-tiktok-report/get-tiktok-report.mjs | 31 ++++++++ .../get-youtube-report/get-youtube-report.mjs | 42 +++++++++++ components/hypeauditor/hypeauditor.app.mjs | 74 ++++++++++++++++++- components/hypeauditor/package.json | 7 +- 5 files changed, 192 insertions(+), 6 deletions(-) create mode 100644 components/hypeauditor/actions/get-instagram-report/get-instagram-report.mjs create mode 100644 components/hypeauditor/actions/get-tiktok-report/get-tiktok-report.mjs create mode 100644 components/hypeauditor/actions/get-youtube-report/get-youtube-report.mjs diff --git a/components/hypeauditor/actions/get-instagram-report/get-instagram-report.mjs b/components/hypeauditor/actions/get-instagram-report/get-instagram-report.mjs new file mode 100644 index 0000000000000..348ed3aab325c --- /dev/null +++ b/components/hypeauditor/actions/get-instagram-report/get-instagram-report.mjs @@ -0,0 +1,44 @@ +import app from "../../hypeauditor.app.mjs"; +import { ConfigurationError } from "@pipedream/platform"; + +export default { + key: "hypeauditor-get-instagram-report", + name: "Get Instagram Report", + description: "Returns a report about the specified Instagram user. [See the documentation](https://hypeauditor.readme.io/reference/report_instagram#requests)", + version: "0.0.1", + type: "action", + props: { + app, + username: { + propDefinition: [ + app, + "username", + ], + }, + userId: { + propDefinition: [ + app, + "userId", + ], + }, + }, + + async run({ $ }) { + if (!this.userId && !this.username) { + throw new ConfigurationError("You need to inform a Channel ID or Channel Username"); + } + + const response = await this.app.getInstagramReport({ + $, + params: { + username: this.userId ?? this.username, + v: "2", + }, + + }); + + $.export("$summary", `Successfully sent the request. Report state: '${response.result.report_state}'`); + + return response; + }, +}; diff --git a/components/hypeauditor/actions/get-tiktok-report/get-tiktok-report.mjs b/components/hypeauditor/actions/get-tiktok-report/get-tiktok-report.mjs new file mode 100644 index 0000000000000..30a0ceefbbcb7 --- /dev/null +++ b/components/hypeauditor/actions/get-tiktok-report/get-tiktok-report.mjs @@ -0,0 +1,31 @@ +import app from "../../hypeauditor.app.mjs"; + +export default { + key: "hypeauditor-get-tiktok-report", + name: "Get Tiktok Report", + description: "Returns a report about the specified Tiktok channel. [See the documentation](https://hypeauditor.readme.io/reference/get_report_tiktok)", + version: "0.0.1", + type: "action", + props: { + app, + channelUsername: { + propDefinition: [ + app, + "channelUsername", + ], + optional: false, + }, + }, + + async run({ $ }) { + const response = await this.app.getTiktokReport({ + $, + data: { + channel: this.channelUsername, + }, + }); + $.export("$summary", `Successfully sent the request. Report state: '${response.result.report_state}'`); + + return response; + }, +}; diff --git a/components/hypeauditor/actions/get-youtube-report/get-youtube-report.mjs b/components/hypeauditor/actions/get-youtube-report/get-youtube-report.mjs new file mode 100644 index 0000000000000..65a52af1d6f12 --- /dev/null +++ b/components/hypeauditor/actions/get-youtube-report/get-youtube-report.mjs @@ -0,0 +1,42 @@ +import app from "../../hypeauditor.app.mjs"; +import { ConfigurationError } from "@pipedream/platform"; + +export default { + key: "hypeauditor-get-youtube-report", + name: "Get Youtube Report", + description: "Returns a report about the specified Youtube channel. [See the documentation](https://hypeauditor.readme.io/reference/report_youtube)", + version: "0.0.1", + type: "action", + props: { + app, + channelId: { + propDefinition: [ + app, + "channelId", + ], + }, + channelUsername: { + propDefinition: [ + app, + "channelUsername", + ], + }, + }, + + async run({ $ }) { + if (!this.channelId && !this.channelUsername) { + throw new ConfigurationError("You need to inform a Channel ID or Channel Username"); + } + + const response = await this.app.getYoutubeReport({ + $, + data: { + channel: this.channelId ?? this.channelUsername, + }, + }); + + $.export("$summary", `Successfully sent the request. Report state: '${response.result.report_state}'`); + + return response; + }, +}; diff --git a/components/hypeauditor/hypeauditor.app.mjs b/components/hypeauditor/hypeauditor.app.mjs index b345205533325..cf5b884c70e59 100644 --- a/components/hypeauditor/hypeauditor.app.mjs +++ b/components/hypeauditor/hypeauditor.app.mjs @@ -1,11 +1,77 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "hypeauditor", - propDefinitions: {}, + propDefinitions: { + username: { + type: "string", + label: "Username", + description: "Username to request the report", + optional: true, + }, + userId: { + type: "string", + label: "User ID", + description: "User ID to request the report", + optional: true, + }, + channelUsername: { + type: "string", + label: "Channel Username", + description: "Identify the user by their Channel Username", + optional: true, + }, + channelId: { + type: "string", + label: "Channel ID", + description: "Identify the user by their Channel ID", + optional: true, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://hypeauditor.com/api/method"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, + path, + headers, + ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + url: this._baseUrl() + path, + headers: { + ...headers, + "content-type": "application/x-www-form-urlencoded", + "x-auth-id": `${this.$auth.client_id}`, + "x-auth-token": `${this.$auth.api_token}`, + "user-agent": "pipedream/1", + }, + }); + }, + async getInstagramReport(args = {}) { + return this._makeRequest({ + path: "/auditor.report/", + method: "post", + ...args, + }); + }, + async getYoutubeReport(args = {}) { + return this._makeRequest({ + path: "/auditor.youtube/", + method: "post", + ...args, + }); + }, + async getTiktokReport(args = {}) { + return this._makeRequest({ + path: "/auditor.tiktok", + method: "post", + ...args, + }); }, }, }; diff --git a/components/hypeauditor/package.json b/components/hypeauditor/package.json index 3c1285d450771..aaf6b8a4ec645 100644 --- a/components/hypeauditor/package.json +++ b/components/hypeauditor/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/hypeauditor", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream HypeAuditor Components", "main": "hypeauditor.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } -} \ No newline at end of file +} From c801e2ddcc89337f36ff5cfe243039c5a583a463 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Mon, 13 Jan 2025 18:17:13 -0300 Subject: [PATCH 2/3] Done requests changes --- pnpm-lock.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ad0d4660bbcf1..44e632514458c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4989,7 +4989,11 @@ importers: components/hygraph: {} - components/hypeauditor: {} + components/hypeauditor: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 components/hyperise: dependencies: From c97aca9265061ae805f42a3aae363a82f0480eea Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Mon, 13 Jan 2025 18:18:21 -0300 Subject: [PATCH 3/3] Update components/hypeauditor/actions/get-instagram-report/get-instagram-report.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../actions/get-instagram-report/get-instagram-report.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/hypeauditor/actions/get-instagram-report/get-instagram-report.mjs b/components/hypeauditor/actions/get-instagram-report/get-instagram-report.mjs index 348ed3aab325c..4c7ccc391bc0f 100644 --- a/components/hypeauditor/actions/get-instagram-report/get-instagram-report.mjs +++ b/components/hypeauditor/actions/get-instagram-report/get-instagram-report.mjs @@ -25,7 +25,7 @@ export default { async run({ $ }) { if (!this.userId && !this.username) { - throw new ConfigurationError("You need to inform a Channel ID or Channel Username"); + throw new ConfigurationError("You need to provide either a User ID or Username"); } const response = await this.app.getInstagramReport({