Skip to content

Commit ab2aa4f

Browse files
authored
new components (#16715)
1 parent 375489e commit ab2aa4f

File tree

6 files changed

+349
-5
lines changed

6 files changed

+349
-5
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import waboxapp from "../../waboxapp.app.mjs";
2+
3+
export default {
4+
key: "waboxapp-send-image",
5+
name: "Send Image",
6+
description: "Send an image in WhatsApp to a specific phone number. [See the documentation](https://www.waboxapp.com/assets/doc/waboxapp-API-v3.pdf)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
waboxapp,
11+
uid: {
12+
propDefinition: [
13+
waboxapp,
14+
"uid",
15+
],
16+
},
17+
to: {
18+
propDefinition: [
19+
waboxapp,
20+
"to",
21+
],
22+
},
23+
customUid: {
24+
propDefinition: [
25+
waboxapp,
26+
"customUid",
27+
],
28+
},
29+
url: {
30+
propDefinition: [
31+
waboxapp,
32+
"url",
33+
],
34+
label: "Image URL",
35+
description: "URL of the image to send",
36+
},
37+
caption: {
38+
propDefinition: [
39+
waboxapp,
40+
"caption",
41+
],
42+
},
43+
description: {
44+
propDefinition: [
45+
waboxapp,
46+
"description",
47+
],
48+
},
49+
},
50+
async run({ $ }) {
51+
const response = await this.waboxapp.sendImage({
52+
$,
53+
data: {
54+
uid: this.uid,
55+
to: this.to,
56+
custom_uid: this.customUid,
57+
url: this.url,
58+
caption: this.caption,
59+
description: this.description,
60+
},
61+
});
62+
63+
$.export("$summary", `Successfully sent image to ${this.to}`);
64+
return response;
65+
},
66+
};
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import waboxapp from "../../waboxapp.app.mjs";
2+
3+
export default {
4+
key: "waboxapp-send-link",
5+
name: "Send Link",
6+
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)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
waboxapp,
11+
uid: {
12+
propDefinition: [
13+
waboxapp,
14+
"uid",
15+
],
16+
},
17+
to: {
18+
propDefinition: [
19+
waboxapp,
20+
"to",
21+
],
22+
},
23+
customUid: {
24+
propDefinition: [
25+
waboxapp,
26+
"customUid",
27+
],
28+
},
29+
url: {
30+
propDefinition: [
31+
waboxapp,
32+
"url",
33+
],
34+
label: "Link URL",
35+
description: "URL of the link to send",
36+
},
37+
caption: {
38+
propDefinition: [
39+
waboxapp,
40+
"caption",
41+
],
42+
},
43+
description: {
44+
propDefinition: [
45+
waboxapp,
46+
"description",
47+
],
48+
},
49+
urlThumb: {
50+
propDefinition: [
51+
waboxapp,
52+
"urlThumb",
53+
],
54+
},
55+
},
56+
async run({ $ }) {
57+
const response = await this.waboxapp.sendLink({
58+
$,
59+
data: {
60+
uid: this.uid,
61+
to: this.to,
62+
custom_uid: this.customUid,
63+
url: this.url,
64+
caption: this.caption,
65+
description: this.description,
66+
url_thumb: this.urlThumb,
67+
},
68+
});
69+
70+
$.export("$summary", `Successfully sent link to ${this.to}`);
71+
return response;
72+
},
73+
};
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import waboxapp from "../../waboxapp.app.mjs";
2+
3+
export default {
4+
key: "waboxapp-send-media",
5+
name: "Send Media",
6+
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)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
waboxapp,
11+
uid: {
12+
propDefinition: [
13+
waboxapp,
14+
"uid",
15+
],
16+
},
17+
to: {
18+
propDefinition: [
19+
waboxapp,
20+
"to",
21+
],
22+
},
23+
customUid: {
24+
propDefinition: [
25+
waboxapp,
26+
"customUid",
27+
],
28+
},
29+
url: {
30+
propDefinition: [
31+
waboxapp,
32+
"url",
33+
],
34+
label: "File URL",
35+
description: "URL of the file to send",
36+
},
37+
caption: {
38+
propDefinition: [
39+
waboxapp,
40+
"caption",
41+
],
42+
},
43+
description: {
44+
propDefinition: [
45+
waboxapp,
46+
"description",
47+
],
48+
},
49+
urlThumb: {
50+
propDefinition: [
51+
waboxapp,
52+
"urlThumb",
53+
],
54+
},
55+
},
56+
async run({ $ }) {
57+
const response = await this.waboxapp.sendMedia({
58+
$,
59+
data: {
60+
uid: this.uid,
61+
to: this.to,
62+
custom_uid: this.customUid,
63+
url: this.url,
64+
caption: this.caption,
65+
description: this.description,
66+
url_thumb: this.urlThumb,
67+
},
68+
});
69+
70+
$.export("$summary", `Successfully sent media file to ${this.to}`);
71+
return response;
72+
},
73+
};
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import waboxapp from "../../waboxapp.app.mjs";
2+
3+
export default {
4+
key: "waboxapp-send-text-message",
5+
name: "Send Text Message",
6+
description: "Send a WhatsApp message to a specific phone number. [See the documentation](https://www.waboxapp.com/assets/doc/waboxapp-API-v3.pdf)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
waboxapp,
11+
uid: {
12+
propDefinition: [
13+
waboxapp,
14+
"uid",
15+
],
16+
},
17+
to: {
18+
propDefinition: [
19+
waboxapp,
20+
"to",
21+
],
22+
},
23+
customUid: {
24+
propDefinition: [
25+
waboxapp,
26+
"customUid",
27+
],
28+
},
29+
text: {
30+
type: "string",
31+
label: "Message Text",
32+
description: "The text message to send",
33+
},
34+
},
35+
async run({ $ }) {
36+
const response = await this.waboxapp.sendMessage({
37+
$,
38+
data: {
39+
uid: this.uid,
40+
to: this.to,
41+
custom_uid: this.customUid,
42+
text: this.text,
43+
},
44+
});
45+
46+
$.export("$summary", `Successfully sent message to ${this.to}`);
47+
return response;
48+
},
49+
};

