Skip to content

Commit 44485d1

Browse files
committed
wip
1 parent 55fbfd7 commit 44485d1

File tree

9 files changed

+292
-123
lines changed

9 files changed

+292
-123
lines changed
Lines changed: 47 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,84 @@
11
import charthop from "../../charthop.app.mjs";
2-
import { axios } from "@pipedream/platform";
32

43
export default {
54
key: "charthop-create-employee",
65
name: "Create Employee",
7-
description: "Adds a new employee to the system. [See the documentation](https://docs.charthop.com)",
6+
description: "Adds a new employee to the system. [See the documentation](https://api.charthop.com/swagger#/user/createUser)",
87
version: "0.0.{{ts}}",
98
type: "action",
109
props: {
11-
charthop: {
12-
type: "app",
13-
app: "charthop",
10+
charthop,
11+
orgId: {
12+
propDefinition: [
13+
charthop,
14+
"orgId",
15+
],
16+
},
17+
firstName: {
18+
propDefinition: [
19+
charthop,
20+
"firstName",
21+
],
1422
},
15-
addEmployeeName: {
23+
middleName: {
1624
propDefinition: [
1725
charthop,
18-
"addEmployeeName",
26+
"middleName",
1927
],
2028
},
21-
addEmployeeEmail: {
29+
lastName: {
2230
propDefinition: [
2331
charthop,
24-
"addEmployeeEmail",
32+
"lastName",
2533
],
2634
},
27-
addEmployeeRole: {
35+
preferredFirstName: {
2836
propDefinition: [
2937
charthop,
30-
"addEmployeeRole",
38+
"preferredFirstName",
3139
],
3240
},
33-
addEmployeeStartDate: {
41+
preferredLastName: {
3442
propDefinition: [
3543
charthop,
36-
"addEmployeeStartDate",
44+
"preferredLastName",
3745
],
3846
},
39-
addEmployeeDepartment: {
47+
email: {
4048
propDefinition: [
4149
charthop,
42-
"addEmployeeDepartment",
50+
"email",
4351
],
4452
},
45-
addEmployeeCustomFields: {
53+
status: {
4654
propDefinition: [
4755
charthop,
48-
"addEmployeeCustomFields",
56+
"status",
4957
],
5058
},
5159
},
5260
async run({ $ }) {
53-
const employee = await this.charthop.addEmployee();
54-
$.export("$summary", `Created employee ${this.addEmployeeName}`);
55-
return employee;
61+
const response = await this.charthop.createUser({
62+
$,
63+
data: {
64+
orgs: [
65+
{
66+
orgId: this.orgId,
67+
access: "MEMBER",
68+
roleId: await this.charthop.getEmployeeRoleId($),
69+
},
70+
],
71+
name: {
72+
first: this.firstName,
73+
middle: this.middleName,
74+
last: this.lastName,
75+
pref: this.preferredFirstName,
76+
prefLast: this.preferredLastName,
77+
},
78+
email: this.email,
79+
},
80+
});
81+
$.export("$summary", `Successfully created employee with ID: ${response.id}`);
82+
return response;
5683
},
5784
};

components/charthop/actions/record-compensation-change/record-compensation-change.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import charthop from "../../charthop.app.mjs";
2-
import { axios } from "@pipedream/platform";
32

43
export default {
54
key: "charthop-record-compensation-change",
Lines changed: 69 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,96 @@
11
import charthop from "../../charthop.app.mjs";
2-
import { axios } from "@pipedream/platform";
32

43
export default {
54
key: "charthop-update-employee-details",
65
name: "Update Employee Details",
7-
description: "Updates an existing employee's profile, including department, role, or compensation. [See the documentation](https://docs.charthop.com)",
6+
description: "Updates an existing employee's details. [See the documentation](https://api.charthop.com/swagger#/user/updateUser)",
87
version: "0.0.{{ts}}",
98
type: "action",
109
props: {
1110
charthop,
12-
updateEmployeeId: {
11+
orgId: {
1312
propDefinition: [
1413
charthop,
15-
"updateEmployeeId",
14+
"orgId",
1615
],
1716
},
18-
updateFields: {
17+
employeeId: {
1918
propDefinition: [
2019
charthop,
21-
"updateFields",
20+
"employeeId",
21+
(c) => ({
22+
orgId: c.orgId,
23+
}),
2224
],
2325
},
24-
updateMetadata: {
26+
firstName: {
2527
propDefinition: [
2628
charthop,
27-
"updateMetadata",
29+
"firstName",
2830
],
2931
optional: true,
3032
},
33+
middleName: {
34+
propDefinition: [
35+
charthop,
36+
"middleName",
37+
],
38+
},
39+
lastName: {
40+
propDefinition: [
41+
charthop,
42+
"lastName",
43+
],
44+
optional: true,
45+
},
46+
preferredFirstName: {
47+
propDefinition: [
48+
charthop,
49+
"preferredFirstName",
50+
],
51+
},
52+
preferredLastName: {
53+
propDefinition: [
54+
charthop,
55+
"preferredLastName",
56+
],
57+
},
58+
email: {
59+
propDefinition: [
60+
charthop,
61+
"email",
62+
],
63+
optional: true,
64+
},
65+
status: {
66+
propDefinition: [
67+
charthop,
68+
"status",
69+
],
70+
},
3171
},
3272
async run({ $ }) {
33-
const response = await this.charthop.updateEmployeeProfile();
34-
$.export("$summary", `Successfully updated employee with ID ${this.updateEmployeeId}`);
73+
const {
74+
name, email,
75+
} = await this.charthop.getUser({
76+
$,
77+
userId: this.employeeId,
78+
});
79+
const response = await this.charthop.updateUser({
80+
$,
81+
userId: this.employeeId,
82+
data: {
83+
name: {
84+
first: this.firstName || name.first,
85+
middle: this.middleName || name.middle,
86+
last: this.lastName || name.last,
87+
pref: this.preferredFirstName || name.pref,
88+
prefLast: this.preferredLastName || name.prefLast,
89+
},
90+
email: this.email || email,
91+
},
92+
});
93+
$.export("$summary", `Successfully updated employee with ID ${this.employeeId}`);
3594
return response;
3695
},
3796
};

0 commit comments

Comments
 (0)