Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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,43 @@
import lucca from "../../lucca.app.mjs";

export default {
key: "lucca-approve-leave-request",
name: "Approve Or Deny Leave Request",
description: "Approve or Deny a pending leave request. [See the documentation](https://developers.lucca.fr/api-reference/legacy/timmi-absences/leave-requests/approve-or-deny-a-leave-request)",
version: "0.0.1",
type: "action",
props: {
lucca,
leaveRequestId: {
propDefinition: [
lucca,
"leaveRequestId",
],
},
approved: {
type: "boolean",
label: "Approved",
description: "Whether the leave request should be approved.",
optional: true,
},
comment: {
type: "string",
label: "Comment",
description: "Optional comment about the approval decision.",
optional: true,
},
},
async run({ $ }) {
const response = await this.lucca.approveLeaveRequest({
$,
leaveRequestId: this.leaveRequestId,
data: {
approved: this.approved,
comment: this.comment,
},
});

$.export("$summary", `Leave request ${this.leaveRequestId} was successfully processed.`);
return response;
},
};
172 changes: 172 additions & 0 deletions components/lucca/actions/update-user-info/update-user-info.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
import lucca from "../../lucca.app.mjs";

export default {
key: "lucca-update-user-info",
name: "Update User Info",
description: "Update profile or HR information for an existing user. [See the documentation](https://developers.lucca.fr/api-reference/legacy/directory/update-a-user-by-id)",
version: "0.0.1",
type: "action",
props: {
lucca,
userId: {
propDefinition: [
lucca,
"userId",
],
},
firstName: {
type: "string",
label: "First Name",
description: "The user's first name",
optional: true,
},
lastName: {
type: "string",
label: "Last Name",
description: "The user's last name",
optional: true,
},
mail: {
type: "string",
label: "Email",
description: "The user's email",
optional: true,
},
login: {
type: "string",
label: "Login",
description: "The user's login",
optional: true,
},
legalEntityId: {
type: "integer",
label: "Legal Entity ID",
description: "The ID of the legal entity",
optional: true,
},
cspId: {
type: "integer",
label: "CSP ID",
description: "The ID of the CSP",
optional: true,
},
calendarId: {
type: "integer",
label: "Calendar ID",
description: "The ID of the calendar",
optional: true,
},
employeeNumber: {
type: "string",
label: "Employee Number",
description: "The employee number",
optional: true,
},
birthDate: {
type: "string",
label: "Birth Date",
description: "The birth date of the user. Format: 'YYYY-MM-DD'.",
optional: true,
},
departmentId: {
type: "integer",
label: "Department ID",
description: "The ID of the department",
optional: true,
},
managerId: {
type: "integer",
label: "Manager ID",
description: "The ID of the manager",
optional: true,
},
rolePrincipalId: {
type: "integer",
label: "Role Principal ID",
description: "The ID of the role principal",
optional: true,
},
cultureId: {
type: "integer",
label: "Culture ID",
description: "The ID of the culture",
optional: true,
},
address: {
type: "string",
label: "Address",
description: "The address of the user",
optional: true,
},
bankName: {
type: "string",
label: "Bank Name",
description: "The name of the bank",
optional: true,
},
directLine: {
type: "string",
label: "Direct Line",
description: "The direct line of the user",
optional: true,
},
jobTitle: {
type: "string",
label: "Job Title",
description: "The job title of the user",
optional: true,
},
gender: {
type: "string",
label: "Gender",
description: "The gender of the user",
optional: true,
},
nationality: {
type: "string",
label: "Nationality",
description: "The nationality of the user",
optional: true,
},
personalEmail: {
type: "string",
label: "Personal Email",
description: "The personal email of the user",
optional: true,
},
personalMobile: {
type: "string",
label: "Personal Mobile",
description: "The personal mobile of the user",
optional: true,
},
professionalMobile: {
type: "string",
label: "Professional Mobile",
description: "The professional mobile of the user",
optional: true,
},
quote: {
type: "string",
label: "Quote",
description: "The quote of the user",
optional: true,
},
},
async run({ $ }) {
const {
lucca,
userId,
...data
} = this;

const response = await lucca.updateUserProfile({
$,
userId,
data,
});

$.export("$summary", `Successfully updated user with ID: ${this.userId}`);
return response;
},
};
1 change: 1 addition & 0 deletions components/lucca/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const LIMIT = 100;
133 changes: 128 additions & 5 deletions components/lucca/lucca.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,134 @@
import { axios } from "@pipedream/platform";
import { LIMIT } from "./common/constants.mjs";

export default {
type: "app",
app: "lucca",
propDefinitions: {},
propDefinitions: {
userId: {
type: "string",
label: "User ID",
description: "The ID of the user",
async options({ page }) {
const { data: { items } } = await this.listUsers({
params: {
paging: `${LIMIT * page},${LIMIT}`,
},
});

return items.map(({
id: value, name: label,
}) => ({
label,
value,
}));
},
},
leaveRequestId: {
type: "string",
label: "Leave Request ID",
description: "The ID of the leave request to approve",
async options({ page }) {
const { data: { items } } = await this.listLeaveRequests({
params: {
paging: `${LIMIT * page},${LIMIT}`,
status: 0,
},
});
return items.map(({
id: value, name: label,
}) => ({
label,
value,
}));
},
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return `${this.$auth.api_url}/api/v3`;
},
_headers() {
return {
"authorization": `lucca application=${this.$auth.api_key}`,
};
},
_makeRequest({
$ = this, path, ...opts
}) {
return axios($, {
url: this._baseUrl() + path,
headers: this._headers(),
...opts,
});
},
listLeaveTypes(opts = {}) {
return this._makeRequest({
path: "/leaveperiods/leavetypes",
...opts,
});
},
listUsers(opts = {}) {
return this._makeRequest({
path: "/users",
...opts,
});
},
listLeaveRequests(opts = {}) {
return this._makeRequest({
path: "/leaveRequests",
...opts,
});
},
approveLeaveRequest({
leaveRequestId, ...opts
}) {
return this._makeRequest({
method: "POST",
path: `/leaveRequests/${leaveRequestId}/approvals`,
...opts,
});
},
updateUserProfile({
userId, ...opts
}) {
return this._makeRequest({
method: "PUT",
path: `/users/${userId}`,
...opts,
});
},
listExpenseClaims(opts = {}) {
return this._makeRequest({
path: "/expenseClaims",
...opts,
});
},
async *paginate({
fn, params = {}, maxResults = null, ...opts
}) {
let hasMore = false;
let count = 0;
let page = 0;

do {
params.paging = `${LIMIT * page},${LIMIT}`;
page++;
const { data: { items } } = await fn({
params,
...opts,
});
for (const d of items) {
yield d;

if (maxResults && ++count === maxResults) {
return count;
}
}

hasMore = items.length;

} while (hasMore);
},
},
};
};
7 changes: 5 additions & 2 deletions components/lucca/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/lucca",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Lucca Components",
"main": "lucca.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"
}
}
}
Loading
Loading