Skip to content

Commit 7fb6211

Browse files
[Components] onbee_app #13861 (#14339)
* Added actions * Update components/onbee_app/actions/update-employee/update-employee.mjs Co-authored-by: michelle0927 <[email protected]> --------- Co-authored-by: michelle0927 <[email protected]>
1 parent c321846 commit 7fb6211

File tree

6 files changed

+263
-8
lines changed

6 files changed

+263
-8
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import app from "../../onbee_app.app.mjs";
2+
3+
export default {
4+
key: "onbee_app-create-employee",
5+
name: "Create Employee",
6+
description: "Adds an employee to the system. [See the documentation](https://docs.onboardee.io/api/#tag/Employees/paths/~1employees~1add/post)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
firstname: {
12+
propDefinition: [
13+
app,
14+
"firstname",
15+
],
16+
},
17+
surname: {
18+
propDefinition: [
19+
app,
20+
"surname",
21+
],
22+
},
23+
privateEmail: {
24+
propDefinition: [
25+
app,
26+
"privateEmail",
27+
],
28+
},
29+
workEmail: {
30+
propDefinition: [
31+
app,
32+
"workEmail",
33+
],
34+
},
35+
dateOfBirth: {
36+
propDefinition: [
37+
app,
38+
"dateOfBirth",
39+
],
40+
},
41+
},
42+
43+
async run({ $ }) {
44+
const response = await this.app.createEmployee({
45+
$,
46+
data: {
47+
firstname: this.firstname,
48+
surname: this.surname,
49+
privateEmail: this.privateEmail,
50+
workEmail: this.workEmail,
51+
dateOfBirth: this.dateOfBirth,
52+
},
53+
});
54+
55+
$.export("$summary", `Successfully created Employee with ID '${response.payload._id}'`);
56+
57+
return response;
58+
},
59+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import app from "../../onbee_app.app.mjs";
2+
3+
export default {
4+
key: "onbee_app-delete-employee",
5+
name: "Delete Employee",
6+
description: "Delete an employee with the specified ID. [See the documentation](https://docs.onboardee.io/api/#tag/Employees/paths/~1employees~1edit~1{id}/post)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
employeeId: {
12+
propDefinition: [
13+
app,
14+
"employeeId",
15+
],
16+
},
17+
},
18+
19+
async run({ $ }) {
20+
const response = await this.app.deleteEmployee({
21+
$,
22+
employeeId: this.employeeId,
23+
});
24+
25+
$.export("$summary", `Successfully deleted Employee with ID '${this.employeeId}'`);
26+
27+
return response;
28+
},
29+
};
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import app from "../../onbee_app.app.mjs";
2+
3+
export default {
4+
key: "onbee_app-update-employee",
5+
name: "Update Employee",
6+
description: "Update an employee with the specified ID. [See the documentation](https://docs.onboardee.io/api/#tag/Employees/paths/~1employees~1edit~1{id}/post)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
employeeId: {
12+
propDefinition: [
13+
app,
14+
"employeeId",
15+
],
16+
},
17+
firstname: {
18+
propDefinition: [
19+
app,
20+
"firstname",
21+
],
22+
optional: true,
23+
},
24+
surname: {
25+
propDefinition: [
26+
app,
27+
"surname",
28+
],
29+
optional: true,
30+
},
31+
privateEmail: {
32+
propDefinition: [
33+
app,
34+
"privateEmail",
35+
],
36+
},
37+
workEmail: {
38+
propDefinition: [
39+
app,
40+
"workEmail",
41+
],
42+
},
43+
dateOfBirth: {
44+
propDefinition: [
45+
app,
46+
"dateOfBirth",
47+
],
48+
},
49+
},
50+
51+
async run({ $ }) {
52+
const response = await this.app.updateEmployee({
53+
$,
54+
employeeId: this.employeeId,
55+
data: {
56+
firstname: this.firstname,
57+
surname: this.surname,
58+
privateEmail: this.privateEmail,
59+
workEmail: this.workEmail,
60+
dateOfBirth: this.dateOfBirth,
61+
},
62+
});
63+
64+
$.export("$summary", `Successfully updated Employee with ID '${response.payload._id}'`);
65+
66+
return response;
67+
},
68+
};
Lines changed: 98 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,104 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "onbee_app",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
employeeId: {
8+
type: "string",
9+
label: "Employee ID",
10+
description: "ID of the Employee",
11+
async options() {
12+
const response = await this.getEmployees();
13+
14+
const employeeIds = response.payload;
15+
16+
return employeeIds.map(({
17+
_id, firstname, surname,
18+
}) => ({
19+
value: _id,
20+
label: `${firstname} ${surname}`,
21+
}));
22+
},
23+
},
24+
firstname: {
25+
type: "string",
26+
label: "First Name",
27+
description: "First name of the employee",
28+
},
29+
surname: {
30+
type: "string",
31+
label: "Last Name",
32+
description: "Last name of the employee",
33+
},
34+
privateEmail: {
35+
type: "string",
36+
label: "Private Email",
37+
description: "Private email of the employee",
38+
optional: true,
39+
},
40+
workEmail: {
41+
type: "string",
42+
label: "Work Email",
43+
description: "Work email of the employee",
44+
optional: true,
45+
},
46+
dateOfBirth: {
47+
type: "string",
48+
label: "Date of Birth",
49+
description: "Date of birth of the employee, i.e.: `1997-12-03`",
50+
optional: true,
51+
},
52+
},
553
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
54+
_baseUrl() {
55+
return `https://${this.$auth.workspace_name}.onbee.app/api`;
56+
},
57+
async _makeRequest(opts = {}) {
58+
const {
59+
$ = this,
60+
path,
61+
headers,
62+
...otherOpts
63+
} = opts;
64+
return axios($, {
65+
...otherOpts,
66+
url: this._baseUrl() + path,
67+
headers: {
68+
...headers,
69+
Authorization: `Bearer ${this.$auth.api_token}`,
70+
},
71+
});
72+
},
73+
async createEmployee(args = {}) {
74+
return this._makeRequest({
75+
path: "/employees/add",
76+
method: "post",
77+
...args,
78+
});
79+
},
80+
async updateEmployee({
81+
employeeId, ...args
82+
}) {
83+
return this._makeRequest({
84+
path: `/employees/edit/${employeeId}`,
85+
method: "post",
86+
...args,
87+
});
88+
},
89+
async deleteEmployee({
90+
employeeId, ...args
91+
}) {
92+
return this._makeRequest({
93+
path: `/employee-delete/${employeeId}`,
94+
...args,
95+
});
96+
},
97+
async getEmployees(args = {}) {
98+
return this._makeRequest({
99+
path: "/employee-list/",
100+
...args,
101+
});
9102
},
10103
},
11-
};
104+
};

components/onbee_app/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/onbee_app",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Onbee.app Components",
55
"main": "onbee_app.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
15-
}
18+
}

pnpm-lock.yaml

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)