From db4f28b0f1734c72dcd49b947a2ce9394f9e3ce8 Mon Sep 17 00:00:00 2001 From: Lucas Caresia Date: Fri, 19 Sep 2025 09:38:23 -0300 Subject: [PATCH] Added actions --- .../actions/create-contact/create-contact.mjs | 77 +++++++++++ .../actions/create-voucher/create-voucher.mjs | 71 +++++++++++ components/etermin/common/constants.mjs | 6 + components/etermin/etermin.app.mjs | 120 +++++++++++++++++- components/etermin/package.json | 4 +- pnpm-lock.yaml | 21 ++- 6 files changed, 281 insertions(+), 18 deletions(-) create mode 100644 components/etermin/actions/create-contact/create-contact.mjs create mode 100644 components/etermin/actions/create-voucher/create-voucher.mjs create mode 100644 components/etermin/common/constants.mjs diff --git a/components/etermin/actions/create-contact/create-contact.mjs b/components/etermin/actions/create-contact/create-contact.mjs new file mode 100644 index 0000000000000..235ae66394351 --- /dev/null +++ b/components/etermin/actions/create-contact/create-contact.mjs @@ -0,0 +1,77 @@ +import app from "../../etermin.app.mjs"; + +export default { + key: "etermin-create-contact", + name: "Create Contact", + description: "Create a new contact on eTermin. [See the documentation](https://app.swaggerhub.com/apis/etermin.net/eTermin-API/1.0.0#/Contact/post_contact)", + version: "0.0.1", + type: "action", + props: { + app, + updateWhenExistsgdt: { + propDefinition: [ + app, + "updateWhenExistsgdt", + ], + }, + salutation: { + propDefinition: [ + app, + "salutation", + ], + }, + title: { + propDefinition: [ + app, + "title", + ], + }, + lastname: { + propDefinition: [ + app, + "lastName", + ], + }, + firstname: { + propDefinition: [ + app, + "firstName", + ], + }, + company: { + propDefinition: [ + app, + "company", + ], + }, + birthday: { + propDefinition: [ + app, + "birthday", + ], + }, + email: { + propDefinition: [ + app, + "email", + ], + }, + }, + async run({ $ }) { + const response = await this.app.createContact({ + $, + params: { + updatewhenexistsgdt: this.updateWhenExistsgdt, + salutation: this.salutation, + title: this.title, + lastname: this.lastName, + firstname: this.firstName, + company: this.company, + birthday: this.birthday, + email: this.email, + }, + }); + $.export("$summary", "Successfully created the new contact"); + return response; + }, +}; diff --git a/components/etermin/actions/create-voucher/create-voucher.mjs b/components/etermin/actions/create-voucher/create-voucher.mjs new file mode 100644 index 0000000000000..97a049d8996f3 --- /dev/null +++ b/components/etermin/actions/create-voucher/create-voucher.mjs @@ -0,0 +1,71 @@ +import app from "../../etermin.app.mjs"; + +export default { + key: "etermin-create-voucher", + name: "Create Voucher", + description: "Create a new voucher on eTermin. [See the documentation](https://app.swaggerhub.com/apis/etermin.net/eTermin-API/1.0.0#/Voucher/post_api_voucher)", + version: "0.0.1", + type: "action", + props: { + app, + id: { + propDefinition: [ + app, + "id", + ], + }, + description: { + propDefinition: [ + app, + "description", + ], + }, + priceInclVat: { + propDefinition: [ + app, + "priceInclVat", + ], + }, + isPercentage: { + propDefinition: [ + app, + "isPercentage", + ], + }, + customerEmail: { + propDefinition: [ + app, + "customerEmail", + ], + }, + validFrom: { + propDefinition: [ + app, + "validFrom", + ], + }, + validUntil: { + propDefinition: [ + app, + "validUntil", + ], + }, + }, + async run({ $ }) { + const response = await this.app.createVoucher({ + $, + params: { + id: this.id, + description: this.description, + priceinclvat: this.priceInClvat, + priceoriginal: this.priceOriginal, + ispercentage: this.isPercentage, + customeremail: this.customerEmail, + validfrom: this.validFrom, + validuntil: this.validUntil, + }, + }); + $.export("$summary", "Successfully created the new voucher"); + return response; + }, +}; diff --git a/components/etermin/common/constants.mjs b/components/etermin/common/constants.mjs new file mode 100644 index 0000000000000..6d9e2c5098c73 --- /dev/null +++ b/components/etermin/common/constants.mjs @@ -0,0 +1,6 @@ +export default { + UPDATE_OPTIONS: [ + 1, + 2, + ], +}; diff --git a/components/etermin/etermin.app.mjs b/components/etermin/etermin.app.mjs index 2a26947e945ef..e4ffe0b232230 100644 --- a/components/etermin/etermin.app.mjs +++ b/components/etermin/etermin.app.mjs @@ -1,11 +1,123 @@ +import { axios } from "@pipedream/platform"; +import constants from "./common/constants.mjs"; + export default { type: "app", app: "etermin", - propDefinitions: {}, + propDefinitions: { + updateWhenExistsgdt: { + type: "string", + label: "Update When Exists", + description: "Set to 1 to check if the contact is already existing. If so the existing contact gets updated. Needs email or firstname, lastname and birthday", + options: constants.UPDATE_OPTIONS, + }, + salutation: { + type: "string", + label: "Salutation", + description: "Salutation or greeting prefix", + }, + title: { + type: "string", + label: "Title", + description: "Title of the contact", + }, + lastName: { + type: "string", + label: "Last Name", + description: "Contact's last name", + }, + firstName: { + type: "string", + label: "First Name", + description: "Contact's first name", + }, + company: { + type: "string", + label: "Company", + description: "Name of the company associated with the contact", + }, + birthday: { + type: "string", + label: "Birthday", + description: "Contact's date of birth in YYYY-MM-DD format", + }, + email: { + type: "string", + label: "Email", + description: "Email address of the contact", + }, + id: { + type: "string", + label: "ID", + description: "ID of the voucher", + }, + description: { + type: "string", + label: "Description", + description: "Description of the voucher", + }, + priceInclVat: { + type: "string", + label: "Price Including VAT", + description: "Price including VAT of the voucher", + }, + isPercentage: { + type: "boolean", + label: "Is Percentage", + description: "Indicates if the value of the vaucher is a percentage", + }, + customerEmail: { + type: "string", + label: "Customer Email", + description: "Email address of the customer receiving the offer", + }, + validFrom: { + type: "string", + label: "Valid From", + description: "Start date of validity in YYYY-MM-DD format", + }, + validUntil: { + type: "string", + label: "Valid Until", + description: "End date of validity in YYYY-MM-DD format", + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://www.etermin.net/api"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, + path, + headers, + ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + url: this._baseUrl() + path, + headers: { + "publickey": `${this.$auth.public_key}`, + "salt": `${this.$auth.salt}`, + "signature": `${this.$auth.signature}`, + ...headers, + }, + }); + }, + + async createContact(args = {}) { + return this._makeRequest({ + path: "/contact", + method: "post", + ...args, + }); + }, + async createVoucher(args = {}) { + return this._makeRequest({ + path: "/voucher", + method: "post", + ...args, + }); }, }, }; diff --git a/components/etermin/package.json b/components/etermin/package.json index 22587b6fd5925..cad075fdf94fc 100644 --- a/components/etermin/package.json +++ b/components/etermin/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/etermin", - "version": "0.6.0", + "version": "0.7.0", "description": "Pipedream etermin Components", "main": "etermin.app.mjs", "keywords": [ @@ -13,6 +13,6 @@ "access": "public" }, "dependencies": { - "@pipedream/platform": "^3.0.0" + "@pipedream/platform": "^3.1.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0b06542d2495a..e7a06176519bb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4623,8 +4623,8 @@ importers: components/etermin: dependencies: '@pipedream/platform': - specifier: ^3.0.0 - version: 3.0.3 + specifier: ^3.1.0 + version: 3.1.0 components/ethereum: {} @@ -7082,8 +7082,7 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/instamojo: - specifiers: {} + components/instamojo: {} components/instant: {} @@ -11733,8 +11732,7 @@ importers: components/redmine: {} - components/reduct_video: - specifiers: {} + components/reduct_video: {} components/referral_rocket: {} @@ -13038,8 +13036,7 @@ importers: specifier: 1.6.0 version: 1.6.0 - components/shopware: - specifiers: {} + components/shopware: {} components/short: dependencies: @@ -30942,22 +30939,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==}