Skip to content

Commit

Permalink
[Components] Altiria: New action send-sms (#13946)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Sep 16, 2024
1 parent 3d6759a commit 7567870
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 7 deletions.
51 changes: 51 additions & 0 deletions components/altiria/actions/send-sms/send-sms.mjs
Original file line number Diff line number Diff line change
@@ -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](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: {
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;
},
};
45 changes: 41 additions & 4 deletions components/altiria/altiria.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,48 @@
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,
url: this.getUrl(path),
headers: this.getHeaders(headers),
data: this.getDataAuth(data),
});
},
post(args = {}) {
return this.makeRequest({
method: "POST",
...args,
});
},
},
};
};
7 changes: 5 additions & 2 deletions components/altiria/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/altiria",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Altiria Components",
"main": "altiria.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "3.0.1"
}
}
}
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7567870

Please sign in to comment.