diff --git a/components/dynamic_content_snippet/actions/create-or-update-website-content/create-or-update-website-content.mjs b/components/dynamic_content_snippet/actions/create-or-update-website-content/create-or-update-website-content.mjs new file mode 100644 index 0000000000000..eb41fa6feec82 --- /dev/null +++ b/components/dynamic_content_snippet/actions/create-or-update-website-content/create-or-update-website-content.mjs @@ -0,0 +1,38 @@ +import dynamicContentSnippet from "../../dynamic_content_snippet.app.mjs"; + +export default { + key: "dynamic_content_snippet-create-or-update-website-content", + name: "Create or Update Website Content", + description: "Create or update website content. [See the documentation](https://contentsnip.com/documentation.htm)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: true, + openWorldHint: true, + readOnlyHint: false, + }, + props: { + dynamicContentSnippet, + url: { + type: "string", + label: "URL", + description: "URL of the webpage where content will appear", + }, + htmlContent: { + type: "string", + label: "HTML Content", + description: "HTML content to display at the target URL", + }, + }, + async run({ $ }) { + const response = await this.dynamicContentSnippet.createOrUpdateWebsiteContent({ + $, + data: { + url: this.url, + htmlContent: this.htmlContent, + }, + }); + $.export("$summary", `Successfully created or updated website content for \`${this.url}.\``); + return response; + }, +}; diff --git a/components/dynamic_content_snippet/dynamic_content_snippet.app.mjs b/components/dynamic_content_snippet/dynamic_content_snippet.app.mjs index 90dad4416ef37..2123ceea728df 100644 --- a/components/dynamic_content_snippet/dynamic_content_snippet.app.mjs +++ b/components/dynamic_content_snippet/dynamic_content_snippet.app.mjs @@ -1,11 +1,30 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "dynamic_content_snippet", propDefinitions: {}, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://app.contentsnip.com/api"; + }, + _makeRequest({ + $ = this, path, ...opts + }) { + return axios($, { + ...opts, + url: `${this._baseUrl()}${path}`, + headers: { + "x-api-key": `${this.$auth.api_key}`, + }, + }); + }, + createOrUpdateWebsiteContent(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/mappings", + ...opts, + }); }, }, -}; \ No newline at end of file +}; diff --git a/components/dynamic_content_snippet/package.json b/components/dynamic_content_snippet/package.json index 9b2643dd0a65c..93107c6c11112 100644 --- a/components/dynamic_content_snippet/package.json +++ b/components/dynamic_content_snippet/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/dynamic_content_snippet", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Dynamic Content Snippet Components", "main": "dynamic_content_snippet.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.1.1" } -} \ No newline at end of file +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a89f72da8aa97..60202f28ccff4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2043,8 +2043,7 @@ importers: components/braintree: {} - components/brand_dev: - specifiers: {} + components/brand_dev: {} components/brandblast: {} @@ -3588,8 +3587,7 @@ importers: components/currents_api: {} - components/cursor: - specifiers: {} + components/cursor: {} components/customer_fields: dependencies: @@ -4496,7 +4494,11 @@ importers: specifier: ^1.6.8 version: 1.6.8 - components/dynamic_content_snippet: {} + components/dynamic_content_snippet: + dependencies: + '@pipedream/platform': + specifier: ^3.1.1 + version: 3.1.1 components/dynamics_365_business_central_api: dependencies: @@ -5669,8 +5671,7 @@ importers: components/funnelcockpit: {} - components/fynk: - specifiers: {} + components/fynk: {} components/gagelist: dependencies: @@ -6736,8 +6737,7 @@ importers: components/helcim: {} - components/helicone: - specifiers: {} + components/helicone: {} components/helium: dependencies: @@ -8649,8 +8649,7 @@ importers: specifier: ^1.6.8 version: 1.6.8 - components/magicalapi: - specifiers: {} + components/magicalapi: {} components/magileads: {} @@ -12280,8 +12279,7 @@ importers: specifier: ^3.1.1 version: 3.1.1 - components/relationcity: - specifiers: {} + components/relationcity: {} components/relavate: dependencies: @@ -14054,8 +14052,7 @@ importers: components/socialkit: {} - components/socket: - specifiers: {} + components/socket: {} components/softledger: {} @@ -15438,8 +15435,7 @@ importers: components/turbohire: {} - components/turbosmtp: - specifiers: {} + components/turbosmtp: {} components/turbot_pipes: dependencies: @@ -15871,8 +15867,7 @@ importers: specifier: ^3.1.1 version: 3.1.1 - components/validemail: - specifiers: {} + components/validemail: {} components/vapi: dependencies: @@ -15976,8 +15971,7 @@ importers: components/verticalresponse: {} - components/veryfi: - specifiers: {} + components/veryfi: {} components/vestaboard: dependencies: