Skip to content

Commit 9f6508a

Browse files
authored
New Components - esendex (#16943)
* wip * pnpm-lock.yaml * updates * pnpm-lock.yaml * updates
1 parent 3014ab7 commit 9f6508a

File tree

10 files changed

+423
-20
lines changed

10 files changed

+423
-20
lines changed

components/esendex/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import esendex from "../../esendex.app.mjs";
2+
import constants from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "esendex-send-sms-message",
6+
name: "Send SMS Message",
7+
description: "Send an SMS message to a recipient. [See the documentation](https://developers.esendex.com/api-reference/#messagedispatcher)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
esendex,
12+
accountReference: {
13+
propDefinition: [
14+
esendex,
15+
"accountReference",
16+
],
17+
},
18+
to: {
19+
type: "string",
20+
label: "To",
21+
description: "The phone number to send the message to. E.g. `447700900123`",
22+
},
23+
message: {
24+
type: "string",
25+
label: "Message",
26+
description: "The message to send",
27+
},
28+
from: {
29+
type: "string",
30+
label: "From",
31+
description: "The default alphanumeric originator that the message appears to originate from. This must be either a valid phone number or an alphanumeric value with a maximum length of 11 characters, that may contain letters, numbers and the following special characters: * $ ? ! ” # % & _ - , @ ' +. Special characters may not work for all networks in France.",
32+
optional: true,
33+
},
34+
sendAt: {
35+
type: "string",
36+
label: "Send At",
37+
description: "The scheduled time to send the messages in this request. The format is `yyyy-MM-ddThh:mm:ssZ` where y=year, M=month, d=day, T=separator, h=hour, m=min and s=seconds. The value is treated as per ISO 8601 semantics, e.g. without time zone information the value is assumed to be the local time of the server, otherwise as an offset from UTC with Z representing a UTC time.",
38+
optional: true,
39+
},
40+
characterSet: {
41+
type: "string",
42+
label: "Character Set",
43+
description: "The character set of the message to be used. Valid values are: GSM, Unicode and Auto. When using Auto the most appropriate character set is automatically detected. The default value is GSM. When using auto, if unicode characters are detected, the number of characters available in a message will change from 160 to 70.",
44+
options: constants.CHARACTER_SETS,
45+
optional: true,
46+
},
47+
validity: {
48+
type: "integer",
49+
label: "Validity",
50+
description: "The validity period for this message in hours (default to 0 which indicates the MAX allowed). The maximum allowed validity period is 72 hours.",
51+
optional: true,
52+
},
53+
},
54+
async run({ $ }) {
55+
const response = await this.esendex.sendMessage({
56+
$,
57+
data: {
58+
accountreference: this.accountReference,
59+
sendat: this.sendAt,
60+
messages: [
61+
{
62+
to: this.to,
63+
body: this.message,
64+
from: this.from,
65+
type: "SMS",
66+
characterset: this.characterSet,
67+
validity: this.validity,
68+
},
69+
],
70+
},
71+
});
72+
$.export("$summary", `Successfully sent SMS message to ${this.to}`);
73+
return response;
74+
},
75+
};
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import esendex from "../../esendex.app.mjs";
2+
import constants from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "esendex-send-voice-message",
6+
name: "Send Voice Message",
7+
description: "Send a voice message to a recipient. [See the documentation](https://developers.esendex.com/api-reference/#messagedispatcher)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
esendex,
12+
accountReference: {
13+
propDefinition: [
14+
esendex,
15+
"accountReference",
16+
],
17+
},
18+
to: {
19+
type: "string",
20+
label: "To",
21+
description: "The phone number to send the message to. E.g. `447700900123`",
22+
},
23+
message: {
24+
type: "string",
25+
label: "Message",
26+
description: "The message to send",
27+
},
28+
from: {
29+
type: "string",
30+
label: "From",
31+
description: "The default alphanumeric originator that the message appears to originate from. This must be either a valid phone number or an alphanumeric value with a maximum length of 11 characters, that may contain letters, numbers and the following special characters: * $ ? ! ” # % & _ - , @ ' +. Special characters may not work for all networks in France.",
32+
optional: true,
33+
},
34+
sendAt: {
35+
type: "string",
36+
label: "Send At",
37+
description: "The scheduled time to send the messages in this request. The format is `yyyy-MM-ddThh:mm:ssZ` where y=year, M=month, d=day, T=separator, h=hour, m=min and s=seconds. The value is treated as per ISO 8601 semantics, e.g. without time zone information the value is assumed to be the local time of the server, otherwise as an offset from UTC with Z representing a UTC time.",
38+
optional: true,
39+
},
40+
characterSet: {
41+
type: "string",
42+
label: "Character Set",
43+
description: "The character set of the message to be used. Valid values are: GSM, Unicode and Auto. When using Auto the most appropriate character set is automatically detected. The default value is GSM. When using auto, if unicode characters are detected, the number of characters available in a message will change from 160 to 70.",
44+
options: constants.CHARACTER_SETS,
45+
optional: true,
46+
},
47+
lang: {
48+
type: "string",
49+
label: "Language",
50+
description: "The language to use for this Voice message",
51+
options: constants.LANGUAGES,
52+
},
53+
retries: {
54+
type: "integer",
55+
label: "Retries",
56+
description: "The number of times to attempt to call and deliver a Voice message",
57+
optional: true,
58+
},
59+
},
60+
async run({ $ }) {
61+
const response = await this.esendex.sendMessage({
62+
$,
63+
data: {
64+
accountreference: this.accountReference,
65+
sendat: this.sendAt,
66+
messages: [
67+
{
68+
to: this.to,
69+
body: this.message,
70+
from: this.from,
71+
type: "Voice",
72+
characterset: this.characterSet,
73+
lang: this.lang,
74+
retries: this.retries,
75+
},
76+
],
77+
},
78+
});
79+
$.export("$summary", `Successfully sent voicemessage to ${this.to}`);
80+
return response;
81+
},
82+
};

