n8n-nodes-aivencerealtycrm 2.0.2 → 2.0.3

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.
@@ -64,6 +64,10 @@ class AivenceRealty {
64
64
  name: 'Calculator',
65
65
  value: 'calculator',
66
66
  },
67
+ {
68
+ name: 'Agent',
69
+ value: 'agent',
70
+ },
67
71
  ],
68
72
  default: 'lead',
69
73
  description: 'Recurso del CRM a operar',
@@ -1297,7 +1301,153 @@ class AivenceRealty {
1297
1301
  },
1298
1302
  },
1299
1303
  default: false,
1300
- description: 'Si está activado, usará el JSON completo del nodo anterior con campos: name, email, phone, specialties, rating, availability',
1304
+ description: 'Si está activado, usará el JSON completo del nodo anterior. Si desactivado, mostrará campos individuales.',
1305
+ },
1306
+ // Contractor Create Fields (when useJsonInput is false)
1307
+ {
1308
+ displayName: 'Nombre',
1309
+ name: 'contractorNombre',
1310
+ type: 'string',
1311
+ required: true,
1312
+ displayOptions: {
1313
+ show: {
1314
+ resource: ['contractor'],
1315
+ operation: ['create'],
1316
+ useJsonInput: [false],
1317
+ },
1318
+ },
1319
+ default: '',
1320
+ description: 'Nombre del contratista',
1321
+ },
1322
+ {
1323
+ displayName: 'Email',
1324
+ name: 'contractorEmail',
1325
+ type: 'string',
1326
+ required: true,
1327
+ displayOptions: {
1328
+ show: {
1329
+ resource: ['contractor'],
1330
+ operation: ['create'],
1331
+ useJsonInput: [false],
1332
+ },
1333
+ },
1334
+ default: '',
1335
+ placeholder: 'nombre@email.com',
1336
+ description: 'Email del contratista',
1337
+ },
1338
+ {
1339
+ displayName: 'Teléfono',
1340
+ name: 'contractorTelefono',
1341
+ type: 'string',
1342
+ required: true,
1343
+ displayOptions: {
1344
+ show: {
1345
+ resource: ['contractor'],
1346
+ operation: ['create'],
1347
+ useJsonInput: [false],
1348
+ },
1349
+ },
1350
+ default: '',
1351
+ placeholder: '+54 11 1234-5678',
1352
+ description: 'Teléfono del contratista',
1353
+ },
1354
+ {
1355
+ displayName: 'Especialización',
1356
+ name: 'contractorEspecializacion',
1357
+ type: 'string',
1358
+ required: true,
1359
+ displayOptions: {
1360
+ show: {
1361
+ resource: ['contractor'],
1362
+ operation: ['create'],
1363
+ useJsonInput: [false],
1364
+ },
1365
+ },
1366
+ default: '',
1367
+ placeholder: 'Plomería, Electricidad, Pintura...',
1368
+ description: 'Especialización o área de trabajo del contratista',
1369
+ },
1370
+ {
1371
+ displayName: 'Descripción',
1372
+ name: 'contractorDescripcion',
1373
+ type: 'string',
1374
+ typeOptions: {
1375
+ rows: 3,
1376
+ },
1377
+ displayOptions: {
1378
+ show: {
1379
+ resource: ['contractor'],
1380
+ operation: ['create'],
1381
+ useJsonInput: [false],
1382
+ },
1383
+ },
1384
+ default: '',
1385
+ description: 'Descripción adicional del contratista',
1386
+ },
1387
+ {
1388
+ displayName: 'Ciudad',
1389
+ name: 'contractorCiudad',
1390
+ type: 'string',
1391
+ displayOptions: {
1392
+ show: {
1393
+ resource: ['contractor'],
1394
+ operation: ['create'],
1395
+ useJsonInput: [false],
1396
+ },
1397
+ },
1398
+ default: '',
1399
+ placeholder: 'Buenos Aires',
1400
+ description: 'Ciudad donde trabaja el contratista',
1401
+ },
1402
+ {
1403
+ displayName: 'Disponible',
1404
+ name: 'contractorDisponible',
1405
+ type: 'boolean',
1406
+ displayOptions: {
1407
+ show: {
1408
+ resource: ['contractor'],
1409
+ operation: ['create'],
1410
+ useJsonInput: [false],
1411
+ },
1412
+ },
1413
+ default: true,
1414
+ description: 'Si el contratista está disponible para trabajos',
1415
+ },
1416
+ {
1417
+ displayName: 'Tarifa por Hora',
1418
+ name: 'contractorTarifaHora',
1419
+ type: 'number',
1420
+ displayOptions: {
1421
+ show: {
1422
+ resource: ['contractor'],
1423
+ operation: ['create'],
1424
+ useJsonInput: [false],
1425
+ },
1426
+ },
1427
+ default: 0,
1428
+ description: 'Tarifa por hora del contratista',
1429
+ },
1430
+ {
1431
+ displayName: 'Moneda',
1432
+ name: 'contractorMoneda',
1433
+ type: 'options',
1434
+ displayOptions: {
1435
+ show: {
1436
+ resource: ['contractor'],
1437
+ operation: ['create'],
1438
+ useJsonInput: [false],
1439
+ },
1440
+ },
1441
+ options: [
1442
+ { name: 'Peso Argentino (ARS)', value: 'ARS' },
1443
+ { name: 'Dólar (USD)', value: 'USD' },
1444
+ { name: 'Peso Mexicano (MXN)', value: 'MXN' },
1445
+ { name: 'Peso Colombiano (COP)', value: 'COP' },
1446
+ { name: 'Sol Peruano (PEN)', value: 'PEN' },
1447
+ { name: 'Peso Chileno (CLP)', value: 'CLP' },
1448
+ ],
1449
+ default: 'ARS',
1450
+ description: 'Moneda para la tarifa',
1301
1451
  },
