Skip to content

Commit d78ca47

Browse files
authored
New Components - breathe (#15075)
* breathe init * new components * pnpm-lock.yaml * updates * pnpm-lock.yaml * pnpm-lock.yaml * fix typo * allow selecting multiple employees * updates
1 parent 883a06b commit d78ca47

File tree

10 files changed

+684
-7
lines changed

10 files changed

+684
-7
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import breathe from "../../breathe.app.mjs";
2+
import { ConfigurationError } from "@pipedream/platform";
3+
4+
export default {
5+
key: "breathe-approve-or-reject-leave-request",
6+
name: "Approve or Reject Leave Request",
7+
description: "Approve or reject an employee leave request in Breathe. [See the documentation](https://developer.breathehr.com/examples#!/leave_requests)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
breathe,
12+
employeeId: {
13+
propDefinition: [
14+
breathe,
15+
"employeeId",
16+
],
17+
},
18+
leaveRequestId: {
19+
propDefinition: [
20+
breathe,
21+
"leaveRequestId",
22+
(c) => ({
23+
employeeId: c.employeeId,
24+
}),
25+
],
26+
},
27+
approveOrReject: {
28+
type: "string",
29+
label: "Approve or Reject?",
30+
description: "Whether to approve or reject the leave request",
31+
options: [
32+
"approve",
33+
"reject",
34+
],
35+
},
36+
rejectionReason: {
37+
type: "string",
38+
label: "Rejection Reason",
39+
description: "The reason for rejecting the leave request",
40+
optional: true,
41+
},
42+
},
43+
async run({ $ }) {
44+
if (this.approveOrReject === "reject" && !this.rejectionReason) {
45+
throw new ConfigurationError("Rejection Reason is required if rejecting the leave request");
46+
}
47+
48+
let response;
49+
if (this.approveOrReject === "reject") {
50+
response = await this.breathe.rejectLeaveRequest({
51+
$,
52+
leaveRequestId: this.leaveRequestId,
53+
data: {
54+
leave_request: {
55+
rejection_reason: this.rejectionReason,
56+
},
57+
},
58+
});
59+
}
60+
else {
61+
response = await this.breathe.approveLeaveRequest({
62+
$,
63+
leaveRequestId: this.leaveRequestId,
64+
});
65+
}
66+
67+
$.export("$summary", `Successfully ${this.approveOrReject === "reject"
68+
? "rejected"
69+
: "approved"} leave request with ID: ${this.leaveRequestId}`);
70+
return response;
71+
},
72+
};
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
import breathe from "../../breathe.app.mjs";
2+
3+
export default {
4+
key: "breathe-create-employee",
5+
name: "Create Employee",
6+
description: "Creates a new employee in Breathe. [See the documentation](https://developer.breathehr.com/examples#!/employees/POST_version_employees_json)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
breathe,
11+
firstName: {
12+
type: "string",
13+
label: "First Name",
14+
description: "First name of the employee",
15+
},
16+
lastName: {
17+
type: "string",
18+
label: "Last Name",
19+
description: "Last name of the employee",
20+
},
21+
email: {
22+
type: "string",
23+
label: "Email",
24+
description: "Email address of the employee",
25+
},
26+
companyJoinDate: {
27+
type: "string",
28+
label: "Company Join Date",
29+
description: "The date that the employee joined the company. Example: `2023-12-25`",
30+
},
31+
dob: {
32+
type: "string",
33+
label: "Date of Birth",
34+
description: "The date of birth of the employee",
35+
optional: true,
36+
},
37+
jobTitle: {
38+
type: "string",
39+
label: "Job Title",
40+
description: "The job title of the employee",
41+
optional: true,
42+
},
43+
departmentId: {
44+
propDefinition: [
45+
breathe,
46+
"departmentId",
47+
],
48+
},
49+
divisionId: {
50+
propDefinition: [
51+
breathe,
52+
"divisionId",
53+
],
54+
},
55+
locationId: {
56+
propDefinition: [
57+
breathe,
58+
"locationId",
59+
],
60+
},
61+
workingPatternId: {
62+
propDefinition: [
63+
breathe,
64+
"workingPatternId",
65+
],
66+
},
67+
holidayAllowanceId: {
68+
propDefinition: [
69+
breathe,
70+
"holidayAllowanceId",
71+
],
72+
},
73+
workMobile: {
74+
type: "string",
75+
label: "Work Mobile",
76+
description: "The work moblie phone number of the employee",
77+
optional: true,
78+
},
79+
personalMobile: {
80+
type: "string",
81+
label: "Personal Mobile",
82+
description: "The personal mobile phone number of the employee",
83+
optional: true,
84+
},
85+
homeTelephone: {
86+
type: "string",
87+
label: "Home Telephone",
88+
description: "The home telephone number of the employee",
89+
optional: true,
90+
},
91+
},
92+
async run({ $ }) {
93+
const response = await this.breathe.createEmployee({
94+
$,
95+
data: {
96+
employee: {
97+
person_type: "Employee",
98+
first_name: this.firstName,
99+
last_name: this.lastName,
100+
email: this.email,
101+
company_join_date: this.companyJoinDate,
102+
dob: this.dob,
103+
job_title: this.jobTitle,
104+
work_mobile: this.workMobile,
105+
personal_mobile: this.personalMobile,
106+
home_telephone: this.homeTelephone,
107+
department: this.departmentId,
108+
division: this.divisionId,
109+
location: this.locationId,
110+
working_pattern: this.workingPatternId,
111+
holiday_allowance: this.holidayAllowanceId,
112+
},
113+
},
114+
});
115+
$.export("$summary", `Successfully created employee with ID: ${response.employees[0].id}`);
116+
return response;
117+
},
118+
};
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import breathe from "../../breathe.app.mjs";
2+
3+
export default {
4+
key: "breathe-create-leave-request",
5+
name: "Create Leave Request",
6+
description: "Creates a new leave request for an employee in Breathe. [See the documentation](https://developer.breathehr.com/examples#!/employees/POST_version_employees_id_leave_requests_json)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
breathe,
11+
employeeId: {
12+
propDefinition: [
13+
breathe,
14+
"employeeId",
15+
],
16+
},
17+
startDate: {
18+
type: "string",
19+
label: "Start Date",
20+
description: "The start date of the leave request. Example: `2023-12-25`",
21+
},
22+
endDate: {
23+
type: "string",
24+
label: "End Date",
25+
description: "The end date of the leave request. Example: `2023-12-27`",
26+
},
27+
halfStart: {
28+
type: "boolean",
29+
label: "Half Start",
30+
description: "Set to `true` if requesting a half-day",
31+
default: false,
32+
optional: true,
33+
},
34+
notes: {
35+
type: "string",
36+
label: "Notes",
37+
description: "Notes about the leave request",
38+
optional: true,
39+
},
40+
},
41+
async run({ $ }) {
42+
const response = await this.breathe.createLeaveRequest({
43+
$,
44+
employeeId: this.employeeId,
45+
data: {
46+
leave_request: {
47+
start_date: this.startDate,
48+
end_date: this.endDate,
49+
half_start: this.halfStart,
50+
notes: this.notes,
51+
},
52+
},
53+
});
54+
$.export("$summary", `Successfully created leave for employee with ID: ${this.employeeId}`);
55+
return response;
56+
},
57+
};

0 commit comments

Comments
 (0)