Skip to content

Commit 55fbfd7

Browse files
committed
charthop init
1 parent 4546757 commit 55fbfd7

File tree

8 files changed

+719
-3
lines changed

8 files changed

+719
-3
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import charthop from "../../charthop.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "charthop-create-employee",
6+
name: "Create Employee",
7+
description: "Adds a new employee to the system. [See the documentation](https://docs.charthop.com)",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
charthop: {
12+
type: "app",
13+
app: "charthop",
14+
},
15+
addEmployeeName: {
16+
propDefinition: [
17+
charthop,
18+
"addEmployeeName",
19+
],
20+
},
21+
addEmployeeEmail: {
22+
propDefinition: [
23+
charthop,
24+
"addEmployeeEmail",
25+
],
26+
},
27+
addEmployeeRole: {
28+
propDefinition: [
29+
charthop,
30+
"addEmployeeRole",
31+
],
32+
},
33+
addEmployeeStartDate: {
34+
propDefinition: [
35+
charthop,
36+
"addEmployeeStartDate",
37+
],
38+
},
39+
addEmployeeDepartment: {
40+
propDefinition: [
41+
charthop,
42+
"addEmployeeDepartment",
43+
],
44+
},
45+
addEmployeeCustomFields: {
46+
propDefinition: [
47+
charthop,
48+
"addEmployeeCustomFields",
49+
],
50+
},
51+
},
52+
async run({ $ }) {
53+
const employee = await this.charthop.addEmployee();
54+
$.export("$summary", `Created employee ${this.addEmployeeName}`);
55+
return employee;
56+
},
57+
};
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import charthop from "../../charthop.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "charthop-record-compensation-change",
6+
name: "Record Compensation Change",
7+
description: "Logs or modifies an employee's compensation records, such as salary increases, bonuses, or equity grants. [See the documentation]()",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
charthop,
12+
employeeId: {
13+
propDefinition: [
14+
charthop,
15+
"modifyCompensationEmployeeId",
16+
],
17+
},
18+
compensationDetails: {
19+
propDefinition: [
20+
charthop,
21+
"modifyCompensationDetails",
22+
],
23+
},
24+
effectiveDate: {
25+
propDefinition: [
26+
charthop,
27+
"modifyCompensationEffectiveDate",
28+
],
29+
optional: true,
30+
},
31+
reason: {
32+
propDefinition: [
33+
charthop,
34+
"modifyCompensationReason",
35+
],
36+
optional: true,
37+
},
38+
},
39+
async run({ $ }) {
40+
const response = await this.charthop.modifyCompensation();
41+
const summaryParts = [
42+
`Compensation for employee ID ${this.employeeId} has been updated`,
43+
];
44+
if (this.reason) {
45+
summaryParts.push(`for reason: ${this.reason}`);
46+
}
47+
$.export("$summary", summaryParts.join(" ") + ".");
48+
return response;
49+
},
50+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import charthop from "../../charthop.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "charthop-update-employee-details",
6+
name: "Update Employee Details",
7+
description: "Updates an existing employee's profile, including department, role, or compensation. [See the documentation](https://docs.charthop.com)",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
charthop,
12+
updateEmployeeId: {
13+
propDefinition: [
14+
charthop,
15+
"updateEmployeeId",
16+
],
17+
},
18+
updateFields: {
19+
propDefinition: [
20+
charthop,
21+
"updateFields",
22+
],
23+
},
24+
updateMetadata: {
25+
propDefinition: [
26+
charthop,
27+
"updateMetadata",
28+
],
29+
optional: true,
30+
},
31+
},
32+
async run({ $ }) {
33+
const response = await this.charthop.updateEmployeeProfile();
34+
$.export("$summary", `Successfully updated employee with ID ${this.updateEmployeeId}`);
35+
return response;
36+
},
37+
};
Lines changed: 228 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,237 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "charthop",
4-
propDefinitions: {},
6+
version: "0.0.{{ts}}",
7+
propDefinitions: {
8+
// Event Filters for New Employee Added
9+
newEmployeeDepartmentFilter: {
10+
type: "string",
11+
label: "Department Filter",
12+
description: "Optional department filter for new employee events.",
13+
optional: true,
14+
},
15+
newEmployeeRoleFilter: {
16+
type: "string",
17+
label: "Role Filter",
18+
description: "Optional role filter for new employee events.",
19+
optional: true,
20+
},
21+
// Event Filters for Compensation Details Updated
22+
compensationDepartmentFilter: {
23+
type: "string",
24+
label: "Department Filter",
25+
description: "Optional department filter for compensation update events.",
26+
optional: true,
27+
},
28+
compensationEmployeeIdFilter: {
29+
type: "string",
30+
label: "Employee ID Filter",
31+
description: "Optional employee ID filter for compensation update events.",
32+
optional: true,
33+
},
34+
// Event Filters for Organizational Structure Changes
35+
orgStructureTeamFilter: {
36+
type: "string",
37+
label: "Team Filter",
38+
description: "Optional team filter for organizational structure change events.",
39+
optional: true,
40+
},
41+
orgStructureDivisionFilter: {
42+
type: "string",
43+
label: "Division Filter",
44+
description: "Optional division filter for organizational structure change events.",
45+
optional: true,
46+
},
47+
48+
// Action: Add New Employee
49+
addEmployeeName: {
50+
type: "string",
51+
label: "Employee Name",
52+
description: "Name of the new employee.",
53+
},
54+
addEmployeeEmail: {
55+
type: "string",
56+
label: "Employee Email",
57+
description: "Email address of the new employee.",
58+
},
59+
addEmployeeRole: {
60+
type: "string",
61+
label: "Employee Role",
62+
description: "Role of the new employee.",
63+
},
64+
addEmployeeStartDate: {
65+
type: "string",
66+
label: "Start Date",
67+
description: "Optional start date for the new employee.",
68+
optional: true,
69+
},
70+
addEmployeeDepartment: {
71+
type: "string",
72+
label: "Department",
73+
description: "Optional department for the new employee.",
74+
optional: true,
75+
},
76+
addEmployeeCustomFields: {
77+
type: "string[]",
78+
label: "Custom Fields",
79+
description: "Optional custom fields for the new employee. Provide as JSON strings.",
80+
optional: true,
81+
},
82+
83+
// Action: Update Employee Profile
84+
updateEmployeeId: {
85+
type: "string",
86+
label: "Employee ID",
87+
description: "ID of the employee to update.",
88+
},
89+
updateFields: {
90+
type: "string[]",
91+
label: "Fields to Update",
92+
description: "Fields to update in the employee profile. Provide as JSON strings.",
93+
},
94+
updateMetadata: {
95+
type: "string",
96+
label: "Metadata",
97+
description: "Optional metadata for the employee update. Provide as a JSON string.",
98+
optional: true,
99+
},
100+
101+
// Action: Modify Compensation Records
102+
modifyCompensationEmployeeId: {
103+
type: "string",
104+
label: "Employee ID",
105+
description: "ID of the employee for compensation update.",
106+
},
107+
modifyCompensationDetails: {
108+
type: "string",
109+
label: "Compensation Details",
110+
description: "Details of the compensation update. Provide as a JSON string.",
111+
},
112+
modifyCompensationEffectiveDate: {
113+
type: "string",
114+
label: "Effective Date",
115+
description: "Optional effective date for the compensation update.",
116+
optional: true,
117+
},
118+
modifyCompensationReason: {
119+
type: "string",
120+
label: "Reason for Change",
121+
description: "Optional reason for the compensation update.",
122+
optional: true,
123+
},
124+
},
5125
methods: {
6-
// this.$auth contains connected account data
126+
// Existing method
7127
authKeys() {
8128
console.log(Object.keys(this.$auth));
9129
},
130+
131+
_baseUrl() {
132+
return "https://api.charthop.com";
133+
},
134+
async _makeRequest(opts = {}) {
135+
const {
136+
$ = this, method = "GET", path = "/", headers, ...otherOpts
137+
} = opts;
138+
return axios($, {
139+
...otherOpts,
140+
method,
141+
url: `${this._baseUrl()}${path}`,
142+
headers: {
143+
...headers,
144+
"Authorization": `Bearer ${this.$auth.api_token}`,
145+
"Content-Type": "application/json",
146+
},
147+
});
148+
},
149+
// Event: Emit New Employee Added Event
150+
async emitNewEmployeeAddedEvent(opts = {}) {
151+
const data = {};
152+
if (this.newEmployeeDepartmentFilter) data.department = this.newEmployeeDepartmentFilter;
153+
if (this.newEmployeeRoleFilter) data.role = this.newEmployeeRoleFilter;
154+
return this._makeRequest({
155+
method: "POST",
156+
path: "/events/new-employee-added",
157+
data,
158+
});
159+
},
160+
// Event: Emit Compensation Updated Event
161+
async emitCompensationUpdatedEvent(opts = {}) {
162+
const data = {};
163+
if (this.compensationDepartmentFilter) data.department = this.compensationDepartmentFilter;
164+
if (this.compensationEmployeeIdFilter) data.employee_id = this.compensationEmployeeIdFilter;
165+
return this._makeRequest({
166+
method: "POST",
167+
path: "/events/compensation-updated",
168+
data,
169+
});
170+
},
171+
// Event: Emit Organizational Structure Changed Event
172+
async emitOrgStructureChangedEvent(opts = {}) {
173+
const data = {};
174+
if (this.orgStructureTeamFilter) data.team = this.orgStructureTeamFilter;
175+
if (this.orgStructureDivisionFilter) data.division = this.orgStructureDivisionFilter;
176+
return this._makeRequest({
177+
method: "POST",
178+
path: "/events/org-structure-changed",
179+
data,
180+
});
181+
},
182+
183+
// Action: Add New Employee
184+
async addEmployee(opts = {}) {
185+
const data = {
186+
name: this.addEmployeeName,
187+
email: this.addEmployeeEmail,
188+
role: this.addEmployeeRole,
189+
};
190+
if (this.addEmployeeStartDate) data.start_date = this.addEmployeeStartDate;
191+
if (this.addEmployeeDepartment) data.department = this.addEmployeeDepartment;
192+
if (this.addEmployeeCustomFields) {
193+
data.custom_fields = this.addEmployeeCustomFields.map((field) => JSON.parse(field));
194+
}
195+
return this._makeRequest({
196+
method: "POST",
197+
path: "/employees",
198+
data,
199+
});
200+
},
201+
202+
// Action: Update Employee Profile
203+
async updateEmployeeProfile(opts = {}) {
204+
const data = {};
205+
if (this.updateFields) {
206+
data.fields_to_update = this.updateFields.map((field) => JSON.parse(field));
207+
}
208+
if (this.updateMetadata) {
209+
data.metadata = JSON.parse(this.updateMetadata);
210+
}
211+
return this._makeRequest({
212+
method: "PUT",
213+
path: `/employees/${this.updateEmployeeId}`,
214+
data,
215+
});
216+
},
217+
218+
// Action: Modify Compensation Records
219+
async modifyCompensation(opts = {}) {
220+
const data = {};
221+
if (this.modifyCompensationDetails) {
222+
data.compensation_details = JSON.parse(this.modifyCompensationDetails);
223+
}
224+
if (this.modifyCompensationEffectiveDate) {
225+
data.effective_date = this.modifyCompensationEffectiveDate;
226+
}
227+
if (this.modifyCompensationReason) {
228+
data.reason = this.modifyCompensationReason;
229+
}
230+
return this._makeRequest({
231+
method: "PUT",
232+
path: `/employees/${this.modifyCompensationEmployeeId}/compensation`,
233+
data,
234+
});
235+
},
10236
},
11237
};

components/charthop/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
"publishConfig": {
1313
"access": "public"
1414
}
15-
}
15+
}

0 commit comments

Comments
 (0)