components/waboxapp/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/waboxapp",
3-
"version": "0.6.0",
3+
"version": "0.7.0",
44
"description": "Pipedream waboxapp Components",
55
"main": "waboxapp.app.mjs",
66
"keywords": [
Lines changed: 87 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,94 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "waboxapp",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
uid: {
8+
type: "string",
9+
label: "UID",
10+
description: "Your account phone number with international code. E.g. 34666123456",
11+
},
12+
to: {
13+
type: "string",
14+
label: "To",
15+
description: "Recipient's phone number with international code. E.g. 34666789123",
16+
},
17+
customUid: {
18+
type: "string",
19+
label: "Custom UID",
20+
description: "Your custom unique ID for the new message to be send. **Must be unique**. Will be sent back to you on ACK events",
21+
},
22+
url: {
23+
type: "string",
24+
label: "URL",
25+
description: "URL of the content to send",
26+
},
27+
caption: {
28+
type: "string",
29+
label: "Caption",
30+
description: "Title to show on the preview",
31+
optional: true,
32+
},
33+
description: {
34+
type: "string",
35+
label: "Description",
36+
description: "Extended description to show on the preview",
37+
optional: true,
38+
},
39+
urlThumb: {
40+
type: "string",
41+
label: "Thumbnail URL",
42+
description: "URL of the thumbnail image to show on the preview",
43+
optional: true,
44+
},
45+
},
546
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
47+
_baseUrl() {
48+
return "https://www.waboxapp.com/api";
49+
},
50+
_makeRequest({
51+
$ = this,
52+
path,
53+
params,
54+
...otherOpts
55+
}) {
56+
return axios($, {
57+
url: `${this._baseUrl()}${path}`,
58+
params: {
59+
...params,
60+
token: this.$auth.api_token,
61+
},
62+
...otherOpts,
63+
});
64+
},
65+
sendMessage(opts = {}) {
66+
return this._makeRequest({
67+
method: "POST",
68+
path: "/send/chat",
69+
...opts,
70+
});
71+
},
72+
sendImage(opts = {}) {
73+
return this._makeRequest({
74+
method: "POST",
75+
path: "/send/image",
76+
...opts,
77+
});
78+
},
79+
sendLink(opts = {}) {
80+
return this._makeRequest({
81+
method: "POST",
82+
path: "/send/link",
83+
...opts,
84+
});
85+
},
86+
sendMedia(opts = {}) {
87+
return this._makeRequest({
88+
method: "POST",
89+
path: "/send/media",
90+
...opts,
91+
});
992
},
1093
},
1194
};

0 commit comments

Comments
 (0)