Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions components/esendex/.gitignore

This file was deleted.

75 changes: 75 additions & 0 deletions components/esendex/actions/send-sms-message/send-sms-message.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import esendex from "../../esendex.app.mjs";
import constants from "../../common/constants.mjs";

export default {
key: "esendex-send-sms-message",
name: "Send SMS Message",
description: "Send an SMS message to a recipient. [See the documentation](https://developers.esendex.com/api-reference/#messagedispatcher)",
version: "0.0.1",
type: "action",
props: {
esendex,
accountReference: {
propDefinition: [
esendex,
"accountReference",
],
},
to: {
type: "string",
label: "To",
description: "The phone number to send the message to. E.g. `447700900123`",
},
message: {
type: "string",
label: "Message",
description: "The message to send",
},
from: {
type: "string",
label: "From",
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.",
optional: true,
},
sendAt: {
type: "string",
label: "Send At",
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.",
optional: true,
},
characterSet: {
type: "string",
label: "Character Set",
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.",
options: constants.CHARACTER_SETS,
optional: true,
},
validity: {
type: "integer",
label: "Validity",
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.",
optional: true,
},
},
async run({ $ }) {
const response = await this.esendex.sendMessage({
$,
data: {
accountreference: this.accountReference,
sendat: this.sendAt,
messages: [
{
to: this.to,
body: this.message,
from: this.from,
type: "SMS",
characterset: this.characterSet,
validity: this.validity,
},
],
},
});
$.export("$summary", `Successfully sent SMS message to ${this.to}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import esendex from "../../esendex.app.mjs";
import constants from "../../common/constants.mjs";

export default {
key: "esendex-send-voice-message",
name: "Send Voice Message",
description: "Send a voice message to a recipient. [See the documentation](https://developers.esendex.com/api-reference/#messagedispatcher)",
version: "0.0.1",
type: "action",
props: {
esendex,
accountReference: {
propDefinition: [
esendex,
"accountReference",
],
},
to: {
type: "string",
label: "To",
description: "The phone number to send the message to. E.g. `447700900123`",
},
message: {
type: "string",
label: "Message",
description: "The message to send",
},
from: {
type: "string",
label: "From",
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.",
optional: true,
},
sendAt: {
type: "string",
label: "Send At",
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.",
optional: true,
},
characterSet: {
type: "string",
label: "Character Set",
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.",
options: constants.CHARACTER_SETS,
optional: true,
},
lang: {
type: "string",
label: "Language",
description: "The language to use for this Voice message",
options: constants.LANGUAGES,
},
retries: {
type: "integer",
label: "Retries",
description: "The number of times to attempt to call and deliver a Voice message",
optional: true,
},
},
async run({ $ }) {
const response = await this.esendex.sendMessage({
$,
data: {
accountreference: this.accountReference,
sendat: this.sendAt,
messages: [
{
to: this.to,
body: this.message,
from: this.from,
type: "Voice",
characterset: this.characterSet,
lang: this.lang,
retries: this.retries,
},
],
},
});
$.export("$summary", `Successfully sent voicemessage to ${this.to}`);
return response;
},
};
13 changes: 0 additions & 13 deletions components/esendex/app/esendex.app.ts

This file was deleted.

58 changes: 58 additions & 0 deletions components/esendex/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const CHARACTER_SETS = [
"GSM",
"Unicode",
"Auto",
];

const LANGUAGES = [
{
label: "English UK",
value: "en-GB",
},
{
label: "English Australian",
value: "en-AU",
},
{
label: "French",
value: "fr-FR",
},
{
label: "Spanish",
value: "es-ES",
},
{
label: "German",
value: "de-DE",
},
];

const MESSAGE_STATUSES = [
"Acknowledged",
"Authorised",
"Connecting",
"Delivered",
"Dispatched",
"Expired",
"Failed",
"FailedAuthorisation",
"PartiallyDelivered",
"Processing",
"Queued",
"Rejected",
"Scheduled",
"Sent",
"Submitted",
];

const MESSAGE_TYPES = [
"SMS",
"Voice",
];

export default {
CHARACTER_SETS,
LANGUAGES,
MESSAGE_STATUSES,
MESSAGE_TYPES,
};
56 changes: 56 additions & 0 deletions components/esendex/esendex.app.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "esendex",
propDefinitions: {
accountReference: {
type: "string",
label: "Account Reference",
description: "The account reference to use for the request",
async options() {
const { accounts } = await this.listAccounts();
return accounts.map((account) => ({
label: account.label,
value: account.reference,
}));
},
},
},
methods: {
_baseUrl() {
return "https://api.esendex.com/v1.0";
},
_makeRequest({
$ = this, path, ...opts
}) {
return axios($, {
url: `${this._baseUrl()}${path}`,
auth: {
username: `${this.$auth.username}`,
password: `${this.$auth.api_password}`,
},
...opts,
});
},
listAccounts(opts = {}) {
return this._makeRequest({
path: "/accounts",
...opts,
});
},
listMessages(opts = {}) {
return this._makeRequest({
path: "/messageheaders",
...opts,
});
},
sendMessage(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/messagedispatcher",
...opts,
});
},
},
};
9 changes: 6 additions & 3 deletions components/esendex/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
{
"name": "@pipedream/esendex",
"version": "0.0.2",
"version": "0.1.0",
"description": "Pipedream Esendex Components",
"main": "dist/app/esendex.app.mjs",
"main": "esendex.app.mjs",
"keywords": [
"pipedream",
"esendex"
],
"files": ["dist"],
"homepage": "https://pipedream.com/apps/esendex",
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3",
"simple-xml2json": "^1.2.3"
}
}
Loading
Loading