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
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import kenjo from "../../kenjo.app.mjs";
import { ConfigurationError } from "@pipedream/platform";

export default {
key: "kenjo-create-attendance-entry",
name: "Create Attendance Entry",
description: "Creates a new attendance entry for an employee in Kenjo. [See the documentation](https://kenjo.readme.io/reference/post_attendances)",
version: "0.0.1",
type: "action",
props: {
kenjo,
employeeId: {
propDefinition: [
kenjo,
"employeeId",
],
},
date: {
type: "string",
label: "Date",
description: "The date of the entry. Format: `YYYY-MM-DD`",
},
startTime: {
type: "string",
label: "Start Time",
description: "The start time of the entry. Format: `hh:mm:ss`",
},
endTime: {
type: "string",
label: "End Time",
description: "The end time of the entry. Format: `hh:mm:ss`",
optional: true,
},
breakStartTime: {
type: "string",
label: "Break Start Time",
description: "The start time of the break. Format: `hh:mm:ss`",
optional: true,
},
breakEndTime: {
type: "string",
label: "Break End Time",
description: "The end time of the break. Format: `hh:mm:ss`",
optional: true,
},
comment: {
type: "string",
label: "Comment",
description: "Comment to describe the attendance record",
optional: true,
},
},
async run({ $ }) {
if (this.breakEndTime && !this.breakStartTime) {
throw new ConfigurationError("Break Start Time is required if including a break");
}

const response = await this.kenjo.createAttendanceEntry({
$,
data: {
userId: this.employeeId,
date: this.date,
startTime: this.startTime,
endTime: this.endTime,
breaks: this.breakStartTime && [
{
start: this.breakStartTime,
end: this.breakEndTime,
},
],
comment: this.comment,
},
});
$.export("$summary", `Successfully created attendance entry with ID: ${response._id}`);
return response;
},
};
178 changes: 178 additions & 0 deletions components/kenjo/actions/create-employee/create-employee.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
import kenjo from "../../kenjo.app.mjs";

export default {
key: "kenjo-create-employee",
name: "Create Employee",
description: "Creates a new employee in Kenjo. [See the documentation](https://kenjo.readme.io/reference/post_employees)",
version: "0.0.1",
type: "action",
props: {
kenjo,
email: {
type: "string",
label: "Email",
description: "The email address of the employee",
},
firstName: {
type: "string",
label: "First Name",
description: "The first name of the employee",
},
lastName: {
type: "string",
label: "Last Name",
description: "The last name of the employee",
},
companyId: {
propDefinition: [
kenjo,
"companyId",
],
},
weeklyHours: {
type: "integer",
label: "Weekly Hours",
description: "The number of weekly hours that an employee works",
},
officeId: {
propDefinition: [
kenjo,
"officeId",
(c) => ({
companyId: c.companyId,
}),
],
},
departmentId: {
propDefinition: [
kenjo,
"departmentId",
],
},
language: {
type: "string",
label: "Language",
description: "The employee's language",
options: [
"en",
"es",
"de",
],
optional: true,
},
birthdate: {
type: "string",
label: "Birthdate",
description: "The birthdate of the employee. Format `YYYY-MM-DDThh:mm:ss.000Z`",
optional: true,
},
jobTitle: {
type: "string",
label: "Job Title",
description: "The job title of the employee",
optional: true,
},
workPhone: {
type: "string",
label: "Work Phone",
description: "The work phone number of the employee",
optional: true,
},
personalPhone: {
type: "string",
label: "Personal Phone",
description: "The personal phone number of the employee",
optional: true,
},
workDays: {
type: "string[]",
label: "Work Days",
description: "The days of the week that the employee works",
options: [
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday",
"sunday",
],
optional: true,
},
trackAttendance: {
type: "boolean",
label: "Track Attendance",
description: "Set to `true` to activate attendance tracking for the employee",
optional: true,
},
street: {
type: "string",
label: "Street",
description: "The street address of the employee",
optional: true,
},
postalCode: {
type: "string",
label: "Postal Code",
description: "The postal code of the employee",
optional: true,
},
city: {
type: "string",
label: "City",
description: "The city of the employee",
optional: true,
},
country: {
type: "string",
label: "Country",
description: "The country code in ISO 3166-1 alpha-2. Example: `ES`",
optional: true,
},
},
async run({ $ }) {
const workSchedule = {
trackAttendance: this.trackAttendance,
};
if (this.workDays?.length) {
for (const day of this.workDays) {
workSchedule[`${day}WorkingDay`] = true;
}
}

const response = await this.kenjo.createEmployee({
$,
data: {
account: {
email: this.email,
language: this.language,
},
personal: {
firstName: this.firstName,
lastName: this.lastName,
birthdate: this.birthdate,
},
work: {
companyId: this.companyId,
officeId: this.officeId,
departmentId: this.departmentId,
weeklyHours: this.weeklyHours,
jobTitle: this.jobTitle,
workPhone: this.workPhone,
},
workSchedule,
address: (this.street || this.postalCode || this.city || this.country) && {
street: this.street,
postalCode: this.postalCode,
city: this.city,
country: this.country,
},
home: this.personalPhone && {
personalPhone: this.personalPhone,
},
},
});
$.export("$summary", `Created employee with ID: ${response.account._id}`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import kenjo from "../../kenjo.app.mjs";

export default {
key: "kenjo-create-leave-request",
name: "Create Leave Request",
description: "Creates a new leave request in Kenjo. [See the documentation](https://kenjo.readme.io/reference/post_time-off-requests).",
version: "0.0.1",
type: "action",
props: {
kenjo,
employeeId: {
propDefinition: [
kenjo,
"employeeId",
],
},
timeOffTypeId: {
propDefinition: [
kenjo,
"timeOffTypeId",
],
},
from: {
type: "string",
label: "From",
description: "The starting date of the time-off request in format `YYYY-MM-DD`",
},
to: {
type: "string",
label: "To",
description: "The ending date of the time-off request in format `YYYY-MM-DD`",
},
partOfDayFrom: {
type: "string",
label: "Part of Day From",
description: "The duration of the from date. 'StartOfDay' means that the from date is the entire day. 'HalfOfDay' means that the request starts to apply in the middle of the from day. If not specified, the default value will be 'StartOfDay'.",
options: [
"StartOfDay",
"HalfOfDay",
],
optional: true,
},
partOfDayTo: {
type: "string",
label: "Part of Day To",
description: "The duration of the to date. 'EndOfDay' means that the to date is the entire day. 'HalfOfDay' means the request starts to apply in the middle of the to day. If not specified, the default value will be 'EndOfDay'.",
options: [
"HalfOfDay",
"EndOfDay",
],
optional: true,
},
description: {
type: "string",
label: "Description",
description: "The description of the time-off request",
optional: true,
},
},
async run({ $ }) {
const response = await this.kenjo.createLeaveRequest({
$,
data: {
_userId: this.employeeId,
_timeOffTypeId: this.timeOffTypeId,
from: this.from,
to: this.to,
partOfDayFrom: this.partOfDayFrom,
partOfDayTo: this.partOfDayTo,
description: this.description,
},
});
$.export("$summary", `Successfully created leave request with ID: ${response._id}`);
return response;
},
};
Loading
Loading