@limetech/n8n-nodes-lime 0.2.9 → 0.3.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.
- package/.dockerignore +1 -0
- package/.github/workflows/lint.yml +21 -0
- package/.github/workflows/release.yml +82 -0
- package/.github/workflows/test-and-build.yml +47 -0
- package/.prettierignore +4 -0
- package/.prettierrc.mjs +1 -0
- package/.releaserc.json +34 -0
- package/CHANGELOG.md +74 -0
- package/Dockerfile +21 -0
- package/README.md +4 -0
- package/credentials/FortnoxApi.credentials.ts +61 -0
- package/credentials/LimeCrmApi.credentials.ts +60 -0
- package/docker-compose.yml +46 -0
- package/eslint.config.mjs +27 -0
- package/jest.config.js +11 -0
- package/nodes/fortnox/Fortnox.node.json +18 -0
- package/nodes/fortnox/Fortnox.node.ts +102 -0
- package/nodes/fortnox/FortnoxTrigger.node.json +18 -0
- package/nodes/fortnox/FortnoxTrigger.node.ts +196 -0
- package/nodes/fortnox/commons.ts +94 -0
- package/nodes/fortnox/fortnoxLogo.svg +15 -0
- package/nodes/fortnox/model.ts +25 -0
- package/nodes/fortnox/resources/customers/filterParameters.ts +47 -0
- package/nodes/fortnox/resources/customers/index.ts +57 -0
- package/nodes/fortnox/resources/customers/model.ts +107 -0
- package/nodes/fortnox/resources/customers/operations/create.operation.ts +303 -0
- package/nodes/fortnox/resources/customers/operations/delete.operation.ts +44 -0
- package/nodes/fortnox/resources/customers/operations/get.operation.ts +45 -0
- package/nodes/fortnox/resources/customers/operations/getAll.operation.ts +80 -0
- package/nodes/fortnox/resources/customers/operations/update.operation.ts +278 -0
- package/nodes/fortnox/resources/customers/sortParameters.ts +32 -0
- package/nodes/fortnox/resources/invoice/filterParameters.ts +88 -0
- package/nodes/fortnox/resources/invoice/index.ts +51 -0
- package/nodes/fortnox/resources/invoice/invoiceParameters.ts +214 -0
- package/nodes/fortnox/resources/invoice/model.ts +160 -0
- package/nodes/fortnox/resources/invoice/operations/create.operation.ts +72 -0
- package/nodes/fortnox/resources/invoice/operations/get.operation.ts +45 -0
- package/nodes/fortnox/resources/invoice/operations/getAll.operation.ts +101 -0
- package/nodes/fortnox/resources/invoice/operations/update.operation.ts +74 -0
- package/nodes/fortnox/transport/errorCodes.ts +62 -0
- package/nodes/fortnox/transport/index.ts +98 -0
- package/nodes/lime-crm/LimeCrm.node.json +18 -0
- package/nodes/lime-crm/LimeCrmNode.node.ts +135 -0
- package/nodes/lime-crm/LimeCrmTrigger.node.ts +263 -0
- package/nodes/lime-crm/assets/lime-crm.svg +1 -0
- package/nodes/lime-crm/commons/constants.ts +9 -0
- package/nodes/lime-crm/commons/index.ts +9 -0
- package/nodes/lime-crm/commons/limetype.ts +11 -0
- package/nodes/lime-crm/commons/task.ts +55 -0
- package/nodes/lime-crm/commons/webhook.ts +50 -0
- package/nodes/lime-crm/methods/getEntitiesForErpSystem.ts +11 -0
- package/nodes/lime-crm/methods/getLimeTypeProperties.ts +27 -0
- package/nodes/lime-crm/methods/getLimeTypes.ts +23 -0
- package/nodes/lime-crm/methods/index.ts +3 -0
- package/nodes/lime-crm/resources/erpConnector/index.ts +43 -0
- package/nodes/lime-crm/resources/erpConnector/operations/createOrUpdateObjects.operation.ts +69 -0
- package/nodes/lime-crm/resources/erpConnector/operations/transform.operation.ts +274 -0
- package/nodes/lime-crm/resources/erpConnector/transform.ts +49 -0
- package/nodes/lime-crm/resources/erpConnector/transformers/baseTransformer.ts +18 -0
- package/nodes/lime-crm/resources/erpConnector/transformers/fortnox.ts +201 -0
- package/nodes/lime-crm/resources/erpConnector/transformers/index.ts +1 -0
- package/nodes/lime-crm/resources/limeObject/index.ts +64 -0
- package/nodes/lime-crm/resources/limeObject/operations/create.operation.ts +152 -0
- package/nodes/lime-crm/resources/limeObject/operations/delete.operation.ts +55 -0
- package/nodes/lime-crm/resources/limeObject/operations/get.operation.ts +54 -0
- package/nodes/lime-crm/resources/limeObject/operations/search.operation.ts +99 -0
- package/nodes/lime-crm/resources/limeObject/operations/update.operation.ts +157 -0
- package/nodes/lime-crm/resources/limeType/index.ts +58 -0
- package/nodes/lime-crm/resources/limeType/operations/getProperties.operation.ts +42 -0
- package/nodes/lime-crm/resources/limeType/operations/getType.operation.ts +36 -0
- package/nodes/lime-crm/resources/limeType/operations/listTypes.operation.ts +18 -0
- package/nodes/lime-crm/transport/commons.ts +44 -0
- package/nodes/lime-crm/transport/erpConnector.ts +21 -0
- package/nodes/lime-crm/transport/index.ts +17 -0
- package/nodes/lime-crm/transport/limeobjects.ts +83 -0
- package/nodes/lime-crm/transport/limetypes.ts +68 -0
- package/nodes/lime-crm/transport/task.ts +32 -0
- package/nodes/lime-crm/transport/webhooks.ts +61 -0
- package/nodes/nodeResponse.ts +13 -0
- package/package.json +36 -16
- package/tests/fixtures/fortnox.ts +182 -0
- package/tests/transform.spec.ts +187 -0
- package/tsconfig.json +30 -0
- package/index.js +0 -3
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import {
|
|
2
|
+
INodeType,
|
|
3
|
+
INodeTypeDescription,
|
|
4
|
+
ITriggerFunctions,
|
|
5
|
+
ITriggerResponse,
|
|
6
|
+
NodeConnectionType,
|
|
7
|
+
NodeOperationError,
|
|
8
|
+
} from 'n8n-workflow';
|
|
9
|
+
import WebSocket from 'ws';
|
|
10
|
+
import { FORTNOX_API_CREDENTIAL_KEY } from './commons';
|
|
11
|
+
|
|
12
|
+
interface Topic {
|
|
13
|
+
topic: string;
|
|
14
|
+
offset?: string | null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface Topics {
|
|
18
|
+
topics: Topic[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class FortnoxTrigger implements INodeType {
|
|
22
|
+
description: INodeTypeDescription = {
|
|
23
|
+
displayName: 'Fortnox Trigger',
|
|
24
|
+
name: 'fortnoxTrigger',
|
|
25
|
+
icon: 'file:fortnoxLogo.svg',
|
|
26
|
+
group: ['trigger'],
|
|
27
|
+
version: 1,
|
|
28
|
+
description:
|
|
29
|
+
"Triggers workflows in real time by subscribing to Fortnox's WebSocket API for updates " +
|
|
30
|
+
'on selected topics like invoices or customers.',
|
|
31
|
+
defaults: {
|
|
32
|
+
name: 'Fortnox Trigger',
|
|
33
|
+
},
|
|
34
|
+
inputs: [],
|
|
35
|
+
outputs: [NodeConnectionType.Main],
|
|
36
|
+
credentials: [
|
|
37
|
+
{
|
|
38
|
+
name: FORTNOX_API_CREDENTIAL_KEY,
|
|
39
|
+
required: true,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
properties: [
|
|
43
|
+
{
|
|
44
|
+
displayName: 'Include Child Tenants',
|
|
45
|
+
name: 'includeChildTenants',
|
|
46
|
+
type: 'boolean',
|
|
47
|
+
required: true,
|
|
48
|
+
default: false,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
displayName: 'Topics',
|
|
52
|
+
name: 'topicCollection',
|
|
53
|
+
required: true,
|
|
54
|
+
type: 'fixedCollection',
|
|
55
|
+
typeOptions: {
|
|
56
|
+
multipleValues: true,
|
|
57
|
+
},
|
|
58
|
+
default: {},
|
|
59
|
+
placeholder: 'Add Topics',
|
|
60
|
+
description: 'Topics to subscribe to',
|
|
61
|
+
options: [
|
|
62
|
+
{
|
|
63
|
+
name: 'topics',
|
|
64
|
+
displayName: 'Topics',
|
|
65
|
+
values: [
|
|
66
|
+
{
|
|
67
|
+
displayName: 'Topic',
|
|
68
|
+
name: 'topic',
|
|
69
|
+
type: 'options',
|
|
70
|
+
required: true,
|
|
71
|
+
default: 'customers',
|
|
72
|
+
options: [
|
|
73
|
+
{
|
|
74
|
+
name: 'Customers',
|
|
75
|
+
value: 'customers',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'Invoices',
|
|
79
|
+
value: 'invoices',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'Orders',
|
|
83
|
+
value: 'orders',
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
description: 'Topic to subscribe to',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
displayName: 'Offset',
|
|
90
|
+
name: 'offset',
|
|
91
|
+
type: 'string',
|
|
92
|
+
default: '',
|
|
93
|
+
description:
|
|
94
|
+
'Offset to supply in order to get events replayed up to 14 days back',
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
async trigger(this: ITriggerFunctions): Promise<ITriggerResponse> {
|
|
104
|
+
const includeChildTenants = this.getNodeParameter(
|
|
105
|
+
'includeChildTenants'
|
|
106
|
+
) as boolean;
|
|
107
|
+
const topicCollection = this.getNodeParameter(
|
|
108
|
+
'topicCollection',
|
|
109
|
+
{}
|
|
110
|
+
) as Topics;
|
|
111
|
+
|
|
112
|
+
const credentials = await this.getCredentials('fortnoxApi');
|
|
113
|
+
|
|
114
|
+
if (!credentials.clientSecret) {
|
|
115
|
+
throw new NodeOperationError(
|
|
116
|
+
this.getNode(),
|
|
117
|
+
"Credential 'Client Secret' must be provided for the node to work properly"
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const socket = new WebSocket('wss://ws.fortnox.se/topics-v1');
|
|
122
|
+
|
|
123
|
+
const startSocket = async () => {
|
|
124
|
+
const commands = {
|
|
125
|
+
'Add Tenants': 'add-tenants-v1',
|
|
126
|
+
'Add Topics': 'add-topics-v1',
|
|
127
|
+
Subscribe: 'subscribe-v1',
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
socket.on('open', () => {
|
|
131
|
+
socket.send(
|
|
132
|
+
JSON.stringify({
|
|
133
|
+
command: commands['Add Tenants'],
|
|
134
|
+
includeChildTenants: includeChildTenants,
|
|
135
|
+
clientSecret: credentials.clientSecret,
|
|
136
|
+
accessTokens: [`Bearer ${credentials.token}`],
|
|
137
|
+
})
|
|
138
|
+
);
|
|
139
|
+
const data = JSON.stringify({
|
|
140
|
+
command: commands['Add Topics'],
|
|
141
|
+
topics: topicCollection.topics,
|
|
142
|
+
});
|
|
143
|
+
socket.send(data);
|
|
144
|
+
|
|
145
|
+
socket.send(
|
|
146
|
+
JSON.stringify({
|
|
147
|
+
command: commands['Subscribe'],
|
|
148
|
+
})
|
|
149
|
+
);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
socket.on('message', (data: string) => {
|
|
153
|
+
const message = JSON.parse(data);
|
|
154
|
+
|
|
155
|
+
if (Object.values(commands).includes(message.response)) {
|
|
156
|
+
if (message.result != 'ok') {
|
|
157
|
+
this.emitError(
|
|
158
|
+
new NodeOperationError(
|
|
159
|
+
this.getNode(),
|
|
160
|
+
`Unexpected response from Fortnox: ${JSON.stringify(message)}`
|
|
161
|
+
)
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
} else {
|
|
165
|
+
this.emit([this.helpers.returnJsonArray(message)]);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
socket.on('error', (error: Error) => {
|
|
170
|
+
this.emitError(
|
|
171
|
+
new NodeOperationError(
|
|
172
|
+
this.getNode(),
|
|
173
|
+
'Websocket Error: ' + error.message
|
|
174
|
+
)
|
|
175
|
+
);
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const closeFunction = async () => {
|
|
180
|
+
socket.close();
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
if (this.getMode() === 'manual') {
|
|
184
|
+
async function manualTriggerFunction() {
|
|
185
|
+
await startSocket();
|
|
186
|
+
}
|
|
187
|
+
return {
|
|
188
|
+
closeFunction,
|
|
189
|
+
manualTriggerFunction,
|
|
190
|
+
};
|
|
191
|
+
} else {
|
|
192
|
+
await startSocket();
|
|
193
|
+
return { closeFunction };
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {
|
|
2
|
+
INodeProperties,
|
|
3
|
+
INodePropertyOptions,
|
|
4
|
+
INodePropertyTypeOptions,
|
|
5
|
+
} from 'n8n-workflow';
|
|
6
|
+
|
|
7
|
+
export const FORTNOX_API_CREDENTIAL_KEY = 'fortnoxApi';
|
|
8
|
+
|
|
9
|
+
export type ParameterTypes = 'string' | 'boolean' | 'number';
|
|
10
|
+
|
|
11
|
+
export type ParameterDefaultValueTypes = string | boolean | number;
|
|
12
|
+
|
|
13
|
+
export type ParameterDefinition = [
|
|
14
|
+
displayName: string,
|
|
15
|
+
name: string,
|
|
16
|
+
parameterType: ParameterTypes,
|
|
17
|
+
defaultValue: ParameterDefaultValueTypes,
|
|
18
|
+
typeOptions: INodePropertyTypeOptions,
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
export type OptionParameterDefinition = {
|
|
22
|
+
displayName: string;
|
|
23
|
+
name: string;
|
|
24
|
+
parameters: Array<[string, string]>;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type CollectionParameterDefinition = {
|
|
28
|
+
displayName: string;
|
|
29
|
+
name: string;
|
|
30
|
+
parameters: ParameterDefinition[];
|
|
31
|
+
multipleValues: boolean;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const createParameter = (
|
|
35
|
+
displayName: string,
|
|
36
|
+
name: string,
|
|
37
|
+
parameterType: ParameterTypes,
|
|
38
|
+
defaultValue: ParameterDefaultValueTypes,
|
|
39
|
+
typeOptions: INodePropertyTypeOptions
|
|
40
|
+
): INodeProperties => ({
|
|
41
|
+
displayName: displayName,
|
|
42
|
+
name: name,
|
|
43
|
+
type: parameterType,
|
|
44
|
+
default: defaultValue,
|
|
45
|
+
typeOptions: typeOptions,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export function createOptionParameter(
|
|
49
|
+
option: OptionParameterDefinition
|
|
50
|
+
): INodeProperties {
|
|
51
|
+
const parameters: INodePropertyOptions[] = option.parameters.map(
|
|
52
|
+
([parameterName, parameterValue]) => {
|
|
53
|
+
return {
|
|
54
|
+
name: parameterName,
|
|
55
|
+
value: parameterValue,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
displayName: option.displayName,
|
|
62
|
+
name: option.name,
|
|
63
|
+
type: 'options',
|
|
64
|
+
noDataExpression: true,
|
|
65
|
+
options: parameters,
|
|
66
|
+
default: parameters[0].value,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function createCollectionParameter(
|
|
71
|
+
collection: CollectionParameterDefinition
|
|
72
|
+
): INodeProperties {
|
|
73
|
+
const parameters: INodeProperties[] = collection.parameters.map(
|
|
74
|
+
([displayName, name, parameterType, defaultValue, typeOptions]) =>
|
|
75
|
+
createParameter(
|
|
76
|
+
displayName,
|
|
77
|
+
name,
|
|
78
|
+
parameterType,
|
|
79
|
+
defaultValue,
|
|
80
|
+
typeOptions
|
|
81
|
+
)
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
displayName: collection.displayName,
|
|
86
|
+
typeOptions: {
|
|
87
|
+
multipleValues: collection.multipleValues,
|
|
88
|
+
},
|
|
89
|
+
name: collection.name,
|
|
90
|
+
default: {},
|
|
91
|
+
type: 'collection',
|
|
92
|
+
options: parameters,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<svg version="1.2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1550 1550" width="1550" height="1550">
|
|
2
|
+
<title>fortnox-brand-symbol-svg</title>
|
|
3
|
+
<style>
|
|
4
|
+
.s0 { fill: #003824 }
|
|
5
|
+
.s1 { fill: #007533 }
|
|
6
|
+
.s2 { fill: #ffc200 }
|
|
7
|
+
.s3 { fill: #00db33 }
|
|
8
|
+
</style>
|
|
9
|
+
<path class="s0" d="m774.4 302.8h243.3c17.6 0 27.1 9.5 27.1 27.1v129.8c0 17.5-9.4 26.9-27.1 26.9h-243.3c-56.7 0-94.5 37.9-94.5 94.6v177h337.8c17.6 0 27.1 9.5 27.1 27v129.8c0 17.6-9.4 27.1-27.1 27.1h-337.8v252.6c0 17.6-9.5 27.1-27.1 27.1h-135.1c-17.6 0-27.1-9.4-27.1-27.1v-608.1c0-168.9 114.9-283.9 283.8-283.9"/>
|
|
10
|
+
<g>
|
|
11
|
+
<path class="s1" d="m774.8 1549.9c-148.3 0-294.9-42.5-421.6-124.7-157-101.7-271.7-256.7-323.1-436.3-51-177.8-36.9-367.9 39.6-535.2 12.3-26.8 44-38.6 70.8-26.3 26.7 12.2 38.6 43.9 26.2 70.7-65.9 144.2-78 308.2-34.1 461.5 44.3 154.8 143.3 288.5 278.6 376.2 160.5 104.1 358.5 134.3 543.2 82.8 28.4-7.8 57.8 8.8 65.7 37.1 7.8 28.4-8.8 57.8-37.1 65.6-68.5 19.2-138.5 28.5-208.3 28.5z"/>
|
|
12
|
+
<path class="s2" d="m1162.9 1436.8c-17.6 0-34.9-8.8-45-24.8-15.8-24.8-8.5-57.8 16.3-73.6 81.1-51.7 148.9-118.8 201.3-199.7 200.5-309.2 112.1-723.8-197-924.3-10.1-6.6-21.2-13.2-34.7-20.9-25.6-14.5-34.7-47-20.1-72.7 14.5-25.6 47-34.7 72.7-20.1 15.5 8.7 28.3 16.4 40.2 24.1 358.5 232.5 460.9 713.4 228.4 1071.9-60.8 93.8-139.4 171.7-233.5 231.6-8.9 5.7-18.8 8.4-28.6 8.4z"/>
|
|
13
|
+
<path class="s3" d="m234 350.8c-12.5 0-25.2-4.3-35.2-13.2-22.2-19.5-24.3-53.2-4.8-75.3 186.3-211.8 473.6-305.2 749.4-243.7 28.8 6.4 46.9 34.9 40.5 63.7-6.4 28.7-34.9 46.8-63.7 40.4-237.9-53-485.5 27.6-646.3 210-10.5 11.9-25.2 18.1-39.9 18.1z"/>
|
|
14
|
+
</g>
|
|
15
|
+
</svg>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IDataObject } from 'n8n-workflow';
|
|
2
|
+
|
|
3
|
+
export interface ErrorInformationModel {
|
|
4
|
+
// fields in ErrorInformationModel can start with lowercase or uppercase,
|
|
5
|
+
code?: number;
|
|
6
|
+
Code?: number;
|
|
7
|
+
error?: number;
|
|
8
|
+
Error?: number;
|
|
9
|
+
message?: string;
|
|
10
|
+
Message?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ErrorResponseModel extends IDataObject {
|
|
14
|
+
ErrorInformation: ErrorInformationModel;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface MetaInformationModel {
|
|
18
|
+
'@TotalResources': number;
|
|
19
|
+
'@TotalPages': number;
|
|
20
|
+
'@CurrentPage': number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface ResponseModel extends IDataObject {
|
|
24
|
+
MetaInformation: MetaInformationModel;
|
|
25
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { INodeProperties } from 'n8n-workflow';
|
|
2
|
+
import {
|
|
3
|
+
createOptionParameter,
|
|
4
|
+
createParameter,
|
|
5
|
+
OptionParameterDefinition,
|
|
6
|
+
ParameterDefinition,
|
|
7
|
+
} from '../../commons';
|
|
8
|
+
|
|
9
|
+
const optionParametersDefinitions: OptionParameterDefinition[] = [
|
|
10
|
+
{
|
|
11
|
+
displayName: 'Activity',
|
|
12
|
+
name: 'filter',
|
|
13
|
+
parameters: [
|
|
14
|
+
['Active', 'active'],
|
|
15
|
+
['Inactive', 'inactive'],
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
const parametersDefinitions: ParameterDefinition[] = [
|
|
21
|
+
['Customer Number', 'customernumber', 'string', '', {}],
|
|
22
|
+
['Name', 'name', 'string', '', {}],
|
|
23
|
+
['ZIP Code', 'zipcode', 'string', '', {}],
|
|
24
|
+
['City', 'city', 'string', '', {}],
|
|
25
|
+
['Email', 'email', 'string', '', {}],
|
|
26
|
+
['Phone', 'phone', 'string', '', {}],
|
|
27
|
+
['Organisation Number', 'organisationnumber', 'string', '', {}],
|
|
28
|
+
['GLN', 'gln', 'string', '', {}],
|
|
29
|
+
['GLN Delivery', 'glndelivery', 'string', '', {}],
|
|
30
|
+
['Last Modified', 'lastmodified', 'string', '', {}],
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
export const filterParameters: INodeProperties[] = [
|
|
34
|
+
...optionParametersDefinitions.map((option) =>
|
|
35
|
+
createOptionParameter(option)
|
|
36
|
+
),
|
|
37
|
+
...parametersDefinitions.map(
|
|
38
|
+
([displayName, name, filterType, defaultValue, typeOptions]) =>
|
|
39
|
+
createParameter(
|
|
40
|
+
displayName,
|
|
41
|
+
name,
|
|
42
|
+
filterType,
|
|
43
|
+
defaultValue,
|
|
44
|
+
typeOptions
|
|
45
|
+
)
|
|
46
|
+
),
|
|
47
|
+
];
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IExecuteFunctions,
|
|
3
|
+
INodeProperties,
|
|
4
|
+
NodePropertyTypes,
|
|
5
|
+
} from 'n8n-workflow';
|
|
6
|
+
|
|
7
|
+
import * as get from './operations/get.operation';
|
|
8
|
+
import * as getAll from './operations/getAll.operation';
|
|
9
|
+
import * as create from './operations/create.operation';
|
|
10
|
+
import * as update from './operations/update.operation';
|
|
11
|
+
import * as delete_ from './operations/delete.operation';
|
|
12
|
+
|
|
13
|
+
export const customerProperties: INodeProperties[] = [
|
|
14
|
+
{
|
|
15
|
+
displayName: 'Operation',
|
|
16
|
+
name: 'operation',
|
|
17
|
+
type: 'options' as NodePropertyTypes,
|
|
18
|
+
noDataExpression: true,
|
|
19
|
+
displayOptions: {
|
|
20
|
+
show: {
|
|
21
|
+
resource: ['customer'],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
options: [
|
|
25
|
+
get.description,
|
|
26
|
+
getAll.description,
|
|
27
|
+
create.description,
|
|
28
|
+
update.description,
|
|
29
|
+
delete_.description,
|
|
30
|
+
],
|
|
31
|
+
default: 'getAll',
|
|
32
|
+
},
|
|
33
|
+
...get.properties,
|
|
34
|
+
...getAll.properties,
|
|
35
|
+
...create.properties,
|
|
36
|
+
...update.properties,
|
|
37
|
+
...delete_.properties,
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
export async function customerOperations(
|
|
41
|
+
this: IExecuteFunctions,
|
|
42
|
+
{ operation, i }: { operation: string; i: number }
|
|
43
|
+
) {
|
|
44
|
+
if (operation === 'get') {
|
|
45
|
+
return await get.execute.call(this, i);
|
|
46
|
+
} else if (operation === 'getAll') {
|
|
47
|
+
return await getAll.execute.call(this, i);
|
|
48
|
+
} else if (operation === 'create') {
|
|
49
|
+
return await create.execute.call(this, i);
|
|
50
|
+
} else if (operation === 'update') {
|
|
51
|
+
return await update.execute.call(this, i);
|
|
52
|
+
} else if (operation === 'delete') {
|
|
53
|
+
return await delete_.execute.call(this, i);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { ResponseModel } from '../../model';
|
|
2
|
+
|
|
3
|
+
export interface CustomerBase {
|
|
4
|
+
'@url': string;
|
|
5
|
+
Address1: string | null;
|
|
6
|
+
Address2: string | null;
|
|
7
|
+
City: string | null;
|
|
8
|
+
CustomerNumber: number;
|
|
9
|
+
Email: string | null;
|
|
10
|
+
Name: string;
|
|
11
|
+
OrganisationNumber: string;
|
|
12
|
+
Phone: string | null;
|
|
13
|
+
ZipCode: number | string | null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type DeliveryType = 'PRINT' | 'EMAIL' | 'PRINTSERVICE';
|
|
17
|
+
|
|
18
|
+
export interface DefaultDeliveryTypes {
|
|
19
|
+
Invoice: DeliveryType;
|
|
20
|
+
Order: DeliveryType;
|
|
21
|
+
Offer: DeliveryType;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface DefaultTemplates {
|
|
25
|
+
Order: string | null;
|
|
26
|
+
Offer: string | null;
|
|
27
|
+
Invoice: string | null;
|
|
28
|
+
CashInvoice: string | null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface CustomerDetails {
|
|
32
|
+
Address1: string | null;
|
|
33
|
+
Address2: string | null;
|
|
34
|
+
City: string | null;
|
|
35
|
+
Country: string | null;
|
|
36
|
+
Comments: string | null;
|
|
37
|
+
Currency: string;
|
|
38
|
+
CostCenter: string | null;
|
|
39
|
+
CountryCode: string | null;
|
|
40
|
+
Active: boolean;
|
|
41
|
+
CustomerNumber: string;
|
|
42
|
+
DefaultDeliveryTypes: DefaultDeliveryTypes;
|
|
43
|
+
DefaultTemplates: DefaultTemplates;
|
|
44
|
+
DeliveryAddress1: string | null;
|
|
45
|
+
DeliveryAddress2: string | null;
|
|
46
|
+
DeliveryCity: string | null;
|
|
47
|
+
DeliveryCountry: string | null;
|
|
48
|
+
DeliveryCountryCode: string | null;
|
|
49
|
+
DeliveryFax: string | null;
|
|
50
|
+
DeliveryName: string | null;
|
|
51
|
+
DeliveryPhone1: string | null;
|
|
52
|
+
DeliveryPhone2: string | null;
|
|
53
|
+
DeliveryZipCode: string | null;
|
|
54
|
+
Email: string | null;
|
|
55
|
+
EmailInvoice: string | null;
|
|
56
|
+
EmailInvoiceBCC: string | null;
|
|
57
|
+
EmailInvoiceCC: string | null;
|
|
58
|
+
EmailOffer: string | null;
|
|
59
|
+
EmailOfferBCC: string | null;
|
|
60
|
+
EmailOfferCC: string | null;
|
|
61
|
+
EmailOrder: string | null;
|
|
62
|
+
EmailOrderBCC: string | null;
|
|
63
|
+
EmailOrderCC: string | null;
|
|
64
|
+
ExternalReference: string | null;
|
|
65
|
+
Fax: string | null;
|
|
66
|
+
GLN: string | null;
|
|
67
|
+
GLNDelivery: string | null;
|
|
68
|
+
InvoiceAdministrationFee: number | null;
|
|
69
|
+
InvoiceDiscount: number | null;
|
|
70
|
+
InvoiceFreight: number | null;
|
|
71
|
+
InvoiceRemark: string | null;
|
|
72
|
+
Name: string;
|
|
73
|
+
OrganisationNumber: string;
|
|
74
|
+
OurReference: string | null;
|
|
75
|
+
Phone1: string | null;
|
|
76
|
+
Phone2: string | null;
|
|
77
|
+
PriceList: string | null;
|
|
78
|
+
Project: string | null;
|
|
79
|
+
SalesAccount: string | null;
|
|
80
|
+
ShowPriceVATIncluded: boolean;
|
|
81
|
+
TermsOfDelivery: string | null;
|
|
82
|
+
TermsOfPayment: string | null;
|
|
83
|
+
Type: 'PRIVATE' | 'COMPANY';
|
|
84
|
+
VATNumber: string | null;
|
|
85
|
+
VATType: 'SEVAT' | 'SEREVERSEDVAT' | 'EUREVERSEDVAT' | 'EUVAT' | 'EXPORT';
|
|
86
|
+
VisitingAddress: string | null;
|
|
87
|
+
VisitingCity: string | null;
|
|
88
|
+
VisitingCountry: string | null;
|
|
89
|
+
VisitingCountryCode: string | null;
|
|
90
|
+
VisitingZipCode: string | null;
|
|
91
|
+
WayOfDelivery: string | null;
|
|
92
|
+
WWW: string | null;
|
|
93
|
+
YourReference: string | null;
|
|
94
|
+
ZipCode: string | null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface Customer extends CustomerDetails {
|
|
98
|
+
'@url': string;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface CustomersResponse extends ResponseModel {
|
|
102
|
+
Customers: CustomerBase[];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface CustomerResponse {
|
|
106
|
+
Customer: Customer;
|
|
107
|
+
}
|