From 7e37cfcc0d1eb5c244b00959e2a399341431f077 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Tue, 16 Sep 2025 10:56:52 -0300 Subject: [PATCH] Added actions --- .../actions/add-zipcode/add-zipcode.mjs | 37 +++++++++++ .../get-account-data/get-account-data.mjs | 19 ++++++ .../search-categories/search-categories.mjs | 28 +++++++++ components/redcircle_api/package.json | 5 +- .../redcircle_api/redcircle_api.app.mjs | 63 +++++++++++++++++-- pnpm-lock.yaml | 15 ++--- 6 files changed, 154 insertions(+), 13 deletions(-) create mode 100644 components/redcircle_api/actions/add-zipcode/add-zipcode.mjs create mode 100644 components/redcircle_api/actions/get-account-data/get-account-data.mjs create mode 100644 components/redcircle_api/actions/search-categories/search-categories.mjs diff --git a/components/redcircle_api/actions/add-zipcode/add-zipcode.mjs b/components/redcircle_api/actions/add-zipcode/add-zipcode.mjs new file mode 100644 index 0000000000000..8ae5268a8164c --- /dev/null +++ b/components/redcircle_api/actions/add-zipcode/add-zipcode.mjs @@ -0,0 +1,37 @@ +import app from "../../redcircle_api.app.mjs"; + +export default { + key: "redcircle_api-add-zipcode", + name: "Add Zipcode", + description: "Add a zipcode to Redcircle API. [See the documentation](https://docs.trajectdata.com/redcircleapi/zipcodes-api/add)", + version: "0.0.1", + type: "action", + props: { + app, + zipcode: { + propDefinition: [ + app, + "zipcode", + ], + }, + domain: { + propDefinition: [ + app, + "domain", + ], + }, + }, + async run({ $ }) { + const response = await this.app.addZipcode({ + $, + data: [ + { + zipcode: this.zipcode, + domain: this.domain, + }, + ], + }); + $.export("$summary", "Successfully sent the request"); + return response; + }, +}; diff --git a/components/redcircle_api/actions/get-account-data/get-account-data.mjs b/components/redcircle_api/actions/get-account-data/get-account-data.mjs new file mode 100644 index 0000000000000..04a91c989fa01 --- /dev/null +++ b/components/redcircle_api/actions/get-account-data/get-account-data.mjs @@ -0,0 +1,19 @@ +import app from "../../redcircle_api.app.mjs"; + +export default { + key: "redcircle_api-get-account-data", + name: "Get Account Data", + description: "Get your account details. [See the documentation](https://docs.trajectdata.com/redcircleapi/account-api)", + version: "0.0.1", + type: "action", + props: { + app, + }, + async run({ $ }) { + const response = await this.app.getAccountData({ + $, + }); + $.export("$summary", "Successfully retrieved the account data"); + return response; + }, +}; diff --git a/components/redcircle_api/actions/search-categories/search-categories.mjs b/components/redcircle_api/actions/search-categories/search-categories.mjs new file mode 100644 index 0000000000000..a135293563c19 --- /dev/null +++ b/components/redcircle_api/actions/search-categories/search-categories.mjs @@ -0,0 +1,28 @@ +import app from "../../redcircle_api.app.mjs"; + +export default { + key: "redcircle_api-search-categories", + name: "Search Categories", + description: "Search for a category in Redcirle API. [See the documentation](https://docs.trajectdata.com/redcircleapi/categories-api/list-and-search)", + version: "0.0.1", + type: "action", + props: { + app, + searchTerm: { + propDefinition: [ + app, + "searchTerm", + ], + }, + }, + async run({ $ }) { + const response = await this.app.searchCategories({ + $, + params: { + "search_term": this.searchTerm, + }, + }); + $.export("$summary", "Successfully sent the request and retrieved " + response.categories.length + " categories"); + return response; + }, +}; diff --git a/components/redcircle_api/package.json b/components/redcircle_api/package.json index 57b45351906af..f89f7e2189ea1 100644 --- a/components/redcircle_api/package.json +++ b/components/redcircle_api/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/redcircle_api", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream RedCircle API Components", "main": "redcircle_api.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.1.0" } } diff --git a/components/redcircle_api/redcircle_api.app.mjs b/components/redcircle_api/redcircle_api.app.mjs index b57d3ab691910..31c149d8aad1a 100644 --- a/components/redcircle_api/redcircle_api.app.mjs +++ b/components/redcircle_api/redcircle_api.app.mjs @@ -1,11 +1,64 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "redcircle_api", - propDefinitions: {}, + propDefinitions: { + searchTerm: { + type: "string", + label: "Search Term", + description: "The term to search for a category", + optional: true, + }, + zipcode: { + type: "string", + label: "Zipcode", + description: "Description for zipcode", + }, + domain: { + type: "string", + label: "Domain", + description: "Description for domain", + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://api.redcircleapi.com"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, + path, + params, + ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + url: this._baseUrl() + path, + params: { + api_key: `${this.$auth.api_key}`, + ...params, + }, + }); + }, + async searchCategories(args = {}) { + return this._makeRequest({ + path: "/categories", + ...args, + }); + }, + async getAccountData(args = {}) { + return this._makeRequest({ + path: "/account", + ...args, + }); + }, + async addZipcode(args = {}) { + return this._makeRequest({ + path: "/zipcodes", + method: "post", + ...args, + }); }, }, -}; \ No newline at end of file +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d17fc49d907df..837db30c4dec4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4939,8 +4939,7 @@ importers: specifier: ^3.1.0 version: 3.1.0 - components/financial_data: - specifiers: {} + components/financial_data: {} components/findymail: dependencies: @@ -7914,8 +7913,7 @@ importers: components/lightpanda: {} - components/lightspeed_ecom_c_series: - specifiers: {} + components/lightspeed_ecom_c_series: {} components/lightspeed_retail_pos: dependencies: @@ -8759,8 +8757,7 @@ importers: components/microsoft_advertising: {} - components/microsoft_authenticator: - specifiers: {} + components/microsoft_authenticator: {} components/microsoft_azure_ai_translator: dependencies: @@ -11690,7 +11687,11 @@ importers: specifier: ^3.24.0 version: 3.30.0 - components/redcircle_api: {} + components/redcircle_api: + dependencies: + '@pipedream/platform': + specifier: ^3.1.0 + version: 3.1.0 components/reddit: dependencies: