n8n-nodes-idb2b 3.2.7 → 3.2.9
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.
|
@@ -163,7 +163,7 @@ class IDB2B {
|
|
|
163
163
|
endpoint = `/contacts/${(0, common_1.sanitizeId)(contactId)}/activities`;
|
|
164
164
|
}
|
|
165
165
|
else {
|
|
166
|
-
const companyId = this.getNodeParameter("
|
|
166
|
+
const companyId = this.getNodeParameter("getAllCompanyId", i);
|
|
167
167
|
endpoint = `/leads/${(0, common_1.sanitizeId)(companyId)}/activities`;
|
|
168
168
|
}
|
|
169
169
|
qs.limit = limit;
|
|
@@ -171,28 +171,33 @@ class IDB2B {
|
|
|
171
171
|
}
|
|
172
172
|
else if (operation === "get") {
|
|
173
173
|
method = "GET";
|
|
174
|
+
const activityScope = this.getNodeParameter("activityScope", i);
|
|
174
175
|
const activityId = this.getNodeParameter("activityId", i);
|
|
175
|
-
|
|
176
|
+
if (activityScope === "contact") {
|
|
177
|
+
const parentContactId = this.getNodeParameter("activityParentContactId", i);
|
|
178
|
+
endpoint = `/contacts/${(0, common_1.sanitizeId)(parentContactId)}/activities/${(0, common_1.sanitizeId)(activityId)}`;
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
const parentCompanyId = this.getNodeParameter("activityParentCompanyId", i);
|
|
182
|
+
endpoint = `/leads/${(0, common_1.sanitizeId)(parentCompanyId)}/activities/${(0, common_1.sanitizeId)(activityId)}`;
|
|
183
|
+
}
|
|
176
184
|
}
|
|
177
185
|
else if (operation === "create") {
|
|
178
186
|
method = "POST";
|
|
179
|
-
endpoint = constants_1.ENDPOINTS.ACTIVITIES;
|
|
180
|
-
const subject = this.getNodeParameter("subject", i);
|
|
181
187
|
const associateWith = this.getNodeParameter("associateWith", i);
|
|
188
|
+
const subject = this.getNodeParameter("subject", i);
|
|
182
189
|
const additionalFields = this.getNodeParameter("additionalFields", i, {});
|
|
183
190
|
if (!subject || !subject.trim()) {
|
|
184
191
|
throw new Error("Subject is required to create an activity");
|
|
185
192
|
}
|
|
186
|
-
// Must send as multipart/form-data — the /activities endpoint uses
|
|
187
|
-
// FilesInterceptor which does not parse JSON bodies reliably
|
|
188
193
|
const formPayload = { subject: subject.trim() };
|
|
189
194
|
if (associateWith === "company") {
|
|
190
195
|
const companyId = this.getNodeParameter("activityCompanyId", i);
|
|
191
|
-
|
|
196
|
+
endpoint = `/leads/${(0, common_1.sanitizeId)(companyId)}/activities`;
|
|
192
197
|
}
|
|
193
198
|
else {
|
|
194
199
|
const contactId = this.getNodeParameter("activityContactId", i);
|
|
195
|
-
|
|
200
|
+
endpoint = `/contacts/${(0, common_1.sanitizeId)(contactId)}/activities`;
|
|
196
201
|
}
|
|
197
202
|
// Merge optional additional fields
|
|
198
203
|
Object.entries(additionalFields).forEach(([key, value]) => {
|
|
@@ -206,8 +211,16 @@ class IDB2B {
|
|
|
206
211
|
}
|
|
207
212
|
else if (operation === "update") {
|
|
208
213
|
method = "PATCH";
|
|
214
|
+
const activityScope = this.getNodeParameter("activityScope", i);
|
|
209
215
|
const activityId = this.getNodeParameter("activityId", i);
|
|
210
|
-
|
|
216
|
+
if (activityScope === "contact") {
|
|
217
|
+
const parentContactId = this.getNodeParameter("activityParentContactId", i);
|
|
218
|
+
endpoint = `/contacts/${(0, common_1.sanitizeId)(parentContactId)}/activities/${(0, common_1.sanitizeId)(activityId)}`;
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
const parentCompanyId = this.getNodeParameter("activityParentCompanyId", i);
|
|
222
|
+
endpoint = `/leads/${(0, common_1.sanitizeId)(parentCompanyId)}/activities/${(0, common_1.sanitizeId)(activityId)}`;
|
|
223
|
+
}
|
|
211
224
|
const additionalFields = this.getNodeParameter("additionalFields", i, {});
|
|
212
225
|
const updatePayload = {};
|
|
213
226
|
Object.entries(additionalFields).forEach(([key, value]) => {
|
|
@@ -221,8 +234,16 @@ class IDB2B {
|
|
|
221
234
|
}
|
|
222
235
|
else if (operation === "delete") {
|
|
223
236
|
method = "DELETE";
|
|
237
|
+
const activityScope = this.getNodeParameter("activityScope", i);
|
|
224
238
|
const activityId = this.getNodeParameter("activityId", i);
|
|
225
|
-
|
|
239
|
+
if (activityScope === "contact") {
|
|
240
|
+
const parentContactId = this.getNodeParameter("activityParentContactId", i);
|
|
241
|
+
endpoint = `/contacts/${(0, common_1.sanitizeId)(parentContactId)}/activities/${(0, common_1.sanitizeId)(activityId)}`;
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
const parentCompanyId = this.getNodeParameter("activityParentCompanyId", i);
|
|
245
|
+
endpoint = `/leads/${(0, common_1.sanitizeId)(parentCompanyId)}/activities/${(0, common_1.sanitizeId)(activityId)}`;
|
|
246
|
+
}
|
|
226
247
|
}
|
|
227
248
|
}
|
|
228
249
|
else if (resource === "company") {
|
|
@@ -15,8 +15,8 @@ exports.activityOperations = {
|
|
|
15
15
|
{
|
|
16
16
|
name: 'Get All',
|
|
17
17
|
value: 'getAll',
|
|
18
|
-
action: 'Get all activities
|
|
19
|
-
description: 'Retrieve all activities for a specific company
|
|
18
|
+
action: 'Get all activities',
|
|
19
|
+
description: 'Retrieve all activities for a specific company or contact',
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
name: 'Get',
|
|
@@ -46,6 +46,55 @@ exports.activityOperations = {
|
|
|
46
46
|
default: 'getAll',
|
|
47
47
|
};
|
|
48
48
|
exports.activityFields = [
|
|
49
|
+
// Scope selector for get, update, delete
|
|
50
|
+
{
|
|
51
|
+
displayName: 'Scope',
|
|
52
|
+
name: 'activityScope',
|
|
53
|
+
type: 'options',
|
|
54
|
+
default: 'company',
|
|
55
|
+
required: true,
|
|
56
|
+
displayOptions: {
|
|
57
|
+
show: {
|
|
58
|
+
resource: ['activity'],
|
|
59
|
+
operation: ['get', 'update', 'delete'],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
options: [
|
|
63
|
+
{ name: 'Company (Lead)', value: 'company' },
|
|
64
|
+
{ name: 'Contact', value: 'contact' },
|
|
65
|
+
],
|
|
66
|
+
description: 'Whether this activity belongs to a company (lead) or a contact',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
displayName: 'Company ID',
|
|
70
|
+
name: 'activityParentCompanyId',
|
|
71
|
+
type: 'string',
|
|
72
|
+
default: '',
|
|
73
|
+
required: true,
|
|
74
|
+
displayOptions: {
|
|
75
|
+
show: {
|
|
76
|
+
resource: ['activity'],
|
|
77
|
+
operation: ['get', 'update', 'delete'],
|
|
78
|
+
activityScope: ['company'],
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
description: 'ID of the company (lead) that owns this activity',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
displayName: 'Contact ID',
|
|
85
|
+
name: 'activityParentContactId',
|
|
86
|
+
type: 'string',
|
|
87
|
+
default: '',
|
|
88
|
+
required: true,
|
|
89
|
+
displayOptions: {
|
|
90
|
+
show: {
|
|
91
|
+
resource: ['activity'],
|
|
92
|
+
operation: ['get', 'update', 'delete'],
|
|
93
|
+
activityScope: ['contact'],
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
description: 'ID of the contact that owns this activity',
|
|
97
|
+
},
|
|
49
98
|
// Activity ID — required for get, update, delete
|
|
50
99
|
{
|
|
51
100
|
displayName: 'Activity ID',
|
|
@@ -82,7 +131,7 @@ exports.activityFields = [
|
|
|
82
131
|
},
|
|
83
132
|
{
|
|
84
133
|
displayName: 'Company ID',
|
|
85
|
-
name: '
|
|
134
|
+
name: 'getAllCompanyId',
|
|
86
135
|
type: 'string',
|
|
87
136
|
default: '',
|
|
88
137
|
required: true,
|