Skip to content

Commit 44ee8d9

Browse files
committed
[Components] helpspot #14147
Sources - New Request - New Request Updated Actions - Update Request - Create Request
1 parent a332e95 commit 44ee8d9

File tree

13 files changed

+842
-361
lines changed

13 files changed

+842
-361
lines changed
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
import {
2+
NOTE_IS_HTML,
3+
NOTE_TYPE_OPTIONS,
4+
OPENED_VIA_OPTIONS,
5+
} from "../../common/constants.mjs";
6+
import helpspot from "../../helpspot.app.mjs";
7+
8+
export default {
9+
props: {
10+
helpspot,
11+
tNote: {
12+
type: "string",
13+
label: "Note",
14+
description: "The note of the request",
15+
},
16+
xCategory: {
17+
propDefinition: [
18+
helpspot,
19+
"xCategory",
20+
],
21+
},
22+
fNoteType: {
23+
type: "string",
24+
label: "Note Type",
25+
description: "The type of the note",
26+
options: NOTE_TYPE_OPTIONS,
27+
optional: true,
28+
},
29+
fNoteIsHTML: {
30+
type: "string",
31+
label: "Note Is HTML?",
32+
description: "whether the note is HTML or text",
33+
optional: true,
34+
options: NOTE_IS_HTML,
35+
},
36+
sTitle: {
37+
type: "string",
38+
label: "Subject",
39+
description: "The title used as email subject",
40+
optional: true,
41+
},
42+
xStatus: {
43+
propDefinition: [
44+
helpspot,
45+
"xStatus",
46+
],
47+
optional: true,
48+
},
49+
sUserId: {
50+
type: "string",
51+
label: "User Id",
52+
description: "The Id of the customer",
53+
optional: true,
54+
},
55+
sFirstName: {
56+
type: "string",
57+
label: "First Name",
58+
description: "The first name of the request creator",
59+
optional: true,
60+
},
61+
sLastName: {
62+
type: "string",
63+
label: "Last Name",
64+
description: "The last name of the request creator",
65+
optional: true,
66+
},
67+
sEmail: {
68+
type: "string",
69+
label: "Email",
70+
description: "The email of the request creator",
71+
optional: true,
72+
},
73+
sPhone: {
74+
type: "string",
75+
label: "Phone",
76+
description: "The phone number of the request creator",
77+
optional: true,
78+
},
79+
fUrgent: {
80+
type: "boolean",
81+
label: "Urgent",
82+
description: "Whether the request is urgent or not",
83+
optional: true,
84+
},
85+
fOpenedVia: {
86+
type: "integer",
87+
label: "Opened Via",
88+
description: "Request opened via",
89+
options: OPENED_VIA_OPTIONS,
90+
optional: true,
91+
},
92+
emailFrom: {
93+
propDefinition: [
94+
helpspot,
95+
"emailFrom",
96+
],
97+
optional: true,
98+
},
99+
emailCC: {
100+
type: "string[]",
101+
label: "Email CC",
102+
description: "A list of emails to CC on the request",
103+
optional: true,
104+
},
105+
emailBCC: {
106+
type: "string[]",
107+
label: "Email BCC",
108+
description: "A list of emails to BCC on the request",
109+
optional: true,
110+
},
111+
emailStaff: {
112+
propDefinition: [
113+
helpspot,
114+
"emailStaff",
115+
],
116+
optional: true,
117+
},
118+
},
119+
async run({ $ }) {
120+
await this.getValidation();
121+
122+
const fn = this.getFunction();
123+
const response = await fn({
124+
$,
125+
data: this.getData(),
126+
});
127+
128+
$.export("$summary", this.getSummary(response));
129+
return response;
130+
},
131+
};
Lines changed: 33 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,45 @@
1-
import helpspot from "../../helpspot.app.mjs";
2-
import { axios } from "@pipedream/platform";
1+
import { parseObject } from "../../common/utils.mjs";
2+
import common from "../common/request-base.mjs";
33

