Skip to content

Commit 7567870

Browse files
jcortesmichelle0927vunguyenhung
authored
[Components] Altiria: New action send-sms (#13946)
* Altiria: New action send-sms * Update components/altiria/actions/send-sms/send-sms.mjs Co-authored-by: michelle0927 <[email protected]> * Remove Debug --------- Co-authored-by: michelle0927 <[email protected]> Co-authored-by: Leo Vu <[email protected]>
1 parent 3d6759a commit 7567870

File tree

4 files changed

+101
-7
lines changed

4 files changed

+101
-7
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import app from "../../altiria.app.mjs";
2+
3+
export default {
4+
key: "altiria-send-sms",
5+
name: "Send SMS",
6+
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).",
7+
type: "action",
8+
version: "0.0.1",
9+
props: {
10+
app,
11+
destination: {
12+
type: "string[]",
13+
label: "Destination Phone Numbers",
14+
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.",
15+
},
16+
msg: {
17+
type: "string",
18+
label: "Message",
19+
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.",
20+
},
21+
},
22+
methods: {
23+
sendSms(args = {}) {
24+
return this.app.post({
25+
path: "/sendSms",
26+
...args,
27+
});
28+
},
29+
},
30+
async run({ $ }) {
31+
const {
32+
sendSms,
33+
destination,
34+
msg,
35+
} = this;
36+
37+
const response = await sendSms({
38+
$,
39+
data: {
40+
destination,
41+
message: {
42+
msg,
43+
},
44+
},
45+
});
46+
47+
$.export("$summary", "Successfully sent SMS message.");
48+
49+
return response;
50+
},
51+
};

components/altiria/altiria.app.mjs

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,48 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "altiria",
46
propDefinitions: {},
57
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
8+
getUrl(path) {
9+
return `https://www.altiria.net:8443/apirest/ws${path}`;
10+
},
11+
getHeaders(headers) {
12+
return {
13+
...headers,
14+
"Content-Type": "application/json;charset=UTF-8",
15+
"Accept": "application/json",
16+
};
17+
},
18+
getDataAuth(data) {
19+
const {
20+
api_key: apiKey,
21+
api_secret: apiSecret,
22+
} = this.$auth;
23+
return {
24+
...data,
25+
credentials: {
26+
apiKey,
27+
apiSecret,
28+
},
29+
};
30+
},
31+
makeRequest({
32+
$ = this, path, headers, data, ...args
33+
} = {}) {
34+
return axios($, {
35+
...args,
36+
url: this.getUrl(path),
37+
headers: this.getHeaders(headers),
38+
data: this.getDataAuth(data),
39+
});
40+
},
41+
post(args = {}) {
42+
return this.makeRequest({
43+
method: "POST",
44+
...args,
45+
});
946
},
1047
},
11-
};
48+
};

components/altiria/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/altiria",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Altiria Components",
55
"main": "altiria.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "3.0.1"
1417
}
15-
}
18+
}

pnpm-lock.yaml

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)