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..4c7ccc391bc0f --- /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 provide either a User ID or 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 +} 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: