@joshuanode/n8n-nodes-scalepad 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -121
- package/dist/nodes/ScalePadCore/ScalePadCore.node.js +798 -11
- package/dist/nodes/ScalePadCore/descriptions/ActionItemDescription.d.ts +3 -0
- package/dist/nodes/ScalePadCore/descriptions/ActionItemDescription.js +306 -0
- package/dist/nodes/ScalePadCore/descriptions/AssessmentDescription.d.ts +3 -0
- package/dist/nodes/ScalePadCore/descriptions/AssessmentDescription.js +291 -0
- package/dist/nodes/ScalePadCore/descriptions/AssessmentTemplateDescription.d.ts +3 -0
- package/dist/nodes/ScalePadCore/descriptions/AssessmentTemplateDescription.js +59 -0
- package/dist/nodes/ScalePadCore/descriptions/ContractDescription.js +242 -21
- package/dist/nodes/ScalePadCore/descriptions/GoalDescription.d.ts +3 -0
- package/dist/nodes/ScalePadCore/descriptions/GoalDescription.js +468 -0
- package/dist/nodes/ScalePadCore/descriptions/HardwareLifecycleDescription.d.ts +3 -0
- package/dist/nodes/ScalePadCore/descriptions/HardwareLifecycleDescription.js +81 -0
- package/dist/nodes/ScalePadCore/descriptions/InitiativeDescription.d.ts +3 -0
- package/dist/nodes/ScalePadCore/descriptions/InitiativeDescription.js +565 -0
- package/dist/nodes/ScalePadCore/descriptions/LmContractDescription.d.ts +3 -0
- package/dist/nodes/ScalePadCore/descriptions/LmContractDescription.js +342 -0
- package/dist/nodes/ScalePadCore/descriptions/MeetingDescription.d.ts +3 -0
- package/dist/nodes/ScalePadCore/descriptions/MeetingDescription.js +501 -0
- package/dist/nodes/ScalePadCore/descriptions/NoteDescription.d.ts +3 -0
- package/dist/nodes/ScalePadCore/descriptions/NoteDescription.js +289 -0
- package/dist/nodes/ScalePadLifecycleManager/ScalePadLifecycleManager.node.d.ts +6 -0
- package/dist/nodes/ScalePadLifecycleManager/ScalePadLifecycleManager.node.js +837 -0
- package/dist/nodes/ScalePadLifecycleManager/descriptions/ActionItemDescription.d.ts +3 -0
- package/dist/nodes/ScalePadLifecycleManager/descriptions/ActionItemDescription.js +306 -0
- package/dist/nodes/ScalePadLifecycleManager/descriptions/AssessmentDescription.d.ts +3 -0
- package/dist/nodes/ScalePadLifecycleManager/descriptions/AssessmentDescription.js +291 -0
- package/dist/nodes/ScalePadLifecycleManager/descriptions/AssessmentTemplateDescription.d.ts +3 -0
- package/dist/nodes/ScalePadLifecycleManager/descriptions/AssessmentTemplateDescription.js +59 -0
- package/dist/nodes/ScalePadLifecycleManager/descriptions/ContractDescription.d.ts +3 -0
- package/dist/nodes/ScalePadLifecycleManager/descriptions/ContractDescription.js +342 -0
- package/dist/nodes/ScalePadLifecycleManager/descriptions/GoalDescription.d.ts +3 -0
- package/dist/nodes/ScalePadLifecycleManager/descriptions/GoalDescription.js +468 -0
- package/dist/nodes/ScalePadLifecycleManager/descriptions/HardwareLifecycleDescription.d.ts +3 -0
- package/dist/nodes/ScalePadLifecycleManager/descriptions/HardwareLifecycleDescription.js +81 -0
- package/dist/nodes/ScalePadLifecycleManager/descriptions/InitiativeDescription.d.ts +3 -0
- package/dist/nodes/ScalePadLifecycleManager/descriptions/InitiativeDescription.js +565 -0
- package/dist/nodes/ScalePadLifecycleManager/descriptions/MeetingDescription.d.ts +3 -0
- package/dist/nodes/ScalePadLifecycleManager/descriptions/MeetingDescription.js +501 -0
- package/dist/nodes/ScalePadLifecycleManager/descriptions/NoteDescription.d.ts +3 -0
- package/dist/nodes/ScalePadLifecycleManager/descriptions/NoteDescription.js +289 -0
- package/dist/nodes/ScalePadLifecycleManager/scalepad.svg +17 -0
- package/package.json +1 -1
|
@@ -0,0 +1,837 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ScalePadLifecycleManager = void 0;
|
|
4
|
+
const GenericFunctions_1 = require("../shared/GenericFunctions");
|
|
5
|
+
const MeetingDescription_1 = require("./descriptions/MeetingDescription");
|
|
6
|
+
const InitiativeDescription_1 = require("./descriptions/InitiativeDescription");
|
|
7
|
+
const GoalDescription_1 = require("./descriptions/GoalDescription");
|
|
8
|
+
const ActionItemDescription_1 = require("./descriptions/ActionItemDescription");
|
|
9
|
+
const AssessmentDescription_1 = require("./descriptions/AssessmentDescription");
|
|
10
|
+
const NoteDescription_1 = require("./descriptions/NoteDescription");
|
|
11
|
+
const AssessmentTemplateDescription_1 = require("./descriptions/AssessmentTemplateDescription");
|
|
12
|
+
const HardwareLifecycleDescription_1 = require("./descriptions/HardwareLifecycleDescription");
|
|
13
|
+
const ContractDescription_1 = require("./descriptions/ContractDescription");
|
|
14
|
+
class ScalePadLifecycleManager {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.description = {
|
|
17
|
+
displayName: 'ScalePad Lifecycle Manager',
|
|
18
|
+
name: 'scalePadLifecycleManager',
|
|
19
|
+
icon: 'file:scalepad.svg',
|
|
20
|
+
group: ['transform'],
|
|
21
|
+
version: 1,
|
|
22
|
+
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
23
|
+
description: 'Interact with ScalePad Lifecycle Manager API',
|
|
24
|
+
defaults: {
|
|
25
|
+
name: 'ScalePad Lifecycle Manager',
|
|
26
|
+
},
|
|
27
|
+
inputs: ['main'],
|
|
28
|
+
outputs: ['main'],
|
|
29
|
+
credentials: [
|
|
30
|
+
{
|
|
31
|
+
name: 'scalePadCoreApi',
|
|
32
|
+
required: true,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
requestDefaults: {
|
|
36
|
+
baseURL: 'https://api.scalepad.com',
|
|
37
|
+
headers: {
|
|
38
|
+
Accept: 'application/json',
|
|
39
|
+
'Content-Type': 'application/json',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
properties: [
|
|
43
|
+
{
|
|
44
|
+
displayName: 'Resource',
|
|
45
|
+
name: 'resource',
|
|
46
|
+
type: 'options',
|
|
47
|
+
noDataExpression: true,
|
|
48
|
+
options: [
|
|
49
|
+
{
|
|
50
|
+
name: 'Action Item',
|
|
51
|
+
value: 'actionItem',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'Assessment',
|
|
55
|
+
value: 'assessment',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'Assessment Template',
|
|
59
|
+
value: 'assessmentTemplate',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'Contract',
|
|
63
|
+
value: 'contract',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'Goal',
|
|
67
|
+
value: 'goal',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'Hardware Lifecycle',
|
|
71
|
+
value: 'hardwareLifecycle',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: 'Initiative',
|
|
75
|
+
value: 'initiative',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'Meeting',
|
|
79
|
+
value: 'meeting',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'Note',
|
|
83
|
+
value: 'note',
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
default: 'meeting',
|
|
87
|
+
},
|
|
88
|
+
...MeetingDescription_1.meetingOperations,
|
|
89
|
+
...MeetingDescription_1.meetingFields,
|
|
90
|
+
...InitiativeDescription_1.initiativeOperations,
|
|
91
|
+
...InitiativeDescription_1.initiativeFields,
|
|
92
|
+
...GoalDescription_1.goalOperations,
|
|
93
|
+
...GoalDescription_1.goalFields,
|
|
94
|
+
...ActionItemDescription_1.actionItemOperations,
|
|
95
|
+
...ActionItemDescription_1.actionItemFields,
|
|
96
|
+
...AssessmentDescription_1.assessmentOperations,
|
|
97
|
+
...AssessmentDescription_1.assessmentFields,
|
|
98
|
+
...NoteDescription_1.noteOperations,
|
|
99
|
+
...NoteDescription_1.noteFields,
|
|
100
|
+
...AssessmentTemplateDescription_1.assessmentTemplateOperations,
|
|
101
|
+
...AssessmentTemplateDescription_1.assessmentTemplateFields,
|
|
102
|
+
...HardwareLifecycleDescription_1.hardwareLifecycleOperations,
|
|
103
|
+
...HardwareLifecycleDescription_1.hardwareLifecycleFields,
|
|
104
|
+
...ContractDescription_1.contractOperations,
|
|
105
|
+
...ContractDescription_1.contractFields,
|
|
106
|
+
],
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
async execute() {
|
|
110
|
+
const items = this.getInputData();
|
|
111
|
+
const returnData = [];
|
|
112
|
+
const resource = this.getNodeParameter('resource', 0);
|
|
113
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
114
|
+
const basePath = '/lifecycle-manager/v1';
|
|
115
|
+
for (let i = 0; i < items.length; i++) {
|
|
116
|
+
try {
|
|
117
|
+
// ==================== MEETING ====================
|
|
118
|
+
if (resource === 'meeting') {
|
|
119
|
+
if (operation === 'create') {
|
|
120
|
+
const clientId = this.getNodeParameter('clientId', i);
|
|
121
|
+
const title = this.getNodeParameter('title', i);
|
|
122
|
+
const scheduledAt = this.getNodeParameter('scheduledAt', i);
|
|
123
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
124
|
+
const body = {
|
|
125
|
+
client_id: clientId,
|
|
126
|
+
title,
|
|
127
|
+
scheduled_at: scheduledAt,
|
|
128
|
+
...additionalFields,
|
|
129
|
+
};
|
|
130
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'POST', `${basePath}/meetings`, body);
|
|
131
|
+
returnData.push({ json: responseData });
|
|
132
|
+
}
|
|
133
|
+
if (operation === 'get') {
|
|
134
|
+
const meetingId = this.getNodeParameter('meetingId', i);
|
|
135
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'GET', `${basePath}/meetings/${meetingId}`);
|
|
136
|
+
returnData.push({ json: responseData });
|
|
137
|
+
}
|
|
138
|
+
if (operation === 'getAll') {
|
|
139
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
140
|
+
const filters = this.getNodeParameter('filters', i);
|
|
141
|
+
const qs = {};
|
|
142
|
+
if (!returnAll) {
|
|
143
|
+
qs.page_size = this.getNodeParameter('limit', i);
|
|
144
|
+
}
|
|
145
|
+
if (filters.clientId) {
|
|
146
|
+
qs['filter[client_id]'] = `eq:${filters.clientId}`;
|
|
147
|
+
}
|
|
148
|
+
if (filters.isCompleted !== undefined) {
|
|
149
|
+
qs['filter[is_completed]'] = `eq:${filters.isCompleted}`;
|
|
150
|
+
}
|
|
151
|
+
let responseData;
|
|
152
|
+
if (returnAll) {
|
|
153
|
+
responseData = await GenericFunctions_1.scalePadCoreApiRequestAllItems.call(this, 'GET', `${basePath}/meetings`, {}, qs);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
const response = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'GET', `${basePath}/meetings`, {}, qs);
|
|
157
|
+
responseData = response.data || [];
|
|
158
|
+
}
|
|
159
|
+
responseData.forEach((item) => {
|
|
160
|
+
returnData.push({ json: item });
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
if (operation === 'update') {
|
|
164
|
+
const meetingId = this.getNodeParameter('meetingId', i);
|
|
165
|
+
const updateFields = this.getNodeParameter('updateFields', i);
|
|
166
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${basePath}/meetings/${meetingId}`, updateFields);
|
|
167
|
+
returnData.push({ json: responseData });
|
|
168
|
+
}
|
|
169
|
+
if (operation === 'delete') {
|
|
170
|
+
const meetingId = this.getNodeParameter('meetingId', i);
|
|
171
|
+
await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'DELETE', `${basePath}/meetings/${meetingId}`);
|
|
172
|
+
returnData.push({ json: { success: true } });
|
|
173
|
+
}
|
|
174
|
+
if (operation === 'updateCompletionStatus') {
|
|
175
|
+
const meetingId = this.getNodeParameter('meetingId', i);
|
|
176
|
+
const isCompleted = this.getNodeParameter('isCompleted', i);
|
|
177
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${basePath}/meetings/${meetingId}/completion-status`, { is_completed: isCompleted });
|
|
178
|
+
returnData.push({ json: responseData });
|
|
179
|
+
}
|
|
180
|
+
if (operation === 'addUserAttendees') {
|
|
181
|
+
const meetingId = this.getNodeParameter('meetingId', i);
|
|
182
|
+
const userIds = this.getNodeParameter('userIds', i)
|
|
183
|
+
.split(',')
|
|
184
|
+
.map((id) => id.trim());
|
|
185
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'POST', `${basePath}/meetings/${meetingId}/attendees/users`, { user_ids: userIds });
|
|
186
|
+
returnData.push({ json: responseData });
|
|
187
|
+
}
|
|
188
|
+
if (operation === 'removeUserAttendees') {
|
|
189
|
+
const meetingId = this.getNodeParameter('meetingId', i);
|
|
190
|
+
const userIds = this.getNodeParameter('userIds', i)
|
|
191
|
+
.split(',')
|
|
192
|
+
.map((id) => id.trim());
|
|
193
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'DELETE', `${basePath}/meetings/${meetingId}/attendees/users`, { user_ids: userIds });
|
|
194
|
+
returnData.push({ json: responseData });
|
|
195
|
+
}
|
|
196
|
+
if (operation === 'addContactAttendees') {
|
|
197
|
+
const meetingId = this.getNodeParameter('meetingId', i);
|
|
198
|
+
const contactIds = this.getNodeParameter('contactIds', i)
|
|
199
|
+
.split(',')
|
|
200
|
+
.map((id) => id.trim());
|
|
201
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'POST', `${basePath}/meetings/${meetingId}/attendees/contacts`, { contact_ids: contactIds });
|
|
202
|
+
returnData.push({ json: responseData });
|
|
203
|
+
}
|
|
204
|
+
if (operation === 'removeContactAttendees') {
|
|
205
|
+
const meetingId = this.getNodeParameter('meetingId', i);
|
|
206
|
+
const contactIds = this.getNodeParameter('contactIds', i)
|
|
207
|
+
.split(',')
|
|
208
|
+
.map((id) => id.trim());
|
|
209
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'DELETE', `${basePath}/meetings/${meetingId}/attendees/contacts`, { contact_ids: contactIds });
|
|
210
|
+
returnData.push({ json: responseData });
|
|
211
|
+
}
|
|
212
|
+
if (operation === 'listInitiatives') {
|
|
213
|
+
const meetingId = this.getNodeParameter('meetingId', i);
|
|
214
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'GET', `${basePath}/meetings/${meetingId}/initiatives`);
|
|
215
|
+
returnData.push({ json: responseData });
|
|
216
|
+
}
|
|
217
|
+
if (operation === 'linkInitiative') {
|
|
218
|
+
const meetingId = this.getNodeParameter('meetingId', i);
|
|
219
|
+
const initiativeId = this.getNodeParameter('initiativeId', i);
|
|
220
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${basePath}/meetings/${meetingId}/initiatives/${initiativeId}`);
|
|
221
|
+
returnData.push({ json: responseData });
|
|
222
|
+
}
|
|
223
|
+
if (operation === 'unlinkInitiative') {
|
|
224
|
+
const meetingId = this.getNodeParameter('meetingId', i);
|
|
225
|
+
const initiativeId = this.getNodeParameter('initiativeId', i);
|
|
226
|
+
await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'DELETE', `${basePath}/meetings/${meetingId}/initiatives/${initiativeId}`);
|
|
227
|
+
returnData.push({ json: { success: true } });
|
|
228
|
+
}
|
|
229
|
+
if (operation === 'listGoals') {
|
|
230
|
+
const meetingId = this.getNodeParameter('meetingId', i);
|
|
231
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'GET', `${basePath}/meetings/${meetingId}/goals`);
|
|
232
|
+
returnData.push({ json: responseData });
|
|
233
|
+
}
|
|
234
|
+
if (operation === 'linkGoal') {
|
|
235
|
+
const meetingId = this.getNodeParameter('meetingId', i);
|
|
236
|
+
const goalId = this.getNodeParameter('goalId', i);
|
|
237
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${basePath}/meetings/${meetingId}/goals/${goalId}`);
|
|
238
|
+
returnData.push({ json: responseData });
|
|
239
|
+
}
|
|
240
|
+
if (operation === 'unlinkGoal') {
|
|
241
|
+
const meetingId = this.getNodeParameter('meetingId', i);
|
|
242
|
+
const goalId = this.getNodeParameter('goalId', i);
|
|
243
|
+
await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'DELETE', `${basePath}/meetings/${meetingId}/goals/${goalId}`);
|
|
244
|
+
returnData.push({ json: { success: true } });
|
|
245
|
+
}
|
|
246
|
+
if (operation === 'listActionItems') {
|
|
247
|
+
const meetingId = this.getNodeParameter('meetingId', i);
|
|
248
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'GET', `${basePath}/meetings/${meetingId}/action-items`);
|
|
249
|
+
returnData.push({ json: responseData });
|
|
250
|
+
}
|
|
251
|
+
if (operation === 'linkActionItem') {
|
|
252
|
+
const meetingId = this.getNodeParameter('meetingId', i);
|
|
253
|
+
const actionItemId = this.getNodeParameter('actionItemId', i);
|
|
254
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${basePath}/meetings/${meetingId}/action-items/${actionItemId}`);
|
|
255
|
+
returnData.push({ json: responseData });
|
|
256
|
+
}
|
|
257
|
+
if (operation === 'unlinkActionItem') {
|
|
258
|
+
const meetingId = this.getNodeParameter('meetingId', i);
|
|
259
|
+
const actionItemId = this.getNodeParameter('actionItemId', i);
|
|
260
|
+
await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'DELETE', `${basePath}/meetings/${meetingId}/action-items/${actionItemId}`);
|
|
261
|
+
returnData.push({ json: { success: true } });
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
// ==================== INITIATIVE ====================
|
|
265
|
+
if (resource === 'initiative') {
|
|
266
|
+
if (operation === 'create') {
|
|
267
|
+
const clientId = this.getNodeParameter('clientId', i);
|
|
268
|
+
const title = this.getNodeParameter('title', i);
|
|
269
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
270
|
+
const body = {
|
|
271
|
+
client_id: clientId,
|
|
272
|
+
title,
|
|
273
|
+
...additionalFields,
|
|
274
|
+
};
|
|
275
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'POST', `${basePath}/initiatives`, body);
|
|
276
|
+
returnData.push({ json: responseData });
|
|
277
|
+
}
|
|
278
|
+
if (operation === 'get') {
|
|
279
|
+
const initiativeId = this.getNodeParameter('initiativeId', i);
|
|
280
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'GET', `${basePath}/initiatives/${initiativeId}`);
|
|
281
|
+
returnData.push({ json: responseData });
|
|
282
|
+
}
|
|
283
|
+
if (operation === 'getAll') {
|
|
284
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
285
|
+
const filters = this.getNodeParameter('filters', i);
|
|
286
|
+
const qs = {};
|
|
287
|
+
if (!returnAll) {
|
|
288
|
+
qs.page_size = this.getNodeParameter('limit', i);
|
|
289
|
+
}
|
|
290
|
+
if (filters.clientId) {
|
|
291
|
+
qs['filter[client_id]'] = `eq:${filters.clientId}`;
|
|
292
|
+
}
|
|
293
|
+
if (filters.status) {
|
|
294
|
+
qs['filter[status]'] = `eq:${filters.status}`;
|
|
295
|
+
}
|
|
296
|
+
if (filters.priority) {
|
|
297
|
+
qs['filter[priority]'] = `eq:${filters.priority}`;
|
|
298
|
+
}
|
|
299
|
+
let responseData;
|
|
300
|
+
if (returnAll) {
|
|
301
|
+
responseData = await GenericFunctions_1.scalePadCoreApiRequestAllItems.call(this, 'GET', `${basePath}/initiatives`, {}, qs);
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
const response = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'GET', `${basePath}/initiatives`, {}, qs);
|
|
305
|
+
responseData = response.data || [];
|
|
306
|
+
}
|
|
307
|
+
responseData.forEach((item) => {
|
|
308
|
+
returnData.push({ json: item });
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
if (operation === 'update') {
|
|
312
|
+
const initiativeId = this.getNodeParameter('initiativeId', i);
|
|
313
|
+
const updateFields = this.getNodeParameter('updateFields', i);
|
|
314
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${basePath}/initiatives/${initiativeId}`, updateFields);
|
|
315
|
+
returnData.push({ json: responseData });
|
|
316
|
+
}
|
|
317
|
+
if (operation === 'delete') {
|
|
318
|
+
const initiativeId = this.getNodeParameter('initiativeId', i);
|
|
319
|
+
await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'DELETE', `${basePath}/initiatives/${initiativeId}`);
|
|
320
|
+
returnData.push({ json: { success: true } });
|
|
321
|
+
}
|
|
322
|
+
if (operation === 'updateStatus') {
|
|
323
|
+
const initiativeId = this.getNodeParameter('initiativeId', i);
|
|
324
|
+
const status = this.getNodeParameter('status', i);
|
|
325
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${basePath}/initiatives/${initiativeId}/status`, { status });
|
|
326
|
+
returnData.push({ json: responseData });
|
|
327
|
+
}
|
|
328
|
+
if (operation === 'updateSchedule') {
|
|
329
|
+
const initiativeId = this.getNodeParameter('initiativeId', i);
|
|
330
|
+
const fiscalYear = this.getNodeParameter('fiscalYear', i);
|
|
331
|
+
const fiscalQuarter = this.getNodeParameter('fiscalQuarter', i);
|
|
332
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${basePath}/initiatives/${initiativeId}/schedule`, { fiscal_year: fiscalYear, fiscal_quarter: fiscalQuarter });
|
|
333
|
+
returnData.push({ json: responseData });
|
|
334
|
+
}
|
|
335
|
+
if (operation === 'updatePriority') {
|
|
336
|
+
const initiativeId = this.getNodeParameter('initiativeId', i);
|
|
337
|
+
const priority = this.getNodeParameter('priority', i);
|
|
338
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${basePath}/initiatives/${initiativeId}/priority`, { priority });
|
|
339
|
+
returnData.push({ json: responseData });
|
|
340
|
+
}
|
|
341
|
+
if (operation === 'updateBudget') {
|
|
342
|
+
const initiativeId = this.getNodeParameter('initiativeId', i);
|
|
343
|
+
const oneTimeInvestment = this.getNodeParameter('oneTimeInvestment', i);
|
|
344
|
+
const recurringInvestment = this.getNodeParameter('recurringInvestment', i);
|
|
345
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${basePath}/initiatives/${initiativeId}/budget`, {
|
|
346
|
+
one_time_investment: oneTimeInvestment,
|
|
347
|
+
recurring_investment: recurringInvestment,
|
|
348
|
+
});
|
|
349
|
+
returnData.push({ json: responseData });
|
|
350
|
+
}
|
|
351
|
+
if (operation === 'listMeetings') {
|
|
352
|
+
const initiativeId = this.getNodeParameter('initiativeId', i);
|
|
353
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'GET', `${basePath}/initiatives/${initiativeId}/meetings`);
|
|
354
|
+
returnData.push({ json: responseData });
|
|
355
|
+
}
|
|
356
|
+
if (operation === 'linkMeeting') {
|
|
357
|
+
const initiativeId = this.getNodeParameter('initiativeId', i);
|
|
358
|
+
const meetingId = this.getNodeParameter('meetingId', i);
|
|
359
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${basePath}/initiatives/${initiativeId}/meetings/${meetingId}`);
|
|
360
|
+
returnData.push({ json: responseData });
|
|
361
|
+
}
|
|
362
|
+
if (operation === 'unlinkMeeting') {
|
|
363
|
+
const initiativeId = this.getNodeParameter('initiativeId', i);
|
|
364
|
+
const meetingId = this.getNodeParameter('meetingId', i);
|
|
365
|
+
await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'DELETE', `${basePath}/initiatives/${initiativeId}/meetings/${meetingId}`);
|
|
366
|
+
returnData.push({ json: { success: true } });
|
|
367
|
+
}
|
|
368
|
+
if (operation === 'listGoals') {
|
|
369
|
+
const initiativeId = this.getNodeParameter('initiativeId', i);
|
|
370
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'GET', `${basePath}/initiatives/${initiativeId}/goals`);
|
|
371
|
+
returnData.push({ json: responseData });
|
|
372
|
+
}
|
|
373
|
+
if (operation === 'linkGoal') {
|
|
374
|
+
const initiativeId = this.getNodeParameter('initiativeId', i);
|
|
375
|
+
const goalId = this.getNodeParameter('goalId', i);
|
|
376
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${basePath}/initiatives/${initiativeId}/goals/${goalId}`);
|
|
377
|
+
returnData.push({ json: responseData });
|
|
378
|
+
}
|
|
379
|
+
if (operation === 'unlinkGoal') {
|
|
380
|
+
const initiativeId = this.getNodeParameter('initiativeId', i);
|
|
381
|
+
const goalId = this.getNodeParameter('goalId', i);
|
|
382
|
+
await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'DELETE', `${basePath}/initiatives/${initiativeId}/goals/${goalId}`);
|
|
383
|
+
returnData.push({ json: { success: true } });
|
|
384
|
+
}
|
|
385
|
+
if (operation === 'listActionItems') {
|
|
386
|
+
const initiativeId = this.getNodeParameter('initiativeId', i);
|
|
387
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'GET', `${basePath}/initiatives/${initiativeId}/action-items`);
|
|
388
|
+
returnData.push({ json: responseData });
|
|
389
|
+
}
|
|
390
|
+
if (operation === 'linkActionItem') {
|
|
391
|
+
const initiativeId = this.getNodeParameter('initiativeId', i);
|
|
392
|
+
const actionItemId = this.getNodeParameter('actionItemId', i);
|
|
393
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${basePath}/initiatives/${initiativeId}/action-items/${actionItemId}`);
|
|
394
|
+
returnData.push({ json: responseData });
|
|
395
|
+
}
|
|
396
|
+
if (operation === 'unlinkActionItem') {
|
|
397
|
+
const initiativeId = this.getNodeParameter('initiativeId', i);
|
|
398
|
+
const actionItemId = this.getNodeParameter('actionItemId', i);
|
|
399
|
+
await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'DELETE', `${basePath}/initiatives/${initiativeId}/action-items/${actionItemId}`);
|
|
400
|
+
returnData.push({ json: { success: true } });
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
// ==================== GOAL ====================
|
|
404
|
+
if (resource === 'goal') {
|
|
405
|
+
if (operation === 'create') {
|
|
406
|
+
const clientId = this.getNodeParameter('clientId', i);
|
|
407
|
+
const title = this.getNodeParameter('title', i);
|
|
408
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
409
|
+
const body = {
|
|
410
|
+
client_id: clientId,
|
|
411
|
+
title,
|
|
412
|
+
...additionalFields,
|
|
413
|
+
};
|
|
414
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'POST', `${basePath}/goals`, body);
|
|
415
|
+
returnData.push({ json: responseData });
|
|
416
|
+
}
|
|
417
|
+
if (operation === 'get') {
|
|
418
|
+
const goalId = this.getNodeParameter('goalId', i);
|
|
419
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'GET', `${basePath}/goals/${goalId}`);
|
|
420
|
+
returnData.push({ json: responseData });
|
|
421
|
+
}
|
|
422
|
+
if (operation === 'getAll') {
|
|
423
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
424
|
+
const filters = this.getNodeParameter('filters', i);
|
|
425
|
+
const qs = {};
|
|
426
|
+
if (!returnAll) {
|
|
427
|
+
qs.page_size = this.getNodeParameter('limit', i);
|
|
428
|
+
}
|
|
429
|
+
if (filters.clientId) {
|
|
430
|
+
qs['filter[client_id]'] = `eq:${filters.clientId}`;
|
|
431
|
+
}
|
|
432
|
+
if (filters.status) {
|
|
433
|
+
qs['filter[status]'] = `eq:${filters.status}`;
|
|
434
|
+
}
|
|
435
|
+
if (filters.category) {
|
|
436
|
+
qs['filter[category]'] = `eq:${filters.category}`;
|
|
437
|
+
}
|
|
438
|
+
let responseData;
|
|
439
|
+
if (returnAll) {
|
|
440
|
+
responseData = await GenericFunctions_1.scalePadCoreApiRequestAllItems.call(this, 'GET', `${basePath}/goals`, {}, qs);
|
|
441
|
+
}
|
|
442
|
+
else {
|
|
443
|
+
const response = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'GET', `${basePath}/goals`, {}, qs);
|
|
444
|
+
responseData = response.data || [];
|
|
445
|
+
}
|
|
446
|
+
responseData.forEach((item) => {
|
|
447
|
+
returnData.push({ json: item });
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
if (operation === 'update') {
|
|
451
|
+
const goalId = this.getNodeParameter('goalId', i);
|
|
452
|
+
const updateFields = this.getNodeParameter('updateFields', i);
|
|
453
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${basePath}/goals/${goalId}`, updateFields);
|
|
454
|
+
returnData.push({ json: responseData });
|
|
455
|
+
}
|
|
456
|
+
if (operation === 'delete') {
|
|
457
|
+
const goalId = this.getNodeParameter('goalId', i);
|
|
458
|
+
await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'DELETE', `${basePath}/goals/${goalId}`);
|
|
459
|
+
returnData.push({ json: { success: true } });
|
|
460
|
+
}
|
|
461
|
+
if (operation === 'updateStatus') {
|
|
462
|
+
const goalId = this.getNodeParameter('goalId', i);
|
|
463
|
+
const status = this.getNodeParameter('status', i);
|
|
464
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${basePath}/goals/${goalId}/status`, { status });
|
|
465
|
+
returnData.push({ json: responseData });
|
|
466
|
+
}
|
|
467
|
+
if (operation === 'updateSchedule') {
|
|
468
|
+
const goalId = this.getNodeParameter('goalId', i);
|
|
469
|
+
const fiscalYear = this.getNodeParameter('fiscalYear', i);
|
|
470
|
+
const fiscalQuarter = this.getNodeParameter('fiscalQuarter', i);
|
|
471
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${basePath}/goals/${goalId}/schedule`, { fiscal_year: fiscalYear, fiscal_quarter: fiscalQuarter });
|
|
472
|
+
returnData.push({ json: responseData });
|
|
473
|
+
}
|
|
474
|
+
if (operation === 'listMeetings') {
|
|
475
|
+
const goalId = this.getNodeParameter('goalId', i);
|
|
476
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'GET', `${basePath}/goals/${goalId}/meetings`);
|
|
477
|
+
returnData.push({ json: responseData });
|
|
478
|
+
}
|
|
479
|
+
if (operation === 'linkMeeting') {
|
|
480
|
+
const goalId = this.getNodeParameter('goalId', i);
|
|
481
|
+
const meetingId = this.getNodeParameter('meetingId', i);
|
|
482
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${basePath}/goals/${goalId}/meetings/${meetingId}`);
|
|
483
|
+
returnData.push({ json: responseData });
|
|
484
|
+
}
|
|
485
|
+
if (operation === 'unlinkMeeting') {
|
|
486
|
+
const goalId = this.getNodeParameter('goalId', i);
|
|
487
|
+
const meetingId = this.getNodeParameter('meetingId', i);
|
|
488
|
+
await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'DELETE', `${basePath}/goals/${goalId}/meetings/${meetingId}`);
|
|
489
|
+
returnData.push({ json: { success: true } });
|
|
490
|
+
}
|
|
491
|
+
if (operation === 'listInitiatives') {
|
|
492
|
+
const goalId = this.getNodeParameter('goalId', i);
|
|
493
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'GET', `${basePath}/goals/${goalId}/initiatives`);
|
|
494
|
+
returnData.push({ json: responseData });
|
|
495
|
+
}
|
|
496
|
+
if (operation === 'linkInitiative') {
|
|
497
|
+
const goalId = this.getNodeParameter('goalId', i);
|
|
498
|
+
const initiativeId = this.getNodeParameter('initiativeId', i);
|
|
499
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${basePath}/goals/${goalId}/initiatives/${initiativeId}`);
|
|
500
|
+
returnData.push({ json: responseData });
|
|
501
|
+
}
|
|
502
|
+
if (operation === 'unlinkInitiative') {
|
|
503
|
+
const goalId = this.getNodeParameter('goalId', i);
|
|
504
|
+
const initiativeId = this.getNodeParameter('initiativeId', i);
|
|
505
|
+
await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'DELETE', `${basePath}/goals/${goalId}/initiatives/${initiativeId}`);
|
|
506
|
+
returnData.push({ json: { success: true } });
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
// ==================== ACTION ITEM ====================
|
|
510
|
+
if (resource === 'actionItem') {
|
|
511
|
+
if (operation === 'create') {
|
|
512
|
+
const clientId = this.getNodeParameter('clientId', i);
|
|
513
|
+
const title = this.getNodeParameter('title', i);
|
|
514
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
515
|
+
const body = {
|
|
516
|
+
client_id: clientId,
|
|
517
|
+
title,
|
|
518
|
+
...additionalFields,
|
|
519
|
+
};
|
|
520
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'POST', `${basePath}/action-items`, body);
|
|
521
|
+
returnData.push({ json: responseData });
|
|
522
|
+
}
|
|
523
|
+
if (operation === 'get') {
|
|
524
|
+
const actionItemId = this.getNodeParameter('actionItemId', i);
|
|
525
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'GET', `${basePath}/action-items/${actionItemId}`);
|
|
526
|
+
returnData.push({ json: responseData });
|
|
527
|
+
}
|
|
528
|
+
if (operation === 'getAll') {
|
|
529
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
530
|
+
const filters = this.getNodeParameter('filters', i);
|
|
531
|
+
const qs = {};
|
|
532
|
+
if (!returnAll) {
|
|
533
|
+
qs.page_size = this.getNodeParameter('limit', i);
|
|
534
|
+
}
|
|
535
|
+
if (filters.clientId) {
|
|
536
|
+
qs['filter[client_id]'] = `eq:${filters.clientId}`;
|
|
537
|
+
}
|
|
538
|
+
if (filters.assigneeId) {
|
|
539
|
+
qs['filter[assignee_id]'] = `eq:${filters.assigneeId}`;
|
|
540
|
+
}
|
|
541
|
+
if (filters.isCompleted !== undefined) {
|
|
542
|
+
qs['filter[is_completed]'] = `eq:${filters.isCompleted}`;
|
|
543
|
+
}
|
|
544
|
+
if (filters.priority) {
|
|
545
|
+
qs['filter[priority]'] = `eq:${filters.priority}`;
|
|
546
|
+
}
|
|
547
|
+
let responseData;
|
|
548
|
+
if (returnAll) {
|
|
549
|
+
responseData = await GenericFunctions_1.scalePadCoreApiRequestAllItems.call(this, 'GET', `${basePath}/action-items`, {}, qs);
|
|
550
|
+
}
|
|
551
|
+
else {
|
|
552
|
+
const response = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'GET', `${basePath}/action-items`, {}, qs);
|
|
553
|
+
responseData = response.data || [];
|
|
554
|
+
}
|
|
555
|
+
responseData.forEach((item) => {
|
|
556
|
+
returnData.push({ json: item });
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
if (operation === 'update') {
|
|
560
|
+
const actionItemId = this.getNodeParameter('actionItemId', i);
|
|
561
|
+
const updateFields = this.getNodeParameter('updateFields', i);
|
|
562
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${basePath}/action-items/${actionItemId}`, updateFields);
|
|
563
|
+
returnData.push({ json: responseData });
|
|
564
|
+
}
|
|
565
|
+
if (operation === 'delete') {
|
|
566
|
+
const actionItemId = this.getNodeParameter('actionItemId', i);
|
|
567
|
+
await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'DELETE', `${basePath}/action-items/${actionItemId}`);
|
|
568
|
+
returnData.push({ json: { success: true } });
|
|
569
|
+
}
|
|
570
|
+
if (operation === 'toggleCompletion') {
|
|
571
|
+
const actionItemId = this.getNodeParameter('actionItemId', i);
|
|
572
|
+
const isCompleted = this.getNodeParameter('isCompleted', i);
|
|
573
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${basePath}/action-items/${actionItemId}/completion-status`, { is_completed: isCompleted });
|
|
574
|
+
returnData.push({ json: responseData });
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
// ==================== ASSESSMENT ====================
|
|
578
|
+
if (resource === 'assessment') {
|
|
579
|
+
if (operation === 'create') {
|
|
580
|
+
const clientId = this.getNodeParameter('clientId', i);
|
|
581
|
+
const templateId = this.getNodeParameter('templateId', i);
|
|
582
|
+
const title = this.getNodeParameter('title', i);
|
|
583
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
584
|
+
const body = {
|
|
585
|
+
client_id: clientId,
|
|
586
|
+
template_id: templateId,
|
|
587
|
+
title,
|
|
588
|
+
...additionalFields,
|
|
589
|
+
};
|
|
590
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'POST', `${basePath}/assessments`, body);
|
|
591
|
+
returnData.push({ json: responseData });
|
|
592
|
+
}
|
|
593
|
+
if (operation === 'get') {
|
|
594
|
+
const assessmentId = this.getNodeParameter('assessmentId', i);
|
|
595
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'GET', `${basePath}/assessments/${assessmentId}`);
|
|
596
|
+
returnData.push({ json: responseData });
|
|
597
|
+
}
|
|
598
|
+
if (operation === 'getAll') {
|
|
599
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
600
|
+
const filters = this.getNodeParameter('filters', i);
|
|
601
|
+
const qs = {};
|
|
602
|
+
if (!returnAll) {
|
|
603
|
+
qs.page_size = this.getNodeParameter('limit', i);
|
|
604
|
+
}
|
|
605
|
+
if (filters.clientId) {
|
|
606
|
+
qs['filter[client_id]'] = `eq:${filters.clientId}`;
|
|
607
|
+
}
|
|
608
|
+
if (filters.templateId) {
|
|
609
|
+
qs['filter[template_id]'] = `eq:${filters.templateId}`;
|
|
610
|
+
}
|
|
611
|
+
if (filters.isCompleted !== undefined) {
|
|
612
|
+
qs['filter[is_completed]'] = `eq:${filters.isCompleted}`;
|
|
613
|
+
}
|
|
614
|
+
let responseData;
|
|
615
|
+
if (returnAll) {
|
|
616
|
+
responseData = await GenericFunctions_1.scalePadCoreApiRequestAllItems.call(this, 'GET', `${basePath}/assessments`, {}, qs);
|
|
617
|
+
}
|
|
618
|
+
else {
|
|
619
|
+
const response = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'GET', `${basePath}/assessments`, {}, qs);
|
|
620
|
+
responseData = response.data || [];
|
|
621
|
+
}
|
|
622
|
+
responseData.forEach((item) => {
|
|
623
|
+
returnData.push({ json: item });
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
if (operation === 'update') {
|
|
627
|
+
const assessmentId = this.getNodeParameter('assessmentId', i);
|
|
628
|
+
const updateFields = this.getNodeParameter('updateFields', i);
|
|
629
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${basePath}/assessments/${assessmentId}`, updateFields);
|
|
630
|
+
returnData.push({ json: responseData });
|
|
631
|
+
}
|
|
632
|
+
if (operation === 'delete') {
|
|
633
|
+
const assessmentId = this.getNodeParameter('assessmentId', i);
|
|
634
|
+
await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'DELETE', `${basePath}/assessments/${assessmentId}`);
|
|
635
|
+
returnData.push({ json: { success: true } });
|
|
636
|
+
}
|
|
637
|
+
if (operation === 'updateCompletionStatus') {
|
|
638
|
+
const assessmentId = this.getNodeParameter('assessmentId', i);
|
|
639
|
+
const isCompleted = this.getNodeParameter('isCompleted', i);
|
|
640
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${basePath}/assessments/${assessmentId}/completion-status`, { is_completed: isCompleted });
|
|
641
|
+
returnData.push({ json: responseData });
|
|
642
|
+
}
|
|
643
|
+
if (operation === 'evaluate') {
|
|
644
|
+
const assessmentId = this.getNodeParameter('assessmentId', i);
|
|
645
|
+
const evaluationData = this.getNodeParameter('evaluationData', i);
|
|
646
|
+
const body = JSON.parse(evaluationData);
|
|
647
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${basePath}/assessments/${assessmentId}/evaluate`, body);
|
|
648
|
+
returnData.push({ json: responseData });
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
// ==================== NOTE ====================
|
|
652
|
+
if (resource === 'note') {
|
|
653
|
+
if (operation === 'create') {
|
|
654
|
+
const clientId = this.getNodeParameter('clientId', i);
|
|
655
|
+
const title = this.getNodeParameter('title', i);
|
|
656
|
+
const content = this.getNodeParameter('content', i);
|
|
657
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
658
|
+
const body = {
|
|
659
|
+
client_id: clientId,
|
|
660
|
+
title,
|
|
661
|
+
content,
|
|
662
|
+
...additionalFields,
|
|
663
|
+
};
|
|
664
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'POST', `${basePath}/notes`, body);
|
|
665
|
+
returnData.push({ json: responseData });
|
|
666
|
+
}
|
|
667
|
+
if (operation === 'get') {
|
|
668
|
+
const noteId = this.getNodeParameter('noteId', i);
|
|
669
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'GET', `${basePath}/notes/${noteId}`);
|
|
670
|
+
returnData.push({ json: responseData });
|
|
671
|
+
}
|
|
672
|
+
if (operation === 'getAll') {
|
|
673
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
674
|
+
const filters = this.getNodeParameter('filters', i);
|
|
675
|
+
const qs = {};
|
|
676
|
+
if (!returnAll) {
|
|
677
|
+
qs.page_size = this.getNodeParameter('limit', i);
|
|
678
|
+
}
|
|
679
|
+
if (filters.clientId) {
|
|
680
|
+
qs['filter[client_id]'] = `eq:${filters.clientId}`;
|
|
681
|
+
}
|
|
682
|
+
if (filters.isArchived !== undefined) {
|
|
683
|
+
qs['filter[is_archived]'] = `eq:${filters.isArchived}`;
|
|
684
|
+
}
|
|
685
|
+
if (filters.noteType) {
|
|
686
|
+
qs['filter[note_type]'] = `eq:${filters.noteType}`;
|
|
687
|
+
}
|
|
688
|
+
let responseData;
|
|
689
|
+
if (returnAll) {
|
|
690
|
+
responseData = await GenericFunctions_1.scalePadCoreApiRequestAllItems.call(this, 'GET', `${basePath}/notes`, {}, qs);
|
|
691
|
+
}
|
|
692
|
+
else {
|
|
693
|
+
const response = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'GET', `${basePath}/notes`, {}, qs);
|
|
694
|
+
responseData = response.data || [];
|
|
695
|
+
}
|
|
696
|
+
responseData.forEach((item) => {
|
|
697
|
+
returnData.push({ json: item });
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
if (operation === 'update') {
|
|
701
|
+
const noteId = this.getNodeParameter('noteId', i);
|
|
702
|
+
const updateFields = this.getNodeParameter('updateFields', i);
|
|
703
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${basePath}/notes/${noteId}`, updateFields);
|
|
704
|
+
returnData.push({ json: responseData });
|
|
705
|
+
}
|
|
706
|
+
if (operation === 'toggleArchiveStatus') {
|
|
707
|
+
const noteId = this.getNodeParameter('noteId', i);
|
|
708
|
+
const isArchived = this.getNodeParameter('isArchived', i);
|
|
709
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${basePath}/notes/${noteId}/archive-status`, { is_archived: isArchived });
|
|
710
|
+
returnData.push({ json: responseData });
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
// ==================== ASSESSMENT TEMPLATE ====================
|
|
714
|
+
if (resource === 'assessmentTemplate') {
|
|
715
|
+
if (operation === 'getAll') {
|
|
716
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
717
|
+
const qs = {};
|
|
718
|
+
if (!returnAll) {
|
|
719
|
+
qs.page_size = this.getNodeParameter('limit', i);
|
|
720
|
+
}
|
|
721
|
+
let responseData;
|
|
722
|
+
if (returnAll) {
|
|
723
|
+
responseData = await GenericFunctions_1.scalePadCoreApiRequestAllItems.call(this, 'GET', `${basePath}/assessment-templates`, {}, qs);
|
|
724
|
+
}
|
|
725
|
+
else {
|
|
726
|
+
const response = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'GET', `${basePath}/assessment-templates`, {}, qs);
|
|
727
|
+
responseData = response.data || [];
|
|
728
|
+
}
|
|
729
|
+
responseData.forEach((item) => {
|
|
730
|
+
returnData.push({ json: item });
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
// ==================== HARDWARE LIFECYCLE ====================
|
|
735
|
+
if (resource === 'hardwareLifecycle') {
|
|
736
|
+
if (operation === 'getAll') {
|
|
737
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
738
|
+
const filters = this.getNodeParameter('filters', i);
|
|
739
|
+
const qs = {};
|
|
740
|
+
if (!returnAll) {
|
|
741
|
+
qs.page_size = this.getNodeParameter('limit', i);
|
|
742
|
+
}
|
|
743
|
+
if (filters.clientId) {
|
|
744
|
+
qs['filter[client_id]'] = `eq:${filters.clientId}`;
|
|
745
|
+
}
|
|
746
|
+
let responseData;
|
|
747
|
+
if (returnAll) {
|
|
748
|
+
responseData = await GenericFunctions_1.scalePadCoreApiRequestAllItems.call(this, 'GET', `${basePath}/assets/hardware-lifecycles`, {}, qs);
|
|
749
|
+
}
|
|
750
|
+
else {
|
|
751
|
+
const response = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'GET', `${basePath}/assets/hardware-lifecycles`, {}, qs);
|
|
752
|
+
responseData = response.data || [];
|
|
753
|
+
}
|
|
754
|
+
responseData.forEach((item) => {
|
|
755
|
+
returnData.push({ json: item });
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
// ==================== CONTRACT ====================
|
|
760
|
+
if (resource === 'contract') {
|
|
761
|
+
if (operation === 'create') {
|
|
762
|
+
const clientId = this.getNodeParameter('clientId', i);
|
|
763
|
+
const name = this.getNodeParameter('name', i);
|
|
764
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
765
|
+
const body = {
|
|
766
|
+
client_id: clientId,
|
|
767
|
+
name,
|
|
768
|
+
...additionalFields,
|
|
769
|
+
};
|
|
770
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'POST', `${basePath}/contracts`, body);
|
|
771
|
+
returnData.push({ json: responseData });
|
|
772
|
+
}
|
|
773
|
+
if (operation === 'get') {
|
|
774
|
+
const contractId = this.getNodeParameter('contractId', i);
|
|
775
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'GET', `${basePath}/contracts/${contractId}`);
|
|
776
|
+
returnData.push({ json: responseData });
|
|
777
|
+
}
|
|
778
|
+
if (operation === 'getAll') {
|
|
779
|
+
const returnAll = this.getNodeParameter('returnAll', i);
|
|
780
|
+
const filters = this.getNodeParameter('filters', i);
|
|
781
|
+
const qs = {};
|
|
782
|
+
if (!returnAll) {
|
|
783
|
+
qs.page_size = this.getNodeParameter('limit', i);
|
|
784
|
+
}
|
|
785
|
+
if (filters.clientId) {
|
|
786
|
+
qs['filter[client_id]'] = `eq:${filters.clientId}`;
|
|
787
|
+
}
|
|
788
|
+
if (filters.contractType) {
|
|
789
|
+
qs['filter[contract_type]'] = `eq:${filters.contractType}`;
|
|
790
|
+
}
|
|
791
|
+
if (filters.vendor) {
|
|
792
|
+
qs['filter[vendor]'] = `eq:${filters.vendor}`;
|
|
793
|
+
}
|
|
794
|
+
let responseData;
|
|
795
|
+
if (returnAll) {
|
|
796
|
+
responseData = await GenericFunctions_1.scalePadCoreApiRequestAllItems.call(this, 'GET', `${basePath}/contracts`, {}, qs);
|
|
797
|
+
}
|
|
798
|
+
else {
|
|
799
|
+
const response = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'GET', `${basePath}/contracts`, {}, qs);
|
|
800
|
+
responseData = response.data || [];
|
|
801
|
+
}
|
|
802
|
+
responseData.forEach((item) => {
|
|
803
|
+
returnData.push({ json: item });
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
if (operation === 'update') {
|
|
807
|
+
const contractId = this.getNodeParameter('contractId', i);
|
|
808
|
+
const updateFields = this.getNodeParameter('updateFields', i);
|
|
809
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${basePath}/contracts/${contractId}`, updateFields);
|
|
810
|
+
returnData.push({ json: responseData });
|
|
811
|
+
}
|
|
812
|
+
if (operation === 'delete') {
|
|
813
|
+
const contractId = this.getNodeParameter('contractId', i);
|
|
814
|
+
await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'DELETE', `${basePath}/contracts/${contractId}`);
|
|
815
|
+
returnData.push({ json: { success: true } });
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
catch (error) {
|
|
820
|
+
if (this.continueOnFail()) {
|
|
821
|
+
returnData.push({
|
|
822
|
+
json: {
|
|
823
|
+
error: error.message,
|
|
824
|
+
},
|
|
825
|
+
pairedItem: {
|
|
826
|
+
item: i,
|
|
827
|
+
},
|
|
828
|
+
});
|
|
829
|
+
continue;
|
|
830
|
+
}
|
|
831
|
+
throw error;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
return [returnData];
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
exports.ScalePadLifecycleManager = ScalePadLifecycleManager;
|