From 79bba5f5c71c14a06a6b72fb3bf68c7b9a283d13 Mon Sep 17 00:00:00 2001 From: Jorge Cortes Date: Fri, 13 Sep 2024 12:27:54 -0500 Subject: [PATCH 1/3] Altiria: New action send-sms --- .../altiria/actions/send-sms/send-sms.mjs | 51 +++++++++++++++++++ components/altiria/altiria.app.mjs | 46 +++++++++++++++-- components/altiria/package.json | 7 ++- pnpm-lock.yaml | 5 +- 4 files changed, 102 insertions(+), 7 deletions(-) create mode 100644 components/altiria/actions/send-sms/send-sms.mjs diff --git a/components/altiria/actions/send-sms/send-sms.mjs b/components/altiria/actions/send-sms/send-sms.mjs new file mode 100644 index 0000000000000..cfadd41b4fdae --- /dev/null +++ b/components/altiria/actions/send-sms/send-sms.mjs @@ -0,0 +1,51 @@ +import app from "../../altiria.app.mjs"; + +export default { + key: "altiria-send-sms", + name: "Send SMS", + description: "Send an SMS message. The message will be sent to the phone numbers you specify. [See the documentation](https://static.altiria.com/especificaciones/altiria_push_rest.pdf).", + type: "action", + version: "0.0.1", + props: { + app, + destination: { + type: "string[]", + label: "Destination Phone Numbers", + description: "The phone numbers to which the message will be sent. Each number will be specified in international numbering format without the prefix `00` or the sign `+`. Eg: `34645852126`. It is essential to include the country prefix (`34` for Spain) so that the message reaches the expected destination. It must not exceed 16 digits. In any case, it is recommended not to exceed **100** phone numbers per request.", + }, + msg: { + type: "string", + label: "Message", + description: "Message to send. The list of valid characters and the maximum allowed length is detailed in section 2.4 of the documentation. It cannot be empty (empty string). Mobile web identifiers can be added to generate unique shortened links in the message body. See section 2.5 for more details on mobile webs.", + }, + }, + methods: { + sendSms(args = {}) { + return this.app.post({ + path: "/sendSms", + ...args, + }); + }, + }, + async run({ $ }) { + const { + sendSms, + destination, + msg, + } = this; + + const response = await sendSms({ + $, + data: { + destination, + message: { + msg, + }, + }, + }); + + $.export("$summary", "Successfully sent SMS message."); + + return response; + }, +}; diff --git a/components/altiria/altiria.app.mjs b/components/altiria/altiria.app.mjs index 199d11d592312..2fd5be50c4923 100644 --- a/components/altiria/altiria.app.mjs +++ b/components/altiria/altiria.app.mjs @@ -1,11 +1,49 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "altiria", propDefinitions: {}, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + getUrl(path) { + return `https://www.altiria.net:8443/apirest/ws${path}`; + }, + getHeaders(headers) { + return { + ...headers, + "Content-Type": "application/json;charset=UTF-8", + "Accept": "application/json", + }; + }, + getDataAuth(data) { + const { + api_key: apiKey, + api_secret: apiSecret, + } = this.$auth; + return { + ...data, + credentials: { + apiKey, + apiSecret, + }, + }; + }, + makeRequest({ + $ = this, path, headers, data, ...args + } = {}) { + return axios($, { + ...args, + debug: true, + url: this.getUrl(path), + headers: this.getHeaders(headers), + data: this.getDataAuth(data), + }); + }, + post(args = {}) { + return this.makeRequest({ + method: "POST", + ...args, + }); }, }, -}; \ No newline at end of file +}; diff --git a/components/altiria/package.json b/components/altiria/package.json index 05ee27319050b..06bbf031e565e 100644 --- a/components/altiria/package.json +++ b/components/altiria/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/altiria", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Altiria Components", "main": "altiria.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "3.0.1" } -} \ No newline at end of file +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bf362a2cf22d0..2a82348cc43b7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -486,7 +486,10 @@ importers: specifiers: {} components/altiria: - specifiers: {} + specifiers: + '@pipedream/platform': 3.0.1 + dependencies: + '@pipedream/platform': 3.0.1 components/altoviz: specifiers: From 7f10a274da2e27f8c07312d9f5d32643b6e5eb82 Mon Sep 17 00:00:00 2001 From: Jorge Cortes Date: Fri, 13 Sep 2024 15:11:57 -0500 Subject: [PATCH 2/3] Update components/altiria/actions/send-sms/send-sms.mjs Co-authored-by: michelle0927 --- components/altiria/actions/send-sms/send-sms.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/altiria/actions/send-sms/send-sms.mjs b/components/altiria/actions/send-sms/send-sms.mjs index cfadd41b4fdae..7141a52baeb8a 100644 --- a/components/altiria/actions/send-sms/send-sms.mjs +++ b/components/altiria/actions/send-sms/send-sms.mjs @@ -16,7 +16,7 @@ export default { msg: { type: "string", label: "Message", - description: "Message to send. The list of valid characters and the maximum allowed length is detailed in section 2.4 of the documentation. It cannot be empty (empty string). Mobile web identifiers can be added to generate unique shortened links in the message body. See section 2.5 for more details on mobile webs.", + description: "Message to send. The list of valid characters and the maximum allowed length is detailed in section 2.4 of the [documentation](https://static.altiria.com/especificaciones/altiria_push_rest.pdf). It cannot be empty (empty string). Mobile web identifiers can be added to generate unique shortened links in the message body. See section 2.5 for more details on mobile webs.", }, }, methods: { From a8bae083ae12ca19df15750ac9a947834519dc3e Mon Sep 17 00:00:00 2001 From: Leo Vu Date: Mon, 16 Sep 2024 09:25:07 +0700 Subject: [PATCH 3/3] Remove Debug --- components/altiria/altiria.app.mjs | 1 - 1 file changed, 1 deletion(-) diff --git a/components/altiria/altiria.app.mjs b/components/altiria/altiria.app.mjs index 2fd5be50c4923..deb5f70a942d3 100644 --- a/components/altiria/altiria.app.mjs +++ b/components/altiria/altiria.app.mjs @@ -33,7 +33,6 @@ export default { } = {}) { return axios($, { ...args, - debug: true, url: this.getUrl(path), headers: this.getHeaders(headers), data: this.getDataAuth(data),