Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions components/onbee_app/actions/create-employee/create-employee.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import app from "../../onbee_app.app.mjs";

export default {
key: "onbee_app-create-employee",
name: "Create Employee",
description: "Adds an employee to the system. [See the documentation](https://docs.onboardee.io/api/#tag/Employees/paths/~1employees~1add/post)",
version: "0.0.1",
type: "action",
props: {
app,
firstname: {
propDefinition: [
app,
"firstname",
],
},
surname: {
propDefinition: [
app,
"surname",
],
},
privateEmail: {
propDefinition: [
app,
"privateEmail",
],
},
workEmail: {
propDefinition: [
app,
"workEmail",
],
},
dateOfBirth: {
propDefinition: [
app,
"dateOfBirth",
],
},
},

async run({ $ }) {
const response = await this.app.createEmployee({
$,
data: {
firstname: this.firstname,
surname: this.surname,
privateEmail: this.privateEmail,
workEmail: this.workEmail,
dateOfBirth: this.dateOfBirth,
},
});

$.export("$summary", `Successfully created Employee with ID '${response.payload._id}'`);

return response;
},
};
29 changes: 29 additions & 0 deletions components/onbee_app/actions/delete-employee/delete-employee.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import app from "../../onbee_app.app.mjs";

export default {
key: "onbee_app-delete-employee",
name: "Delete Employee",
description: "Delete an employee with the specified ID. [See the documentation](https://docs.onboardee.io/api/#tag/Employees/paths/~1employees~1edit~1{id}/post)",
version: "0.0.1",
type: "action",
props: {
app,
employeeId: {
propDefinition: [
app,
"employeeId",
],
},
},

async run({ $ }) {
const response = await this.app.deleteEmployee({
$,
employeeId: this.employeeId,
});

$.export("$summary", `Successfully deleted Employee with ID '${this.employeeId}'`);

return response;
},
};
68 changes: 68 additions & 0 deletions components/onbee_app/actions/update-employee/update-employee.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import app from "../../onbee_app.app.mjs";

export default {
key: "onbee_app-update-employee",
name: "Update Employee",
description: "Update an employee with the specified ID. [See the documentation](https://docs.onboardee.io/api/#tag/Employees/paths/~1employees~1edit~1{id}/post)",
version: "0.0.1",
type: "action",
props: {
app,
employeeId: {
propDefinition: [
app,
"employeeId",
],
},
firstname: {
propDefinition: [
app,
"firstname",
],
optional: true,
},
surname: {
propDefinition: [
app,
"surname",
],
optional: true,
},
privateEmail: {
propDefinition: [
app,
"privateEmail",
],
},
workEmail: {
propDefinition: [
app,
"workEmail",
],
},
dateOfBirth: {
propDefinition: [
app,
"dateOfBirth",
],
},
},

async run({ $ }) {
const response = await this.app.updateEmployee({
$,
employeeId: this.employeeId,
data: {
firstname: this.firstname,
surname: this.surname,
privateEmail: this.privateEmail,
workEmail: this.workEmail,
dateOfBirth: this.dateOfBirth,
},
});

$.export("$summary", `Successfully updated Employee with ID '${response.payload._id}'`);

return response;
},
};
103 changes: 98 additions & 5 deletions components/onbee_app/onbee_app.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,104 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "onbee_app",
propDefinitions: {},
propDefinitions: {
employeeId: {
type: "string",
label: "Employee ID",
description: "ID of the Employee",
async options() {
const response = await this.getEmployees();

const employeeIds = response.payload;

return employeeIds.map(({
_id, firstname, surname,
}) => ({
value: _id,
label: `${firstname} ${surname}`,
}));
},
},
firstname: {
type: "string",
label: "First Name",
description: "First name of the employee",
},
surname: {
type: "string",
label: "Last Name",
description: "Last name of the employee",
},
privateEmail: {
type: "string",
label: "Private Email",
description: "Private email of the employee",
optional: true,
},
workEmail: {
type: "string",
label: "Work Email",
description: "Work email of the employee",
optional: true,
},
dateOfBirth: {
type: "string",
label: "Date of Birth",
description: "Date of birth of the employee, i.e.: `1997-12-03`",
optional: true,
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return `https://${this.$auth.workspace_name}.onbee.app/api`;
},
async _makeRequest(opts = {}) {
const {
$ = this,
path,
headers,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
headers: {
...headers,
Authorization: `Bearer ${this.$auth.api_token}`,
},
});
},
async createEmployee(args = {}) {
return this._makeRequest({
path: "/employees/add",
method: "post",
...args,
});
},
async updateEmployee({
employeeId, ...args
}) {
return this._makeRequest({
path: `/employees/edit/${employeeId}`,
method: "post",
...args,
});
},
async deleteEmployee({
employeeId, ...args
}) {
return this._makeRequest({
path: `/employee-delete/${employeeId}`,
...args,
});
},
async getEmployees(args = {}) {
return this._makeRequest({
path: "/employee-list/",
...args,
});
},
},
};
};
7 changes: 5 additions & 2 deletions components/onbee_app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/onbee_app",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Onbee.app Components",
"main": "onbee_app.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
}
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading