|
| 1 | +import { axios } from "@pipedream/platform"; |
| 2 | + |
1 | 3 | export default { |
2 | 4 | type: "app", |
3 | 5 | app: "hypeauditor", |
4 | | - propDefinitions: {}, |
| 6 | + version: "0.0.ts", |
| 7 | + propDefinitions: { |
| 8 | + youtubeChannel: { |
| 9 | + type: "string", |
| 10 | + label: "YouTube Channel ID or Username", |
| 11 | + description: "The YouTube channel ID or username for which to generate a report.", |
| 12 | + }, |
| 13 | + youtubeFeatures: { |
| 14 | + type: "string", |
| 15 | + label: "Features List", |
| 16 | + description: "Optional list of features to include in the YouTube report.", |
| 17 | + optional: true, |
| 18 | + }, |
| 19 | + tiktokUser: { |
| 20 | + type: "string", |
| 21 | + label: "TikTok User Name or ID", |
| 22 | + description: "The TikTok username or ID for which to generate a report.", |
| 23 | + }, |
| 24 | + instagramUser: { |
| 25 | + type: "string", |
| 26 | + label: "Instagram User Name or ID", |
| 27 | + description: "The Instagram username or ID for which to generate a report.", |
| 28 | + }, |
| 29 | + twitchChannel: { |
| 30 | + type: "string", |
| 31 | + label: "Twitch Channel Username", |
| 32 | + description: "The Twitch channel username for which to generate a report.", |
| 33 | + }, |
| 34 | + }, |
5 | 35 | methods: { |
6 | | - // this.$auth contains connected account data |
7 | 36 | authKeys() { |
8 | 37 | console.log(Object.keys(this.$auth)); |
9 | 38 | }, |
| 39 | + _baseUrl() { |
| 40 | + return "https://hypeauditor.com/api/method/auditor"; |
| 41 | + }, |
| 42 | + async _makeRequest(opts = {}) { |
| 43 | + const { |
| 44 | + $ = this, method = "GET", path = "/", headers = {}, ...otherOpts |
| 45 | + } = opts; |
| 46 | + return axios($, { |
| 47 | + method, |
| 48 | + url: `${this._baseUrl()}${path}`, |
| 49 | + headers: { |
| 50 | + ...headers, |
| 51 | + "X-Auth-Token": this.$auth.token, |
| 52 | + "X-Auth-Id": this.$auth.id, |
| 53 | + }, |
| 54 | + ...otherOpts, |
| 55 | + }); |
| 56 | + }, |
| 57 | + async getYouTubeReport(opts = {}) { |
| 58 | + const { |
| 59 | + channel, features, |
| 60 | + } = opts; |
| 61 | + const params = { |
| 62 | + channel, |
| 63 | + }; |
| 64 | + if (features) { |
| 65 | + params.features = features; |
| 66 | + } |
| 67 | + return this._makeRequest({ |
| 68 | + path: "/youtube/", |
| 69 | + params, |
| 70 | + }); |
| 71 | + }, |
| 72 | + async getTikTokReport(opts = {}) { |
| 73 | + const { channel } = opts; |
| 74 | + return this._makeRequest({ |
| 75 | + path: "/tiktok/", |
| 76 | + params: { |
| 77 | + channel, |
| 78 | + }, |
| 79 | + }); |
| 80 | + }, |
| 81 | + async getInstagramReport(opts = {}) { |
| 82 | + const { channel } = opts; |
| 83 | + return this._makeRequest({ |
| 84 | + path: "/instagram/", |
| 85 | + params: { |
| 86 | + channel, |
| 87 | + }, |
| 88 | + }); |
| 89 | + }, |
| 90 | + async getTwitchReport(opts = {}) { |
| 91 | + const { channel } = opts; |
| 92 | + return this._makeRequest({ |
| 93 | + path: "/twitch/", |
| 94 | + params: { |
| 95 | + channel, |
| 96 | + }, |
| 97 | + }); |
| 98 | + }, |
10 | 99 | }, |
11 | 100 | }; |
0 commit comments