Skip to content

Commit 6af21c2

Browse files
committed
Adjustments
1 parent 04c6c45 commit 6af21c2

File tree

5 files changed

+48
-51
lines changed

5 files changed

+48
-51
lines changed

components/yay_com/actions/create-outbound-call/create-outbound-call.mjs

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import yay_com from "../../app/yay_com.app.mjs";
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import yayCom from "../../yay_com.app.mjs";
23

34
export default {
45
key: "yay_com-create-outbound-call",
@@ -7,46 +8,65 @@ export default {
78
version: "0.0.1",
89
type: "action",
910
props: {
10-
yay_com,
11+
yayCom,
1112
userUuid: {
1213
propDefinition: [
13-
yay_com,
14+
yayCom,
1415
"sipUser",
1516
],
1617
},
1718
destination: {
1819
propDefinition: [
19-
yay_com,
20+
yayCom,
2021
"destination",
2122
],
2223
},
2324
displayName: {
2425
propDefinition: [
25-
yay_com,
26+
yayCom,
2627
"displayName",
2728
],
2829
},
2930
sipUsers: {
3031
propDefinition: [
31-
yay_com,
32+
yayCom,
3233
"sipUsers",
3334
],
3435
},
3536
huntGroups: {
3637
propDefinition: [
37-
yay_com,
38+
yayCom,
3839
"huntGroups",
3940
],
4041
},
4142
},
4243
async run({ $ }) {
43-
const response = await this.yay_com.createOutboundCall({
44+
// Combine sipUsers and huntGroups into the targets array
45+
const targets = [
46+
...(this.sipUsers?.map((uuid) => ({
47+
type: "sipuser",
48+
uuid,
49+
})) || []),
50+
...(this.huntGroups?.map((uuid) => ({
51+
type: "huntgroup",
52+
uuid,
53+
})) || []),
54+
];
55+
56+
if (!targets.length) {
57+
throw new ConfigurationError("Please provide at least one target (SIP user or hunt group)");
58+
}
59+
60+
const response = await this.yayCom.createOutboundCall({
4461
$,
45-
userUuid: this.userUuid,
46-
destination: this.destination,
47-
displayName: this.displayName,
48-
sipUsers: this.sipUsers || [],
49-
huntGroups: this.huntGroups || [],
62+
data: {
63+
user_uuid: this.userUuid,
64+
destination: this.destination,
65+
display_name: this.displayName,
66+
...(targets.length > 0 && {
67+
targets,
68+
}),
69+
},
5070
});
5171

5272
$.export("$summary", `Successfully initiated outbound call to ${this.destination}`);

components/yay_com/actions/get-documents/get-documents.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import yay_com from "../../yay_com.app.mjs";
1+
import yayCom from "../../yay_com.app.mjs";
22

33
export default {
44
key: "yay_com-get-documents",
@@ -8,10 +8,10 @@ export default {
88
version: "0.0.1",
99
type: "action",
1010
props: {
11-
yay_com,
11+
yayCom,
1212
},
1313
async run({ $ }) {
14-
const response = await this.yay_com.listDocuments({
14+
const response = await this.yayCom.listDocuments({
1515
$,
1616
});
1717
const { length } = response;
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import yay_com from "../../app/yay_com.app.mjs";
1+
import yayCom from "../../yay_com.app.mjs";
22

33
export default {
44
key: "yay_com-get-phone-books",
@@ -7,12 +7,16 @@ export default {
77
version: "0.0.1",
88
type: "action",
99
props: {
10-
yay_com,
10+
yayCom,
1111
},
1212
async run({ $ }) {
13-
const response = await this.yay_com.listPhoneBooks($);
14-
const phoneBooks = response.data || [];
15-
$.export("$summary", `Successfully retrieved ${phoneBooks.length} phone book(s)`);
13+
const response = await this.yayCom.listPhoneBooks({
14+
$,
15+
});
16+
const { length } = response;
17+
$.export("$summary", `Successfully retrieved ${length} phone book${length === 1
18+
? ""
19+
: "s"}`);
1620
return response;
1721
},
1822
};

components/yay_com/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
"publishConfig": {
1313
"access": "public"
1414
}
15-
}
15+
}

components/yay_com/yay_com.app.mjs

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -111,38 +111,11 @@ export default {
111111
...args,
112112
});
113113
},
114-
async createOutboundCall({
115-
$,
116-
userUuid,
117-
destination,
118-
displayName,
119-
sipUsers = [],
120-
huntGroups = [],
121-
}) {
122-
// Combine sipUsers and huntGroups into the targets array
123-
const targets = [
124-
...sipUsers.map((uuid) => ({
125-
type: "sipuser",
126-
uuid,
127-
})),
128-
...huntGroups.map((uuid) => ({
129-
type: "huntgroup",
130-
uuid,
131-
})),
132-
];
133-
114+
async createOutboundCall(args) {
134115
return this._makeRequest({
135-
$,
136116
method: "POST",
137117
path: "/calls/outbound",
138-
data: {
139-
user_uuid: userUuid,
140-
destination,
141-
display_name: displayName,
142-
...(targets.length > 0 && {
143-
targets,
144-
}),
145-
},
118+
...args,
146119
});
147120
},
148121
},

0 commit comments

Comments
 (0)