Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { parseObjectEntries } from "../../../firecrawl/common/utils.mjs";
import connectwise from "../../connectwise_psa.app.mjs";

export default {
key: "connectwise_psa-create-contact",
name: "Create Contact",
description: "Creates a new contact in Connectwise. [See the documentation](https://developer.connectwise.com/Products/ConnectWise_PSA/REST#/Contacts/postCompanyContacts)",
version: "0.0.1",
version: "0.1.0",
type: "action",
props: {
connectwise,
Expand Down Expand Up @@ -91,6 +92,17 @@ export default {
"country",
],
},
isDefault: {
type: "boolean",
label: "Primary Contact",
description: "Whether the contact is the primary (default) contact for the company",
optional: true,
},
additionalOptions: {
type: "object",
label: "Additional Options",
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.",
},
},
async run({ $ }) {
const communicationItems = [];
Expand Down Expand Up @@ -145,6 +157,8 @@ export default {
id: this.department,
}
: undefined,
defaultFlag: this.isDefault,
...(this.additionalOptions && parseObjectEntries(this.additionalOptions)),
},
});
$.export("$summary", `Successfully created contact with ID: ${response.id}`);
Expand Down
54 changes: 51 additions & 3 deletions components/connectwise_psa/actions/create-ticket/create-ticket.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "connectwise_psa-create-ticket",
name: "Create Ticket",
description: "Creates a new ticket in Connectwise. [See the documentation](https://developer.connectwise.com/Products/ConnectWise_PSA/REST#/Tickets/postServiceTickets)",
version: "0.0.1",
version: "0.1.0",
type: "action",
props: {
connectwise,
Expand All @@ -31,6 +31,23 @@ export default {
"priority",
],
},
note: {
type: "string[]",
label: "Note(s)",
description: "Text content of one or more notes to add to the ticket",
optional: true,
},
},
methods: {
createTicketNote({
id, ...args
}) {
return this.connectwise._makeRequest({
method: "POST",
path: `/service/tickets/${id}/notes`,
...args,
});
},
},
async run({ $ }) {
const response = await this.connectwise.createTicket({
Expand All @@ -52,7 +69,38 @@ export default {
: undefined,
},
});
$.export("$summary", `Successfully created ticket with ID: ${response.id}`);
return response;
const { id } = response;
const { note } = this;
const createdNotes = [];
if (id && note?.length) {
const notes = Array.isArray(note)
? note
: [
note,
];
for (let note of notes) {
const response = await this.createTicketNote({
$,
id,
data: {
text: note,
detailDescriptionFlag: true,
},
});
createdNotes.push(response);
}
}
const amountNotes = createdNotes.length;
$.export("$summary", `Successfully created ticket (ID: ${id})${amountNotes
? ` and added ${amountNotes} notes`
: ""}`);
return {
...(amountNotes
? {
createdNotes,
}
: undefined),
...response,
};
},
};
22 changes: 22 additions & 0 deletions components/connectwise_psa/common/utils.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function optionalParseAsJSON(value) {
try {
return JSON.parse(value);
} catch (e) {
return value;
}
}

export function parseObjectEntries(value) {
const obj = typeof value === "string"
? JSON.parse(value)
: value;
return Object.fromEntries(
Object.entries(obj).map(([
key,
value,
]) => [
key,
optionalParseAsJSON(value),
]),
);
}
2 changes: 1 addition & 1 deletion components/connectwise_psa/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/connectwise_psa",
"version": "0.1.1",
"version": "0.1.2",
"description": "Pipedream Connectwise PSA Components",
"main": "connectwise_psa.app.mjs",
"keywords": [
Expand Down
6 changes: 2 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading