diff --git a/components/adyntel/actions/google-ads-by-company/google-ads-by-company.mjs b/components/adyntel/actions/google-ads-by-company/google-ads-by-company.mjs new file mode 100644 index 0000000000000..ba3bd648f6dcc --- /dev/null +++ b/components/adyntel/actions/google-ads-by-company/google-ads-by-company.mjs @@ -0,0 +1,39 @@ +import adyntel from "../../adyntel.app.mjs"; + +export default { + key: "adyntel-google-ads-by-company", + name: "Get Google Ads by Company", + description: "Retrieve all Google ads for a given company domain. [See the documentation](https://docs.adyntel.com/ad-libraries/google)", + version: "0.0.1", + type: "action", + props: { + adyntel, + companyDomain: { + type: "string", + label: "Company Domain", + description: "The company domain. Company domain has to be passed in the 'company.com' format, meaning all prefixes like 'https://' or 'www.' need to be removed.", + }, + mediaType: { + type: "string", + label: "Media Type", + description: "Filter results based on media type", + options: [ + "text", + "image", + "video", + ], + optional: true, + }, + }, + async run({ $ }) { + const response = await this.adyntel.getGoogleAds({ + $, + data: { + company_domain: this.companyDomain, + media_type: this.mediaType, + }, + }); + $.export("$summary", `Fetched Google Ads for domain ${this.companyDomain}`); + return response; + }, +}; diff --git a/components/adyntel/actions/meta-ad-search/meta-ad-search.mjs b/components/adyntel/actions/meta-ad-search/meta-ad-search.mjs new file mode 100644 index 0000000000000..6446011faafd0 --- /dev/null +++ b/components/adyntel/actions/meta-ad-search/meta-ad-search.mjs @@ -0,0 +1,37 @@ +import adyntel from "../../adyntel.app.mjs"; + +export default { + key: "adyntel-meta-ad-search", + name: "Meta Ad Search", + description: "Searches the Meta ad library. [See the documentation](https://docs.adyntel.com/ad-libraries/meta-ad-search)", + version: "0.0.1", + type: "action", + props: { + adyntel, + keyword: { + propDefinition: [ + adyntel, + "keyword", + ], + }, + countryCode: { + propDefinition: [ + adyntel, + "countryCode", + ], + }, + }, + async run({ $ }) { + const response = await this.adyntel.metaAdSearch({ + $, + data: { + keyword: this.keyword, + country_code: this.countryCode, + }, + }); + $.export("$summary", `Successfully performed Meta ad search with keyword: \`${this.keyword}\`${this.countryCode + ? ` and country code: \`${this.countryCode}\`` + : ""}`); + return response; + }, +}; diff --git a/components/adyntel/actions/tiktok-search/tiktok-search.mjs b/components/adyntel/actions/tiktok-search/tiktok-search.mjs new file mode 100644 index 0000000000000..e3cff438ff4e9 --- /dev/null +++ b/components/adyntel/actions/tiktok-search/tiktok-search.mjs @@ -0,0 +1,28 @@ +import adyntel from "../../adyntel.app.mjs"; + +export default { + key: "adyntel-tiktok-search", + name: "Search TikTok Ads", + description: "Search TikTok ads using a keyword. [See the documentation](https://docs.adyntel.com/ad-libraries/tiktok-search)", + version: "0.0.1", + type: "action", + props: { + adyntel, + keyword: { + propDefinition: [ + adyntel, + "keyword", + ], + }, + }, + async run({ $ }) { + const response = await this.adyntel.getTiktokAds({ + $, + data: { + keyword: this.keyword, + }, + }); + $.export("$summary", `Successfully retrieved TikTok ads for keyword: \`${this.keyword}\``); + return response; + }, +}; diff --git a/components/adyntel/adyntel.app.mjs b/components/adyntel/adyntel.app.mjs index 8da4a37b92e22..9ca2b9d7d106e 100644 --- a/components/adyntel/adyntel.app.mjs +++ b/components/adyntel/adyntel.app.mjs @@ -1,11 +1,60 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "adyntel", - propDefinitions: {}, + propDefinitions: { + keyword: { + type: "string", + label: "Keyword", + description: "The keyword to search by", + }, + countryCode: { + type: "string", + label: "Country Code", + description: "Use if you want to limit the search to only one country. E.g. `US`", + optional: true, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://api.adyntel.com"; + }, + _makeRequest({ + $ = this, + method = "POST", + path = "/", + data = {}, + ...otherOpts + }) { + return axios($, { + ...otherOpts, + method, + url: `${this._baseUrl()}${path}`, + data: { + ...data, + api_key: this.$auth.api_key, + email: this.$auth.username, + }, + }); + }, + metaAdSearch(opts = {}) { + return this._makeRequest({ + path: "/facebook_ad_search", + ...opts, + }); + }, + getGoogleAds(opts = {}) { + return this._makeRequest({ + path: "/google", + ...opts, + }); + }, + getTiktokAds(opts = {}) { + return this._makeRequest({ + path: "/tiktok_search", + ...opts, + }); }, }, }; diff --git a/components/adyntel/package.json b/components/adyntel/package.json index 0552c186b6826..6a90415cd193f 100644 --- a/components/adyntel/package.json +++ b/components/adyntel/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/adyntel", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Adyntel Components", "main": "adyntel.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/components/facebook_graph_api/facebook_graph_api.app.mjs b/components/facebook_graph_api/facebook_graph_api.app.mjs index e43e6f28f6bc8..a897a39bcf741 100644 --- a/components/facebook_graph_api/facebook_graph_api.app.mjs +++ b/components/facebook_graph_api/facebook_graph_api.app.mjs @@ -8,4 +8,4 @@ export default { console.log(Object.keys(this.$auth)); }, }, -}; \ No newline at end of file +}; diff --git a/components/gather/gather.app.mjs b/components/gather/gather.app.mjs index 8ffeb104402d4..e4656c599633c 100644 --- a/components/gather/gather.app.mjs +++ b/components/gather/gather.app.mjs @@ -8,4 +8,4 @@ export default { console.log(Object.keys(this.$auth)); }, }, -}; \ No newline at end of file +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 88c0fcbfb9798..a77a141ff6751 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -379,7 +379,11 @@ importers: specifier: ^20.0.0 version: 20.0.0 - components/adyntel: {} + components/adyntel: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 components/aerisweather: dependencies: @@ -4308,8 +4312,7 @@ importers: components/facebook_conversions: {} - components/facebook_graph_api: - specifiers: {} + components/facebook_graph_api: {} components/facebook_groups: dependencies: @@ -4929,8 +4932,7 @@ importers: components/gatekeeper: {} - components/gather: - specifiers: {} + components/gather: {} components/gatherup: dependencies: