@pipedream/bandwidth 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2020 Pipedream, Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,47 @@
1
+ const bandwidth = require("../../bandwidth.app.js");
2
+
3
+ module.exports = {
4
+ key: "bandwidth-send-sms",
5
+ name: "Send SMS",
6
+ description: "Send an SMS message using Bandwidth's Messaging API",
7
+ type: "action",
8
+ version: "1.0.0",
9
+ props: {
10
+ bandwidth,
11
+ messageTo: {
12
+ propDefinition: [
13
+ bandwidth,
14
+ "messageTo",
15
+ ],
16
+ },
17
+ from: {
18
+ propDefinition: [
19
+ bandwidth,
20
+ "from",
21
+ ],
22
+ },
23
+ message: {
24
+ propDefinition: [
25
+ bandwidth,
26
+ "message",
27
+ ],
28
+ },
29
+ messagingApplicationId: {
30
+ propDefinition: [
31
+ bandwidth,
32
+ "messagingApplicationId",
33
+ ],
34
+ },
35
+ },
36
+ async run () {
37
+ const response = await this.bandwidth.sendSms(
38
+ this.messageTo,
39
+ this.from,
40
+ this.message,
41
+ this.messagingApplicationId,
42
+ );
43
+ console.log("Status Code:", response.statusCode);
44
+ console.log("Message ID:", response.result.id);
45
+ return response;
46
+ },
47
+ };
@@ -0,0 +1,53 @@
1
+ const bandwidthMessaging = require("@bandwidth/messaging");
2
+
3
+ module.exports = {
4
+ type: "app",
5
+ app: "bandwidth",
6
+ propDefinitions: {
7
+ messageTo: {
8
+ type: "string",
9
+ label: "To",
10
+ description: "The number the message will be sent to, in E164 format ex `+19195551234`",
11
+ },
12
+ from: {
13
+ type: "string",
14
+ label: "From",
15
+ description: "The number the call or message event will come from, in E164 format ex `+19195551234`",
16
+ },
17
+ message: {
18
+ type: "string",
19
+ label: "Message",
20
+ description: "The text message content",
21
+ },
22
+ messagingApplicationId: {
23
+ type: "string",
24
+ label: "Messaging Application ID",
25
+ description: "The ID from the messaging application created in the [Bandwidth Dashboard](https://dashboard.bandwidth.com).\n\nThe application must be associated with the location that the `from` number lives on.",
26
+ },
27
+ mediaUrl: {
28
+ type: "string[]",
29
+ label: "Media URL",
30
+ description: "Publicly addressible URL of the media you would like to send with the SMS",
31
+ },
32
+ },
33
+ methods: {
34
+ getMessagingClient() {
35
+ return new bandwidthMessaging.Client({
36
+ basicAuthUserName: this.$auth.username,
37
+ basicAuthPassword: this.$auth.password,
38
+ });
39
+ },
40
+ async sendSms(to, from, message, messagingApplicationId) {
41
+ const controller = new bandwidthMessaging.ApiController(this.getMessagingClient());
42
+ const data = {
43
+ applicationId: messagingApplicationId,
44
+ to: [
45
+ to,
46
+ ],
47
+ from: from,
48
+ text: message,
49
+ };
50
+ return await controller.createMessage(this.$auth.accountId, data);
51
+ },
52
+ },
53
+ };
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "@pipedream/bandwidth",
3
+ "version": "1.0.0",
4
+ "description": "Pipedream Bandwidth Components",
5
+ "main": "index.js",
6
+ "keywords": [
7
+ "pipedream",
8
+ "bandwidth"
9
+ ],
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "author": "Bandwidth",
14
+ "license": "MIT",
15
+ "dependencies": {
16
+ "@bandwidth/messaging": "^4.0.0"
17
+ }
18
+ }
@@ -0,0 +1,30 @@
1
+ const bandwidth = require("../../bandwidth.app");
2
+
3
+ module.exports = {
4
+ name: "New Incoming SMS",
5
+ description: "Emits an event each time a `message-received` event is received at the source url",
6
+ key: "bandwidth-new-incoming-sms",
7
+ version: "1.1.0",
8
+ props: {
9
+ bandwidth,
10
+ http: {
11
+ type: "$.interface.http",
12
+ customResponse: true,
13
+ },
14
+ },
15
+
16
+ async run(event) {
17
+ const messageBody = event.body[0];
18
+ this.http.respond({
19
+ status: 204,
20
+ });
21
+
22
+ if (messageBody.message.direction == "in") {
23
+ this.$emit(messageBody, {
24
+ summary: "Message Received",
25
+ id: messageBody.message.id,
26
+ ts: +new Date(messageBody.time),
27
+ });
28
+ }
29
+ },
30
+ };
@@ -0,0 +1,31 @@
1
+ const bandwidth = require('../../bandwidth.app');
2
+
3
+ module.exports = {
4
+ name: 'New Outgoing SMS',
5
+ description:
6
+ 'Emits an event each time an outbound message status event is received at the source url',
7
+ key: 'bandwidth-new-ourgoing-sms',
8
+ version: '1.1.1',
9
+ props: {
10
+ bandwidth,
11
+ http: {
12
+ type: '$.interface.http',
13
+ customResponse: true,
14
+ },
15
+ },
16
+
17
+ async run(event) {
18
+ const messageBody = event.body[0];
19
+ this.http.respond({
20
+ status: 204,
21
+ });
22
+
23
+ if (messageBody.message.direction == 'out') {
24
+ this.$emit(messageBody, {
25
+ summary: messageBody.type,
26
+ id: messageBody.message.id,
27
+ ts: +new Date(messageBody.time),
28
+ });
29
+ }
30
+ },
31
+ };