n8n-nodes-aivencerealtycrm 1.0.5 → 1.0.7

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.
@@ -131,10 +131,173 @@ class AivenceRealty {
131
131
  operation: ['create', 'update'],
132
132
  },
133
133
  },
134
- default: true,
134
+ default: false,
135
135
  description: 'Si está activado, usará el JSON completo del nodo anterior',
136
136
  },
137
137
  // ============================================
138
+ // LEAD CREATE/UPDATE FIELDS (Structured)
139
+ // ============================================
140
+ {
141
+ displayName: 'Nombre',
142
+ name: 'name',
143
+ type: 'string',
144
+ required: true,
145
+ displayOptions: {
146
+ show: {
147
+ resource: ['lead'],
148
+ operation: ['create', 'update'],
149
+ useJsonInput: [false],
150
+ },
151
+ },
152
+ default: '',
153
+ description: 'Nombre completo del lead',
154
+ },
155
+ {
156
+ displayName: 'Email',
157
+ name: 'email',
158
+ type: 'string',
159
+ required: true,
160
+ displayOptions: {
161
+ show: {
162
+ resource: ['lead'],
163
+ operation: ['create', 'update'],
164
+ useJsonInput: [false],
165
+ },
166
+ },
167
+ default: '',
168
+ description: 'Email del lead',
169
+ },
170
+ {
171
+ displayName: 'Teléfono',
172
+ name: 'phone',
173
+ type: 'string',
174
+ required: true,
175
+ displayOptions: {
176
+ show: {
177
+ resource: ['lead'],
178
+ operation: ['create', 'update'],
179
+ useJsonInput: [false],
180
+ },
181
+ },
182
+ default: '',
183
+ description: 'Teléfono del lead',
184
+ },
185
+ {
186
+ displayName: 'Mensaje',
187
+ name: 'message',
188
+ type: 'string',
189
+ typeOptions: {
190
+ rows: 4,
191
+ },
192
+ displayOptions: {
193
+ show: {
194
+ resource: ['lead'],
195
+ operation: ['create', 'update'],
196
+ useJsonInput: [false],
197
+ },
198
+ },
199
+ default: '',
200
+ description: 'Mensaje o consulta del lead',
201
+ },
202
+ {
203
+ displayName: 'Interés',
204
+ name: 'interest',
205
+ type: 'options',
206
+ options: [
207
+ {
208
+ name: 'Compra',
209
+ value: 'compra',
210
+ },
211
+ {
212
+ name: 'Alquiler',
213
+ value: 'alquiler',
214
+ },
215
+ ],
216
+ displayOptions: {
217
+ show: {
218
+ resource: ['lead'],
219
+ operation: ['create', 'update'],
220
+ useJsonInput: [false],
221
+ },
222
+ },
223
+ default: 'compra',
224
+ description: 'Tipo de interés del lead',
225
+ },
226
+ {
227
+ displayName: 'Presupuesto Mínimo',
228
+ name: 'budget_min',
229
+ type: 'number',
230
+ displayOptions: {
231
+ show: {
232
+ resource: ['lead'],
233
+ operation: ['create', 'update'],
234
+ useJsonInput: [false],
235
+ },
236
+ },
237
+ default: 0,
238
+ description: 'Presupuesto mínimo',
239
+ },
240
+ {
241
+ displayName: 'Presupuesto Máximo',
242
+ name: 'budget_max',
243
+ type: 'number',
244
+ displayOptions: {
245
+ show: {
246
+ resource: ['lead'],
247
+ operation: ['create', 'update'],
248
+ useJsonInput: [false],
249
+ },
250
+ },
251
+ default: 0,
252
+ description: 'Presupuesto máximo',
253
+ },
254
+ {
255
+ displayName: 'Áreas Preferidas',
256
+ name: 'preferred_areas',
257
+ type: 'string',
258
+ displayOptions: {
259
+ show: {
260
+ resource: ['lead'],
261
+ operation: ['create', 'update'],
262
+ useJsonInput: [false],
263
+ },
264
+ },
265
+ default: '',
266
+ description: 'Áreas preferidas separadas por comas',
267
+ },
268
+ {
269
+ displayName: 'Tipo de Propiedad',
270
+ name: 'property_type',
271
+ type: 'options',
272
+ options: [
273
+ {
274
+ name: 'Apartamento',
275
+ value: 'apartamento',
276
+ },
277
+ {
278
+ name: 'Casa',
279
+ value: 'casa',
280
+ },
281
+ {
282
+ name: 'Loft',
283
+ value: 'loft',
284
+ },
285
+ {
286
+ name: 'Estudio',
287
+ value: 'estudio',
288
+ },
289
+ ],
290
+ displayOptions: {
291
+ show: {
292
+ resource: ['lead'],
293
+ operation: ['create', 'update'],
294
+ useJsonInput: [false],
295
+ },
296
+ },
297
+ default: 'apartamento',
298
+ description: 'Tipo de propiedad de interés',
299
+ },
300
+ // ============================================
138
301
  // PROPERTY OPERATIONS
