diff --git a/components/waboxapp/actions/send-image/send-image.mjs b/components/waboxapp/actions/send-image/send-image.mjs new file mode 100644 index 0000000000000..c181913843d65 --- /dev/null +++ b/components/waboxapp/actions/send-image/send-image.mjs @@ -0,0 +1,66 @@ +import waboxapp from "../../waboxapp.app.mjs"; + +export default { + key: "waboxapp-send-image", + name: "Send Image", + description: "Send an image in WhatsApp to a specific phone number. [See the documentation](https://www.waboxapp.com/assets/doc/waboxapp-API-v3.pdf)", + version: "0.0.1", + type: "action", + props: { + waboxapp, + uid: { + propDefinition: [ + waboxapp, + "uid", + ], + }, + to: { + propDefinition: [ + waboxapp, + "to", + ], + }, + customUid: { + propDefinition: [ + waboxapp, + "customUid", + ], + }, + url: { + propDefinition: [ + waboxapp, + "url", + ], + label: "Image URL", + description: "URL of the image to send", + }, + caption: { + propDefinition: [ + waboxapp, + "caption", + ], + }, + description: { + propDefinition: [ + waboxapp, + "description", + ], + }, + }, + async run({ $ }) { + const response = await this.waboxapp.sendImage({ + $, + data: { + uid: this.uid, + to: this.to, + custom_uid: this.customUid, + url: this.url, + caption: this.caption, + description: this.description, + }, + }); + + $.export("$summary", `Successfully sent image to ${this.to}`); + return response; + }, +}; diff --git a/components/waboxapp/actions/send-link/send-link.mjs b/components/waboxapp/actions/send-link/send-link.mjs new file mode 100644 index 0000000000000..020e0426528fc --- /dev/null +++ b/components/waboxapp/actions/send-link/send-link.mjs @@ -0,0 +1,73 @@ +import waboxapp from "../../waboxapp.app.mjs"; + +export default { + key: "waboxapp-send-link", + name: "Send Link", + description: "Send a link with preview in WhatsApp to a specific phone number. [See the documentation](https://www.waboxapp.com/assets/doc/waboxapp-API-v3.pdf)", + version: "0.0.1", + type: "action", + props: { + waboxapp, + uid: { + propDefinition: [ + waboxapp, + "uid", + ], + }, + to: { + propDefinition: [ + waboxapp, + "to", + ], + }, + customUid: { + propDefinition: [ + waboxapp, + "customUid", + ], + }, + url: { + propDefinition: [ + waboxapp, + "url", + ], + label: "Link URL", + description: "URL of the link to send", + }, + caption: { + propDefinition: [ + waboxapp, + "caption", + ], + }, + description: { + propDefinition: [ + waboxapp, + "description", + ], + }, + urlThumb: { + propDefinition: [ + waboxapp, + "urlThumb", + ], + }, + }, + async run({ $ }) { + const response = await this.waboxapp.sendLink({ + $, + data: { + uid: this.uid, + to: this.to, + custom_uid: this.customUid, + url: this.url, + caption: this.caption, + description: this.description, + url_thumb: this.urlThumb, + }, + }); + + $.export("$summary", `Successfully sent link to ${this.to}`); + return response; + }, +}; diff --git a/components/waboxapp/actions/send-media/send-media.mjs b/components/waboxapp/actions/send-media/send-media.mjs new file mode 100644 index 0000000000000..fcbd71f92e790 --- /dev/null +++ b/components/waboxapp/actions/send-media/send-media.mjs @@ -0,0 +1,73 @@ +import waboxapp from "../../waboxapp.app.mjs"; + +export default { + key: "waboxapp-send-media", + name: "Send Media", + description: "Send any kind of file in WhatsApp to a specific phone number. [See the documentation](https://www.waboxapp.com/assets/doc/waboxapp-API-v3.pdf)", + version: "0.0.1", + type: "action", + props: { + waboxapp, + uid: { + propDefinition: [ + waboxapp, + "uid", + ], + }, + to: { + propDefinition: [ + waboxapp, + "to", + ], + }, + customUid: { + propDefinition: [ + waboxapp, + "customUid", + ], + }, + url: { + propDefinition: [ + waboxapp, + "url", + ], + label: "File URL", + description: "URL of the file to send", + }, + caption: { + propDefinition: [ + waboxapp, + "caption", + ], + }, + description: { + propDefinition: [ + waboxapp, + "description", + ], + }, + urlThumb: { + propDefinition: [ + waboxapp, + "urlThumb", + ], + }, + }, + async run({ $ }) { + const response = await this.waboxapp.sendMedia({ + $, + data: { + uid: this.uid, + to: this.to, + custom_uid: this.customUid, + url: this.url, + caption: this.caption, + description: this.description, + url_thumb: this.urlThumb, + }, + }); + + $.export("$summary", `Successfully sent media file to ${this.to}`); + return response; + }, +}; diff --git a/components/waboxapp/actions/send-text-message/send-text-message.mjs b/components/waboxapp/actions/send-text-message/send-text-message.mjs new file mode 100644 index 0000000000000..7c441fd71c4f2 --- /dev/null +++ b/components/waboxapp/actions/send-text-message/send-text-message.mjs @@ -0,0 +1,49 @@ +import waboxapp from "../../waboxapp.app.mjs"; + +export default { + key: "waboxapp-send-text-message", + name: "Send Text Message", + description: "Send a WhatsApp message to a specific phone number. [See the documentation](https://www.waboxapp.com/assets/doc/waboxapp-API-v3.pdf)", + version: "0.0.1", + type: "action", + props: { + waboxapp, + uid: { + propDefinition: [ + waboxapp, + "uid", + ], + }, + to: { + propDefinition: [ + waboxapp, + "to", + ], + }, + customUid: { + propDefinition: [ + waboxapp, + "customUid", + ], + }, + text: { + type: "string", + label: "Message Text", + description: "The text message to send", + }, + }, + async run({ $ }) { + const response = await this.waboxapp.sendMessage({ + $, + data: { + uid: this.uid, + to: this.to, + custom_uid: this.customUid, + text: this.text, + }, + }); + + $.export("$summary", `Successfully sent message to ${this.to}`); + return response; + }, +}; diff --git a/components/waboxapp/package.json b/components/waboxapp/package.json index 8e721b82bcc11..95ba2ab87a597 100644 --- a/components/waboxapp/package.json +++ b/components/waboxapp/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/waboxapp", - "version": "0.6.0", + "version": "0.7.0", "description": "Pipedream waboxapp Components", "main": "waboxapp.app.mjs", "keywords": [ diff --git a/components/waboxapp/waboxapp.app.mjs b/components/waboxapp/waboxapp.app.mjs index cc02bc2a6cf88..25eeba2c89e72 100644 --- a/components/waboxapp/waboxapp.app.mjs +++ b/components/waboxapp/waboxapp.app.mjs @@ -1,11 +1,94 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "waboxapp", - propDefinitions: {}, + propDefinitions: { + uid: { + type: "string", + label: "UID", + description: "Your account phone number with international code. E.g. 34666123456", + }, + to: { + type: "string", + label: "To", + description: "Recipient's phone number with international code. E.g. 34666789123", + }, + customUid: { + type: "string", + label: "Custom UID", + description: "Your custom unique ID for the new message to be send. **Must be unique**. Will be sent back to you on ACK events", + }, + url: { + type: "string", + label: "URL", + description: "URL of the content to send", + }, + caption: { + type: "string", + label: "Caption", + description: "Title to show on the preview", + optional: true, + }, + description: { + type: "string", + label: "Description", + description: "Extended description to show on the preview", + optional: true, + }, + urlThumb: { + type: "string", + label: "Thumbnail URL", + description: "URL of the thumbnail image to show on the preview", + optional: true, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://www.waboxapp.com/api"; + }, + _makeRequest({ + $ = this, + path, + params, + ...otherOpts + }) { + return axios($, { + url: `${this._baseUrl()}${path}`, + params: { + ...params, + token: this.$auth.api_token, + }, + ...otherOpts, + }); + }, + sendMessage(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/send/chat", + ...opts, + }); + }, + sendImage(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/send/image", + ...opts, + }); + }, + sendLink(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/send/link", + ...opts, + }); + }, + sendMedia(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/send/media", + ...opts, + }); }, }, };