Skip to content

Commit db76782

Browse files
committed
new components
1 parent 4a2b1bc commit db76782

File tree

24 files changed

+1476
-86
lines changed

24 files changed

+1476
-86
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import freshdesk from "../../freshdesk.app.mjs";
2+
import constants from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "freshdesk-create-agent",
6+
name: "Create Agent",
7+
description: "Create an agent in Freshdesk. [See the documentation](https://developers.freshdesk.com/api/#create_agent)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
freshdesk,
12+
email: {
13+
type: "string",
14+
label: "Email",
15+
description: "Email address of the Agent.",
16+
},
17+
ticketScope: {
18+
type: "integer",
19+
label: "Ticket Scope",
20+
description: "Ticket permission of the agent. Current logged in agent can't update his/her ticket_scope",
21+
options: constants.TICKET_SCOPE,
22+
},
23+
occasional: {
24+
type: "boolean",
25+
label: "Occasional",
26+
description: "Set to true if this is an occasional agent (true => occasional, false => full-time)",
27+
optional: true,
28+
},
29+
signature: {
30+
type: "string",
31+
label: "Signature",
32+
description: "Signature of the agent in HTML format",
33+
optional: true,
34+
},
35+
skillIds: {
36+
propDefinition: [
37+
freshdesk,
38+
"skillIds",
39+
],
40+
},
41+
groupIds: {
42+
propDefinition: [
43+
freshdesk,
44+
"groupId",
45+
],
46+
type: "string[]",
47+
label: "Group IDs",
48+
description: "Array of group IDs",
49+
optional: true,
50+
},
51+
roleIds: {
52+
propDefinition: [
53+
freshdesk,
54+
"roleIds",
55+
],
56+
},
57+
agentType: {
58+
type: "integer",
59+
label: "Agent Type",
60+
description: "Type of the agent",
61+
options: constants.AGENT_TYPE,
62+
optional: true,
63+
},
64+
language: {
65+
type: "string",
66+
label: "Language",
67+
description: " Language of the Agent. Default language is `en`",
68+
optional: true,
69+
},
70+
timeZone: {
71+
type: "string",
72+
label: "Time Zone",
73+
description: "Time zone of the agent. Default value is time zone of the domain.",
74+
optional: true,
75+
},
76+
focusMode: {
77+
type: "boolean",
78+
label: "Focus Mode",
79+
description: "Focus mode of the agent. Default value is `true`",
80+
optional: true,
81+
},
82+
},
83+
async run({ $ }) {
84+
const response = await this.freshdesk.createAgent({
85+
$,
86+
data: {
87+
email: this.email,
88+
ticket_scope: this.ticketScope,
89+
occasional: this.occasional,
90+
signature: this.signature,
91+
skill_ids: this.skillIds,
92+
group_ids: this.groupIds,
93+
role_ids: this.roleIds,
94+
agent_type: this.agentType,
95+
language: this.language,
96+
time_zone: this.timeZone,
97+
focus_mode: this.focusMode,
98+
},
99+
});
100+
$.export("$summary", `Agent ${this.email} created successfully`);
101+
return response;
102+
},
103+
};
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import freshdesk from "../../freshdesk.app.mjs";
2+
import constants from "../../common/constants.mjs";
3+
import { parseObject } from "../../common/utils.mjs";
4+
5+
export default {
6+
key: "freshdesk-create-solution-article",
7+
name: "Create Solution Article",
8+
description: "Create a solution article in Freshdesk. [See the documentation](https://developers.freshdesk.com/api/#solution_article_attributes)",
9+
version: "0.0.1",
10+
type: "action",
11+
props: {
12+
freshdesk,
13+
categoryId: {
14+
propDefinition: [
15+
freshdesk,
16+
"categoryId",
17+
],
18+
},
19+
folderId: {
20+
propDefinition: [
21+
freshdesk,
22+
"folderId",
23+
(c) => ({
24+
categoryId: c.categoryId,
25+
}),
26+
],
27+
},
28+
title: {
29+
type: "string",
30+
label: "Title",
31+
description: "Title of the article",
32+
},
33+
description: {
34+
type: "string",
35+
label: "Description",
36+
description: "Description of the article",
37+
},
38+
status: {
39+
type: "integer",
40+
label: "Status",
41+
description: "Status of the article",
42+
options: constants.ARTICLE_STATUS,
43+
},
44+
seoData: {
45+
type: "object",
46+
label: "SEO Data",
47+
description: "Meta data for search engine optimization. Allows meta_title, meta_description and meta_keywords",
48+
optional: true,
49+
},
50+
tags: {
51+
type: "string[]",
52+
label: "Tags",
53+
description: "Tags for the article",
54+
optional: true,
55+
},
56+
},
57+
async run({ $ }) {
58+
const response = await this.freshdesk.createArticle({
59+
$,
60+
folderId: this.folderId,
61+
data: {
62+
title: this.title,
63+
description: this.description,
64+
status: this.status,
65+
seo_data: parseObject(this.seoData),
66+
tags: this.tags,
67+
},
68+
});
69+
$.export("$summary", `Successfully created solution article ${this.title}`);
70+
return response;
71+
},
72+
};
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import freshdesk from "../../freshdesk.app.mjs";
2+
import { parseObject } from "../../common/utils.mjs";
3+
import { ConfigurationError } from "@pipedream/platform";
4+
5+
export default {
6+
key: "freshdesk-create-ticket-field",
7+
name: "Create Ticket Field",
8+
description: "Create a ticket field in Freshdesk. [See the documentation](https://developers.freshdesk.com/api/#create_ticket_field)",
9+
version: "0.0.1",
10+
type: "action",
11+
props: {
12+
freshdesk,
13+
label: {
14+
type: "string",
15+
label: "Label",
16+
description: "Display the name of the Ticket Field",
17+
},
18+
labelForCustomers: {
19+
type: "string",
20+
label: "Label for Customers",
21+
description: "The label for the field as seen by customers",
22+
},
23+
customersCanEdit: {
24+
type: "boolean",
25+
label: "Customers Can Edit",
26+
description: "Whether customers can edit the field",
27+
optional: true,
28+
},
29+
displayedToCustomers: {
30+
type: "boolean",
31+
label: "Displayed to Customers",
32+
description: "Whether the field is displayed to customers",
33+
optional: true,
34+
},
35+
position: {
36+
type: "integer",
37+
label: "Position",
38+
description: "The position of the fieldPosition in which the ticket field is displayed in the form. If not given, it will be displayed on top",
39+
optional: true,
40+
},
41+
type: {
42+
type: "string",
43+
label: "Type",
44+
description: "The type of the field. Can be custom_dropdown, custom_checkbox, custom_text, etc...",
45+
default: "custom_dropdown",
46+
optional: true,
47+
},
48+
requiredForClusure: {
49+
type: "boolean",
50+
label: "Required for Closure",
51+
description: "Set to `true` if the field is mandatory for closing the ticket",
52+
optional: true,
53+
},
54+
requiredForAgents: {
55+
type: "boolean",
56+
label: "Required for Agents",
57+
description: "Set to `true` if the field is mandatory for agents",
58+
optional: true,
59+
},
60+
requiredForCustomers: {
61+
type: "boolean",
62+
label: "Required for Customers",
63+
description: "Set to `true` if the field is mandatory for customers",
64+
optional: true,
65+
},
66+
choices: {
67+
type: "string[]",
68+
label: "Choices",
69+
description: "Array of key, value pairs containing the value and position of dropdown choices. Example: `[{ \"value\": \"Refund\", \"position\": 1 }, { \"value\": \"FaultyProduct\", \"position\": 2 }]`",
70+
optional: true,
71+
},
72+
dependentFields: {
73+
type: "string[]",
74+
label: "Dependent Fields",
75+
description: "Applicable only for dependent fields, this contains details of nested fields Example: `[{ \"label\": \"District\", \"label_for_customers\": \"District\", \"level\": 2 }, { \"label\": \"Branch\", \"label_for_customers\": \"Branch\", \"level\": 3 }]`",
76+
optional: true,
77+
},
78+
sectionMappings: {
79+
type: "string[]",
80+
label: "Section Mappings",
81+
description: "Applicable only if the field is part of a section. This contains the details of a section (ID, position) for which it is been a part of. Example: `[{ \"position\": 3, \"section_id\": 1 }]`",
82+
optional: true,
83+
},
84+
},
85+
async run({ $ }) {
86+
if (this.type === "custom_dropdown" && !this.choices) {
87+
throw new ConfigurationError("Choices are required for custom_dropdown fields");
88+
}
89+
90+
const response = await this.freshdesk.createTicketField({
91+
$,
92+
data: {
93+
label: this.label,
94+
customers_can_edit: this.customersCanEdit,
95+
label_for_customers: this.labelForCustomers,
96+
displayed_to_customers: this.displayedToCustomers,
97+
position: this.position,
98+
type: this.type,
99+
required_for_closure: this.requiredForClusure,
100+
required_for_agents: this.requiredForAgents,
101+
required_for_customers: this.requiredForCustomers,
102+
choices: parseObject(this.choices),
103+
dependent_fields: parseObject(this.dependentFields),
104+
section_mappings: parseObject(this.sectionMappings),
105+
},
106+
});
107+
$.export("$summary", `Successfully created ticket field: ${response.label}`);
108+
return response;
109+
},
110+
};
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import freshdesk from "../../freshdesk.app.mjs";
2+
3+
export default {
4+
key: "freshdesk-delete-solution-article",
5+
name: "Delete Solution Article",
6+
description: "Delete a solution article in Freshdesk. [See the documentation](https://developers.freshdesk.com/api/#solution_article_attributes)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
freshdesk,
11+
categoryId: {
12+
propDefinition: [
13+
freshdesk,
14+
"categoryId",
15+
],
16+
},
17+
folderId: {
18+
propDefinition: [
19+
freshdesk,
20+
"folderId",
21+
(c) => ({
22+
categoryId: c.categoryId,
23+
}),
24+
],
25+
},
26+
articleId: {
27+
propDefinition: [
28+
freshdesk,
29+
"articleId",
30+
(c) => ({
31+
folderId: c.folderId,
32+
}),
33+
],
34+
},
35+
},
36+
async run({ $ }) {
37+
const response = await this.freshdesk.deleteArticle({
38+
$,
39+
articleId: this.articleId,
40+
});
41+
$.export("$summary", `Successfully deleted solution article ${this.articleId}`);
42+
return response;
43+
},
44+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import freshdesk from "../../freshdesk.app.mjs";
2+
3+
export default {
4+
key: "freshdesk-get-contact",
5+
name: "Get Contact",
6+
description: "Get a contact from Freshdesk. [See the documentation](https://developers.freshdesk.com/api/#view_contact)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
freshdesk,
11+
contactId: {
12+
propDefinition: [
13+
freshdesk,
14+
"contactId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const contact = await this.freshdesk.getContact({
20+
$,
21+
contactId: this.contactId,
22+
});
23+
$.export("$summary", `Successfully fetched contact: ${contact.name}`);
24+
return contact;
25+
},
26+
};

0 commit comments

Comments
 (0)