-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - syncmate_by_assitro #16836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6b3a082
syncmate_by_assitro init
luancazarine 4834933
[Components] syncmate_by_assitro #16832
luancazarine e6dc232
pnpm update
luancazarine 3698445
Update components/syncmate_by_assitro/package.json
luancazarine 9ac982c
some adjusts
luancazarine ccf16a7
Merge branch 'issue-16832' of https://github.com/PipedreamHQ/pipedrea…
luancazarine b1a590b
pnpm update
luancazarine de348c1
Merge branch 'master' into issue-16832
luancazarine a7c90a6
pnpm update
luancazarine 6c6aba1
Update components/syncmate_by_assitro/syncmate_by_assitro.app.mjs
luancazarine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,4 +8,4 @@ export default { | |
| console.log(Object.keys(this.$auth)); | ||
| }, | ||
| }, | ||
| }; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,4 +8,4 @@ export default { | |
| console.log(Object.keys(this.$auth)); | ||
| }, | ||
| }, | ||
| }; | ||
| }; | ||
87 changes: 87 additions & 0 deletions
87
components/syncmate_by_assitro/actions/send-bulk-messages/send-bulk-messages.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
| import fs from "fs"; | ||
| import { checkTmp } from "../../common/utils.mjs"; | ||
| import syncmateByAssitro from "../../syncmate_by_assitro.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "syncmate_by_assitro-send-bulk-messages", | ||
| name: "Send Bulk Messages", | ||
| description: "Send multiple WhatsApp messages in bulk. [See the documentation](https://assistro.co/user-guide/bulk-messaging-at-a-scheduled-time-using-syncmate-2/)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| syncmateByAssitro, | ||
| messagesNumber: { | ||
| type: "integer", | ||
| label: "Messages Number", | ||
| description: "The quantity of messages you want to send.", | ||
| reloadProps: true, | ||
| }, | ||
| }, | ||
| async additionalProps() { | ||
| const props = {}; | ||
| for (let i = 1; i <= this.messagesNumber; i++) { | ||
| props[`number${i}`] = { | ||
| type: "string", | ||
| label: `Number ${i}`, | ||
| description: "WhatsApp number with country code", | ||
| }; | ||
| props[`message${i}`] = { | ||
| type: "string", | ||
| label: `Message ${i}`, | ||
| description: "The text message to be sent", | ||
| }; | ||
| props[`media${i}`] = { | ||
| type: "string", | ||
| label: `Media ${i}`, | ||
| description: "The the path to a file in the `/tmp` directory. [See the documentation on working with files](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp).", | ||
| optional: true, | ||
| }; | ||
| props[`fileName${i}`] = { | ||
| type: "string", | ||
| label: `File Name ${i}`, | ||
| description: "The name of the file.", | ||
| optional: true, | ||
| }; | ||
| } | ||
|
|
||
| return props; | ||
| }, | ||
| async run({ $ }) { | ||
| const msgs = []; | ||
|
|
||
| for (let i = 1; i <= this.messagesNumber; i++) { | ||
| if (this[`media${i}`] && !this[`fileName${i}`]) { | ||
| throw new ConfigurationError(`You must provide the File Name ${i}.`); | ||
| } | ||
| const data = { | ||
| number: this[`number${i}`], | ||
| message: this[`message${i}`], | ||
| }; | ||
|
|
||
| if (this[`media${i}`]) { | ||
| const file = fs.readFileSync(checkTmp(this[`media${i}`]), { | ||
| encoding: "base64", | ||
| }); | ||
| data.media = [ | ||
| { | ||
| media_base64: file, | ||
| file_name: this[`fileName${i}`], | ||
| }, | ||
| ]; | ||
| } | ||
|
|
||
| msgs.push(data); | ||
| } | ||
|
|
||
| const response = await this.syncmateByAssitro.sendBulkMessages({ | ||
| $, | ||
| data: { | ||
| msgs, | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully sent ${this.messagesNumber} messages.`); | ||
| return response; | ||
| }, | ||
| }; |
72 changes: 72 additions & 0 deletions
72
components/syncmate_by_assitro/actions/send-message/send-message.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
| import fs from "fs"; | ||
| import { checkTmp } from "../../common/utils.mjs"; | ||
| import syncmateByAssitro from "../../syncmate_by_assitro.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "syncmate_by_assitro-send-message", | ||
| name: "Send WhatsApp Message", | ||
| description: "Send a single WhatsApp message using SyncMate by Assistro. [See the documentation](https://assistro.co/user-guide/connect-your-custom-app-with-syncmate/)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| syncmateByAssitro, | ||
| number: { | ||
| type: "string", | ||
| label: "Number", | ||
| description: "WhatsApp number with country code", | ||
| }, | ||
| message: { | ||
| type: "string", | ||
| label: "Message", | ||
| description: "The text message to be sent", | ||
| }, | ||
| media: { | ||
| type: "string", | ||
| label: "Media", | ||
| description: "The the path to a file in the `/tmp` directory. [See the documentation on working with files](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp).", | ||
| optional: true, | ||
| }, | ||
| fileName: { | ||
| type: "string", | ||
| label: "File Name", | ||
| description: "The name of the file.", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| if (this.media && !this.fileName) { | ||
| throw new ConfigurationError("You must provide the file name."); | ||
| } | ||
|
|
||
| const msgs = [ | ||
| { | ||
| number: this.number, | ||
| message: this.message, | ||
| }, | ||
| ]; | ||
|
|
||
| if (this.media) { | ||
| const file = fs.readFileSync(checkTmp(this.media), { | ||
| encoding: "base64", | ||
| }); | ||
|
|
||
| msgs[0].media = [ | ||
| { | ||
| media_base64: file, | ||
| file_name: this.fileName, | ||
| }, | ||
| ]; | ||
| } | ||
|
|
||
| const response = await this.syncmateByAssitro.sendSingleMessage({ | ||
| $, | ||
| data: { | ||
| msgs, | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully sent message to ${this.number}`); | ||
| return response; | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| export const checkTmp = (filename) => { | ||
| if (!filename.startsWith("/tmp")) { | ||
| return `/tmp/${filename}`; | ||
| } | ||
| return filename; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "name": "@pipedream/syncmate_by_assitro", | ||
| "version": "0.0.1", | ||
| "version": "0.1.0", | ||
| "description": "Pipedream SyncMate by Assitro Components", | ||
| "main": "syncmate_by_assitro.app.mjs", | ||
| "keywords": [ | ||
|
|
@@ -11,5 +11,8 @@ | |
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.0.3" | ||
| } | ||
| } | ||
| } | ||
39 changes: 34 additions & 5 deletions
39
components/syncmate_by_assitro/syncmate_by_assitro.app.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,40 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
|
|
||
| export default { | ||
| type: "app", | ||
| app: "syncmate_by_assitro", | ||
| propDefinitions: {}, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| _baseUrl() { | ||
| return "https://app.assistro.co/api/v1/wapushplus"; | ||
| }, | ||
| _headers() { | ||
| return { | ||
| "Authorization": `Bearer ${this.$auth.api_key}`, | ||
| "Content-Type": "application/json", | ||
| }; | ||
| }, | ||
| _makeRequest({ | ||
| $ = this, path, ...opts | ||
| }) { | ||
| return axios($, { | ||
| url: this._baseUrl() + path, | ||
| headers: this._headers(), | ||
| ...opts, | ||
| }); | ||
| }, | ||
| sendSingleMessage(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: "/single/message", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| sendBulkMessages(opts = {}) { | ||
| return this._makeRequest({ | ||
| method: "POST", | ||
| path: "/bulk/message", | ||
| ...opts, | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
| }; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.