Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
142 changes: 142 additions & 0 deletions components/connectwise_psa/actions/create-company/create-company.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import connectwise from "../../connectwise_psa.app.mjs";

export default {
key: "connectwise_psa-create-company",
name: "Create Company",
description: "Creates a new company in Connectwise. [See the documentation](https://developer.connectwise.com/Products/ConnectWise_PSA/REST#/Companies/postCompanyCompanies)",
version: "0.0.1",
type: "action",
props: {
connectwise,
name: {
type: "string",
label: "Company Name",
description: "The name of the new company",
},
identifier: {
type: "string",
label: "Identifier",
description: "A unique identifier for the company",
},
types: {
propDefinition: [
connectwise,
"companyTypes",
],
},
status: {
propDefinition: [
connectwise,
"status",
],
},
site: {
type: "string",
label: "Site Name",
description: "The site name for the company",
},
address1: {
type: "string",
label: "Address Line 1",
description: "First line of the company's address",
optional: true,
},
address2: {
type: "string",
label: "Address Line 2",
description: "Second line of the company's address",
optional: true,
},
city: {
type: "string",
label: "City",
description: "City of the company",
optional: true,
},
state: {
type: "string",
label: "State",
description: "State of the company",
optional: true,
},
zip: {
type: "string",
label: "Zip",
description: "Zip code of the company",
optional: true,
},
country: {
propDefinition: [
connectwise,
"country",
],
},
phone: {
type: "string",
label: "Phone",
description: "Phone number of the company",
optional: true,
},
website: {
type: "string",
label: "Website",
description: "Website of the company",
optional: true,
},
market: {
propDefinition: [
connectwise,
"market",
],
},
territory: {
propDefinition: [
connectwise,
"territory",
],
},
},
async run({ $ }) {
const types = this.types.map((type) => ({
id: type,
}));
const response = await this.connectwise.createCompany({
$,
data: {
name: this.name,
identifier: this.identifier,
types,
status: {
id: this.status,
},
site: {
name: this.site,
},
addressLine1: this.address1,
addressLine2: this.address2,
city: this.city,
state: this.state,
zip: this.zip,
country: this.country
? {
id: this.country,
}
: undefined,
phoneNumber: this.phone,
website: this.website,
market: this.market
? {
id: this.market,
}
: undefined,
territory: this.territory
? {
id: this.territory,
}
: undefined,
},
});
$.export("$summary", `Successfully created company with ID: ${response.id}`);
return response;
},
};
153 changes: 153 additions & 0 deletions components/connectwise_psa/actions/create-contact/create-contact.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
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",
type: "action",
props: {
connectwise,
firstName: {
type: "string",
label: "First Name",
description: "First name of the contact",
},
lastName: {
type: "string",
label: "Last Name",
description: "Last name of the contact",
},
email: {
type: "string",
label: "Email",
description: "Email address of the contact",
optional: true,
},
types: {
propDefinition: [
connectwise,
"contactTypes",
],
},
company: {
propDefinition: [
connectwise,
"company",
],
optional: true,
},
relationship: {
propDefinition: [
connectwise,
"relationship",
],
},
department: {
propDefinition: [
connectwise,
"department",
],
},
phone: {
type: "string",
label: "Phone",
description: "Phone number of the contact",
optional: true,
},
address1: {
type: "string",
label: "Address Line 1",
description: "First line of the contact's address",
optional: true,
},
address2: {
type: "string",
label: "Address Line 2",
description: "Second line of the contact's address",
optional: true,
},
city: {
type: "string",
label: "City",
description: "City of the contact",
optional: true,
},
state: {
type: "string",
label: "State",
description: "State of the contact",
optional: true,
},
zip: {
type: "string",
label: "Zip",
description: "Zip code of the contact",
optional: true,
},
country: {
propDefinition: [
connectwise,
"country",
],
},
},
async run({ $ }) {
const communicationItems = [];
if (this.email) {
communicationItems.push({
value: this.email,
type: {
id: 1, // email
},
});
}
if (this.phone) {
communicationItems.push({
value: this.phone,
type: {
id: 2, // phone
},
});
}
const types = this.types.map((type) => ({
id: type,
}));
const response = await this.connectwise.createContact({
$,
data: {
firstName: this.firstName,
lastName: this.lastName,
addressLine1: this.address1,
addressLine2: this.address2,
city: this.city,
state: this.state,
zip: this.zip,
country: this.country
? {
id: this.country,
}
: undefined,
communicationItems,
types,
company: this.company
? {
id: this.company,
}
: undefined,
relationship: this.relationship
? {
id: this.relationship,
}
: undefined,
department: this.department
? {
id: this.department,
}
: undefined,
},
});
$.export("$summary", `Successfully created contact with ID: ${response.id}`);
return response;
},
};
58 changes: 58 additions & 0 deletions components/connectwise_psa/actions/create-ticket/create-ticket.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import connectwise from "../../connectwise_psa.app.mjs";

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",
type: "action",
props: {
connectwise,
summary: {
type: "string",
label: "Summary",
description: "The subject line or description line for the ticket",
},
company: {
propDefinition: [
connectwise,
"company",
],
},
contact: {
propDefinition: [
connectwise,
"contact",
],
},
priority: {
propDefinition: [
connectwise,
"priority",
],
},
},
async run({ $ }) {
const response = await this.connectwise.createTicket({
$,
data: {
summary: this.summary,
company: {
id: this.company,
},
contact: this.contact
? {
id: this.contact,
}
: undefined,
priority: this.priority
? {
id: this.priority,
}
: undefined,
},
});
$.export("$summary", `Successfully created ticket with ID: ${response.id}`);
return response;
},
};
Loading