Skip to content

Commit 034a886

Browse files
committed
some adjusts
1 parent 5ea4a38 commit 034a886

File tree

2 files changed

+55
-63
lines changed

2 files changed

+55
-63
lines changed

components/lucca/actions/update-user-info/update-user-info.mjs

Lines changed: 24 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ConfigurationError } from "@pipedream/platform";
12
import lucca from "../../lucca.app.mjs";
23

34
export default {
@@ -45,12 +46,6 @@ export default {
4546
],
4647
optional: true,
4748
},
48-
cspId: {
49-
type: "integer",
50-
label: "CSP ID",
51-
description: "The ID of the CSP",
52-
optional: true,
53-
},
5449
calendarId: {
5550
type: "integer",
5651
label: "Calendar ID",
@@ -69,31 +64,6 @@ export default {
6964
description: "The birth date of the user. Format: 'YYYY-MM-DD'.",
7065
optional: true,
7166
},
72-
departmentId: {
73-
propDefinition: [
74-
lucca,
75-
"departmentId",
76-
],
77-
optional: true,
78-
},
79-
managerId: {
80-
type: "integer",
81-
label: "Manager ID",
82-
description: "The ID of the manager",
83-
optional: true,
84-
},
85-
rolePrincipalId: {
86-
type: "integer",
87-
label: "Role Principal ID",
88-
description: "The ID of the role principal",
89-
optional: true,
90-
},
91-
cultureId: {
92-
type: "integer",
93-
label: "Culture ID",
94-
description: "The ID of the culture",
95-
optional: true,
96-
},
9767
address: {
9868
type: "string",
9969
label: "Address",
@@ -112,22 +82,17 @@ export default {
11282
description: "The direct line of the user",
11383
optional: true,
11484
},
115-
jobTitle: {
116-
type: "string",
117-
label: "Job Title",
118-
description: "The job title of the user",
119-
optional: true,
120-
},
12185
gender: {
12286
type: "string",
12387
label: "Gender",
12488
description: "The gender of the user",
12589
optional: true,
12690
},
12791
nationality: {
128-
type: "string",
129-
label: "Nationality",
130-
description: "The nationality of the user",
92+
propDefinition: [
93+
lucca,
94+
"nationalityId",
95+
],
13196
optional: true,
13297
},
13398
personalEmail: {
@@ -156,19 +121,26 @@ export default {
156121
},
157122
},
158123
async run({ $ }) {
159-
const {
160-
lucca,
161-
userId,
162-
...data
163-
} = this;
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+
});
164136

165-
const response = await lucca.updateUserProfile({
166-
$,
167-
userId,
168-
data,
169-
});
137+
$.export("$summary", `Successfully updated user with ID: ${this.userId}`);
138+
return response;
139+
} catch ({ message }) {
140+
console.log("message: ", message);
170141

171-
$.export("$summary", `Successfully updated user with ID: ${this.userId}`);
172-
return response;
142+
const parsedError = JSON.parse(message);
143+
throw new ConfigurationError(parsedError.Message || parsedError[0].message);
144+
}
173145
},
174146
};

components/lucca/lucca.app.mjs

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@ export default {
4848
label: "Legal Entity ID",
4949
description: "The ID of the legal entity",
5050
async options({ page }) {
51-
const { data: { items } } = await this.listEstablishments({
51+
const { items } = await this.listEstablishments({
5252
params: {
5353
paging: `${LIMIT * page},${LIMIT}`,
5454
status: 0,
5555
},
5656
});
57+
5758
return items.map(({
5859
id: value, name: label,
5960
}) => ({
@@ -70,7 +71,6 @@ export default {
7071
const { data: { items } } = await this.listDepartments({
7172
params: {
7273
paging: `${LIMIT * page},${LIMIT}`,
73-
status: 0,
7474
},
7575
});
7676
return items.map(({
@@ -81,10 +81,24 @@ export default {
8181
}));
8282
},
8383
},
84+
nationalityId: {
85+
type: "string",
86+
label: "Nationality",
87+
description: "The nationality of the user",
88+
async options() {
89+
const { items } = await this.listCountries();
90+
return items.map(({
91+
id: value, name: label,
92+
}) => ({
93+
label,
94+
value,
95+
}));
96+
},
97+
},
8498
},
8599
methods: {
86100
_baseUrl() {
87-
return `${this.$auth.api_url}/api/v3`;
101+
return `${this.$auth.api_url}`;
88102
},
89103
_headers() {
90104
return {
@@ -102,31 +116,37 @@ export default {
102116
},
103117
listLeaveTypes(opts = {}) {
104118
return this._makeRequest({
105-
path: "/leaveperiods/leavetypes",
119+
path: "/api/v3/leaveperiods/leavetypes",
106120
...opts,
107121
});
108122
},
109123
listUsers(opts = {}) {
110124
return this._makeRequest({
111-
path: "/users",
125+
path: "/api/v3/users",
112126
...opts,
113127
});
114128
},
115129
listLeaveRequests(opts = {}) {
116130
return this._makeRequest({
117-
path: "/leaveRequests",
131+
path: "/api/v3/leaveRequests",
118132
...opts,
119133
});
120134
},
121135
listEstablishments(opts = {}) {
122136
return this._makeRequest({
123-
path: "/establishments",
137+
path: "/organization/structure/api/establishments",
138+
...opts,
139+
});
140+
},
141+
listCountries(opts = {}) {
142+
return this._makeRequest({
143+
path: "/organization/structure/api/countries",
124144
...opts,
125145
});
126146
},
127147
listDepartments(opts = {}) {
128148
return this._makeRequest({
129-
path: "/departments",
149+
path: "/api/v3/departments",
130150
...opts,
131151
});
132152
},
@@ -135,7 +155,7 @@ export default {
135155
}) {
136156
return this._makeRequest({
137157
method: "POST",
138-
path: `/leaveRequests/${leaveRequestId}/approvals`,
158+
path: `/api/v3/leaveRequests/${leaveRequestId}/approvals`,
139159
...opts,
140160
});
141161
},
@@ -144,13 +164,13 @@ export default {
144164
}) {
145165
return this._makeRequest({
146166
method: "PUT",
147-
path: `/users/${userId}`,
167+
path: `/api/v3/users/${userId}`,
148168
...opts,
149169
});
150170
},
151171
listExpenseClaims(opts = {}) {
152172
return this._makeRequest({
153-
path: "/expenseClaims",
173+
path: "/api/v3/expenseClaims",
154174
...opts,
155175
});
156176
},

0 commit comments

Comments
 (0)