Skip to content

Commit 75f1423

Browse files
committed
kiwihr init
1 parent 12db647 commit 75f1423

File tree

7 files changed

+708
-4
lines changed

7 files changed

+708
-4
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import kiwihr from "../../kiwihr.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "kiwihr-approve-leave-request",
6+
name: "Approve Leave Request",
7+
description: "Approve a pending leave request for an employee. [See the documentation](https://api.kiwihr.it/api/docs/mutation.doc.html)",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
kiwihr,
12+
leaveRequestId: {
13+
propDefinition: [
14+
kiwihr,
15+
"leaveRequestId",
16+
],
17+
},
18+
approvalDate: {
19+
propDefinition: [
20+
kiwihr,
21+
"approvalDate",
22+
],
23+
optional: true,
24+
},
25+
message: {
26+
propDefinition: [
27+
kiwihr,
28+
"message",
29+
],
30+
optional: true,
31+
},
32+
},
33+
async run({ $ }) {
34+
try {
35+
const response = await this.kiwihr.approveLeaveRequest({
36+
leaveRequestId: this.leaveRequestId,
37+
approvalDate: this.approvalDate,
38+
message: this.message,
39+
});
40+
41+
$.export("$summary", `Successfully approved leave request with ID ${this.leaveRequestId}`);
42+
return response;
43+
} catch (error) {
44+
throw new Error(`Failed to approve leave request: ${error.message}`);
45+
}
46+
},
47+
};
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import kiwihr from "../../kiwihr.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "kiwihr-create-employee",
6+
name: "Create Employee",
7+
description: "Add a new employee to kiwiHR. [See the documentation](https://api.kiwihr.com/api/docs/mutation.doc.html)",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
kiwihr,
12+
employeeName: {
13+
type: "string",
14+
label: "Employee Name",
15+
description: "Name of the employee to add.",
16+
},
17+
email: {
18+
type: "string",
19+
label: "Email",
20+
description: "Email of the employee to add.",
21+
},
22+
startDate: {
23+
type: "string",
24+
label: "Start Date",
25+
description: "Start date of the employee to add. Format: YYYY-MM-DD",
26+
},
27+
department: {
28+
propDefinition: [
29+
kiwihr,
30+
"department",
31+
],
32+
optional: true,
33+
},
34+
jobTitle: {
35+
type: "string",
36+
label: "Job Title",
37+
description: "Job title of the employee. Optional.",
38+
optional: true,
39+
},
40+
location: {
41+
propDefinition: [
42+
kiwihr,
43+
"location",
44+
],
45+
optional: true,
46+
},
47+
},
48+
async run({ $ }) {
49+
const data = {
50+
employeeName: this.employeeName,
51+
email: this.email,
52+
startDate: this.startDate,
53+
department: this.department,
54+
jobTitle: this.jobTitle,
55+
location: this.location,
56+
};
57+
58+
const response = await this.kiwihr.createEmployee(data);
59+
60+
$.export("$summary", `Successfully created employee ${this.employeeName}`);
61+
return response;
62+
},
63+
};
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import kiwihr from "../../kiwihr.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "kiwihr-update-employee-record",
6+
name: "Update Employee Record",
7+
description: "Update an existing employee's record in kiwiHR. [See the documentation](https://api.kiwihr.it/api/docs/mutation.doc.html)",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
kiwihr,
12+
employeeId: {
13+
propDefinition: [
14+
kiwihr,
15+
"employeeId",
16+
],
17+
},
18+
jobTitle: {
19+
propDefinition: [
20+
kiwihr,
21+
"jobTitle",
22+
],
23+
optional: true,
24+
},
25+
department: {
26+
propDefinition: [
27+
kiwihr,
28+
"department",
29+
],
30+
optional: true,
31+
},
32+
supervisor: {
33+
propDefinition: [
34+
kiwihr,
35+
"supervisor",
36+
],
37+
optional: true,
38+
},
39+
},
40+
async run({ $ }) {
41+
const data = {
42+
...(this.jobTitle && {
43+
positionId: this.jobTitle,
44+
}),
45+
...(this.department && {
46+
teamId: this.department,
47+
}),
48+
...(this.supervisor && {
49+
managerId: this.supervisor,
50+
}),
51+
};
52+
53+
const response = await this.kiwihr.updateEmployee({
54+
employeeId: this.employeeId,
55+
...data,
56+
});
57+
58+
$.export("$summary", `Successfully updated employee record for ID: ${this.employeeId}`);
59+
return response;
60+
},
61+
};

0 commit comments

Comments
 (0)