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
29 changes: 12 additions & 17 deletions components/freshdesk/actions/create-company/create-company.mjs
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
import { removeNullEntries } from "../../common/utils.mjs";
import freshdesk from "../../freshdesk.app.mjs";

export default {
key: "freshdesk-create-company",
name: "Create a Company",
description: "Create a company. [See docs here](https://developers.freshdesk.com/api/#companies)",
version: "0.0.1",
description: "Create a company. [See the documentation](https://developers.freshdesk.com/api/#create_company)",
version: "0.0.3",
type: "action",
props: {
freshdesk,
name: {
type: "string",
label: "Name",
description: "Name of the company.",
description: "Name of the company",
},
description: {
type: "string",
label: "Description",
description: "Description of the company.",
description: "Description of the company",
optional: true,
},
note: {
type: "string",
label: "Note",
description: "Any specific note about the company.",
description: "Any specific note about the company",
optional: true,
},
industry: {
type: "string",
label: "Industry",
description: "The industry the company serves in.",
description: "The industry the company serves in",
optional: true,
},
domains: {
Expand All @@ -40,18 +39,14 @@ export default {
},
},
async run({ $ }) {
const payload = removeNullEntries({
name: this.name,
domains: this.domains,
note: this.note,
industry: this.industry,
description: this.description,
});
const response = await this.freshdesk.createCompany({
const {
freshdesk, ...data
} = this;
const response = await freshdesk.createCompany({
$,
payload,
data,
});
response && $.export("$summary", "Company sucessfully created");
response && $.export("$summary", "Company successfully created");
return response;
},
};
33 changes: 16 additions & 17 deletions components/freshdesk/actions/create-contact/create-contact.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { removeNullEntries } from "../../common/utils.mjs";
import freshdesk from "../../freshdesk.app.mjs";

export default {
key: "freshdesk-create-contact",
name: "Create a Contact",
description: "Create a contact. [See docs here](https://developers.freshdesk.com/api/#create_contact)",
version: "0.0.1",
description: "Create a contact. [See the documentation](https://developers.freshdesk.com/api/#create_contact)",
version: "0.1.0",
type: "action",
props: {
freshdesk,
Expand All @@ -16,20 +15,20 @@ export default {
},
email: {
type: "string",
label: "Email",
description: "Primary email address of the contact. If you want to associate additional email(s) with this contact, use the other_emails attribute.",
label: "Email Address",
description: "Primary email address of the contact",
optional: true,
},
otherEmails: {
type: "string[]",
label: "Additional email addresses",
description: "String array of additional email addresses.",
label: "Additional Email Addresses",
description: "One or more additional email addresses for the contact",
optional: true,
},
phone: {
type: "string",
label: "Phone number",
description: "Telephone number of the contact.",
label: "Phone Number",
description: "Phone number of the contact",
optional: true,
},
companyId: {
Expand All @@ -41,16 +40,16 @@ export default {
},
},
async run({ $ }) {
const data = removeNullEntries({
name: this.name,
email: this.email,
other_emails: this.otherEmails,
phone: this.phone,
company_id: this.companyId && Number(this.companyId),
});
const {
companyId, otherEmails, ...data
} = this;
const response = await this.freshdesk.createContact({
$,
data,
data: {
other_emails: otherEmails,
company_id: companyId && Number(companyId),
...data,
},
});
response && $.export("$summary", "Contact successfully created");
return response;
Expand Down
46 changes: 20 additions & 26 deletions components/freshdesk/actions/create-ticket/create-ticket.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import freshdesk from "../../freshdesk.app.mjs";
import { removeNullEntries } from "../../common/utils.mjs";

export default {
key: "freshdesk-create-ticket",
name: "Create a Ticket",
description: "Create a ticket. [See docs here](https://developers.freshdesk.com/api/#tickets)",
version: "0.0.2",
description: "Create a ticket. [See the documentation](https://developers.freshdesk.com/api/#create_ticket)",
version: "0.1.0",
type: "action",
props: {
freshdesk,
Expand All @@ -14,7 +13,6 @@ export default {
freshdesk,
"companyId",
],
description: "ID of the company to which this ticket belongs",
},
email: {
propDefinition: [
Expand All @@ -24,7 +22,6 @@ export default {
companyId,
}),
],
description: "Email address of the requester.",
optional: true,
},
priority: {
Expand All @@ -34,28 +31,28 @@ export default {
],
default: 1,
},
subject: {
type: "string",
label: "Subject",
description: "Subject of the ticket",
optional: true,
},
description: {
type: "string",
label: "Description",
description: "HTML content of the ticket.",
description: "HTML content of the ticket",
optional: true,
},
descriptionText: {
type: "string",
label: "Description text",
description: "Content of the ticket in plain text.",
description: "Content of the ticket in plain text",
optional: true,
},
phone: {
type: "string",
label: "Phone number",
description: "Telephone number of the contact.",
optional: true,
},
subject: {
type: "string",
label: "Subject",
description: "Subject of the ticket.",
description: "Phone number of the requester. If no contact exists with this phone number on Freshdesk, it will be added as a new contact",
optional: true,
},
status: {
Expand All @@ -68,19 +65,16 @@ export default {
},
},
async run({ $ }) {
const data = removeNullEntries({
company_id: this.companyId && Number(this.companyId),
description: this.description,
description_text: this.descriptionText,
email: this.email,
phone: this.phone,
subject: this.subject,
status: this.status && Number(this.status),
priority: this.priority && Number(this.priority),
});
const response = await this.freshdesk.createTicket({
const {
freshdesk, companyId, descriptionText, ...data
} = this;
const response = await freshdesk.createTicket({
$,
data,
data: {
company_id: Number(companyId),
description_text: descriptionText,
...data,
},
});
response && $.export("$summary", "Ticket successfully created");
return response;
Expand Down
22 changes: 13 additions & 9 deletions components/freshdesk/actions/get-ticket/get-ticket.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,27 @@ import freshdesk from "../../freshdesk.app.mjs";
export default {
key: "freshdesk-get-ticket",
name: "Get Ticket Details",
description: "Get a Ticket. [See docs here](https://developers.freshdesk.com/api/#tickets)",
version: "0.0.1",
description: "Get details of a Ticket. [See the documentation](https://developers.freshdesk.com/api/#view_a_ticket)",
version: "0.1.0",
type: "action",
props: {
freshdesk,
id: {
type: "string",
label: "Ticket ID",
description: "Ticket ID.",
ticketId: {
propDefinition: [
freshdesk,
"ticketId",
],
},
},
async run({ $ }) {
const response = await this.freshdesk.getTicket({
const {
freshdesk, ticketId,
} = this;
const response = await freshdesk.getTicket({
$,
id: this.id,
ticketId,
});
response && $.export("$summary", "Successfully found ticket");
response && $.export("$summary", "Successfully retrieved ticket");
return response;
},
};
70 changes: 57 additions & 13 deletions components/freshdesk/actions/list-all-tickets/list-all-tickets.mjs
Original file line number Diff line number Diff line change
@@ -1,25 +1,69 @@
// legacy_hash_id: a_A6i5zz
import { axios } from "@pipedream/platform";
import freshdesk from "../../freshdesk.app.mjs";

export default {
key: "freshdesk-list-all-tickets",
name: "List All Tickets",
description: "Use filters to view only specific tickets (those which match the criteria that you choose). By default, only tickets that have not been deleted or marked as spam will be returned, unless you use the 'deleted' filter.",
version: "0.1.1",
name: "List Tickets",
description:
"Fetch up to 100 tickets according to the selected filters. [See the documentation](https://developers.freshdesk.com/api/#list_all_tickets)",
version: "0.2.0",
type: "action",
props: {
freshdesk: {
type: "app",
app: "freshdesk",
freshdesk,
orderBy: {
type: "string",
label: "Sort By",
description: "Which field to sort tickets by. Defaults to `Created At`",
optional: true,
options: [
{
value: "created_at",
label: "Created At",
},
{
value: "due_by",
label: "Due By",
},
{
value: "updated_at",
label: "Updated At",
},
{
value: "status",
label: "Status",
},
],
},
orderType: {
type: "string",
label: "Sort Order",
description:
"Whether to sort in ascending or descending order. Defaults to descending",
optional: true,
options: [
{
label: "Ascending",
value: "asc",
},
{
label: "Descending",
value: "desc",
},
],
},
},
async run({ $ }) {
return await axios($, {
url: `https://${this.freshdesk.$auth.domain}.freshdesk.com/api/v2/tickets`,
auth: {
username: `${this.freshdesk.$auth.api_key}:X`,
password: "",
const response = await this.freshdesk.listTickets({
$,
params: {
order_by: this.orderBy,
order_type: this.orderType,
},
});

const { length } = response;
$.export("$summary", `Successfully fetched ${length} ticket${length === 1
? ""
: "s"}`);
return response;
},
};
8 changes: 0 additions & 8 deletions components/freshdesk/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
export default {
HTTP_PROTOCOL: "https://",
BASE_PATH: "/api",
VERSION_PATH: "/v2",
PAGE_SIZE: 100,
retriableStatusCodes: [
408,
429,
500,
],
DB_LAST_DATE_CHECK: "DB_LAST_DATE_CHECK",
TICKET_STATUS: [
{
Expand Down
Loading
Loading