|
| 1 | +import { ConfigurationError } from "@pipedream/platform"; |
| 2 | +import lucca from "../../lucca.app.mjs"; |
| 3 | + |
| 4 | +export default { |
| 5 | + key: "lucca-update-user-info", |
| 6 | + name: "Update User Info", |
| 7 | + 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)", |
| 8 | + version: "0.0.1", |
| 9 | + type: "action", |
| 10 | + props: { |
| 11 | + lucca, |
| 12 | + userId: { |
| 13 | + propDefinition: [ |
| 14 | + lucca, |
| 15 | + "userId", |
| 16 | + ], |
| 17 | + }, |
| 18 | + firstName: { |
| 19 | + type: "string", |
| 20 | + label: "First Name", |
| 21 | + description: "The user's first name", |
| 22 | + optional: true, |
| 23 | + }, |
| 24 | + lastName: { |
| 25 | + type: "string", |
| 26 | + label: "Last Name", |
| 27 | + description: "The user's last name", |
| 28 | + optional: true, |
| 29 | + }, |
| 30 | + mail: { |
| 31 | + type: "string", |
| 32 | + label: "Email", |
| 33 | + description: "The user's email", |
| 34 | + optional: true, |
| 35 | + }, |
| 36 | + login: { |
| 37 | + type: "string", |
| 38 | + label: "Login", |
| 39 | + description: "The user's login", |
| 40 | + optional: true, |
| 41 | + }, |
| 42 | + legalEntityId: { |
| 43 | + propDefinition: [ |
| 44 | + lucca, |
| 45 | + "legalEntityId", |
| 46 | + ], |
| 47 | + optional: true, |
| 48 | + }, |
| 49 | + calendarId: { |
| 50 | + type: "integer", |
| 51 | + label: "Calendar ID", |
| 52 | + description: "The ID of the calendar", |
| 53 | + optional: true, |
| 54 | + }, |
| 55 | + employeeNumber: { |
| 56 | + type: "string", |
| 57 | + label: "Employee Number", |
| 58 | + description: "The employee number", |
| 59 | + optional: true, |
| 60 | + }, |
| 61 | + birthDate: { |
| 62 | + type: "string", |
| 63 | + label: "Birth Date", |
| 64 | + description: "The birth date of the user. Format: 'YYYY-MM-DD'.", |
| 65 | + optional: true, |
| 66 | + }, |
| 67 | + address: { |
| 68 | + type: "string", |
| 69 | + label: "Address", |
| 70 | + description: "The address of the user", |
| 71 | + optional: true, |
| 72 | + }, |
| 73 | + bankName: { |
| 74 | + type: "string", |
| 75 | + label: "Bank Name", |
| 76 | + description: "The name of the bank", |
| 77 | + optional: true, |
| 78 | + }, |
| 79 | + directLine: { |
| 80 | + type: "string", |
| 81 | + label: "Direct Line", |
| 82 | + description: "The direct line of the user", |
| 83 | + optional: true, |
| 84 | + }, |
| 85 | + gender: { |
| 86 | + type: "string", |
| 87 | + label: "Gender", |
| 88 | + description: "The gender of the user", |
| 89 | + optional: true, |
| 90 | + }, |
| 91 | + nationality: { |
| 92 | + propDefinition: [ |
| 93 | + lucca, |
| 94 | + "nationalityId", |
| 95 | + ], |
| 96 | + optional: true, |
| 97 | + }, |
| 98 | + personalEmail: { |
| 99 | + type: "string", |
| 100 | + label: "Personal Email", |
| 101 | + description: "The personal email of the user", |
| 102 | + optional: true, |
| 103 | + }, |
| 104 | + personalMobile: { |
| 105 | + type: "string", |
| 106 | + label: "Personal Mobile", |
| 107 | + description: "The personal mobile of the user", |
| 108 | + optional: true, |
| 109 | + }, |
| 110 | + professionalMobile: { |
| 111 | + type: "string", |
| 112 | + label: "Professional Mobile", |
| 113 | + description: "The professional mobile of the user", |
| 114 | + optional: true, |
| 115 | + }, |
| 116 | + quote: { |
| 117 | + type: "string", |
| 118 | + label: "Quote", |
| 119 | + description: "The quote of the user", |
| 120 | + optional: true, |
| 121 | + }, |
| 122 | + }, |
| 123 | + async run({ $ }) { |
| 124 | + try { |
| 125 | + const { |
| 126 | + lucca, |
| 127 | + userId, |
| 128 | + ...data |
| 129 | + } = this; |
| 130 | + |
| 131 | + const response = await lucca.updateUserProfile({ |
| 132 | + $, |
| 133 | + userId, |
| 134 | + data, |
| 135 | + }); |
| 136 | + |
| 137 | + $.export("$summary", `Successfully updated user with ID: ${this.userId}`); |
| 138 | + return response; |
| 139 | + } catch ({ message }) { |
| 140 | + console.log("message: ", message); |
| 141 | + |
| 142 | + const parsedError = JSON.parse(message); |
| 143 | + throw new ConfigurationError(parsedError.Message || parsedError[0].message); |
| 144 | + } |
| 145 | + }, |
| 146 | +}; |
0 commit comments