@joshuanode/n8n-nodes-scalepad 0.0.7 → 0.0.8
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.
|
@@ -519,68 +519,89 @@ class ScalePadCore {
|
|
|
519
519
|
const clientId = this.getNodeParameter('clientId', i);
|
|
520
520
|
const title = this.getNodeParameter('title', i);
|
|
521
521
|
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
522
|
-
//
|
|
522
|
+
// Create initiative: API accepts client_key (nested), name, executive_summary
|
|
523
523
|
const body = {
|
|
524
|
-
|
|
524
|
+
client_key: { id: clientId },
|
|
525
525
|
name: title,
|
|
526
526
|
};
|
|
527
527
|
if (additionalFields.description) {
|
|
528
528
|
body.executive_summary = additionalFields.description;
|
|
529
529
|
}
|
|
530
|
-
|
|
530
|
+
const createResponse = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'POST', `${lmBasePath}/initiatives`, body);
|
|
531
|
+
const initiativeId = createResponse.id;
|
|
532
|
+
const result = { ...createResponse };
|
|
533
|
+
// Status, priority, schedule, and budget are set via separate PUT endpoints
|
|
534
|
+
if (initiativeId) {
|
|
531
535
|
const statusMap = {
|
|
532
|
-
draft: '
|
|
536
|
+
draft: 'New',
|
|
533
537
|
proposed: 'Proposed',
|
|
534
538
|
approved: 'Approved',
|
|
535
539
|
in_progress: 'InProgress',
|
|
536
540
|
completed: 'Completed',
|
|
537
541
|
on_hold: 'OnHold',
|
|
538
|
-
cancelled: '
|
|
542
|
+
cancelled: 'Declined',
|
|
539
543
|
};
|
|
540
|
-
body.status = statusMap[additionalFields.status] || additionalFields.status;
|
|
541
|
-
}
|
|
542
|
-
if (additionalFields.priority) {
|
|
543
544
|
const priorityMap = {
|
|
545
|
+
none: 'None',
|
|
544
546
|
low: 'Low',
|
|
545
547
|
medium: 'Medium',
|
|
546
548
|
high: 'High',
|
|
547
|
-
critical: '
|
|
549
|
+
critical: 'High',
|
|
548
550
|
};
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
551
|
+
if (additionalFields.status) {
|
|
552
|
+
const mappedStatus = statusMap[additionalFields.status] || additionalFields.status;
|
|
553
|
+
try {
|
|
554
|
+
await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${lmBasePath}/initiatives/${initiativeId}/status`, { status: mappedStatus });
|
|
555
|
+
result.status = mappedStatus;
|
|
556
|
+
}
|
|
557
|
+
catch (e) { /* non-critical */ }
|
|
558
|
+
}
|
|
559
|
+
if (additionalFields.priority) {
|
|
560
|
+
const mappedPriority = priorityMap[additionalFields.priority] || additionalFields.priority;
|
|
561
|
+
try {
|
|
562
|
+
await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${lmBasePath}/initiatives/${initiativeId}/priority`, { priority: mappedPriority });
|
|
563
|
+
result.priority = mappedPriority;
|
|
564
|
+
}
|
|
565
|
+
catch (e) { /* non-critical */ }
|
|
566
|
+
}
|
|
567
|
+
if (additionalFields.fiscal_year || additionalFields.fiscal_quarter) {
|
|
568
|
+
try {
|
|
569
|
+
await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${lmBasePath}/initiatives/${initiativeId}/schedule`, {
|
|
570
|
+
fiscal_quarter: {
|
|
571
|
+
year: additionalFields.fiscal_year || new Date().getFullYear(),
|
|
572
|
+
quarter: additionalFields.fiscal_quarter || 1,
|
|
573
|
+
},
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
catch (e) { /* non-critical */ }
|
|
566
577
|
}
|
|
567
578
|
if (additionalFields.recurring_investment && additionalFields.recurring_investment > 0) {
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
579
|
+
try {
|
|
580
|
+
await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${lmBasePath}/initiatives/${initiativeId}/recurring`, {
|
|
581
|
+
recurring_line_items: [{
|
|
582
|
+
label: 'Recurring Investment',
|
|
583
|
+
cost_subunits: Math.round(additionalFields.recurring_investment * 100),
|
|
584
|
+
cost_type: 'Fixed',
|
|
585
|
+
frequency: 'Monthly',
|
|
586
|
+
}],
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
catch (e) { /* non-critical */ }
|
|
573
590
|
}
|
|
574
|
-
if (
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
591
|
+
if (additionalFields.one_time_investment && additionalFields.one_time_investment > 0) {
|
|
592
|
+
try {
|
|
593
|
+
await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${lmBasePath}/initiatives/${initiativeId}/budget`, {
|
|
594
|
+
budget_line_items: [{
|
|
595
|
+
label: 'One-Time Investment',
|
|
596
|
+
cost_subunits: Math.round(additionalFields.one_time_investment * 100),
|
|
597
|
+
cost_type: 'Fixed',
|
|
598
|
+
}],
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
catch (e) { /* non-critical */ }
|
|
580
602
|
}
|
|
581
603
|
}
|
|
582
|
-
|
|
583
|
-
returnData.push({ json: responseData });
|
|
604
|
+
returnData.push({ json: result });
|
|
584
605
|
}
|
|
585
606
|
if (operation === 'get') {
|
|
586
607
|
const initiativeId = this.getNodeParameter('initiativeId', i);
|
|
@@ -644,7 +665,7 @@ class ScalePadCore {
|
|
|
644
665
|
in_progress: 'InProgress',
|
|
645
666
|
completed: 'Completed',
|
|
646
667
|
on_hold: 'OnHold',
|
|
647
|
-
cancelled: '
|
|
668
|
+
cancelled: 'Declined',
|
|
648
669
|
};
|
|
649
670
|
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${lmBasePath}/initiatives/${initiativeId}/status`, { status: statusMap[status] || status });
|
|
650
671
|
returnData.push({ json: responseData });
|
|
@@ -653,17 +674,18 @@ class ScalePadCore {
|
|
|
653
674
|
const initiativeId = this.getNodeParameter('initiativeId', i);
|
|
654
675
|
const fiscalYear = this.getNodeParameter('fiscalYear', i);
|
|
655
676
|
const fiscalQuarter = this.getNodeParameter('fiscalQuarter', i);
|
|
656
|
-
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${lmBasePath}/initiatives/${initiativeId}/schedule`, {
|
|
677
|
+
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${lmBasePath}/initiatives/${initiativeId}/schedule`, { fiscal_quarter: { year: fiscalYear, quarter: fiscalQuarter } });
|
|
657
678
|
returnData.push({ json: responseData });
|
|
658
679
|
}
|
|
659
680
|
if (operation === 'updatePriority') {
|
|
660
681
|
const initiativeId = this.getNodeParameter('initiativeId', i);
|
|
661
682
|
const priority = this.getNodeParameter('priority', i);
|
|
662
683
|
const priorityMap = {
|
|
684
|
+
none: 'None',
|
|
663
685
|
low: 'Low',
|
|
664
686
|
medium: 'Medium',
|
|
665
687
|
high: 'High',
|
|
666
|
-
critical: '
|
|
688
|
+
critical: 'High',
|
|
667
689
|
};
|
|
668
690
|
const responseData = await GenericFunctions_1.scalePadCoreApiRequest.call(this, 'PUT', `${lmBasePath}/initiatives/${initiativeId}/priority`, { priority: priorityMap[priority] || priority });
|
|
669
691
|
returnData.push({ json: responseData });
|
|
@@ -16,11 +16,17 @@ async function scalePadCoreApiRequest(method, endpoint, body = {}, qs = {}) {
|
|
|
16
16
|
: 'https://api-sandbox.scalepad.com';
|
|
17
17
|
const options = {
|
|
18
18
|
method,
|
|
19
|
-
body,
|
|
20
19
|
qs,
|
|
21
20
|
uri: `${baseUrl}${endpoint}`,
|
|
22
21
|
json: true,
|
|
22
|
+
headers: {
|
|
23
|
+
'Content-Type': method === 'GET' ? 'application/json' : 'application/json-patch+json',
|
|
24
|
+
},
|
|
23
25
|
};
|
|
26
|
+
// Only include body for non-GET requests
|
|
27
|
+
if (method !== 'GET') {
|
|
28
|
+
options.body = body;
|
|
29
|
+
}
|
|
24
30
|
try {
|
|
25
31
|
return await this.helpers.requestWithAuthentication.call(this, 'scalePadCoreApi', options);
|
|
26
32
|
}
|