1302
1452
  // ============================================
1303
1453
  // TENANT OPERATIONS
@@ -1361,7 +1511,96 @@ class AivenceRealty {
1361
1511
  },
1362
1512
  },
1363
1513
  default: false,
1364
- description: 'Si está activado, usará el JSON completo del nodo anterior con campos: name, email, phone, property_id, lease_start, lease_end, monthly_rent',
1514
+ description: 'Si está activado, usará el JSON completo del nodo anterior. Si desactivado, mostrará campos individuales.',
1515
+ },
1516
+ // Tenant Create Fields (when useJsonInput is false)
1517
+ {
1518
+ displayName: 'Nombre',
1519
+ name: 'tenantName',
1520
+ type: 'string',
1521
+ required: true,
1522
+ displayOptions: {
1523
+ show: {
1524
+ resource: ['tenant'],
1525
+ operation: ['create'],
1526
+ useJsonInput: [false],
1527
+ },
1528
+ },
1529
+ default: '',
1530
+ description: 'Nombre completo del inquilino',
1531
+ },
1532
+ {
1533
+ displayName: 'Email',
1534
+ name: 'tenantEmail',
1535
+ type: 'string',
1536
+ required: true,
1537
+ displayOptions: {
1538
+ show: {
1539
+ resource: ['tenant'],
1540
+ operation: ['create'],
1541
+ useJsonInput: [false],
1542
+ },
1543
+ },
1544
+ default: '',
1545
+ placeholder: 'inquilino@email.com',
1546
+ description: 'Email del inquilino',
1547
+ },
1548
+ {
1549
+ displayName: 'Teléfono',
1550
+ name: 'tenantPhone',
1551
+ type: 'string',
1552
+ displayOptions: {
1553
+ show: {
1554
+ resource: ['tenant'],
1555
+ operation: ['create'],
1556
+ useJsonInput: [false],
1557
+ },
1558
+ },
1559
+ default: '',
1560
+ placeholder: '+54 11 1234-5678',
1561
+ description: 'Teléfono del inquilino (opcional)',
1562
+ },
1563
+ {
1564
+ displayName: 'Dirección',
1565
+ name: 'tenantAddress',
1566
+ type: 'string',
1567
+ displayOptions: {
1568
+ show: {
1569
+ resource: ['tenant'],
1570
+ operation: ['create'],
1571
+ useJsonInput: [false],
1572
+ },
1573
+ },
1574
+ default: '',
1575
+ description: 'Dirección actual del inquilino (opcional)',
1576
+ },
1577
+ {
1578
+ displayName: 'Contacto de Emergencia - Nombre',
1579
+ name: 'emergencyContactName',
1580
+ type: 'string',
1581
+ displayOptions: {
1582
+ show: {
1583
+ resource: ['tenant'],
1584
+ operation: ['create'],
1585
+ useJsonInput: [false],
1586
+ },
1587
+ },
1588
+ default: '',
1589
+ description: 'Nombre del contacto de emergencia (opcional)',
1590
+ },
1591
+ {
1592
+ displayName: 'Contacto de Emergencia - Teléfono',
1593
+ name: 'emergencyContactPhone',
1594
+ type: 'string',
1595
+ displayOptions: {
1596
+ show: {
1597
+ resource: ['tenant'],
1598
+ operation: ['create'],
1599
+ useJsonInput: [false],
1600
+ },
1601
+ },
1602
+ default: '',
1603
+ description: 'Teléfono del contacto de emergencia (opcional)',
1365
1604
  },
