@pipedream/connectwise_psa 0.1.1 → 0.2.1
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/actions/create-contact/create-contact.mjs +16 -1
- package/actions/create-ticket/create-ticket.mjs +51 -3
- package/common/utils.mjs +22 -0
- package/package.json +1 -1
- package/sources/common/base.mjs +1 -0
- package/sources/new-contact-created/new-contact-created.mjs +1 -1
- package/sources/new-project-created/new-project-created.mjs +1 -1
- package/sources/new-ticket-created/new-ticket-created.mjs +1 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { parseObjectEntries } from "../../common/utils.mjs";
|
|
1
2
|
import connectwise from "../../connectwise_psa.app.mjs";
|
|
2
3
|
|
|
3
4
|
export default {
|
|
4
5
|
key: "connectwise_psa-create-contact",
|
|
5
6
|
name: "Create Contact",
|
|
6
7
|
description: "Creates a new contact in Connectwise. [See the documentation](https://developer.connectwise.com/Products/ConnectWise_PSA/REST#/Contacts/postCompanyContacts)",
|
|
7
|
-
version: "0.0
|
|
8
|
+
version: "0.1.0",
|
|
8
9
|
type: "action",
|
|
9
10
|
props: {
|
|
10
11
|
connectwise,
|
|
@@ -91,6 +92,18 @@ export default {
|
|
|
91
92
|
"country",
|
|
92
93
|
],
|
|
93
94
|
},
|
|
95
|
+
isDefault: {
|
|
96
|
+
type: "boolean",
|
|
97
|
+
label: "Primary Contact",
|
|
98
|
+
description: "Whether the contact is the primary (default) contact for the company",
|
|
99
|
+
optional: true,
|
|
100
|
+
},
|
|
101
|
+
additionalOptions: {
|
|
102
|
+
type: "object",
|
|
103
|
+
label: "Additional Options",
|
|
104
|
+
description: "Additional parameters to send in the request. [See the documentation](https://developer.connectwise.com/Products/ConnectWise_PSA/REST#/Contacts/postCompanyContacts) for available parameters. Values will be parsed as JSON where applicable.",
|
|
105
|
+
optional: true,
|
|
106
|
+
},
|
|
94
107
|
},
|
|
95
108
|
async run({ $ }) {
|
|
96
109
|
const communicationItems = [];
|
|
@@ -145,6 +158,8 @@ export default {
|
|
|
145
158
|
id: this.department,
|
|
146
159
|
}
|
|
147
160
|
: undefined,
|
|
161
|
+
defaultFlag: this.isDefault,
|
|
162
|
+
...(this.additionalOptions && parseObjectEntries(this.additionalOptions)),
|
|
148
163
|
},
|
|
149
164
|
});
|
|
150
165
|
$.export("$summary", `Successfully created contact with ID: ${response.id}`);
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "connectwise_psa-create-ticket",
|
|
5
5
|
name: "Create Ticket",
|
|
6
6
|
description: "Creates a new ticket in Connectwise. [See the documentation](https://developer.connectwise.com/Products/ConnectWise_PSA/REST#/Tickets/postServiceTickets)",
|
|
7
|
-
version: "0.0
|
|
7
|
+
version: "0.1.0",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
connectwise,
|
|
@@ -31,6 +31,23 @@ export default {
|
|
|
31
31
|
"priority",
|
|
32
32
|
],
|
|
33
33
|
},
|
|
34
|
+
note: {
|
|
35
|
+
type: "string[]",
|
|
36
|
+
label: "Note(s)",
|
|
37
|
+
description: "Text content of one or more notes to add to the ticket",
|
|
38
|
+
optional: true,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
methods: {
|
|
42
|
+
createTicketNote({
|
|
43
|
+
id, ...args
|
|
44
|
+
}) {
|
|
45
|
+
return this.connectwise._makeRequest({
|
|
46
|
+
method: "POST",
|
|
47
|
+
path: `/service/tickets/${id}/notes`,
|
|
48
|
+
...args,
|
|
49
|
+
});
|
|
50
|
+
},
|
|
34
51
|
},
|
|
35
52
|
async run({ $ }) {
|
|
36
53
|
const response = await this.connectwise.createTicket({
|
|
@@ -52,7 +69,38 @@ export default {
|
|
|
52
69
|
: undefined,
|
|
53
70
|
},
|
|
54
71
|
});
|
|
55
|
-
|
|
56
|
-
|
|
72
|
+
const { id } = response;
|
|
73
|
+
const { note } = this;
|
|
74
|
+
const createdNotes = [];
|
|
75
|
+
if (id && note?.length) {
|
|
76
|
+
const notes = Array.isArray(note)
|
|
77
|
+
? note
|
|
78
|
+
: [
|
|
79
|
+
note,
|
|
80
|
+
];
|
|
81
|
+
for (let note of notes) {
|
|
82
|
+
const response = await this.createTicketNote({
|
|
83
|
+
$,
|
|
84
|
+
id,
|
|
85
|
+
data: {
|
|
86
|
+
text: note,
|
|
87
|
+
detailDescriptionFlag: true,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
createdNotes.push(response);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const amountNotes = createdNotes.length;
|
|
94
|
+
$.export("$summary", `Successfully created ticket (ID: ${id})${amountNotes
|
|
95
|
+
? ` and added ${amountNotes} notes`
|
|
96
|
+
: ""}`);
|
|
97
|
+
return {
|
|
98
|
+
...(amountNotes
|
|
99
|
+
? {
|
|
100
|
+
createdNotes,
|
|
101
|
+
}
|
|
102
|
+
: undefined),
|
|
103
|
+
...response,
|
|
104
|
+
};
|
|
57
105
|
},
|
|
58
106
|
};
|
package/common/utils.mjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
function optionalParseAsJSON(value) {
|
|
2
|
+
try {
|
|
3
|
+
return JSON.parse(value);
|
|
4
|
+
} catch (e) {
|
|
5
|
+
return value;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function parseObjectEntries(value) {
|
|
10
|
+
const obj = typeof value === "string"
|
|
11
|
+
? JSON.parse(value)
|
|
12
|
+
: value;
|
|
13
|
+
return Object.fromEntries(
|
|
14
|
+
Object.entries(obj).map(([
|
|
15
|
+
key,
|
|
16
|
+
value,
|
|
17
|
+
]) => [
|
|
18
|
+
key,
|
|
19
|
+
optionalParseAsJSON(value),
|
|
20
|
+
]),
|
|
21
|
+
);
|
|
22
|
+
}
|
package/package.json
CHANGED
package/sources/common/base.mjs
CHANGED
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
key: "connectwise_psa-new-contact-created",
|
|
7
7
|
name: "New Contact Created",
|
|
8
8
|
description: "Emit new event when a new contact is created in Connectwise.",
|
|
9
|
-
version: "0.0.
|
|
9
|
+
version: "0.0.2",
|
|
10
10
|
type: "source",
|
|
11
11
|
dedupe: "unique",
|
|
12
12
|
methods: {
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
key: "connectwise_psa-new-project-created",
|
|
7
7
|
name: "New Project Created",
|
|
8
8
|
description: "Emit new event when a new project is created in Connectwise.",
|
|
9
|
-
version: "0.0.
|
|
9
|
+
version: "0.0.2",
|
|
10
10
|
type: "source",
|
|
11
11
|
dedupe: "unique",
|
|
12
12
|
methods: {
|