@pokash/n8n-nodes-optima-rest-api 1.1.23 → 1.2.0
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.
|
@@ -45,13 +45,50 @@ class OptimaRestApiCredentials {
|
|
|
45
45
|
description: 'Kod firmy w Optima',
|
|
46
46
|
required: false,
|
|
47
47
|
},
|
|
48
|
+
{
|
|
49
|
+
displayName: 'Login Model',
|
|
50
|
+
name: 'loginModel',
|
|
51
|
+
type: 'options',
|
|
52
|
+
options: [
|
|
53
|
+
{
|
|
54
|
+
name: 'Subscription Model (2026+)',
|
|
55
|
+
value: 'subscription',
|
|
56
|
+
description: 'Use subscription packages (Podstawowy, FinanseBasic, LogistykaBasic, etc.)',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'Traditional Modules',
|
|
60
|
+
value: 'modules',
|
|
61
|
+
description: 'Use legacy module codes (KP, KH, FA, MAG, etc.)',
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
default: 'subscription',
|
|
65
|
+
description: 'Choose login model based on your Optima version',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
displayName: 'Subscription Packages',
|
|
69
|
+
name: 'subscriptionPackages',
|
|
70
|
+
type: 'string',
|
|
71
|
+
default: 'Podstawowy',
|
|
72
|
+
placeholder: 'Podstawowy,LogistykaBasic,FinanseBasic',
|
|
73
|
+
description: 'Subscription packages (comma-separated): Podstawowy, FinanseBasic, FinansePro, LogistykaBasic, LogistykaPro, RetailBasic, RetailPro, HRBasic, HRPro, DodatekFA, DodatekCRM, DodatekKH, DodatekOBD, DodatekOW',
|
|
74
|
+
displayOptions: {
|
|
75
|
+
show: {
|
|
76
|
+
loginModel: ['subscription'],
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
48
80
|
{
|
|
49
81
|
displayName: 'Modules',
|
|
50
82
|
name: 'modules',
|
|
51
83
|
type: 'string',
|
|
52
84
|
default: 'KP',
|
|
53
|
-
placeholder: 'KP',
|
|
54
|
-
description: 'Moduły Optima (KP
|
|
85
|
+
placeholder: 'KP,KH,FA,MAG',
|
|
86
|
+
description: 'Moduły Optima (comma-separated): KP, KH, KHP, ST, FA, MAG, PK, PKXL, CRM, ANL, DET, BIU, SRW, ODB, KB, KBP, HA, CRMP',
|
|
87
|
+
displayOptions: {
|
|
88
|
+
show: {
|
|
89
|
+
loginModel: ['modules'],
|
|
90
|
+
},
|
|
91
|
+
},
|
|
55
92
|
},
|
|
56
93
|
];
|
|
57
94
|
this.authenticate = {
|
|
@@ -71,7 +108,8 @@ class OptimaRestApiCredentials {
|
|
|
71
108
|
username: '={{$credentials.username}}',
|
|
72
109
|
password: '={{$credentials.password}}',
|
|
73
110
|
company: '={{$credentials.company}}',
|
|
74
|
-
modules: '={{$credentials.modules}}',
|
|
111
|
+
modules: '={{$credentials.loginModel === "modules" ? $credentials.modules : undefined}}',
|
|
112
|
+
subscriptionPackages: '={{$credentials.loginModel === "subscription" ? $credentials.subscriptionPackages : undefined}}',
|
|
75
113
|
},
|
|
76
114
|
},
|
|
77
115
|
};
|
|
@@ -529,7 +529,8 @@ class OptimaRestApi {
|
|
|
529
529
|
const credentials = await this.getCredentials('optimaRestApiCredentials');
|
|
530
530
|
const gatewayUrl = credentials.gatewayUrl;
|
|
531
531
|
// Create unique cache key based on credentials
|
|
532
|
-
const
|
|
532
|
+
const loginModel = credentials.loginModel || 'subscription';
|
|
533
|
+
const cacheKey = `${gatewayUrl}:${credentials.username}:${credentials.company}:${loginModel}`;
|
|
533
534
|
// Check if we have a valid cached token
|
|
534
535
|
const cached = tokenCache.get(cacheKey);
|
|
535
536
|
const now = Date.now();
|
|
@@ -540,15 +541,24 @@ class OptimaRestApi {
|
|
|
540
541
|
}
|
|
541
542
|
else {
|
|
542
543
|
// Token expired or doesn't exist, authenticate
|
|
544
|
+
// Build login body based on selected model
|
|
545
|
+
const loginBody = {
|
|
546
|
+
username: credentials.username,
|
|
547
|
+
password: credentials.password,
|
|
548
|
+
company: credentials.company,
|
|
549
|
+
};
|
|
550
|
+
if (loginModel === 'subscription') {
|
|
551
|
+
// Subscription model (Optima 2026+)
|
|
552
|
+
loginBody.subscriptionPackages = credentials.subscriptionPackages || 'Podstawowy';
|
|
553
|
+
}
|
|
554
|
+
else {
|
|
555
|
+
// Traditional modules model
|
|
556
|
+
loginBody.modules = credentials.modules || 'KP';
|
|
557
|
+
}
|
|
543
558
|
const loginResponse = await this.helpers.request({
|
|
544
559
|
method: 'POST',
|
|
545
560
|
url: `${gatewayUrl}/api/account/login`,
|
|
546
|
-
body:
|
|
547
|
-
username: credentials.username,
|
|
548
|
-
password: credentials.password,
|
|
549
|
-
company: credentials.company,
|
|
550
|
-
modules: credentials.modules || 'KP',
|
|
551
|
-
},
|
|
561
|
+
body: loginBody,
|
|
552
562
|
json: true,
|
|
553
563
|
});
|
|
554
564
|
token = loginResponse.Token;
|