1366
1605
  // ============================================
1367
1606
  // APPOINTMENT OPERATIONS
@@ -1649,6 +1888,97 @@ class AivenceRealty {
1649
1888
  default: 'pending',
1650
1889
  description: 'Nuevo estado de la cita',
1651
1890
  },
1891
+ // Appointment List Filters
1892
+ {
1893
+ displayName: 'Filtro por Propiedad',
1894
+ name: 'appointmentPropertyIdFilter',
1895
+ type: 'number',
1896
+ displayOptions: {
1897
+ show: {
1898
+ resource: ['appointment'],
1899
+ operation: ['list'],
1900
+ },
1901
+ },
1902
+ default: 0,
1903
+ description: 'Filtrar citas por ID de propiedad (opcional, 0 = sin filtro)',
1904
+ },
1905
+ {
1906
+ displayName: 'Filtro por Agente',
1907
+ name: 'appointmentStaffIdFilter',
1908
+ type: 'number',
1909
+ displayOptions: {
1910
+ show: {
1911
+ resource: ['appointment'],
1912
+ operation: ['list'],
1913
+ },
1914
+ },
1915
+ default: 0,
1916
+ description: 'Filtrar citas por ID de agente asignado (opcional, 0 = sin filtro)',
1917
+ },
1918
+ {
1919
+ displayName: 'Filtro por Estado',
1920
+ name: 'appointmentStatusFilter',
1921
+ type: 'options',
1922
+ displayOptions: {
1923
+ show: {
1924
+ resource: ['appointment'],
1925
+ operation: ['list'],
1926
+ },
1927
+ },
1928
+ options: [
1929
+ { name: 'Todos', value: '' },
1930
+ { name: 'Pendiente', value: 'pending' },
1931
+ { name: 'Confirmada', value: 'confirmed' },
1932
+ { name: 'Completada', value: 'completed' },
1933
+ { name: 'Cancelada', value: 'cancelled' },
1934
+ { name: 'Reprogramada', value: 'rescheduled' },
1935
+ ],
1936
+ default: '',
1937
+ description: 'Filtrar citas por estado',
1938
+ },
1939
+ {
1940
+ displayName: 'Fecha Desde',
1941
+ name: 'appointmentDateFrom',
1942
+ type: 'dateTime',
1943
+ displayOptions: {
1944
+ show: {
1945
+ resource: ['appointment'],
1946
+ operation: ['list'],
1947
+ },
1948
+ },
1949
+ default: '',
1950
+ description: 'Filtrar citas desde esta fecha (formato: YYYY-MM-DD)',
1951
+ },
1952
+ {
1953
+ displayName: 'Fecha Hasta',
1954
+ name: 'appointmentDateTo',
1955
+ type: 'dateTime',
1956
+ displayOptions: {
1957
+ show: {
1958
+ resource: ['appointment'],
1959
+ operation: ['list'],
1960
+ },
1961
+ },
1962
+ default: '',
1963
+ description: 'Filtrar citas hasta esta fecha (formato: YYYY-MM-DD)',
1964
+ },
1965
+ {
1966
+ displayName: 'Límite',
1967
+ name: 'appointmentLimit',
1968
+ type: 'number',
1969
+ typeOptions: {
1970
+ minValue: 1,
1971
+ maxValue: 100,
1972
+ },
1973
+ displayOptions: {
1974
+ show: {
1975
+ resource: ['appointment'],
1976
+ operation: ['list'],
1977
+ },
1978
+ },
1979
+ default: 50,
1980
+ description: 'Número máximo de citas a devolver (1-100)',
1981
+ },
1652
1982
  // ============================================