139
302
  // ============================================
140
303
  {
@@ -421,8 +584,39 @@ class AivenceRealty {
421
584
  });
422
585
  }
423
586
  else if (operation === 'create') {
424
- const useJsonInput = this.getNodeParameter('useJsonInput', i, true);
425
- const body = useJsonInput ? items[i].json : {};
587
+ const useJsonInput = this.getNodeParameter('useJsonInput', i, false);
588
+ let body = {};
589
+ if (useJsonInput) {
590
+ // Usar JSON del nodo anterior
591
+ body = items[i].json;
592
+ }
593
+ else {
594
+ // Construir body con campos estructurados
595
+ body = {
596
+ name: this.getNodeParameter('name', i),
597
+ email: this.getNodeParameter('email', i),
598
+ phone: this.getNodeParameter('phone', i),
599
+ message: this.getNodeParameter('message', i, ''),
600
+ interest: this.getNodeParameter('interest', i, 'compra'),
601
+ budget_min: this.getNodeParameter('budget_min', i, 0),
602
+ budget_max: this.getNodeParameter('budget_max', i, 0),
603
+ property_type: this.getNodeParameter('property_type', i, 'apartamento'),
604
+ };
605
+ // Procesar preferred_areas (convertir string separado por comas a array)
606
+ const areasString = this.getNodeParameter('preferred_areas', i, '');
607
+ if (areasString) {
608
+ body.preferred_areas = areasString.split(',').map((area) => area.trim());
609
+ }
610
+ // Remover campos vacíos opcionales
611
+ if (!body.message)
612
+ delete body.message;
613
+ if (body.budget_min === 0)
614
+ delete body.budget_min;
615
+ if (body.budget_max === 0)
616
+ delete body.budget_max;
617
+ if (!body.preferred_areas || body.preferred_areas.length === 0)
618
+ delete body.preferred_areas;
619
+ }
426
620
  responseData = await this.helpers.httpRequest({
427
621
  method: 'POST',
428
622
  url: `${baseUrl}/api/v1/leads`,
@@ -432,8 +626,43 @@ class AivenceRealty {
432
626
  }
433
627
  else if (operation === 'update') {
434
628
  const leadId = this.getNodeParameter('leadId', i);
435
- const useJsonInput = this.getNodeParameter('useJsonInput', i, true);
436
- const body = useJsonInput ? items[i].json : {};
629
+ const useJsonInput = this.getNodeParameter('useJsonInput', i, false);
630
+ let body = {};
631
+ if (useJsonInput) {
632
+ // Usar JSON del nodo anterior
633
+ body = items[i].json;
634
+ }
635
+ else {
636
+ // Construir body con campos estructurados (solo enviar campos proporcionados)
637
+ const name = this.getNodeParameter('name', i, '');
638
+ const email = this.getNodeParameter('email', i, '');
639
+ const phone = this.getNodeParameter('phone', i, '');
640
+ const message = this.getNodeParameter('message', i, '');
641
+ const interest = this.getNodeParameter('interest', i, '');
642
+ const budget_min = this.getNodeParameter('budget_min', i, 0);
643
+ const budget_max = this.getNodeParameter('budget_max', i, 0);
644
+ const property_type = this.getNodeParameter('property_type', i, '');
645
+ const areasString = this.getNodeParameter('preferred_areas', i, '');
646
+ if (name)
647
+ body.name = name;
648
+ if (email)
649
+ body.email = email;
650
+ if (phone)
651
+ body.phone = phone;
652
+ if (message)
653
+ body.message = message;
654
+ if (interest)
655
+ body.interest = interest;
656
+ if (budget_min > 0)
657
+ body.budget_min = budget_min;
658
+ if (budget_max > 0)
659
+ body.budget_max = budget_max;
660
+ if (property_type)
661
+ body.property_type = property_type;
662
+ if (areasString) {
663
+ body.preferred_areas = areasString.split(',').map((area) => area.trim());
664
+ }
665
+ }
437
666
  responseData = await this.helpers.httpRequest({
438
667
  method: 'PATCH',
439
668
  url: `${baseUrl}/api/v1/leads/${leadId}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-aivencerealtycrm",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Nodo n8n para integrar el CRM inmobiliario AivenceRealty",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",