components/esendex/app/esendex.app.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
const CHARACTER_SETS = [
2+
"GSM",
3+
"Unicode",
4+
"Auto",
5+
];
6+
7+
const LANGUAGES = [
8+
{
9+
label: "English UK",
10+
value: "en-GB",
11+
},
12+
{
13+
label: "English Australian",
14+
value: "en-AU",
15+
},
16+
{
17+
label: "French",
18+
value: "fr-FR",
19+
},
20+
{
21+
label: "Spanish",
22+
value: "es-ES",
23+
},
24+
{
25+
label: "German",
26+
value: "de-DE",
27+
},
28+
];
29+
30+
const MESSAGE_STATUSES = [
31+
"Acknowledged",
32+
"Authorised",
33+
"Connecting",
34+
"Delivered",
35+
"Dispatched",
36+
"Expired",
37+
"Failed",
38+
"FailedAuthorisation",
39+
"PartiallyDelivered",
40+
"Processing",
41+
"Queued",
42+
"Rejected",
43+
"Scheduled",
44+
"Sent",
45+
"Submitted",
46+
];
47+
48+
const MESSAGE_TYPES = [
49+
"SMS",
50+
"Voice",
51+
];
52+
53+
export default {
54+
CHARACTER_SETS,
55+
LANGUAGES,
56+
MESSAGE_STATUSES,
57+
MESSAGE_TYPES,
58+
};

components/esendex/esendex.app.mjs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { axios } from "@pipedream/platform";
2+
3+
export default {
4+
type: "app",
5+
app: "esendex",
6+
propDefinitions: {
7+
accountReference: {
8+
type: "string",
9+
label: "Account Reference",
10+
description: "The account reference to use for the request",
11+
async options() {
12+
const { accounts } = await this.listAccounts();
13+
return accounts.map((account) => ({
14+
label: account.label,
15+
value: account.reference,
16+
}));
17+
},
18+
},
19+
},
20+
methods: {
21+
_baseUrl() {
22+
return "https://api.esendex.com/v1.0";
23+
},
24+
_makeRequest({
25+
$ = this, path, ...opts
26+
}) {
27+
return axios($, {
28+
url: `${this._baseUrl()}${path}`,
29+
auth: {
30+
username: `${this.$auth.username}`,
31+
password: `${this.$auth.api_password}`,
32+
},
33+
...opts,
34+
});
35+
},
36+
listAccounts(opts = {}) {
37+
return this._makeRequest({
38+
path: "/accounts",
39+
...opts,
40+
});
41+
},
42+
listMessages(opts = {}) {
43+
return this._makeRequest({
44+
path: "/messageheaders",
45+
...opts,
46+
});
47+
},
48+
sendMessage(opts = {}) {
49+
return this._makeRequest({
50+
method: "POST",
51+
path: "/messagedispatcher",
52+
...opts,
53+
});
54+
},
55+
},
56+
};

components/esendex/package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
{
22
"name": "@pipedream/esendex",
3-
"version": "0.0.2",
3+
"version": "0.1.0",
44
"description": "Pipedream Esendex Components",
5-
"main": "dist/app/esendex.app.mjs",
5+
"main": "esendex.app.mjs",
66
"keywords": [
77
"pipedream",
88
"esendex"
99
],
10-
"files": ["dist"],
1110
"homepage": "https://pipedream.com/apps/esendex",
1211
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1312
"publishConfig": {
1413
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3",
17+
"simple-xml2json": "^1.2.3"
1518
}
1619
}

0 commit comments

Comments
 (0)