Skip to content

Commit 9856c12

Browse files
committed
[Components] kiwihr #15318
Sources - New Employee Actions - Create Employee - Update Employee Record
1 parent 75f1423 commit 9856c12

File tree

15 files changed

+816
-584
lines changed

15 files changed

+816
-584
lines changed

components/kiwihr/actions/approve-leave-request/approve-leave-request.mjs

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 161 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,192 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import { parseError } from "../../common/utils.mjs";
13
import kiwihr from "../../kiwihr.app.mjs";
2-
import { axios } from "@pipedream/platform";
34

45
export default {
56
key: "kiwihr-create-employee",
67
name: "Create Employee",
78
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+
version: "0.0.1",
910
type: "action",
1011
props: {
1112
kiwihr,
12-
employeeName: {
13-
type: "string",
14-
label: "Employee Name",
15-
description: "Name of the employee to add.",
13+
firstName: {
14+
propDefinition: [
15+
kiwihr,
16+
"firstName",
17+
],
18+
},
19+
lastName: {
20+
propDefinition: [
21+
kiwihr,
22+
"lastName",
23+
],
1624
},
1725
email: {
18-
type: "string",
19-
label: "Email",
20-
description: "Email of the employee to add.",
26+
propDefinition: [
27+
kiwihr,
28+
"email",
29+
],
30+
},
31+
workPhones: {
32+
propDefinition: [
33+
kiwihr,
34+
"workPhones",
35+
],
36+
optional: true,
37+
},
38+
employmentStartDate: {
39+
propDefinition: [
40+
kiwihr,
41+
"employmentStartDate",
42+
],
43+
optional: true,
44+
},
45+
aboutMe: {
46+
propDefinition: [
47+
kiwihr,
48+
"aboutMe",
49+
],
50+
optional: true,
51+
},
52+
gender: {
53+
propDefinition: [
54+
kiwihr,
55+
"gender",
56+
],
57+
optional: true,
58+
},
59+
managerId: {
60+
propDefinition: [
61+
kiwihr,
62+
"managerId",
63+
],
64+
optional: true,
65+
},
66+
nationality: {
67+
propDefinition: [
68+
kiwihr,
69+
"nationality",
70+
],
71+
optional: true,
72+
},
73+
teamIds: {
74+
propDefinition: [
75+
kiwihr,
76+
"teamIds",
77+
],
78+
optional: true,
2179
},
22-
startDate: {
23-
type: "string",
24-
label: "Start Date",
25-
description: "Start date of the employee to add. Format: YYYY-MM-DD",
80+
positionId: {
81+
propDefinition: [
82+
kiwihr,
83+
"positionId",
84+
],
85+
optional: true,
86+
},
87+
locationId: {
88+
propDefinition: [
89+
kiwihr,
90+
"locationId",
91+
],
92+
optional: true,
2693
},
27-
department: {
94+
birthDate: {
2895
propDefinition: [
2996
kiwihr,
30-
"department",
97+
"birthDate",
3198
],
3299
optional: true,
33100
},
34-
jobTitle: {
35-
type: "string",
36-
label: "Job Title",
37-
description: "Job title of the employee. Optional.",
101+
personalPhone: {
102+
propDefinition: [
103+
kiwihr,
104+
"personalPhone",
105+
],
38106
optional: true,
39107
},
40-
location: {
108+
personalEmail: {
41109
propDefinition: [
42110
kiwihr,
43-
"location",
111+
"personalEmail",
112+
],
113+
optional: true,
114+
},
115+
addressStreet: {
116+
propDefinition: [
117+
kiwihr,
118+
"addressStreet",
119+
],
120+
optional: true,
121+
},
122+
addressCity: {
123+
propDefinition: [
124+
kiwihr,
125+
"addressCity",
126+
],
127+
optional: true,
128+
},
129+
addressState: {
130+
propDefinition: [
131+
kiwihr,
132+
"addressState",
133+
],
134+
optional: true,
135+
},
136+
addressPostalCode: {
137+
propDefinition: [
138+
kiwihr,
139+
"addressPostalCode",
140+
],
141+
optional: true,
142+
},
143+
addressCountry: {
144+
propDefinition: [
145+
kiwihr,
146+
"addressCountry",
147+
],
148+
optional: true,
149+
},
150+
pronouns: {
151+
propDefinition: [
152+
kiwihr,
153+
"pronouns",
44154
],
45155
optional: true,
46156
},
47157
},
48158
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-
};
159+
try {
160+
const {
161+
kiwihr,
162+
addressStreet,
163+
addressCity,
164+
addressState,
165+
addressPostalCode,
166+
addressCountry,
167+
...user
168+
} = this;
169+
170+
const address = {};
171+
if (addressStreet) address.street = addressStreet;
172+
if (addressCity) address.city = addressCity;
173+
if (addressState) address.state = addressState;
174+
if (addressPostalCode) address.postalCode = addressPostalCode;
175+
if (addressCountry) address.country = addressCountry;
176+
177+
if (Object.keys(address)) {
178+
user.address = address;
179+
}
57180

58-
const response = await this.kiwihr.createEmployee(data);
181+
const response = await kiwihr.createEmployee({
182+
user,
183+
});
59184

60-
$.export("$summary", `Successfully created employee ${this.employeeName}`);
61-
return response;
185+
$.export("$summary", `Successfully created employee ${this.firstName} ${this.lastName}`);
186+
return response;
187+
} catch ({ response }) {
188+
const error = parseError(response);
189+
throw new ConfigurationError(error);
190+
}
62191
},
63192
};

0 commit comments

Comments
 (0)