n8n-nodes-aivencerealtycrm 2.0.4 → 2.1.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.
@@ -68,6 +68,22 @@ class AivenceRealty {
68
68
  name: 'Agent',
69
69
  value: 'agent',
70
70
  },
71
+ {
72
+ name: 'Owner (Propietario)',
73
+ value: 'owner',
74
+ },
75
+ {
76
+ name: 'Tasación',
77
+ value: 'tasacion',
78
+ },
79
+ {
80
+ name: 'DocuSeal (Firma Digital)',
81
+ value: 'docuseal',
82
+ },
83
+ {
84
+ name: 'Mariana (Transferencia)',
85
+ value: 'mariana',
86
+ },
71
87
  ],
72
88
  default: 'lead',
73
89
  description: 'Recurso del CRM a operar',
@@ -2461,256 +2477,1057 @@ class AivenceRealty {
2461
2477
  placeholder: 'Palermo',
2462
2478
  description: 'Filtrar agentes por zona (opcional)',
2463
2479
  },
2464
- ],
2465
- };
2466
- }
2467
- async execute() {
2468
- const items = this.getInputData();
2469
- const returnData = [];
2470
- const credentials = await this.getCredentials('aivenceRealtyApi');
2471
- const baseUrl = credentials.baseUrl;
2472
- for (let i = 0; i < items.length; i++) {
2473
- try {
2474
- const resource = this.getNodeParameter('resource', i);
2475
- const operation = this.getNodeParameter('operation', i);
2476
- let responseData;
2477
- // ============================================
2478
- // LEAD RESOURCE
2479
- // ============================================
2480
- if (resource === 'lead') {
2481
- if (operation === 'list') {
2482
- responseData = await this.helpers.httpRequest({
2483
- method: 'GET',
2484
- url: `${baseUrl}/api/v1/leads`,
2485
- json: true,
2486
- });
2487
- }
2488
- else if (operation === 'create') {
2489
- const useJsonInput = this.getNodeParameter('useJsonInput', i, false);
2490
- let body = {};
2491
- if (useJsonInput) {
2492
- // Usar JSON del nodo anterior
2493
- body = items[i].json;
2494
- }
2495
- else {
2496
- // Construir body con campos estructurados
2497
- body = {
2498
- name: this.getNodeParameter('name', i),
2499
- email: this.getNodeParameter('email', i),
2500
- phone: this.getNodeParameter('phone', i),
2501
- message: this.getNodeParameter('message', i, ''),
2502
- interest: this.getNodeParameter('interest', i, 'compra'),
2503
- budget_min: this.getNodeParameter('budget_min', i, 0),
2504
- budget_max: this.getNodeParameter('budget_max', i, 0),
2505
- property_type: this.getNodeParameter('property_type', i, 'apartamento'),
2506
- conversation_id: this.getNodeParameter('conversation_id', i, ''),
2507
- status: this.getNodeParameter('status', i, 'new'),
2508
- score: this.getNodeParameter('score', i, 0),
2509
- category: this.getNodeParameter('category', i, 'warm'),
2510
- notes: this.getNodeParameter('notes', i, ''),
2511
- crm_id: this.getNodeParameter('crm_id', i, ''),
2512
- };
2513
- // Procesar preferred_areas (convertir string separado por comas a array)
2514
- const areasString = this.getNodeParameter('preferred_areas', i, '');
2515
- if (areasString) {
2516
- body.preferred_areas = areasString.split(',').map((area) => area.trim());
2517
- }
2518
- // Procesar tags (convertir string separado por comas a array)
2519
- const tagsString = this.getNodeParameter('tags', i, '');
2520
- if (tagsString) {
2521
- body.tags = tagsString.split(',').map((tag) => tag.trim());
2522
- }
2523
- // Remover campos vacíos opcionales
2524
- if (!body.message)
2525
- delete body.message;
2526
- if (body.budget_min === 0)
2527
- delete body.budget_min;
2528
- if (body.budget_max === 0)
2529
- delete body.budget_max;
2530
- if (!body.preferred_areas || body.preferred_areas.length === 0)
2531
- delete body.preferred_areas;
2532
- if (!body.conversation_id)
2533
- delete body.conversation_id;
2534
- if (!body.notes)
2535
- delete body.notes;
2536
- if (!body.crm_id)
2537
- delete body.crm_id;
2538
- if (!body.tags || body.tags.length === 0)
2539
- delete body.tags;
2540
- if (body.score === 0)
2541
- delete body.score;
2542
- }
2543
- responseData = await this.helpers.httpRequest({
2544
- method: 'POST',
2545
- url: `${baseUrl}/api/v1/leads`,
2546
- body,
2547
- json: true,
2548
- });
2549
- }
2550
- else if (operation === 'update') {
2551
- const leadId = this.getNodeParameter('leadId', i);
2552
- const useJsonInput = this.getNodeParameter('useJsonInput', i, false);
2553
- let body = {};
2554
- if (useJsonInput) {
2555
- // Usar JSON del nodo anterior
2556
- body = items[i].json;
2557
- }
2558
- else {
2559
- // Construir body con campos estructurados (solo enviar campos proporcionados)
2560
- const name = this.getNodeParameter('name', i, '');
2561
- const email = this.getNodeParameter('email', i, '');
2562
- const phone = this.getNodeParameter('phone', i, '');
2563
- const message = this.getNodeParameter('message', i, '');
2564
- const interest = this.getNodeParameter('interest', i, '');
2565
- const budget_min = this.getNodeParameter('budget_min', i, 0);
2566
- const budget_max = this.getNodeParameter('budget_max', i, 0);
2567
- const property_type = this.getNodeParameter('property_type', i, '');
2568
- const areasString = this.getNodeParameter('preferred_areas', i, '');
2569
- const conversation_id = this.getNodeParameter('conversation_id', i, '');
2570
- const status = this.getNodeParameter('status', i, '');
2571
- const score = this.getNodeParameter('score', i, 0);
2572
- const category = this.getNodeParameter('category', i, '');
2573
- const notes = this.getNodeParameter('notes', i, '');
2574
- const crm_id = this.getNodeParameter('crm_id', i, '');
2575
- const tagsString = this.getNodeParameter('tags', i, '');
2576
- if (name)
2577
- body.name = name;
2578
- if (email)
2579
- body.email = email;
2580
- if (phone)
2581
- body.phone = phone;
2582
- if (message)
2583
- body.message = message;
2584
- if (interest)
2585
- body.interest = interest;
2586
- if (budget_min > 0)
2587
- body.budget_min = budget_min;
2588
- if (budget_max > 0)
2589
- body.budget_max = budget_max;
2590
- if (property_type)
2591
- body.property_type = property_type;
2592
- if (conversation_id)
2593
- body.conversation_id = conversation_id;
2594
- if (status)
2595
- body.status = status;
2596
- if (score > 0)
2597
- body.score = score;
2598
- if (category)
2599
- body.category = category;
2600
- if (notes)
2601
- body.notes = notes;
2602
- if (crm_id)
2603
- body.crm_id = crm_id;
2604
- if (areasString) {
2605
- body.preferred_areas = areasString.split(',').map((area) => area.trim());
2606
- }
2607
- if (tagsString) {
2608
- body.tags = tagsString.split(',').map((tag) => tag.trim());
2609
- }
2610
- }
2611
- responseData = await this.helpers.httpRequest({
2612
- method: 'PATCH',
2613
- url: `${baseUrl}/api/v1/leads/${leadId}`,
2614
- body,
2615
- json: true,
2616
- });
2617
- }
2618
- else if (operation === 'get') {
2619
- const leadId = this.getNodeParameter('leadId', i);
2620
- responseData = await this.helpers.httpRequest({
2621
- method: 'GET',
2622
- url: `${baseUrl}/api/v1/leads/${leadId}`,
2623
- json: true,
2624
- });
2625
- }
2626
- else if (operation === 'addActivity') {
2627
- const leadId = this.getNodeParameter('leadId', i);
2628
- const activityType = this.getNodeParameter('activity_type', i);
2629
- const description = this.getNodeParameter('activity_description', i);
2630
- const body = {
2631
- activity_type: activityType,
2632
- description: description,
2633
- };
2634
- responseData = await this.helpers.httpRequest({
2635
- method: 'POST',
2636
- url: `${baseUrl}/api/v1/mariana/leads/${leadId}/activity`,
2637
- body,
2638
- json: true,
2639
- });
2640
- }
2641
- }
2642
2480
  // ============================================
2643
- // PROPERTY RESOURCE
2481
+ // OWNER (PROPIETARIO) OPERATIONS
2644
2482
  // ============================================
2645
- else if (resource === 'property') {
2646
- if (operation === 'search') {
2647
- // ============================================
2648
- // PROPERTY SEARCH - Smart Zone Logic compatible
2649
- // ============================================
2650
- const qs = {};
2651
- // Property ID (búsqueda directa por ID)
2652
- const propertyId = this.getNodeParameter('searchPropertyId', i, 0);
2653
- if (propertyId > 0) {
2654
- qs.id = propertyId;
2655
- }
2656
- // Operación -> Estado (Laravel espera "estado": "for_rent" o "for_sale")
2657
- const operacion = this.getNodeParameter('searchOperacion', i, '');
2658
- if (operacion && operacion !== 'NULL' && operacion !== '') {
2659
- qs.estado = operacion;
2660
- }
2661
- // Tipo de Propiedad
2662
- const tipoPropiedad = this.getNodeParameter('searchTipoPropiedad', i, '');
2663
- if (tipoPropiedad && tipoPropiedad !== '' && tipoPropiedad !== 'NULL') {
2664
- qs.tipo_propiedad = tipoPropiedad;
2665
- }
2666
- // Zonas (barrios) - Smart Zone Logic aplicado desde workflow
2667
- const zonas = this.getNodeParameter('searchZonas', i, '');
2668
- if (zonas && zonas !== '' && zonas !== 'NULL' && zonas !== 'null') {
2669
- qs.barrio = zonas; // Formato: "Núñez, Saavedra, Belgrano"
2670
- }
2671
- // Dormitorios
2672
- const dormitoriosMin = this.getNodeParameter('searchDormitoriosMin', i, 0);
2673
- if (dormitoriosMin > 0) {
2674
- qs.dormitorios_minimo = dormitoriosMin;
2675
- }
2676
- const dormitoriosMax = this.getNodeParameter('searchDormitoriosMax', i, 0);
2677
- if (dormitoriosMax > 0) {
2678
- qs.dormitorios_maximo = dormitoriosMax;
2679
- }
2680
- // Baños
2681
- const banos = this.getNodeParameter('searchBanos', i, 0);
2682
- if (banos > 0) {
2683
- qs.banos_minimo = banos;
2684
- }
2685
- // Ambientes
2686
- const ambientesMin = this.getNodeParameter('searchAmbientesMin', i, 0);
2687
- if (ambientesMin > 0) {
2688
- qs.ambientes_minimo = ambientesMin;
2689
- }
2690
- const ambientesMax = this.getNodeParameter('searchAmbientesMax', i, 0);
2691
- if (ambientesMax > 0) {
2692
- qs.ambientes_maximo = ambientesMax;
2693
- }
2694
- // Área (Superficie)
2695
- const areaMin = this.getNodeParameter('searchAreaMin', i, 0);
2696
- if (areaMin > 0) {
2697
- qs.area_minima = areaMin;
2698
- }
2699
- const areaMax = this.getNodeParameter('searchAreaMax', i, 0);
2700
- if (areaMax > 0) {
2701
- qs.area_maxima = areaMax;
2702
- }
2703
- // Moneda
2704
- const moneda = this.getNodeParameter('searchMoneda', i, 'USD');
2705
- if (moneda && moneda !== '') {
2706
- qs.moneda = moneda;
2707
- }
2708
- // Precio
2709
- const precioMin = this.getNodeParameter('searchPrecioMin', i, 0);
2710
- if (precioMin > 0) {
2711
- qs.precio_minimo = precioMin;
2712
- }
2713
- const precioMax = this.getNodeParameter('searchPrecioMax', i, 0);
2483
+ {
2484
+ displayName: 'Operación',
2485
+ name: 'operation',
2486
+ type: 'options',
2487
+ noDataExpression: true,
2488
+ displayOptions: {
2489
+ show: {
2490
+ resource: ['owner'],
2491
+ },
2492
+ },
2493
+ options: [
2494
+ {
2495
+ name: 'Create',
2496
+ value: 'create',
2497
+ description: 'Crear nuevo propietario',
2498
+ action: 'Crear propietario',
2499
+ },
2500
+ {
2501
+ name: 'Get',
2502
+ value: 'get',
2503
+ description: 'Obtener propietario por ID',
2504
+ action: 'Obtener propietario',
2505
+ },
2506
+ {
2507
+ name: 'Search',
2508
+ value: 'search',
2509
+ description: 'Buscar propietario por email, teléfono o CUIT',
2510
+ action: 'Buscar propietario',
2511
+ },
2512
+ {
2513
+ name: 'Update',
2514
+ value: 'update',
2515
+ description: 'Actualizar datos de propietario',
2516
+ action: 'Actualizar propietario',
2517
+ },
2518
+ {
2519
+ name: 'List',
2520
+ value: 'list',
2521
+ description: 'Listar todos los propietarios',
2522
+ action: 'Listar propietarios',
2523
+ },
2524
+ ],
2525
+ default: 'create',
2526
+ },
2527
+ // Owner ID (for get, update)
2528
+ {
2529
+ displayName: 'Owner ID',
2530
+ name: 'ownerId',
2531
+ type: 'number',
2532
+ required: true,
2533
+ displayOptions: {
2534
+ show: {
2535
+ resource: ['owner'],
2536
+ operation: ['get', 'update'],
2537
+ },
2538
+ },
2539
+ default: 0,
2540
+ description: 'ID del propietario',
2541
+ },
2542
+ // Owner Create - Nombre
2543
+ {
2544
+ displayName: 'Nombre Completo',
2545
+ name: 'ownerNombre',
2546
+ type: 'string',
2547
+ required: true,
2548
+ displayOptions: {
2549
+ show: {
2550
+ resource: ['owner'],
2551
+ operation: ['create'],
2552
+ },
2553
+ },
2554
+ default: '',
2555
+ placeholder: 'Juan Pérez',
2556
+ description: 'Nombre completo del propietario',
2557
+ },
2558
+ // Owner Create - Email
2559
+ {
2560
+ displayName: 'Email',
2561
+ name: 'ownerEmail',
2562
+ type: 'string',
2563
+ required: true,
2564
+ displayOptions: {
2565
+ show: {
2566
+ resource: ['owner'],
2567
+ operation: ['create'],
2568
+ },
2569
+ },
2570
+ default: '',
2571
+ placeholder: 'juan@ejemplo.com',
2572
+ description: 'Email del propietario',
2573
+ },
2574
+ // Owner Create - Teléfono
2575
+ {
2576
+ displayName: 'Teléfono',
2577
+ name: 'ownerTelefono',
2578
+ type: 'string',
2579
+ required: true,
2580
+ displayOptions: {
2581
+ show: {
2582
+ resource: ['owner'],
2583
+ operation: ['create'],
2584
+ },
2585
+ },
2586
+ default: '',
2587
+ placeholder: '+54 11 1234-5678',
2588
+ description: 'Teléfono del propietario',
2589
+ },
2590
+ // Owner Create - CUIT/CUIL
2591
+ {
2592
+ displayName: 'CUIT/CUIL',
2593
+ name: 'ownerCuit',
2594
+ type: 'string',
2595
+ displayOptions: {
2596
+ show: {
2597
+ resource: ['owner'],
2598
+ operation: ['create', 'update'],
2599
+ },
2600
+ },
2601
+ default: '',
2602
+ placeholder: '20-12345678-9',
2603
+ description: 'CUIT o CUIL del propietario (opcional)',
2604
+ },
2605
+ // Owner Create - Tipo Persona
2606
+ {
2607
+ displayName: 'Tipo de Persona',
2608
+ name: 'ownerTipoPersona',
2609
+ type: 'options',
2610
+ displayOptions: {
2611
+ show: {
2612
+ resource: ['owner'],
2613
+ operation: ['create', 'update'],
2614
+ },
2615
+ },
2616
+ options: [
2617
+ { name: 'Persona Física', value: 'fisica' },
2618
+ { name: 'Persona Jurídica', value: 'juridica' },
2619
+ ],
2620
+ default: 'fisica',
2621
+ description: 'Tipo de persona',
2622
+ },
2623
+ // Owner Create - Dirección
2624
+ {
2625
+ displayName: 'Dirección',
2626
+ name: 'ownerDireccion',
2627
+ type: 'string',
2628
+ displayOptions: {
2629
+ show: {
2630
+ resource: ['owner'],
2631
+ operation: ['create', 'update'],
2632
+ },
2633
+ },
2634
+ default: '',
2635
+ placeholder: 'Av. Corrientes 1234, CABA',
2636
+ description: 'Dirección del propietario (opcional)',
2637
+ },
2638
+ // Owner Create - Notas
2639
+ {
2640
+ displayName: 'Notas',
2641
+ name: 'ownerNotas',
2642
+ type: 'string',
2643
+ typeOptions: {
2644
+ rows: 3,
2645
+ },
2646
+ displayOptions: {
2647
+ show: {
2648
+ resource: ['owner'],
2649
+ operation: ['create', 'update'],
2650
+ },
2651
+ },
2652
+ default: '',
2653
+ description: 'Notas adicionales sobre el propietario (opcional)',
2654
+ },
2655
+ // Owner Search - Email
2656
+ {
2657
+ displayName: 'Buscar por Email',
2658
+ name: 'searchEmail',
2659
+ type: 'string',
2660
+ displayOptions: {
2661
+ show: {
2662
+ resource: ['owner'],
2663
+ operation: ['search'],
2664
+ },
2665
+ },
2666
+ default: '',
2667
+ placeholder: 'juan@ejemplo.com',
2668
+ description: 'Email a buscar (opcional)',
2669
+ },
2670
+ // Owner Search - Teléfono
2671
+ {
2672
+ displayName: 'Buscar por Teléfono',
2673
+ name: 'searchTelefono',
2674
+ type: 'string',
2675
+ displayOptions: {
2676
+ show: {
2677
+ resource: ['owner'],
2678
+ operation: ['search'],
2679
+ },
2680
+ },
2681
+ default: '',
2682
+ placeholder: '11 1234-5678',
2683
+ description: 'Teléfono a buscar (opcional)',
2684
+ },
2685
+ // Owner Search - CUIT
2686
+ {
2687
+ displayName: 'Buscar por CUIT',
2688
+ name: 'searchCuit',
2689
+ type: 'string',
2690
+ displayOptions: {
2691
+ show: {
2692
+ resource: ['owner'],
2693
+ operation: ['search'],
2694
+ },
2695
+ },
2696
+ default: '',
2697
+ placeholder: '20-12345678-9',
2698
+ description: 'CUIT a buscar (opcional)',
2699
+ },
2700
+ // Owner Update - Nombre
2701
+ {
2702
+ displayName: 'Nombre (nuevo)',
2703
+ name: 'updateNombre',
2704
+ type: 'string',
2705
+ displayOptions: {
2706
+ show: {
2707
+ resource: ['owner'],
2708
+ operation: ['update'],
2709
+ },
2710
+ },
2711
+ default: '',
2712
+ description: 'Nuevo nombre (dejar vacío para no cambiar)',
2713
+ },
2714
+ // Owner Update - Email
2715
+ {
2716
+ displayName: 'Email (nuevo)',
2717
+ name: 'updateEmail',
2718
+ type: 'string',
2719
+ displayOptions: {
2720
+ show: {
2721
+ resource: ['owner'],
2722
+ operation: ['update'],
2723
+ },
2724
+ },
2725
+ default: '',
2726
+ description: 'Nuevo email (dejar vacío para no cambiar)',
2727
+ },
2728
+ // Owner Update - Teléfono
2729
+ {
2730
+ displayName: 'Teléfono (nuevo)',
2731
+ name: 'updateTelefono',
2732
+ type: 'string',
2733
+ displayOptions: {
2734
+ show: {
2735
+ resource: ['owner'],
2736
+ operation: ['update'],
2737
+ },
2738
+ },
2739
+ default: '',
2740
+ description: 'Nuevo teléfono (dejar vacío para no cambiar)',
2741
+ },
2742
+ // Owner List - Paginación
2743
+ {
2744
+ displayName: 'Por Página',
2745
+ name: 'ownerPerPage',
2746
+ type: 'number',
2747
+ displayOptions: {
2748
+ show: {
2749
+ resource: ['owner'],
2750
+ operation: ['list'],
2751
+ },
2752
+ },
2753
+ default: 20,
2754
+ description: 'Cantidad de resultados por página',
2755
+ },
2756
+ // ============================================
2757
+ // TASACIÓN OPERATIONS
2758
+ // ============================================
2759
+ {
2760
+ displayName: 'Operación',
2761
+ name: 'operation',
2762
+ type: 'options',
2763
+ noDataExpression: true,
2764
+ displayOptions: {
2765
+ show: {
2766
+ resource: ['tasacion'],
2767
+ },
2768
+ },
2769
+ options: [
2770
+ {
2771
+ name: 'Generate',
2772
+ value: 'generate',
2773
+ description: 'Generar tasación estimada de propiedad',
2774
+ action: 'Generar tasación',
2775
+ },
2776
+ {
2777
+ name: 'Get',
2778
+ value: 'get',
2779
+ description: 'Obtener tasación por ID',
2780
+ action: 'Obtener tasación',
2781
+ },
2782
+ {
2783
+ name: 'List by Owner',
2784
+ value: 'listByOwner',
2785
+ description: 'Listar tasaciones de un propietario',
2786
+ action: 'Listar tasaciones de propietario',
2787
+ },
2788
+ ],
2789
+ default: 'generate',
2790
+ },
2791
+ // Tasación ID
2792
+ {
2793
+ displayName: 'Tasación ID',
2794
+ name: 'tasacionId',
2795
+ type: 'number',
2796
+ required: true,
2797
+ displayOptions: {
2798
+ show: {
2799
+ resource: ['tasacion'],
2800
+ operation: ['get'],
2801
+ },
2802
+ },
2803
+ default: 0,
2804
+ description: 'ID de la tasación',
2805
+ },
2806
+ // Tasación - Owner ID (for listByOwner)
2807
+ {
2808
+ displayName: 'Owner ID',
2809
+ name: 'tasacionOwnerId',
2810
+ type: 'number',
2811
+ required: true,
2812
+ displayOptions: {
2813
+ show: {
2814
+ resource: ['tasacion'],
2815
+ operation: ['listByOwner'],
2816
+ },
2817
+ },
2818
+ default: 0,
2819
+ description: 'ID del propietario para listar sus tasaciones',
2820
+ },
2821
+ // Tasación Generate - Owner ID (opcional)
2822
+ {
2823
+ displayName: 'Owner ID (Guardar)',
2824
+ name: 'tasacionOwnerIdSave',
2825
+ type: 'number',
2826
+ displayOptions: {
2827
+ show: {
2828
+ resource: ['tasacion'],
2829
+ operation: ['generate'],
2830
+ },
2831
+ },
2832
+ default: 0,
2833
+ description: 'ID del propietario para guardar la tasación (0 = no guardar)',
2834
+ },
2835
+ // Tasación Generate - Tipo Propiedad
2836
+ {
2837
+ displayName: 'Tipo de Propiedad',
2838
+ name: 'tasacionTipo',
2839
+ type: 'options',
2840
+ required: true,
2841
+ displayOptions: {
2842
+ show: {
2843
+ resource: ['tasacion'],
2844
+ operation: ['generate'],
2845
+ },
2846
+ },
2847
+ options: [
2848
+ { name: 'Departamento', value: 'departamento' },
2849
+ { name: 'Casa', value: 'casa' },
2850
+ { name: 'PH', value: 'ph' },
2851
+ { name: 'Local Comercial', value: 'local' },
2852
+ { name: 'Oficina', value: 'oficina' },
2853
+ { name: 'Terreno', value: 'terreno' },
2854
+ { name: 'Cochera', value: 'cochera' },
2855
+ ],
2856
+ default: 'departamento',
2857
+ description: 'Tipo de propiedad a tasar',
2858
+ },
2859
+ // Tasación Generate - Barrio
2860
+ {
2861
+ displayName: 'Barrio/Zona',
2862
+ name: 'tasacionBarrio',
2863
+ type: 'string',
2864
+ required: true,
2865
+ displayOptions: {
2866
+ show: {
2867
+ resource: ['tasacion'],
2868
+ operation: ['generate'],
2869
+ },
2870
+ },
2871
+ default: '',
2872
+ placeholder: 'Palermo, Recoleta, Belgrano...',
2873
+ description: 'Barrio o zona de la propiedad',
2874
+ },
2875
+ // Tasación Generate - Metros Cuadrados
2876
+ {
2877
+ displayName: 'Metros Cuadrados',
2878
+ name: 'tasacionMetros',
2879
+ type: 'number',
2880
+ required: true,
2881
+ displayOptions: {
2882
+ show: {
2883
+ resource: ['tasacion'],
2884
+ operation: ['generate'],
2885
+ },
2886
+ },
2887
+ default: 50,
2888
+ description: 'Superficie en metros cuadrados',
2889
+ },
2890
+ // Tasación Generate - Ambientes
2891
+ {
2892
+ displayName: 'Ambientes',
2893
+ name: 'tasacionAmbientes',
2894
+ type: 'number',
2895
+ displayOptions: {
2896
+ show: {
2897
+ resource: ['tasacion'],
2898
+ operation: ['generate'],
2899
+ },
2900
+ },
2901
+ default: 2,
2902
+ description: 'Cantidad de ambientes',
2903
+ },
2904
+ // Tasación Generate - Dormitorios
2905
+ {
2906
+ displayName: 'Dormitorios',
2907
+ name: 'tasacionDormitorios',
2908
+ type: 'number',
2909
+ displayOptions: {
2910
+ show: {
2911
+ resource: ['tasacion'],
2912
+ operation: ['generate'],
2913
+ },
2914
+ },
2915
+ default: 1,
2916
+ description: 'Cantidad de dormitorios',
2917
+ },
2918
+ // Tasación Generate - Baños
2919
+ {
2920
+ displayName: 'Baños',
2921
+ name: 'tasacionBanos',
2922
+ type: 'number',
2923
+ displayOptions: {
2924
+ show: {
2925
+ resource: ['tasacion'],
2926
+ operation: ['generate'],
2927
+ },
2928
+ },
2929
+ default: 1,
2930
+ description: 'Cantidad de baños',
2931
+ },
2932
+ // Tasación Generate - Antigüedad
2933
+ {
2934
+ displayName: 'Antigüedad (años)',
2935
+ name: 'tasacionAntiguedad',
2936
+ type: 'number',
2937
+ displayOptions: {
2938
+ show: {
2939
+ resource: ['tasacion'],
2940
+ operation: ['generate'],
2941
+ },
2942
+ },
2943
+ default: 10,
2944
+ description: 'Antigüedad en años de la propiedad',
2945
+ },
2946
+ // Tasación Generate - Estado
2947
+ {
2948
+ displayName: 'Estado',
2949
+ name: 'tasacionEstado',
2950
+ type: 'options',
2951
+ displayOptions: {
2952
+ show: {
2953
+ resource: ['tasacion'],
2954
+ operation: ['generate'],
2955
+ },
2956
+ },
2957
+ options: [
2958
+ { name: 'Excelente', value: 'excelente' },
2959
+ { name: 'Muy Bueno', value: 'muy_bueno' },
2960
+ { name: 'Bueno', value: 'bueno' },
2961
+ { name: 'Regular', value: 'regular' },
2962
+ { name: 'A Refaccionar', value: 'a_refaccionar' },
2963
+ ],
2964
+ default: 'bueno',
2965
+ description: 'Estado de conservación',
2966
+ },
2967
+ // Tasación Generate - Amenidades
2968
+ {
2969
+ displayName: 'Amenidades',
2970
+ name: 'tasacionAmenidades',
2971
+ type: 'string',
2972
+ displayOptions: {
2973
+ show: {
2974
+ resource: ['tasacion'],
2975
+ operation: ['generate'],
2976
+ },
2977
+ },
2978
+ default: '',
2979
+ placeholder: 'pileta, gym, sum, parrilla...',
2980
+ description: 'Amenidades separadas por coma (aumentan el valor)',
2981
+ },
2982
+ // ============================================
2983
+ // DOCUSEAL (FIRMA DIGITAL) OPERATIONS
2984
+ // ============================================
2985
+ {
2986
+ displayName: 'Operación',
2987
+ name: 'operation',
2988
+ type: 'options',
2989
+ noDataExpression: true,
2990
+ displayOptions: {
2991
+ show: {
2992
+ resource: ['docuseal'],
2993
+ },
2994
+ },
2995
+ options: [
2996
+ {
2997
+ name: 'Create Mandato',
2998
+ value: 'createMandato',
2999
+ description: 'Crear mandato para firma digital',
3000
+ action: 'Crear mandato',
3001
+ },
3002
+ {
3003
+ name: 'Get Status',
3004
+ value: 'getStatus',
3005
+ description: 'Verificar estado de firma',
3006
+ action: 'Verificar estado de firma',
3007
+ },
3008
+ {
3009
+ name: 'List Templates',
3010
+ value: 'listTemplates',
3011
+ description: 'Listar templates disponibles',
3012
+ action: 'Listar templates',
3013
+ },
3014
+ {
3015
+ name: 'Health Check',
3016
+ value: 'health',
3017
+ description: 'Verificar conexión con DocuSeal',
3018
+ action: 'Health check DocuSeal',
3019
+ },
3020
+ ],
3021
+ default: 'createMandato',
3022
+ },
3023
+ // DocuSeal - Submission ID
3024
+ {
3025
+ displayName: 'Submission ID',
3026
+ name: 'docusealSubmissionId',
3027
+ type: 'number',
3028
+ required: true,
3029
+ displayOptions: {
3030
+ show: {
3031
+ resource: ['docuseal'],
3032
+ operation: ['getStatus'],
3033
+ },
3034
+ },
3035
+ default: 0,
3036
+ description: 'ID de la submission en DocuSeal',
3037
+ },
3038
+ // DocuSeal - Tipo Mandato
3039
+ {
3040
+ displayName: 'Tipo de Mandato',
3041
+ name: 'docusealTipo',
3042
+ type: 'options',
3043
+ required: true,
3044
+ displayOptions: {
3045
+ show: {
3046
+ resource: ['docuseal'],
3047
+ operation: ['createMandato'],
3048
+ },
3049
+ },
3050
+ options: [
3051
+ { name: 'Venta', value: 'venta' },
3052
+ { name: 'Alquiler', value: 'alquiler' },
3053
+ ],
3054
+ default: 'venta',
3055
+ description: 'Tipo de mandato a crear',
3056
+ },
3057
+ // DocuSeal - Owner ID
3058
+ {
3059
+ displayName: 'Owner ID',
3060
+ name: 'docusealOwnerId',
3061
+ type: 'number',
3062
+ required: true,
3063
+ displayOptions: {
3064
+ show: {
3065
+ resource: ['docuseal'],
3066
+ operation: ['createMandato'],
3067
+ },
3068
+ },
3069
+ default: 0,
3070
+ description: 'ID del propietario que firmará',
3071
+ },
3072
+ // DocuSeal - Property ID
3073
+ {
3074
+ displayName: 'Property ID',
3075
+ name: 'docusealPropertyId',
3076
+ type: 'number',
3077
+ displayOptions: {
3078
+ show: {
3079
+ resource: ['docuseal'],
3080
+ operation: ['createMandato'],
3081
+ },
3082
+ },
3083
+ default: 0,
3084
+ description: 'ID de la propiedad (opcional)',
3085
+ },
3086
+ // DocuSeal - Duración
3087
+ {
3088
+ displayName: 'Duración (meses)',
3089
+ name: 'docusealDuracion',
3090
+ type: 'number',
3091
+ displayOptions: {
3092
+ show: {
3093
+ resource: ['docuseal'],
3094
+ operation: ['createMandato'],
3095
+ },
3096
+ },
3097
+ default: 6,
3098
+ description: 'Duración del mandato en meses',
3099
+ },
3100
+ // DocuSeal - Comisión
3101
+ {
3102
+ displayName: 'Comisión (%)',
3103
+ name: 'docusealComision',
3104
+ type: 'number',
3105
+ displayOptions: {
3106
+ show: {
3107
+ resource: ['docuseal'],
3108
+ operation: ['createMandato'],
3109
+ },
3110
+ },
3111
+ default: 3,
3112
+ description: 'Porcentaje de comisión',
3113
+ },
3114
+ // DocuSeal - Precio
3115
+ {
3116
+ displayName: 'Precio Sugerido (USD)',
3117
+ name: 'docusealPrecio',
3118
+ type: 'number',
3119
+ displayOptions: {
3120
+ show: {
3121
+ resource: ['docuseal'],
3122
+ operation: ['createMandato'],
3123
+ },
3124
+ },
3125
+ default: 0,
3126
+ description: 'Precio sugerido de publicación (0 = a convenir)',
3127
+ },
3128
+ // ============================================
3129
+ // MARIANA (TRANSFERENCIA) OPERATIONS
3130
+ // ============================================
3131
+ {
3132
+ displayName: 'Operación',
3133
+ name: 'operation',
3134
+ type: 'options',
3135
+ noDataExpression: true,
3136
+ displayOptions: {
3137
+ show: {
3138
+ resource: ['mariana'],
3139
+ },
3140
+ },
3141
+ options: [
3142
+ {
3143
+ name: 'Transfer Lead',
3144
+ value: 'transferLead',
3145
+ description: 'Transferir lead/conversación al departamento de Mariana',
3146
+ action: 'Transferir a Mariana',
3147
+ },
3148
+ {
3149
+ name: 'Get Queue Status',
3150
+ value: 'getQueueStatus',
3151
+ description: 'Ver estado de la cola de Mariana',
3152
+ action: 'Ver cola de Mariana',
3153
+ },
3154
+ ],
3155
+ default: 'transferLead',
3156
+ },
3157
+ // Mariana - Lead ID
3158
+ {
3159
+ displayName: 'Lead ID',
3160
+ name: 'marianaLeadId',
3161
+ type: 'number',
3162
+ required: true,
3163
+ displayOptions: {
3164
+ show: {
3165
+ resource: ['mariana'],
3166
+ operation: ['transferLead'],
3167
+ },
3168
+ },
3169
+ default: 0,
3170
+ description: 'ID del lead a transferir',
3171
+ },
3172
+ // Mariana - Conversation ID
3173
+ {
3174
+ displayName: 'Conversation ID',
3175
+ name: 'marianaConversationId',
3176
+ type: 'number',
3177
+ displayOptions: {
3178
+ show: {
3179
+ resource: ['mariana'],
3180
+ operation: ['transferLead'],
3181
+ },
3182
+ },
3183
+ default: 0,
3184
+ description: 'ID de la conversación en Chatwoot (opcional)',
3185
+ },
3186
+ // Mariana - Motivo
3187
+ {
3188
+ displayName: 'Motivo de Transferencia',
3189
+ name: 'marianaMotivo',
3190
+ type: 'options',
3191
+ required: true,
3192
+ displayOptions: {
3193
+ show: {
3194
+ resource: ['mariana'],
3195
+ operation: ['transferLead'],
3196
+ },
3197
+ },
3198
+ options: [
3199
+ { name: 'Captación de Propiedad', value: 'captacion' },
3200
+ { name: 'Tasación Requerida', value: 'tasacion' },
3201
+ { name: 'Documentación Pendiente', value: 'documentacion' },
3202
+ { name: 'Firma de Mandato', value: 'mandato' },
3203
+ { name: 'Consulta Específica', value: 'consulta' },
3204
+ { name: 'Otro', value: 'otro' },
3205
+ ],
3206
+ default: 'captacion',
3207
+ description: 'Motivo por el cual se transfiere',
3208
+ },
3209
+ // Mariana - Notas
3210
+ {
3211
+ displayName: 'Notas para Mariana',
3212
+ name: 'marianaNotas',
3213
+ type: 'string',
3214
+ typeOptions: {
3215
+ rows: 3,
3216
+ },
3217
+ displayOptions: {
3218
+ show: {
3219
+ resource: ['mariana'],
3220
+ operation: ['transferLead'],
3221
+ },
3222
+ },
3223
+ default: '',
3224
+ placeholder: 'Contexto importante para Mariana...',
3225
+ description: 'Notas adicionales sobre el lead/propiedad',
3226
+ },
3227
+ // Mariana - Urgencia
3228
+ {
3229
+ displayName: 'Urgencia',
3230
+ name: 'marianaUrgencia',
3231
+ type: 'options',
3232
+ displayOptions: {
3233
+ show: {
3234
+ resource: ['mariana'],
3235
+ operation: ['transferLead'],
3236
+ },
3237
+ },
3238
+ options: [
3239
+ { name: 'Normal', value: 'normal' },
3240
+ { name: 'Alta', value: 'alta' },
3241
+ { name: 'Urgente', value: 'urgente' },
3242
+ ],
3243
+ default: 'normal',
3244
+ description: 'Nivel de urgencia de la transferencia',
3245
+ },
3246
+ // Mariana - Datos de Propiedad
3247
+ {
3248
+ displayName: 'Dirección Propiedad',
3249
+ name: 'marianaDireccion',
3250
+ type: 'string',
3251
+ displayOptions: {
3252
+ show: {
3253
+ resource: ['mariana'],
3254
+ operation: ['transferLead'],
3255
+ },
3256
+ },
3257
+ default: '',
3258
+ placeholder: 'Av. Santa Fe 1234, Palermo',
3259
+ description: 'Dirección de la propiedad a captar (si aplica)',
3260
+ },
3261
+ // Mariana - Tipo Operación
3262
+ {
3263
+ displayName: 'Tipo de Operación',
3264
+ name: 'marianaOperacion',
3265
+ type: 'options',
3266
+ displayOptions: {
3267
+ show: {
3268
+ resource: ['mariana'],
3269
+ operation: ['transferLead'],
3270
+ },
3271
+ },
3272
+ options: [
3273
+ { name: 'Venta', value: 'venta' },
3274
+ { name: 'Alquiler', value: 'alquiler' },
3275
+ { name: 'Ambas', value: 'ambas' },
3276
+ { name: 'No Definido', value: 'undefined' },
3277
+ ],
3278
+ default: 'undefined',
3279
+ description: 'Tipo de operación que busca el propietario',
3280
+ },
3281
+ ],
3282
+ };
3283
+ }
3284
+ async execute() {
3285
+ const items = this.getInputData();
3286
+ const returnData = [];
3287
+ const credentials = await this.getCredentials('aivenceRealtyApi');
3288
+ const baseUrl = credentials.baseUrl;
3289
+ for (let i = 0; i < items.length; i++) {
3290
+ try {
3291
+ const resource = this.getNodeParameter('resource', i);
3292
+ const operation = this.getNodeParameter('operation', i);
3293
+ let responseData;
3294
+ // ============================================
3295
+ // LEAD RESOURCE
3296
+ // ============================================
3297
+ if (resource === 'lead') {
3298
+ if (operation === 'list') {
3299
+ responseData = await this.helpers.httpRequest({
3300
+ method: 'GET',
3301
+ url: `${baseUrl}/api/v1/leads`,
3302
+ json: true,
3303
+ });
3304
+ }
3305
+ else if (operation === 'create') {
3306
+ const useJsonInput = this.getNodeParameter('useJsonInput', i, false);
3307
+ let body = {};
3308
+ if (useJsonInput) {
3309
+ // Usar JSON del nodo anterior
3310
+ body = items[i].json;
3311
+ }
3312
+ else {
3313
+ // Construir body con campos estructurados
3314
+ body = {
3315
+ name: this.getNodeParameter('name', i),
3316
+ email: this.getNodeParameter('email', i),
3317
+ phone: this.getNodeParameter('phone', i),
3318
+ message: this.getNodeParameter('message', i, ''),
3319
+ interest: this.getNodeParameter('interest', i, 'compra'),
3320
+ budget_min: this.getNodeParameter('budget_min', i, 0),
3321
+ budget_max: this.getNodeParameter('budget_max', i, 0),
3322
+ property_type: this.getNodeParameter('property_type', i, 'apartamento'),
3323
+ conversation_id: this.getNodeParameter('conversation_id', i, ''),
3324
+ status: this.getNodeParameter('status', i, 'new'),
3325
+ score: this.getNodeParameter('score', i, 0),
3326
+ category: this.getNodeParameter('category', i, 'warm'),
3327
+ notes: this.getNodeParameter('notes', i, ''),
3328
+ crm_id: this.getNodeParameter('crm_id', i, ''),
3329
+ };
3330
+ // Procesar preferred_areas (convertir string separado por comas a array)
3331
+ const areasString = this.getNodeParameter('preferred_areas', i, '');
3332
+ if (areasString) {
3333
+ body.preferred_areas = areasString.split(',').map((area) => area.trim());
3334
+ }
3335
+ // Procesar tags (convertir string separado por comas a array)
3336
+ const tagsString = this.getNodeParameter('tags', i, '');
3337
+ if (tagsString) {
3338
+ body.tags = tagsString.split(',').map((tag) => tag.trim());
3339
+ }
3340
+ // Remover campos vacíos opcionales
3341
+ if (!body.message)
3342
+ delete body.message;
3343
+ if (body.budget_min === 0)
3344
+ delete body.budget_min;
3345
+ if (body.budget_max === 0)
3346
+ delete body.budget_max;
3347
+ if (!body.preferred_areas || body.preferred_areas.length === 0)
3348
+ delete body.preferred_areas;
3349
+ if (!body.conversation_id)
3350
+ delete body.conversation_id;
3351
+ if (!body.notes)
3352
+ delete body.notes;
3353
+ if (!body.crm_id)
3354
+ delete body.crm_id;
3355
+ if (!body.tags || body.tags.length === 0)
3356
+ delete body.tags;
3357
+ if (body.score === 0)
3358
+ delete body.score;
3359
+ }
3360
+ responseData = await this.helpers.httpRequest({
3361
+ method: 'POST',
3362
+ url: `${baseUrl}/api/v1/leads`,
3363
+ body,
3364
+ json: true,
3365
+ });
3366
+ }
3367
+ else if (operation === 'update') {
3368
+ const leadId = this.getNodeParameter('leadId', i);
3369
+ const useJsonInput = this.getNodeParameter('useJsonInput', i, false);
3370
+ let body = {};
3371
+ if (useJsonInput) {
3372
+ // Usar JSON del nodo anterior
3373
+ body = items[i].json;
3374
+ }
3375
+ else {
3376
+ // Construir body con campos estructurados (solo enviar campos proporcionados)
3377
+ const name = this.getNodeParameter('name', i, '');
3378
+ const email = this.getNodeParameter('email', i, '');
3379
+ const phone = this.getNodeParameter('phone', i, '');
3380
+ const message = this.getNodeParameter('message', i, '');
3381
+ const interest = this.getNodeParameter('interest', i, '');
3382
+ const budget_min = this.getNodeParameter('budget_min', i, 0);
3383
+ const budget_max = this.getNodeParameter('budget_max', i, 0);
3384
+ const property_type = this.getNodeParameter('property_type', i, '');
3385
+ const areasString = this.getNodeParameter('preferred_areas', i, '');
3386
+ const conversation_id = this.getNodeParameter('conversation_id', i, '');
3387
+ const status = this.getNodeParameter('status', i, '');
3388
+ const score = this.getNodeParameter('score', i, 0);
3389
+ const category = this.getNodeParameter('category', i, '');
3390
+ const notes = this.getNodeParameter('notes', i, '');
3391
+ const crm_id = this.getNodeParameter('crm_id', i, '');
3392
+ const tagsString = this.getNodeParameter('tags', i, '');
3393
+ if (name)
3394
+ body.name = name;
3395
+ if (email)
3396
+ body.email = email;
3397
+ if (phone)
3398
+ body.phone = phone;
3399
+ if (message)
3400
+ body.message = message;
3401
+ if (interest)
3402
+ body.interest = interest;
3403
+ if (budget_min > 0)
3404
+ body.budget_min = budget_min;
3405
+ if (budget_max > 0)
3406
+ body.budget_max = budget_max;
3407
+ if (property_type)
3408
+ body.property_type = property_type;
3409
+ if (conversation_id)
3410
+ body.conversation_id = conversation_id;
3411
+ if (status)
3412
+ body.status = status;
3413
+ if (score > 0)
3414
+ body.score = score;
3415
+ if (category)
3416
+ body.category = category;
3417
+ if (notes)
3418
+ body.notes = notes;
3419
+ if (crm_id)
3420
+ body.crm_id = crm_id;
3421
+ if (areasString) {
3422
+ body.preferred_areas = areasString.split(',').map((area) => area.trim());
3423
+ }
3424
+ if (tagsString) {
3425
+ body.tags = tagsString.split(',').map((tag) => tag.trim());
3426
+ }
3427
+ }
3428
+ responseData = await this.helpers.httpRequest({
3429
+ method: 'PATCH',
3430
+ url: `${baseUrl}/api/v1/leads/${leadId}`,
3431
+ body,
3432
+ json: true,
3433
+ });
3434
+ }
3435
+ else if (operation === 'get') {
3436
+ const leadId = this.getNodeParameter('leadId', i);
3437
+ responseData = await this.helpers.httpRequest({
3438
+ method: 'GET',
3439
+ url: `${baseUrl}/api/v1/leads/${leadId}`,
3440
+ json: true,
3441
+ });
3442
+ }
3443
+ else if (operation === 'addActivity') {
3444
+ const leadId = this.getNodeParameter('leadId', i);
3445
+ const activityType = this.getNodeParameter('activity_type', i);
3446
+ const description = this.getNodeParameter('activity_description', i);
3447
+ const body = {
3448
+ activity_type: activityType,
3449
+ description: description,
3450
+ };
3451
+ responseData = await this.helpers.httpRequest({
3452
+ method: 'POST',
3453
+ url: `${baseUrl}/api/v1/mariana/leads/${leadId}/activity`,
3454
+ body,
3455
+ json: true,
3456
+ });
3457
+ }
3458
+ }
3459
+ // ============================================
3460
+ // PROPERTY RESOURCE
3461
+ // ============================================
3462
+ else if (resource === 'property') {
3463
+ if (operation === 'search') {
3464
+ // ============================================
3465
+ // PROPERTY SEARCH - Smart Zone Logic compatible
3466
+ // ============================================
3467
+ const qs = {};
3468
+ // Property ID (búsqueda directa por ID)
3469
+ const propertyId = this.getNodeParameter('searchPropertyId', i, 0);
3470
+ if (propertyId > 0) {
3471
+ qs.id = propertyId;
3472
+ }
3473
+ // Operación -> Estado (Laravel espera "estado": "for_rent" o "for_sale")
3474
+ const operacion = this.getNodeParameter('searchOperacion', i, '');
3475
+ if (operacion && operacion !== 'NULL' && operacion !== '') {
3476
+ qs.estado = operacion;
3477
+ }
3478
+ // Tipo de Propiedad
3479
+ const tipoPropiedad = this.getNodeParameter('searchTipoPropiedad', i, '');
3480
+ if (tipoPropiedad && tipoPropiedad !== '' && tipoPropiedad !== 'NULL') {
3481
+ qs.tipo_propiedad = tipoPropiedad;
3482
+ }
3483
+ // Zonas (barrios) - Smart Zone Logic aplicado desde workflow
3484
+ const zonas = this.getNodeParameter('searchZonas', i, '');
3485
+ if (zonas && zonas !== '' && zonas !== 'NULL' && zonas !== 'null') {
3486
+ qs.barrio = zonas; // Formato: "Núñez, Saavedra, Belgrano"
3487
+ }
3488
+ // Dormitorios
3489
+ const dormitoriosMin = this.getNodeParameter('searchDormitoriosMin', i, 0);
3490
+ if (dormitoriosMin > 0) {
3491
+ qs.dormitorios_minimo = dormitoriosMin;
3492
+ }
3493
+ const dormitoriosMax = this.getNodeParameter('searchDormitoriosMax', i, 0);
3494
+ if (dormitoriosMax > 0) {
3495
+ qs.dormitorios_maximo = dormitoriosMax;
3496
+ }
3497
+ // Baños
3498
+ const banos = this.getNodeParameter('searchBanos', i, 0);
3499
+ if (banos > 0) {
3500
+ qs.banos_minimo = banos;
3501
+ }
3502
+ // Ambientes
3503
+ const ambientesMin = this.getNodeParameter('searchAmbientesMin', i, 0);
3504
+ if (ambientesMin > 0) {
3505
+ qs.ambientes_minimo = ambientesMin;
3506
+ }
3507
+ const ambientesMax = this.getNodeParameter('searchAmbientesMax', i, 0);
3508
+ if (ambientesMax > 0) {
3509
+ qs.ambientes_maximo = ambientesMax;
3510
+ }
3511
+ // Área (Superficie)
3512
+ const areaMin = this.getNodeParameter('searchAreaMin', i, 0);
3513
+ if (areaMin > 0) {
3514
+ qs.area_minima = areaMin;
3515
+ }
3516
+ const areaMax = this.getNodeParameter('searchAreaMax', i, 0);
3517
+ if (areaMax > 0) {
3518
+ qs.area_maxima = areaMax;
3519
+ }
3520
+ // Moneda
3521
+ const moneda = this.getNodeParameter('searchMoneda', i, 'USD');
3522
+ if (moneda && moneda !== '') {
3523
+ qs.moneda = moneda;
3524
+ }
3525
+ // Precio
3526
+ const precioMin = this.getNodeParameter('searchPrecioMin', i, 0);
3527
+ if (precioMin > 0) {
3528
+ qs.precio_minimo = precioMin;
3529
+ }
3530
+ const precioMax = this.getNodeParameter('searchPrecioMax', i, 0);
2714
3531
  if (precioMax > 0) {
2715
3532
  qs.precio_maximo = precioMax;
2716
3533
  }
@@ -3399,6 +4216,266 @@ class AivenceRealty {
3399
4216
  });
3400
4217
  }
3401
4218
  }
4219
+ // ============================================
4220
+ // OWNER RESOURCE
4221
+ // ============================================
4222
+ else if (resource === 'owner') {
4223
+ if (operation === 'create') {
4224
+ const body = {
4225
+ nombre: this.getNodeParameter('ownerNombre', i),
4226
+ email: this.getNodeParameter('ownerEmail', i),
4227
+ telefono: this.getNodeParameter('ownerTelefono', i),
4228
+ cuit_cuil: this.getNodeParameter('ownerCuit', i) || undefined,
4229
+ tipo_persona: this.getNodeParameter('ownerTipoPersona', i),
4230
+ direccion: this.getNodeParameter('ownerDireccion', i) || undefined,
4231
+ notas: this.getNodeParameter('ownerNotas', i) || undefined,
4232
+ };
4233
+ responseData = await this.helpers.httpRequest({
4234
+ method: 'POST',
4235
+ url: `${baseUrl}/api/v1/owners`,
4236
+ headers: {
4237
+ 'Authorization': `Bearer ${credentials.apiKey}`,
4238
+ 'Accept': 'application/json',
4239
+ 'Content-Type': 'application/json',
4240
+ },
4241
+ body,
4242
+ json: true,
4243
+ });
4244
+ }
4245
+ else if (operation === 'get') {
4246
+ const ownerId = this.getNodeParameter('ownerId', i);
4247
+ responseData = await this.helpers.httpRequest({
4248
+ method: 'GET',
4249
+ url: `${baseUrl}/api/v1/owners/${ownerId}`,
4250
+ headers: {
4251
+ 'Authorization': `Bearer ${credentials.apiKey}`,
4252
+ 'Accept': 'application/json',
4253
+ },
4254
+ json: true,
4255
+ });
4256
+ }
4257
+ else if (operation === 'search') {
4258
+ const searchEmail = this.getNodeParameter('searchEmail', i);
4259
+ const searchTelefono = this.getNodeParameter('searchTelefono', i);
4260
+ const searchCuit = this.getNodeParameter('searchCuit', i);
4261
+ const params = new URLSearchParams();
4262
+ if (searchEmail)
4263
+ params.append('email', searchEmail);
4264
+ if (searchTelefono)
4265
+ params.append('telefono', searchTelefono);
4266
+ if (searchCuit)
4267
+ params.append('cuit', searchCuit);
4268
+ responseData = await this.helpers.httpRequest({
4269
+ method: 'GET',
4270
+ url: `${baseUrl}/api/v1/owners/search?${params.toString()}`,
4271
+ headers: {
4272
+ 'Authorization': `Bearer ${credentials.apiKey}`,
4273
+ 'Accept': 'application/json',
4274
+ },
4275
+ json: true,
4276
+ });
4277
+ }
4278
+ else if (operation === 'update') {
4279
+ const ownerId = this.getNodeParameter('ownerId', i);
4280
+ const body = {};
4281
+ const updateNombre = this.getNodeParameter('updateNombre', i);
4282
+ const updateEmail = this.getNodeParameter('updateEmail', i);
4283
+ const updateTelefono = this.getNodeParameter('updateTelefono', i);
4284
+ const ownerCuit = this.getNodeParameter('ownerCuit', i);
4285
+ const ownerTipoPersona = this.getNodeParameter('ownerTipoPersona', i);
4286
+ const ownerDireccion = this.getNodeParameter('ownerDireccion', i);
4287
+ const ownerNotas = this.getNodeParameter('ownerNotas', i);
4288
+ if (updateNombre)
4289
+ body.nombre = updateNombre;
4290
+ if (updateEmail)
4291
+ body.email = updateEmail;
4292
+ if (updateTelefono)
4293
+ body.telefono = updateTelefono;
4294
+ if (ownerCuit)
4295
+ body.cuit_cuil = ownerCuit;
4296
+ if (ownerTipoPersona)
4297
+ body.tipo_persona = ownerTipoPersona;
4298
+ if (ownerDireccion)
4299
+ body.direccion = ownerDireccion;
4300
+ if (ownerNotas)
4301
+ body.notas = ownerNotas;
4302
+ responseData = await this.helpers.httpRequest({
4303
+ method: 'PATCH',
4304
+ url: `${baseUrl}/api/v1/owners/${ownerId}`,
4305
+ headers: {
4306
+ 'Authorization': `Bearer ${credentials.apiKey}`,
4307
+ 'Accept': 'application/json',
4308
+ 'Content-Type': 'application/json',
4309
+ },
4310
+ body,
4311
+ json: true,
4312
+ });
4313
+ }
4314
+ else if (operation === 'list') {
4315
+ const perPage = this.getNodeParameter('ownerPerPage', i);
4316
+ responseData = await this.helpers.httpRequest({
4317
+ method: 'GET',
4318
+ url: `${baseUrl}/api/v1/owners?per_page=${perPage}`,
4319
+ headers: {
4320
+ 'Authorization': `Bearer ${credentials.apiKey}`,
4321
+ 'Accept': 'application/json',
4322
+ },
4323
+ json: true,
4324
+ });
4325
+ }
4326
+ }
4327
+ // ============================================
4328
+ // TASACIÓN RESOURCE
4329
+ // ============================================
4330
+ else if (resource === 'tasacion') {
4331
+ if (operation === 'generate') {
4332
+ const body = {
4333
+ tipo_propiedad: this.getNodeParameter('tasacionTipo', i),
4334
+ barrio: this.getNodeParameter('tasacionBarrio', i),
4335
+ metros_cuadrados: this.getNodeParameter('tasacionMetros', i),
4336
+ ambientes: this.getNodeParameter('tasacionAmbientes', i) || undefined,
4337
+ dormitorios: this.getNodeParameter('tasacionDormitorios', i) || undefined,
4338
+ banos: this.getNodeParameter('tasacionBanos', i) || undefined,
4339
+ antiguedad: this.getNodeParameter('tasacionAntiguedad', i) || undefined,
4340
+ estado: this.getNodeParameter('tasacionEstado', i) || undefined,
4341
+ amenidades: this.getNodeParameter('tasacionAmenidades', i) || undefined,
4342
+ owner_id: this.getNodeParameter('tasacionOwnerIdSave', i) || undefined,
4343
+ };
4344
+ responseData = await this.helpers.httpRequest({
4345
+ method: 'POST',
4346
+ url: `${baseUrl}/api/v1/tasaciones/generate`,
4347
+ headers: {
4348
+ 'Authorization': `Bearer ${credentials.apiKey}`,
4349
+ 'Accept': 'application/json',
4350
+ 'Content-Type': 'application/json',
4351
+ },
4352
+ body,
4353
+ json: true,
4354
+ });
4355
+ }
4356
+ else if (operation === 'get') {
4357
+ const tasacionId = this.getNodeParameter('tasacionId', i);
4358
+ responseData = await this.helpers.httpRequest({
4359
+ method: 'GET',
4360
+ url: `${baseUrl}/api/v1/tasaciones/${tasacionId}`,
4361
+ headers: {
4362
+ 'Authorization': `Bearer ${credentials.apiKey}`,
4363
+ 'Accept': 'application/json',
4364
+ },
4365
+ json: true,
4366
+ });
4367
+ }
4368
+ else if (operation === 'listByOwner') {
4369
+ const ownerId = this.getNodeParameter('tasacionOwnerId', i);
4370
+ responseData = await this.helpers.httpRequest({
4371
+ method: 'GET',
4372
+ url: `${baseUrl}/api/v1/tasaciones/owner/${ownerId}`,
4373
+ headers: {
4374
+ 'Authorization': `Bearer ${credentials.apiKey}`,
4375
+ 'Accept': 'application/json',
4376
+ },
4377
+ json: true,
4378
+ });
4379
+ }
4380
+ }
4381
+ // ============================================
4382
+ // DOCUSEAL RESOURCE
4383
+ // ============================================
4384
+ else if (resource === 'docuseal') {
4385
+ if (operation === 'createMandato') {
4386
+ const body = {
4387
+ tipo: this.getNodeParameter('docusealTipo', i),
4388
+ owner_id: this.getNodeParameter('docusealOwnerId', i),
4389
+ property_id: this.getNodeParameter('docusealPropertyId', i) || undefined,
4390
+ duracion_meses: this.getNodeParameter('docusealDuracion', i) || undefined,
4391
+ comision_porcentaje: this.getNodeParameter('docusealComision', i) || undefined,
4392
+ precio_sugerido: this.getNodeParameter('docusealPrecio', i) || undefined,
4393
+ };
4394
+ responseData = await this.helpers.httpRequest({
4395
+ method: 'POST',
4396
+ url: `${baseUrl}/api/v1/docuseal/mandatos`,
4397
+ headers: {
4398
+ 'Authorization': `Bearer ${credentials.apiKey}`,
4399
+ 'Accept': 'application/json',
4400
+ 'Content-Type': 'application/json',
4401
+ },
4402
+ body,
4403
+ json: true,
4404
+ });
4405
+ }
4406
+ else if (operation === 'getStatus') {
4407
+ const submissionId = this.getNodeParameter('docusealSubmissionId', i);
4408
+ responseData = await this.helpers.httpRequest({
4409
+ method: 'GET',
4410
+ url: `${baseUrl}/api/v1/docuseal/submissions/${submissionId}`,
4411
+ headers: {
4412
+ 'Authorization': `Bearer ${credentials.apiKey}`,
4413
+ 'Accept': 'application/json',
4414
+ },
4415
+ json: true,
4416
+ });
4417
+ }
4418
+ else if (operation === 'listTemplates') {
4419
+ responseData = await this.helpers.httpRequest({
4420
+ method: 'GET',
4421
+ url: `${baseUrl}/api/v1/docuseal/templates`,
4422
+ headers: {
4423
+ 'Authorization': `Bearer ${credentials.apiKey}`,
4424
+ 'Accept': 'application/json',
4425
+ },
4426
+ json: true,
4427
+ });
4428
+ }
4429
+ else if (operation === 'health') {
4430
+ responseData = await this.helpers.httpRequest({
4431
+ method: 'GET',
4432
+ url: `${baseUrl}/api/v1/docuseal/health`,
4433
+ headers: {
4434
+ 'Authorization': `Bearer ${credentials.apiKey}`,
4435
+ 'Accept': 'application/json',
4436
+ },
4437
+ json: true,
4438
+ });
4439
+ }
4440
+ }
4441
+ // ============================================
4442
+ // MARIANA RESOURCE
4443
+ // ============================================
4444
+ else if (resource === 'mariana') {
4445
+ if (operation === 'transferLead') {
4446
+ const body = {
4447
+ lead_id: this.getNodeParameter('marianaLeadId', i),
4448
+ conversation_id: this.getNodeParameter('marianaConversationId', i) || undefined,
4449
+ motivo: this.getNodeParameter('marianaMotivo', i),
4450
+ notas: this.getNodeParameter('marianaNotas', i) || undefined,
4451
+ urgencia: this.getNodeParameter('marianaUrgencia', i),
4452
+ direccion_propiedad: this.getNodeParameter('marianaDireccion', i) || undefined,
4453
+ tipo_operacion: this.getNodeParameter('marianaOperacion', i) || undefined,
4454
+ };
4455
+ responseData = await this.helpers.httpRequest({
4456
+ method: 'POST',
4457
+ url: `${baseUrl}/api/v1/mariana/transfer`,
4458
+ headers: {
4459
+ 'Authorization': `Bearer ${credentials.apiKey}`,
4460
+ 'Accept': 'application/json',
4461
+ 'Content-Type': 'application/json',
4462
+ },
4463
+ body,
4464
+ json: true,
4465
+ });
4466
+ }
4467
+ else if (operation === 'getQueueStatus') {
4468
+ responseData = await this.helpers.httpRequest({
4469
+ method: 'GET',
4470
+ url: `${baseUrl}/api/v1/mariana/queue`,
4471
+ headers: {
4472
+ 'Authorization': `Bearer ${credentials.apiKey}`,
4473
+ 'Accept': 'application/json',
4474
+ },
4475
+ json: true,
4476
+ });
4477
+ }
4478
+ }
3402
4479
  // Formatear respuesta
3403
4480
  const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
3404
4481
  returnData.push(...executionData);