From 79de956fff20d32a254c22b617feb984f63cff17 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Tue, 30 Sep 2025 16:13:22 -0300 Subject: [PATCH] Added actions --- .../create-customer/create-customer.mjs | 42 +++++++++ .../actions/get-customers/get-customers.mjs | 19 ++++ .../update-customer/update-customer.mjs | 56 ++++++++++++ components/paddle/common/constants.mjs | 6 ++ components/paddle/package.json | 5 +- components/paddle/paddle.app.mjs | 91 ++++++++++++++++++- pnpm-lock.yaml | 20 ++-- 7 files changed, 224 insertions(+), 15 deletions(-) create mode 100644 components/paddle/actions/create-customer/create-customer.mjs create mode 100644 components/paddle/actions/get-customers/get-customers.mjs create mode 100644 components/paddle/actions/update-customer/update-customer.mjs create mode 100644 components/paddle/common/constants.mjs diff --git a/components/paddle/actions/create-customer/create-customer.mjs b/components/paddle/actions/create-customer/create-customer.mjs new file mode 100644 index 0000000000000..3d5faa7a36b41 --- /dev/null +++ b/components/paddle/actions/create-customer/create-customer.mjs @@ -0,0 +1,42 @@ +import app from "../../paddle.app.mjs"; + +export default { + key: "paddle-create-customer", + name: "Create Customer", + description: "Create a new customer in Paddle. [See the documentation](https://developer.paddle.com/api-reference/customers/create-customer)", + version: "0.0.1", + type: "action", + props: { + app, + email: { + propDefinition: [ + app, + "email", + ], + }, + name: { + propDefinition: [ + app, + "name", + ], + }, + customData: { + propDefinition: [ + app, + "customData", + ], + }, + }, + async run({ $ }) { + const response = await this.app.createCustomer({ + $, + data: { + email: this.email, + name: this.name, + custom_data: this.customData, + }, + }); + $.export("$summary", "Successfully created a new customer with the ID: " + response.data.id); + return response; + }, +}; diff --git a/components/paddle/actions/get-customers/get-customers.mjs b/components/paddle/actions/get-customers/get-customers.mjs new file mode 100644 index 0000000000000..aa7b7eaa112d1 --- /dev/null +++ b/components/paddle/actions/get-customers/get-customers.mjs @@ -0,0 +1,19 @@ +import app from "../../paddle.app.mjs"; + +export default { + key: "paddle-get-customers", + name: "Get Customers", + description: "Get a list of customers registered in Paddle. [See the documentation](https://developer.paddle.com/api-reference/customers/list-customers)", + version: "0.0.1", + type: "action", + props: { + app, + }, + async run({ $ }) { + const response = await this.app.getCustomers({ + $, + }); + $.export("$summary", "Successfully retrieved " + response.data.length + " customers"); + return response; + }, +}; diff --git a/components/paddle/actions/update-customer/update-customer.mjs b/components/paddle/actions/update-customer/update-customer.mjs new file mode 100644 index 0000000000000..1b1a9b51ec670 --- /dev/null +++ b/components/paddle/actions/update-customer/update-customer.mjs @@ -0,0 +1,56 @@ +import app from "../../paddle.app.mjs"; + +export default { + key: "paddle-update-customer", + name: "Update Customer", + description: "Update the customer with the specified ID. [See the documentation](https://developer.paddle.com/api-reference/customers/update-customer)", + version: "0.0.1", + type: "action", + props: { + app, + customerId: { + propDefinition: [ + app, + "customerId", + ], + }, + email: { + propDefinition: [ + app, + "email", + ], + }, + name: { + propDefinition: [ + app, + "name", + ], + }, + customData: { + propDefinition: [ + app, + "customData", + ], + }, + status: { + propDefinition: [ + app, + "status", + ], + }, + }, + async run({ $ }) { + const response = await this.app.updateCustomer({ + $, + customerId: this.customerId, + data: { + email: this.email, + name: this.name, + custom_data: this.customData, + status: this.status, + }, + }); + $.export("$summary", "Successfully updated the customer with ID: " + this.customerId); + return response; + }, +}; diff --git a/components/paddle/common/constants.mjs b/components/paddle/common/constants.mjs new file mode 100644 index 0000000000000..b7ecf04af123a --- /dev/null +++ b/components/paddle/common/constants.mjs @@ -0,0 +1,6 @@ +export default { + STATUS_OPTIONS: [ + "active", + "archived", + ], +}; diff --git a/components/paddle/package.json b/components/paddle/package.json index 3010d442e47fd..d7ef818cd4ec9 100644 --- a/components/paddle/package.json +++ b/components/paddle/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/paddle", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Paddle Components", "main": "paddle.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/paddle/paddle.app.mjs b/components/paddle/paddle.app.mjs index 98474e3cabdc2..745854feb1d50 100644 --- a/components/paddle/paddle.app.mjs +++ b/components/paddle/paddle.app.mjs @@ -1,11 +1,92 @@ +import { axios } from "@pipedream/platform"; +import constants from "./common/constants.mjs"; + export default { type: "app", app: "paddle", - propDefinitions: {}, + propDefinitions: { + email: { + type: "string", + label: "Email", + description: "Customer's email address", + }, + name: { + type: "string", + label: "Name", + description: "Customer's full name", + }, + customData: { + type: "object", + label: "Custom Data", + description: "Your own structured key-value data", + optional: true, + }, + status: { + type: "string", + label: "Status", + description: "Customer's status", + options: constants.STATUS_OPTIONS, + }, + customerId: { + type: "string", + label: "Customer ID", + description: "Unique identifier of the customer", + async options() { + const response = await this.getCustomers(); + const data = response.data; + return data.map(({ + id, name, + }) => ({ + value: id, + label: name, + })); + }, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://sandbox-api.paddle.com"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, + path, + headers, + ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + url: this._baseUrl() + path, + headers: { + Authorization: `Bearer ${this.$auth.auth_code}`, + ...headers, + }, + }); + }, + + async getCustomers(args = {}) { + return this._makeRequest({ + path: "/customers", + ...args, + }); + }, + + async createCustomer(args = {}) { + return this._makeRequest({ + path: "/customers", + method: "post", + ...args, + }); + }, + + async updateCustomer({ + customerId, ...args + }) { + return this._makeRequest({ + path: `/customers/${customerId}`, + method: "patch", + ...args, + }); }, }, -}; \ No newline at end of file +}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2566e58986c87..1e9ee7512d6d7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6797,8 +6797,7 @@ importers: components/humanloop: {} - components/humantic_ai: - specifiers: {} + components/humantic_ai: {} components/humor_api: dependencies: @@ -10246,7 +10245,11 @@ importers: specifier: ^3.1.0 version: 3.1.0 - components/paddle: {} + components/paddle: + dependencies: + '@pipedream/platform': + specifier: ^3.1.0 + version: 3.1.0 components/page_x: dependencies: @@ -12646,8 +12649,7 @@ importers: specifier: ^4.0.0 version: 4.0.1 - components/securityscorecard: - specifiers: {} + components/securityscorecard: {} components/securitytrails: dependencies: @@ -30986,22 +30988,22 @@ packages: superagent@3.8.1: resolution: {integrity: sha512-VMBFLYgFuRdfeNQSMLbxGSLfmXL/xc+OO+BZp41Za/NRDBet/BNbkRJrYzCUu0u4GU0i/ml2dtT8b9qgkw9z6Q==} engines: {node: '>= 4.0'} - deprecated: Please upgrade to superagent v10.2.2+, see release notes at https://github.com/forwardemail/superagent/releases/tag/v10.2.2 - maintenance is supported by Forward Email @ https://forwardemail.net + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@4.1.0: resolution: {integrity: sha512-FT3QLMasz0YyCd4uIi5HNe+3t/onxMyEho7C3PSqmti3Twgy2rXT4fmkTz6wRL6bTF4uzPcfkUCa8u4JWHw8Ag==} engines: {node: '>= 6.0'} - deprecated: Please upgrade to superagent v10.2.2+, see release notes at https://github.com/forwardemail/superagent/releases/tag/v10.2.2 - maintenance is supported by Forward Email @ https://forwardemail.net + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@5.3.1: resolution: {integrity: sha512-wjJ/MoTid2/RuGCOFtlacyGNxN9QLMgcpYLDQlWFIhhdJ93kNscFonGvrpAHSCVjRVj++DGCglocF7Aej1KHvQ==} engines: {node: '>= 7.0.0'} - deprecated: Please upgrade to superagent v10.2.2+, see release notes at https://github.com/forwardemail/superagent/releases/tag/v10.2.2 - maintenance is supported by Forward Email @ https://forwardemail.net + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net superagent@7.1.6: resolution: {integrity: sha512-gZkVCQR1gy/oUXr+kxJMLDjla434KmSOKbx5iGD30Ql+AkJQ/YlPKECJy2nhqOsHLjGHzoDTXNSjhnvWhzKk7g==} engines: {node: '>=6.4.0 <13 || >=14'} - deprecated: Please upgrade to superagent v10.2.2+, see release notes at https://github.com/forwardemail/superagent/releases/tag/v10.2.2 - maintenance is supported by Forward Email @ https://forwardemail.net + deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net supports-color@10.0.0: resolution: {integrity: sha512-HRVVSbCCMbj7/kdWF9Q+bbckjBHLtHMEoJWlkmYzzdwhYMkjkOwubLM6t7NbWKjgKamGDrWL1++KrjUO1t9oAQ==}