Skip to content

Commit 7015c83

Browse files
committed
Merge branch 'master' into issue-12758
2 parents 3c98dd9 + 5f95b69 commit 7015c83

File tree

72 files changed

+1924
-313
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1924
-313
lines changed

.github/workflows/components-pr.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
restore-keys: |
6565
${{ runner.os }}-pnpm-store-
6666
- name: Setup Node Env
67-
uses: actions/setup-node@v4.0.2
67+
uses: actions/setup-node@v4.0.3
6868
with:
6969
node-version: 18
7070
registry-url: https://registry.npmjs.org/
@@ -153,7 +153,7 @@ jobs:
153153
restore-keys: |
154154
${{ runner.os }}-pnpm-store-
155155
- name: Setup Node Env
156-
uses: actions/setup-node@v4.0.2
156+
uses: actions/setup-node@v4.0.3
157157
with:
158158
node-version: 18
159159
registry-url: https://registry.npmjs.org/

.github/workflows/publish-components.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Install dependencies
3030
run: pnpm install -r --no-frozen-lockfile
3131
- name: Setup Node Env
32-
uses: actions/setup-node@v4.0.2
32+
uses: actions/setup-node@v4.0.3
3333
with:
3434
node-version: 14
3535
registry-url: https://registry.npmjs.org/
@@ -133,7 +133,7 @@ jobs:
133133
restore-keys: |
134134
${{ runner.os }}-pnpm-store-
135135
- name: Setup Node Env
136-
uses: actions/setup-node@v4.0.2
136+
uses: actions/setup-node@v4.0.3
137137
with:
138138
node-version: 14
139139
registry-url: https://registry.npmjs.org/

.github/workflows/publish-marketplace-content.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Install dependencies
3030
run: pnpm install -r --no-frozen-lockfile
3131
- name: Setup Node Env
32-
uses: actions/setup-node@v4.0.2
32+
uses: actions/setup-node@v4.0.3
3333
with:
3434
node-version: 14
3535
registry-url: https://registry.npmjs.org/

.github/workflows/publish-packages.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
3838
restore-keys: |
3939
${{ runner.os }}-pnpm-store-
40-
- uses: actions/setup-node@v4.0.2
40+
- uses: actions/setup-node@v4.0.3
4141
with:
4242
node-version: 18
4343
registry-url: https://registry.npmjs.org/

.github/workflows/pull-request-checks.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
- name: Install dependencies
7171
run: pnpm install -r
7272
- name: Setup Node Env
73-
uses: actions/setup-node@v4.0.2
73+
uses: actions/setup-node@v4.0.3
7474
with:
7575
node-version: 18
7676
registry-url: https://registry.npmjs.org/

blog/pi/poetry.lock

+5-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/_360nrs/_360nrs.app.mjs

+64-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,70 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "_360nrs",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
message: {
8+
type: "string",
9+
label: "Message",
10+
description: "Text of message. At most, there can be 160 characters. The text must be encoded in UTF-8.",
11+
},
12+
phoneNumber: {
13+
type: "string",
14+
label: "Phone Number",
15+
description: "Mobile phone number(s) to receive message. Must include the prefix (e.g. in Spain `34666666666`).",
16+
async options() {
17+
const { data } = await this.listContacts();
18+
return data.map(({
19+
email: label, phone: value,
20+
}) => ({
21+
label,
22+
value,
23+
}));
24+
},
25+
},
26+
from: {
27+
type: "string",
28+
label: "From Sender",
29+
description: "Sender text, this label will consist of 15 numbers or 11 alphanumeric characters.",
30+
},
31+
},
532
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
33+
_baseUrl() {
34+
return "https://dashboard.360nrs.com/api/rest";
35+
},
36+
getHeaders(headers) {
37+
const {
38+
username,
39+
api_password: password,
40+
} = this.$auth;
41+
const token = Buffer.from(`${username}:${password}`).toString("base64");
42+
return {
43+
...headers,
44+
"Content-Type": "application/json",
45+
"Authorization": `Basic ${token}`,
46+
};
47+
},
48+
_makeRequest({
49+
$ = this, path, headers, ...args
50+
} = {}) {
51+
return axios($, {
52+
...args,
53+
url: `${this._baseUrl()}${path}`,
54+
headers: this.getHeaders(headers),
55+
});
56+
},
57+
post(args = {}) {
58+
return this._makeRequest({
59+
method: "POST",
60+
...args,
61+
});
62+
},
63+
listContacts(args = {}) {
64+
return this._makeRequest({
65+
path: "/contacts",
66+
...args,
67+
});
968
},
1069
},
11-
};
70+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import app from "../../_360nrs.app.mjs";
2+
import utils from "../../common/utils.mjs";
3+
4+
export default {
5+
key: "_360nrs-send-sms",
6+
name: "Send SMS",
7+
description: "Send an SMS message to one or more recipients. [See the documentation](https://apidocs.360nrs.com/?shell#sms)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
message: {
13+
propDefinition: [
14+
app,
15+
"message",
16+
],
17+
},
18+
to: {
19+
type: "string[]",
20+
label: "To Phone Number(s)",
21+
propDefinition: [
22+
app,
23+
"phoneNumber",
24+
],
25+
},
26+
from: {
27+
propDefinition: [
28+
app,
29+
"from",
30+
],
31+
},
32+
},
33+
methods: {
34+
sendSMS(args = {}) {
35+
return this.app.post({
36+
path: "/sms",
37+
...args,
38+
});
39+
},
40+
},
41+
async run({ $ }) {
42+
const {
43+
sendSMS,
44+
message,
45+
from,
46+
to,
47+
} = this;
48+
49+
const response = await sendSMS({
50+
data: {
51+
message,
52+
to: utils.parseArray(to),
53+
from,
54+
},
55+
});
56+
57+
$.export("$summary", `Successfully sent SMS with ID \`${response.result[0]?.id}\``);
58+
return response;
59+
},
60+
};

components/_360nrs/common/utils.mjs

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
3+
function parseArray(value) {
4+
try {
5+
if (!value) {
6+
return [];
7+
}
8+
9+
if (Array.isArray(value)) {
10+
return value;
11+
}
12+
13+
const parsedValue = JSON.parse(value);
14+
15+
if (!Array.isArray(parsedValue)) {
16+
throw new Error("Not an array");
17+
}
18+
19+
return parsedValue;
20+
21+
} catch (e) {
22+
throw new ConfigurationError("Make sure the custom expression contains a valid array object");
23+
}
24+
}
25+
26+
export default {
27+
parseArray,
28+
};

components/_360nrs/package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/_360nrs",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream 360NRS Components",
55
"main": "_360nrs.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.0"
1417
}
15-
}
18+
}

0 commit comments

Comments
 (0)