Skip to content

Commit 5e31294

Browse files
committed
create-employee updates
1 parent a5c5ea0 commit 5e31294

File tree

2 files changed

+107
-23
lines changed

2 files changed

+107
-23
lines changed

components/hr_cloud/actions/create-employee/create-employee.mjs

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import hrCloud from "../../hr_cloud.app.mjs";
33
export default {
44
key: "hr_cloud-create-employee",
55
name: "Create Employee",
6-
description: "Create a new employee record in the system. [See the documentation](https://help.hrcloud.com/api/#/introduction#top)",
6+
description: "Create a new employee record in the system. [See the documentation](https://help.hrcloud.com/api/#/employee#POST_employee)",
77
version: "0.0.1",
88
type: "action",
99
props: {
@@ -44,17 +44,45 @@ export default {
4444
"startDate",
4545
],
4646
},
47+
employeeNumber: {
48+
propDefinition: [
49+
hrCloud,
50+
"employeeNumber",
51+
],
52+
},
53+
locationId: {
54+
propDefinition: [
55+
hrCloud,
56+
"locationId",
57+
],
58+
},
59+
employmentStatus: {
60+
propDefinition: [
61+
hrCloud,
62+
"employmentStatusId",
63+
],
64+
},
65+
recordStatus: {
66+
propDefinition: [
67+
hrCloud,
68+
"recordStatus",
69+
],
70+
},
4771
},
4872
async run({ $ }) {
4973
const response = await this.hrCloud.createEmployee({
5074
$,
5175
data: {
52-
first_name: this.firstName,
53-
last_name: this.lastName,
54-
email: this.email,
55-
job_title_id: this.jobTitle,
56-
department_id: this.departmentId,
57-
start_date: this.startDate,
76+
xFirstName: this.firstName,
77+
xLastName: this.lastName,
78+
xEmail: this.email,
79+
xFullName: `${this.firstName} ${this.lastName}`,
80+
xPositionLookup: this.jobTitle,
81+
xDepartmentLookup: this.departmentId,
82+
xStartDate: this.startDate,
83+
xRecordStatus: this.recordStatus,
84+
xEmploymentStatusLookup: this.employmentStatus,
85+
xLocationLookup: this.locationId,
5886
},
5987
});
6088

components/hr_cloud/hr_cloud.app.mjs

Lines changed: 72 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,18 @@ export default {
77
departmentId: {
88
type: "string",
99
label: "Department",
10-
description: "The department to filter by",
10+
description: "The employee department",
1111
async options({ page }) {
1212
const departments = await this.getDepartments({
1313
params: {
1414
page: page + 1,
1515
},
16-
});
16+
}); console.log(departments);
1717
return departments.map((department) => ({
18-
label: department.name,
19-
value: department.id,
18+
label: department.xDepartmentName,
19+
value: department.Id,
2020
}));
2121
},
22-
optional: true,
2322
},
2423
jobTitle: {
2524
type: "string",
@@ -32,11 +31,10 @@ export default {
3231
},
3332
});
3433
return jobTitles.map((jobTitle) => ({
35-
label: jobTitle.name,
36-
value: jobTitle.id,
34+
label: jobTitle.xPositionTitle,
35+
value: jobTitle.Id,
3736
}));
3837
},
39-
optional: true,
4038
},
4139
leaveType: {
4240
type: "string",
@@ -101,6 +99,38 @@ export default {
10199
}));
102100
},
103101
},
102+
locationId: {
103+
type: "string",
104+
label: "Location ID",
105+
description: "The ID of a location",
106+
async options({ page }) {
107+
const locations = await this.getLocations({
108+
params: {
109+
page: page + 1,
110+
},
111+
});
112+
return locations.map((location) => ({
113+
label: location.xLocationName,
114+
value: location.Id,
115+
}));
116+
},
117+
},
118+
employmentStatusId: {
119+
type: "string",
120+
label: "Employment Status ID",
121+
description: "The ID of an employment status",
122+
async options({ page }) {
123+
const statuses = await this.getEmploymentStatus({
124+
params: {
125+
page: page + 1,
126+
},
127+
});
128+
return statuses.map((status) => ({
129+
label: status.xType,
130+
value: status.Id,
131+
}));
132+
},
133+
},
104134
hours: {
105135
type: "integer",
106136
label: "Hours Worked",
@@ -136,6 +166,21 @@ export default {
136166
type: "string",
137167
label: "Start Date",
138168
description: "The employee's start date (YYYY-MM-DD)",
169+
},
170+
employeeNumber: {
171+
type: "string",
172+
label: "Employee Number",
173+
description: "Unique employee number",
174+
},
175+
recordStatus: {
176+
type: "string",
177+
label: "Record Status",
178+
description: "The employee status",
179+
options: [
180+
"Active",
181+
"Inactive",
182+
],
183+
default: "Active",
139184
optional: true,
140185
},
141186
approvalNote: {
@@ -151,7 +196,8 @@ export default {
151196
},
152197
_authHeaders() {
153198
return {
154-
"Authorization": `Bearer ${this.$auth.api_key}`,
199+
"customer_key": `${this.$auth.consumer_key}`,
200+
"customer_secret": `${this.$auth.consumer_secret}`,
155201
"Content-Type": "application/json",
156202
};
157203
},
@@ -218,23 +264,21 @@ export default {
218264
async createEmployee(args = {}) {
219265
return this._makeRequest({
220266
method: "POST",
221-
path: "/employees",
267+
path: "/xEmployee",
222268
...args,
223269
});
224270
},
225271
async getDepartments(args = {}) {
226-
const response = await this._makeRequest({
227-
path: "/departments",
272+
return this._makeRequest({
273+
path: "/xDepartment",
228274
...args,
229275
});
230-
return response.departments || [];
231276
},
232277
async getJobTitles(args = {}) {
233-
const response = await this._makeRequest({
234-
path: "/job-titles",
278+
return this._makeRequest({
279+
path: "/xPosition",
235280
...args,
236281
});
237-
return response.job_titles || [];
238282
},
239283
async getLeaveRequests(args = {}) {
240284
const response = await this._makeRequest({
@@ -250,6 +294,18 @@ export default {
250294
});
251295
return response.leave_types || [];
252296
},
297+
async getLocations(args = {}) {
298+
return this._makeRequest({
299+
path: "/xLocation",
300+
...args,
301+
});
302+
},
303+
async getEmploymentStatus(args = {}) {
304+
return this._makeRequest({
305+
path: "/xEmploymentStatus",
306+
...args,
307+
});
308+
},
253309
async approveLeaveRequest(requestId, args = {}) {
254310
return this._makeRequest({
255311
method: "PUT",

0 commit comments

Comments
 (0)