44
export default {
5+
...common,
56
key: "helpspot-create-request",
67
name: "Create Request",
7-
description: "Creates a new user request. At least one of the following props is needed: first name, last name, user id, email, or phone. [See the documentation](https://support.helpspot.com/index.php?pg=kb.page&id=163)",
8+
description: "Creates a new user request. [See the documentation](https://support.helpspot.com/index.php?pg=kb.page&id=164#private.request.create)",
89
version: "0.0.1",
910
type: "action",
10-
props: {
11-
helpspot,
12-
note: {
13-
type: "string",
14-
label: "Note",
15-
description: "The note content for the request",
11+
methods: {
12+
getValidation() {
13+
if (!this.sFirstName && !this.sLastName && !this.sUserId && !this.sEmail && !this.sPhone) {
14+
throw new Error("You must provide at least one of the following: First Name, Last Name, User ID, Email, or Phone.");
15+
}
1616
},
17-
firstName: {
18-
propDefinition: [
19-
helpspot,
20-
"firstName",
21-
],
17+
getFunction() {
18+
return this.helpspot.createRequest;
2219
},
23-
lastName: {
24-
propDefinition: [
25-
helpspot,
26-
"lastName",
27-
],
20+
getData() {
21+
return {
22+
tNote: this.tNote,
23+
xCategory: this.xCategory,
24+
fNoteType: this.fNoteType && parseInt(this.fNoteType),
25+
fNoteIsHTML: this.fNoteIsHTML && parseInt(this.fNoteIsHTML),
26+
sTitle: this.sTitle,
27+
xStatus: this.xStatus,
28+
sUserId: this.sUserId,
29+
sFirstName: this.sFirstName,
30+
sLastName: this.sLastName,
31+
sEmail: this.sEmail,
32+
sPhone: this.sPhone,
33+
fUrgent: +this.fUrgent,
34+
fOpenedVia: this.fOpenedVia,
35+
email_from: this.emailFrom,
36+
email_cc: parseObject(this.emailCC)?.join(),
37+
email_bcc: parseObject(this.emailBCC)?.join(),
38+
email_staff: parseObject(this.emailStaff)?.join(),
39+
};
2840
},
29-
userId: {
30-
propDefinition: [
31-
helpspot,
32-
"userId",
33-
],
41+
getSummary(response) {
42+
return `Successfully created request with Id: ${response.xRequest}`;
3443
},
35-
email: {
36-
propDefinition: [
37-
helpspot,
38-
"email",
39-
],
40-
},
41-
phone: {
42-
propDefinition: [
43-
helpspot,
44-
"phone",
45-
],
46-
},
47-
},
48-
async run({ $ }) {
49-
if (!this.firstName && !this.lastName && !this.userId && !this.email && !this.phone) {
50-
throw new Error("You must provide at least one of the following: first name, last name, user ID, email, or phone.");
51-
}
52-
53-
const response = await this.helpspot.createRequest({
54-
note: this.note,
55-
firstName: this.firstName,
56-
lastName: this.lastName,
57-
userId: this.userId,
58-
email: this.email,
59-
phone: this.phone,
60-
});
61-
62-
$.export("$summary", `Successfully created request with access key: ${response.accesskey}`);
63-
return response;
6444
},
6545
};
Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,53 @@
1-
import helpspot from "../../helpspot.app.mjs";
2-
import { axios } from "@pipedream/platform";
1+
import { parseObject } from "../../common/utils.mjs";
2+
import common from "../common/request-base.mjs";
33

44
export default {
5+
...common,
56
key: "helpspot-update-request",
67
name: "Update Request",
7-
description: "Updates an existing user request. [See the documentation](https://support.helpspot.com/index.php?pg=kb.page&id=163)",
8-
version: "0.0.{{ts}}",
8+
description: "Updates an existing user request. [See the documentation](https://support.helpspot.com/index.php?pg=kb.page&id=164#private.request.update)",
9+
version: "0.0.1",
910
type: "action",
1011
props: {
11-
helpspot,
12-
xRequestId: {
12+
...common.props,
13+
xRequest: {
1314
propDefinition: [
14-
helpspot,
15-
"xRequestId",
16-
],
17-
},
18-
note: {
19-
propDefinition: [
20-
helpspot,
21-
"note",
15+
common.props.helpspot,
16+
"xRequest",
2217
],
2318
},
2419
},
25-
async run({ $ }) {
26-
const params = {
27-
xRequestId: this.xRequestId,
28-
note: this.note,
29-
};
30-
const response = await this.helpspot.updateRequest(params);
31-
$.export("$summary", `Successfully updated request with ID ${this.xRequestId}`);
32-
return response;
20+
methods: {
21+
getValidation() {
22+
return true;
23+
},
24+
getFunction() {
25+
return this.helpspot.updateRequest;
26+
},
27+
getData() {
28+
return {
29+
xRequest: this.xRequest,
30+
tNote: this.tNote,
31+
xCategory: this.xCategory,
32+
fNoteType: this.fNoteType && parseInt(this.fNoteType),
33+
fNoteIsHTML: this.fNoteIsHTML && parseInt(this.fNoteIsHTML),
34+
sTitle: this.sTitle,
35+
xStatus: this.xStatus,
36+
sUserId: this.sUserId,
37+
sFirstName: this.sFirstName,
38+
sLastName: this.sLastName,
39+
sEmail: this.sEmail,
40+
sPhone: this.sPhone,
41+
fUrgent: +this.fUrgent,
42+
fOpenedVia: this.fOpenedVia,
43+
email_from: this.emailFrom,
44+
email_cc: parseObject(this.emailCC)?.join(),
45+
email_bcc: parseObject(this.emailBCC)?.join(),
46+
email_staff: parseObject(this.emailStaff)?.join(),
47+
};
48+
},
49+
getSummary() {
50+
return `Successfully updated request with ID ${this.xRequest}`;
51+
},
3352
},
3453
};
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
export const LIMIT = 100;
2+
3+
export const NOTE_TYPE_OPTIONS = [
4+
{
5+
label: "Private",
6+
value: "0",
7+
},
8+
{
9+
label: "Public",
10+
value: "1",
11+
},
12+
{
13+
label: "External",
14+
value: "2",
15+
},
16+
];
17+
18+
export const NOTE_IS_HTML = [
19+
{
20+
label: "Text",
21+
value: "0",
22+
},
23+
{
24+
label: "HTML",
25+
value: "1",
26+
},
27+
];
28+
29+
export const OPENED_VIA_OPTIONS = [
30+
{
31+
label: "Email",
32+
value: 1,
33+
},
34+
{
35+
label: "Phone",
36+
value: 2,
37+
},
38+
{
39+
label: "Walk In",
40+
value: 3,
41+
},
42+
{
43+
label: "Mail",
44+
value: 4,
45+
},
46+
{
47+
label: "Other",
48+
value: 5,
49+
},
50+
{
51+
label: "Web Service",
52+
value: 6,
53+
},
54+
{
55+
label: "Web Form",
56+
value: 7,
57+
},
58+
{
59+
label: "Forum",
60+
value: 8,
61+
},
62+
{
63+
label: "Instant Messenger",
64+
value: 9,
65+
},
66+
{
67+
label: "Fax",
68+
value: 10,
69+
},
70+
{
71+
label: "Voicemail",
72+
value: 11,
73+
},
74+
{
75+
label: "Staff Initiated",
76+
value: 12,
77+
},
78+
{
79+
label: "Tab Widget",
80+
value: 13,
81+
},
82+
];

0 commit comments

Comments
 (0)