1653
1983
  // CALCULATOR OPERATIONS
1654
1984
  // ============================================
@@ -1781,7 +2111,7 @@ class AivenceRealty {
1781
2111
  // Tipo de Propiedad (costos escrituración)
1782
2112
  {
1783
2113
  displayName: 'Tipo de Propiedad',
1784
- name: 'property_type',
2114
+ name: 'property_type_escrituracion',
1785
2115
  type: 'options',
1786
2116
  displayOptions: {
1787
2117
  show: {
@@ -1877,6 +2207,209 @@ class AivenceRealty {
1877
2207
  default: 40,
1878
2208
  description: 'Incremento esperado del alquiler por año',
1879
2209
  },
2210
+ // ============================================
2211
+ // AGENT OPERATIONS
2212
+ // ============================================
2213
+ {
2214
+ displayName: 'Operación',
2215
+ name: 'operation',
2216
+ type: 'options',
2217
+ noDataExpression: true,
2218
+ displayOptions: {
2219
+ show: {
2220
+ resource: ['agent'],
2221
+ },
2222
+ },
2223
+ options: [
2224
+ {
2225
+ name: 'List',
2226
+ value: 'list',
2227
+ description: 'Listar agentes disponibles',
2228
+ action: 'Listar agentes',
2229
+ },
2230
+ {
2231
+ name: 'Get',
2232
+ value: 'get',
2233
+ description: 'Obtener agente por ID',
2234
+ action: 'Obtener agente',
2235
+ },
2236
+ {
2237
+ name: 'Assign by Zone',
2238
+ value: 'assignByZone',
2239
+ description: 'Asignar agente automáticamente según zona',
2240
+ action: 'Asignar agente por zona',
2241
+ },
2242
+ {
2243
+ name: 'Notify',
2244
+ value: 'notify',
2245
+ description: 'Notificar agente sobre nueva cita',
2246
+ action: 'Notificar agente',
2247
+ },
2248
+ ],
2249
+ default: 'list',
2250
+ },
2251
+ // Agent ID (for get operation)
2252
+ {
2253
+ displayName: 'Agent ID',
2254
+ name: 'agentId',
2255
+ type: 'number',
2256
+ required: true,
2257
+ displayOptions: {
2258
+ show: {
2259
+ resource: ['agent'],
2260
+ operation: ['get', 'notify'],
2261
+ },
2262
+ },
2263
+ default: 0,
2264
+ description: 'ID del agente',
2265
+ },
2266
+ // Zone (for assignByZone operation)
2267
+ {
2268
+ displayName: 'Zona',
2269
+ name: 'zona',
2270
+ type: 'string',
2271
+ required: true,
2272
+ displayOptions: {
2273
+ show: {
2274
+ resource: ['agent'],
2275
+ operation: ['assignByZone'],
2276
+ },
2277
+ },
2278
+ default: '',
2279
+ placeholder: 'Palermo, Recoleta, etc.',
2280
+ description: 'Zona/barrio para asignar agente automáticamente',
2281
+ },
2282
+ // Booking ID (for assignByZone and notify)
2283
+ {
2284
+ displayName: 'Booking ID',
2285
+ name: 'bookingId',
2286
+ type: 'number',
2287
+ displayOptions: {
2288
+ show: {
2289
+ resource: ['agent'],
2290
+ operation: ['assignByZone', 'notify'],
2291
+ },
2292
+ },
2293
+ default: 0,
2294
+ description: 'ID de la cita (opcional para assignByZone, requerido para notify)',
2295
+ },
2296
+ // Property ID (for assignByZone)
2297
+ {
2298
+ displayName: 'Property ID',
2299
+ name: 'propertyIdAgent',
2300
+ type: 'number',
2301
+ displayOptions: {
2302
+ show: {
2303
+ resource: ['agent'],
2304
+ operation: ['assignByZone'],
2305
+ },
2306
+ },
2307
+ default: 0,
2308
+ description: 'ID de la propiedad (opcional, para contexto)',
2309
+ },
2310
+ // Fecha de la cita (for assignByZone) - Para verificar conflictos de horario
2311
+ {
2312
+ displayName: 'Fecha de Cita',
2313
+ name: 'fechaCita',
2314
+ type: 'string',
2315
+ displayOptions: {
2316
+ show: {
2317
+ resource: ['agent'],
2318
+ operation: ['assignByZone'],
2319
+ },
2320
+ },
2321
+ default: '',
2322
+ placeholder: '2025-12-31',
2323
+ description: 'Fecha de la cita en formato YYYY-MM-DD (opcional, para verificar conflictos)',
2324
+ },
2325
+ // Hora de la cita (for assignByZone) - Para verificar conflictos de horario
2326
+ {
2327
+ displayName: 'Hora de Cita',
2328
+ name: 'horaCita',
2329
+ type: 'string',
2330
+ displayOptions: {
2331
+ show: {
2332
+ resource: ['agent'],
2333
+ operation: ['assignByZone'],
2334
+ },
2335
+ },
2336
+ default: '',
2337
+ placeholder: '10:00',
2338
+ description: 'Hora de la cita en formato HH:MM (opcional, para verificar conflictos)',
2339
+ },
2340
+ // Property Title (for notify)
2341
+ {
2342
+ displayName: 'Property Title',
2343
+ name: 'propertyTitle',
2344
+ type: 'string',
2345
+ displayOptions: {
2346
+ show: {
2347
+ resource: ['agent'],
2348
+ operation: ['notify'],
2349
+ },
2350
+ },
2351
+ default: '',
2352
+ description: 'Título de la propiedad (para notificación)',
2353
+ },
2354
+ // Client Name (for notify)
2355
+ {
2356
+ displayName: 'Client Name',
2357
+ name: 'clientNameNotify',
2358
+ type: 'string',
2359
+ displayOptions: {
2360
+ show: {
2361
+ resource: ['agent'],
2362
+ operation: ['notify'],
2363
+ },
2364
+ },
2365
+ default: '',
2366
+ description: 'Nombre del cliente (para notificación)',
2367
+ },
2368
+ // Appointment Date (for notify)
2369
+ {
2370
+ displayName: 'Appointment Date',
2371
+ name: 'appointmentDate',
2372
+ type: 'string',
2373
+ displayOptions: {
2374
+ show: {
2375
+ resource: ['agent'],
2376
+ operation: ['notify'],
2377
+ },
2378
+ },
2379
+ default: '',
2380
+ placeholder: '2025-01-15',
2381
+ description: 'Fecha de la cita (para notificación)',
2382
+ },
2383
+ // Appointment Time (for notify)
2384
+ {
2385
+ displayName: 'Appointment Time',
2386
+ name: 'appointmentTime',
2387
+ type: 'string',
2388
+ displayOptions: {
2389
+ show: {
2390
+ resource: ['agent'],
2391
+ operation: ['notify'],
2392
+ },
2393
+ },
2394
+ default: '',
2395
+ placeholder: '14:30',
2396
+ description: 'Hora de la cita (para notificación)',
2397
+ },
2398
+ // Zone filter (for list)
2399
+ {
2400
+ displayName: 'Filtrar por Zona',
2401
+ name: 'zonaFilter',
2402
+ type: 'string',
2403
+ displayOptions: {
2404
+ show: {
2405
+ resource: ['agent'],
2406
+ operation: ['list'],
2407
+ },
2408
+ },
2409
+ default: '',
2410
+ placeholder: 'Palermo',
2411
+ description: 'Filtrar agentes por zona (opcional)',
2412
+ },
1880
2413
  ],
1881
2414
  };
1882
2415
  }
@@ -1885,7 +2418,6 @@ class AivenceRealty {
1885
2418
  const returnData = [];
1886
2419
  const credentials = await this.getCredentials('aivenceRealtyApi');
1887
2420
  const baseUrl = credentials.baseUrl;
1888
- const apiKey = credentials.apiKey;
1889
2421
  for (let i = 0; i < items.length; i++) {
1890
2422
  try {
1891
2423
  const resource = this.getNodeParameter('resource', i);
@@ -2287,9 +2819,6 @@ class AivenceRealty {
2287
2819
  responseData = await this.helpers.httpRequest({
2288
2820
  method: 'POST',
2289
2821
  url: `${baseUrl}/api/v1/emails/ingest`,
2290
- headers: {
2291
- 'Authorization': `Bearer ${apiKey}`,
2292
- },
2293
2822
  body,
2294
2823
  json: true,
2295
2824
  });
@@ -2456,8 +2985,32 @@ class AivenceRealty {
2456
2985
  });
2457
2986
  }
2458
2987
  else if (operation === 'create') {
2459
- const useJsonInput = this.getNodeParameter('useJsonInput', i, true);
2460
- const body = useJsonInput ? items[i].json : {};
2988
+ const useJsonInput = this.getNodeParameter('useJsonInput', i, false);
2989
+ let body;
2990
+ if (useJsonInput) {
2991
+ body = items[i].json;
2992
+ }
2993
+ else {
2994
+ body = {
2995
+ nombre: this.getNodeParameter('contractorNombre', i),
2996
+ email: this.getNodeParameter('contractorEmail', i),
2997
+ telefono: this.getNodeParameter('contractorTelefono', i),
2998
+ especializacion: this.getNodeParameter('contractorEspecializacion', i),
2999
+ };
3000
+ const descripcion = this.getNodeParameter('contractorDescripcion', i, '');
3001
+ if (descripcion)
3002
+ body.descripcion = descripcion;
3003
+ const ciudad = this.getNodeParameter('contractorCiudad', i, '');
3004
+ if (ciudad)
3005
+ body.ciudad = ciudad;
3006
+ body.disponible = this.getNodeParameter('contractorDisponible', i, true);
3007
+ const tarifaHora = this.getNodeParameter('contractorTarifaHora', i, 0);
3008
+ if (tarifaHora > 0)
3009
+ body.tarifa_hora = tarifaHora;
3010
+ const moneda = this.getNodeParameter('contractorMoneda', i, 'ARS');
3011
+ if (tarifaHora > 0)
3012
+ body.moneda = moneda;
3013
+ }
2461
3014
  responseData = await this.helpers.httpRequest({
2462
3015
  method: 'POST',
2463
3016
  url: `${baseUrl}/api/v1/contratistas`,
@@ -2504,8 +3057,29 @@ class AivenceRealty {
2504
3057
  });
2505
3058
  }
2506
3059
  else if (operation === 'create') {
2507
- const useJsonInput = this.getNodeParameter('useJsonInput', i, true);
2508
- const body = useJsonInput ? items[i].json : {};
3060
+ const useJsonInput = this.getNodeParameter('useJsonInput', i, false);
3061
+ let body;
3062
+ if (useJsonInput) {
3063
+ body = items[i].json;
3064
+ }
3065
+ else {
3066
+ body = {
3067
+ name: this.getNodeParameter('tenantName', i),
3068
+ email: this.getNodeParameter('tenantEmail', i),
3069
+ };
3070
+ const phone = this.getNodeParameter('tenantPhone', i, '');
3071
+ if (phone)
3072
+ body.phone = phone;
3073
+ const address = this.getNodeParameter('tenantAddress', i, '');
3074
+ if (address)
3075
+ body.address = address;
3076
+ const emergencyName = this.getNodeParameter('emergencyContactName', i, '');
3077
+ if (emergencyName)
3078
+ body.emergency_contact_name = emergencyName;
3079
+ const emergencyPhone = this.getNodeParameter('emergencyContactPhone', i, '');
3080
+ if (emergencyPhone)
3081
+ body.emergency_contact_phone = emergencyPhone;
3082
+ }
2509
3083
  responseData = await this.helpers.httpRequest({
2510
3084
  method: 'POST',
2511
3085
  url: `${baseUrl}/api/v1/inquilinos`,
@@ -2519,9 +3093,29 @@ class AivenceRealty {
2519
3093
  // ============================================
2520
3094
  else if (resource === 'appointment') {
2521
3095
  if (operation === 'list') {
3096
+ const propertyIdFilter = this.getNodeParameter('appointmentPropertyIdFilter', i, 0);
3097
+ const staffIdFilter = this.getNodeParameter('appointmentStaffIdFilter', i, 0);
3098
+ const statusFilter = this.getNodeParameter('appointmentStatusFilter', i, '');
3099
+ const dateFrom = this.getNodeParameter('appointmentDateFrom', i, '');
3100
+ const dateTo = this.getNodeParameter('appointmentDateTo', i, '');
3101
+ const limit = this.getNodeParameter('appointmentLimit', i, 50);
3102
+ const queryParams = [];
3103
+ if (propertyIdFilter > 0)
3104
+ queryParams.push(`property_id=${propertyIdFilter}`);
3105
+ if (staffIdFilter > 0)
3106
+ queryParams.push(`staff_id=${staffIdFilter}`);
3107
+ if (statusFilter)
3108
+ queryParams.push(`status=${encodeURIComponent(statusFilter)}`);
3109
+ if (dateFrom)
3110
+ queryParams.push(`date_from=${encodeURIComponent(dateFrom.split('T')[0])}`);
3111
+ if (dateTo)
3112
+ queryParams.push(`date_to=${encodeURIComponent(dateTo.split('T')[0])}`);
3113
+ if (limit)
3114
+ queryParams.push(`limit=${limit}`);
3115
+ const queryString = queryParams.length > 0 ? `?${queryParams.join('&')}` : '';
2522
3116
  responseData = await this.helpers.httpRequest({
2523
3117
  method: 'GET',
2524
- url: `${baseUrl}/api/v1/reservas`,
3118
+ url: `${baseUrl}/api/v1/reservas${queryString}`,
2525
3119
  json: true,
2526
3120
  });
2527
3121
  }
@@ -2626,7 +3220,7 @@ class AivenceRealty {
2626
3220
  endpoint = '/api/v1/calculadoras/costos-escrituracion';
2627
3221
  body = {
2628
3222
  property_price: this.getNodeParameter('property_price', i),
2629
- property_type: this.getNodeParameter('property_type', i),
3223
+ property_type: this.getNodeParameter('property_type_escrituracion', i),
2630
3224
  is_new: this.getNodeParameter('is_new', i),
2631
3225
  };
2632
3226
  }
@@ -2649,6 +3243,92 @@ class AivenceRealty {
2649
3243
  json: true,
2650
3244
  });
2651
3245
  }
3246
+ // ============================================
3247
+ // AGENT RESOURCE
3248
+ // ============================================
3249
+ else if (resource === 'agent') {
3250
+ if (operation === 'list') {
3251
+ const zonaFilter = this.getNodeParameter('zonaFilter', i);
3252
+ let url = `${baseUrl}/api/v1/agentes/listar-por-zona`;
3253
+ if (zonaFilter) {
3254
+ url += `?zona=${encodeURIComponent(zonaFilter)}`;
3255
+ }
3256
+ responseData = await this.helpers.httpRequest({
3257
+ method: 'GET',
3258
+ url,
3259
+ headers: {
3260
+ 'Authorization': `Bearer ${credentials.apiKey}`,
3261
+ 'Accept': 'application/json',
3262
+ },
3263
+ json: true,
3264
+ });
3265
+ }
3266
+ else if (operation === 'get') {
3267
+ const agentId = this.getNodeParameter('agentId', i);
3268
+ responseData = await this.helpers.httpRequest({
3269
+ method: 'GET',
3270
+ url: `${baseUrl}/api/v1/agentes/${agentId}`,
3271
+ headers: {
3272
+ 'Authorization': `Bearer ${credentials.apiKey}`,
3273
+ 'Accept': 'application/json',
3274
+ },
3275
+ json: true,
3276
+ });
3277
+ }
3278
+ else if (operation === 'assignByZone') {
3279
+ const zona = this.getNodeParameter('zona', i);
3280
+ const bookingId = this.getNodeParameter('bookingId', i);
3281
+ const propertyId = this.getNodeParameter('propertyIdAgent', i);
3282
+ const fechaCita = this.getNodeParameter('fechaCita', i);
3283
+ const horaCita = this.getNodeParameter('horaCita', i);
3284
+ const body = { zona };
3285
+ if (bookingId)
3286
+ body.booking_id = bookingId;
3287
+ if (propertyId)
3288
+ body.property_id = propertyId;
3289
+ if (fechaCita)
3290
+ body.fecha = fechaCita;
3291
+ if (horaCita)
3292
+ body.hora = horaCita;
3293
+ responseData = await this.helpers.httpRequest({
3294
+ method: 'POST',
3295
+ url: `${baseUrl}/api/v1/agentes/asignar-automatico`,
3296
+ headers: {
3297
+ 'Authorization': `Bearer ${credentials.apiKey}`,
3298
+ 'Accept': 'application/json',
3299
+ 'Content-Type': 'application/json',
3300
+ },
3301
+ body,
3302
+ json: true,
3303
+ });
3304
+ }
3305
+ else if (operation === 'notify') {
3306
+ const agentId = this.getNodeParameter('agentId', i);
3307
+ const bookingId = this.getNodeParameter('bookingId', i);
3308
+ const propertyTitle = this.getNodeParameter('propertyTitle', i);
3309
+ const clientName = this.getNodeParameter('clientNameNotify', i);
3310
+ const appointmentDate = this.getNodeParameter('appointmentDate', i);
3311
+ const appointmentTime = this.getNodeParameter('appointmentTime', i);
3312
+ responseData = await this.helpers.httpRequest({
3313
+ method: 'POST',
3314
+ url: `${baseUrl}/api/v1/agentes/notificar-cita`,
3315
+ headers: {
3316
+ 'Authorization': `Bearer ${credentials.apiKey}`,
3317
+ 'Accept': 'application/json',
3318
+ 'Content-Type': 'application/json',
3319
+ },
3320
+ body: {
3321
+ agent_id: agentId,
3322
+ booking_id: bookingId,
3323
+ property_title: propertyTitle,
3324
+ client_name: clientName,
3325
+ appointment_date: appointmentDate,
3326
+ appointment_time: appointmentTime,
3327
+ },
3328
+ json: true,
3329
+ });
3330
+ }
3331
+ }
2652
3332
  // Formatear respuesta
2653
3333
  const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
2654
3334
  returnData.push(...executionData);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-aivencerealtycrm",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "Nodo n8n para integrar el CRM inmobiliario AivenceRealty",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",
@@ -31,7 +31,8 @@
31
31
  "dev": "tsc --watch",
32
32
  "format": "prettier nodes credentials --write",
33
33
  "lint": "eslint nodes credentials package.json",
34
- "lintfix": "eslint nodes credentials package.json --fix"
34
+ "lintfix": "eslint nodes credentials package.json --fix",
35
+ "prepublishOnly": "npm run build"
35
36
  },
36
37
  "files": [
37
38
  "dist"