@disruptive-learning/n8n-nodes-gigstack 1.0.2

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.
@@ -0,0 +1,1207 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Gigstack = void 0;
4
+ class Gigstack {
5
+ constructor() {
6
+ this.description = {
7
+ displayName: "Gigstack",
8
+ name: "gigstack",
9
+ icon: "file:gigstack.svg",
10
+ group: ["transform"],
11
+ version: 2,
12
+ subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
13
+ description: "Interact with Gigstack API - Payments and Invoices",
14
+ defaults: {
15
+ name: "Gigstack",
16
+ },
17
+ inputs: ["main"],
18
+ outputs: ["main"],
19
+ credentials: [
20
+ {
21
+ name: "gigstackApi",
22
+ required: true,
23
+ },
24
+ ],
25
+ properties: [
26
+ {
27
+ displayName: "Resource",
28
+ name: "resource",
29
+ type: "options",
30
+ noDataExpression: true,
31
+ options: [
32
+ {
33
+ name: "Payment",
34
+ value: "payment",
35
+ description: "Work with payments",
36
+ },
37
+ {
38
+ name: "Invoice",
39
+ value: "invoice",
40
+ description: "Work with invoices",
41
+ },
42
+ ],
43
+ default: "payment",
44
+ description: "Resource to use",
45
+ },
46
+ {
47
+ displayName: "Operation",
48
+ name: "operation",
49
+ type: "options",
50
+ noDataExpression: true,
51
+ displayOptions: {
52
+ show: {
53
+ resource: ["payment"],
54
+ },
55
+ },
56
+ options: [
57
+ {
58
+ name: "Get",
59
+ value: "get",
60
+ description: "Get payment details",
61
+ action: "Get a payment",
62
+ },
63
+ {
64
+ name: "Register or request",
65
+ value: "register",
66
+ description: "Register a new payment",
67
+ action: "Register a payment",
68
+ },
69
+ ],
70
+ default: "create",
71
+ },
72
+ {
73
+ displayName: "Amount",
74
+ name: "amount",
75
+ type: "number",
76
+ required: true,
77
+ displayOptions: {
78
+ show: {
79
+ operation: ["create"],
80
+ resource: ["payment"],
81
+ },
82
+ },
83
+ default: 0,
84
+ description: "Amount to be paid",
85
+ },
86
+ {
87
+ displayName: "Currency",
88
+ name: "currency",
89
+ type: "string",
90
+ required: true,
91
+ displayOptions: {
92
+ show: {
93
+ operation: ["create"],
94
+ resource: ["payment"],
95
+ },
96
+ },
97
+ default: "USD",
98
+ description: "Currency for the payment",
99
+ },
100
+ {
101
+ displayName: "Payment ID",
102
+ name: "paymentId",
103
+ type: "string",
104
+ required: true,
105
+ displayOptions: {
106
+ show: {
107
+ operation: ["get"],
108
+ resource: ["payment"],
109
+ },
110
+ },
111
+ default: "",
112
+ description: "ID of the payment to retrieve",
113
+ },
114
+ {
115
+ displayName: "Paid",
116
+ name: "paid",
117
+ type: "boolean",
118
+ required: true,
119
+ displayOptions: {
120
+ show: {
121
+ operation: ["register"],
122
+ resource: ["payment"],
123
+ },
124
+ },
125
+ default: true,
126
+ description: "Whether the payment is already paid",
127
+ },
128
+ {
129
+ displayName: "Currency",
130
+ name: "currency",
131
+ type: "string",
132
+ required: true,
133
+ displayOptions: {
134
+ show: {
135
+ operation: ["register"],
136
+ resource: ["payment"],
137
+ },
138
+ },
139
+ default: "MXN",
140
+ description: "Currency for the payment",
141
+ },
142
+ {
143
+ displayName: "Payment Method",
144
+ name: "paymentMethod",
145
+ type: "options",
146
+ noDataExpression: true,
147
+ required: true,
148
+ displayOptions: {
149
+ show: {
150
+ operation: ["register"],
151
+ resource: ["payment"],
152
+ },
153
+ },
154
+ options: [
155
+ {
156
+ name: "Efectivo (01)",
157
+ value: "01",
158
+ },
159
+ {
160
+ name: "Cheque nominativo (02)",
161
+ value: "02",
162
+ },
163
+ {
164
+ name: "Transferencia electrónica de fondos (03)",
165
+ value: "03",
166
+ },
167
+ {
168
+ name: "Tarjeta de crédito (04)",
169
+ value: "04",
170
+ },
171
+ {
172
+ name: "Monedero electrónico (05)",
173
+ value: "05",
174
+ },
175
+ {
176
+ name: "Dinero electrónico (06)",
177
+ value: "06",
178
+ },
179
+ {
180
+ name: "Vales de despensa (08)",
181
+ value: "08",
182
+ },
183
+ {
184
+ name: "Dación en pago (12)",
185
+ value: "12",
186
+ },
187
+ {
188
+ name: "Pago por subrogación (13)",
189
+ value: "13",
190
+ },
191
+ {
192
+ name: "Pago por consignación (14)",
193
+ value: "14",
194
+ },
195
+ {
196
+ name: "Condonación (15)",
197
+ value: "15",
198
+ },
199
+ {
200
+ name: "Compensación (17)",
201
+ value: "17",
202
+ },
203
+ {
204
+ name: "Novación (23)",
205
+ value: "23",
206
+ },
207
+ {
208
+ name: "Confusión (24)",
209
+ value: "24",
210
+ },
211
+ {
212
+ name: "Remisión de deuda (25)",
213
+ value: "25",
214
+ },
215
+ {
216
+ name: "Prescripción o caducidad (26)",
217
+ value: "26",
218
+ },
219
+ {
220
+ name: "A satisfacción del acreedor (27)",
221
+ value: "27",
222
+ },
223
+ {
224
+ name: "Tarjeta de débito (28)",
225
+ value: "28",
226
+ },
227
+ {
228
+ name: "Tarjeta de servicios (29)",
229
+ value: "29",
230
+ },
231
+ {
232
+ name: "Aplicación de anticipos (30)",
233
+ value: "30",
234
+ },
235
+ {
236
+ name: "Intermediario pagos (31)",
237
+ value: "31",
238
+ },
239
+ {
240
+ name: "Por definir (99)",
241
+ value: "99",
242
+ },
243
+ ],
244
+ default: "01",
245
+ description: "Payment method code",
246
+ },
247
+ {
248
+ displayName: "Automate Invoice On Complete",
249
+ name: "automateInvoiceOnComplete",
250
+ type: "boolean",
251
+ required: true,
252
+ displayOptions: {
253
+ show: {
254
+ operation: ["register"],
255
+ resource: ["payment"],
256
+ },
257
+ },
258
+ default: true,
259
+ description: "Whether to automatically generate an invoice when payment is complete",
260
+ },
261
+ {
262
+ displayName: "Client ID",
263
+ name: "clientId",
264
+ type: "string",
265
+ required: false,
266
+ displayOptions: {
267
+ show: {
268
+ operation: ["register"],
269
+ resource: ["payment"],
270
+ },
271
+ },
272
+ default: "",
273
+ description: "ID of the client",
274
+ },
275
+ {
276
+ displayName: "Email",
277
+ name: "email",
278
+ type: "string",
279
+ required: false,
280
+ displayOptions: {
281
+ show: {
282
+ operation: ["register"],
283
+ resource: ["payment"],
284
+ },
285
+ },
286
+ default: "",
287
+ description: "Email address for the payment",
288
+ },
289
+ {
290
+ displayName: "Items",
291
+ name: "items",
292
+ placeholder: "Add Item",
293
+ type: "fixedCollection",
294
+ typeOptions: {
295
+ multipleValues: true,
296
+ },
297
+ displayOptions: {
298
+ show: {
299
+ operation: ["register"],
300
+ resource: ["payment"],
301
+ },
302
+ },
303
+ default: {},
304
+ options: [
305
+ {
306
+ name: "itemsValues",
307
+ displayName: "Item",
308
+ values: [
309
+ {
310
+ displayName: "Description",
311
+ name: "description",
312
+ type: "string",
313
+ default: "",
314
+ description: "Description of the item",
315
+ },
316
+ {
317
+ displayName: "Discount",
318
+ name: "discount",
319
+ type: "number",
320
+ default: 0,
321
+ description: "Discount amount for the item",
322
+ },
323
+ {
324
+ displayName: "Product Key",
325
+ name: "product_key",
326
+ type: "string",
327
+ default: "01010101",
328
+ description: "Product key for the item",
329
+ },
330
+ {
331
+ displayName: "Unit Key",
332
+ name: "unit_key",
333
+ type: "string",
334
+ default: "E48",
335
+ description: "Unit key for the item",
336
+ },
337
+ {
338
+ displayName: "Unit Name",
339
+ name: "unit_name",
340
+ type: "string",
341
+ default: "Unidad de Servicio",
342
+ description: "Unit name for the item",
343
+ },
344
+ {
345
+ displayName: "Quantity",
346
+ name: "quantity",
347
+ type: "number",
348
+ default: 1,
349
+ description: "Quantity of the item",
350
+ },
351
+ {
352
+ displayName: "Amount",
353
+ name: "amount",
354
+ type: "number",
355
+ default: 0,
356
+ description: "Amount for the item",
357
+ },
358
+ {
359
+ displayName: "Taxes",
360
+ name: "taxes",
361
+ placeholder: "Add Tax",
362
+ type: "fixedCollection",
363
+ typeOptions: {
364
+ multipleValues: true,
365
+ },
366
+ default: {},
367
+ options: [
368
+ {
369
+ name: "taxesValues",
370
+ displayName: "Tax",
371
+ values: [
372
+ {
373
+ displayName: "Factor",
374
+ name: "factor",
375
+ type: "string",
376
+ default: "Tasa",
377
+ description: "Factor type for the tax",
378
+ },
379
+ {
380
+ displayName: "Inclusive",
381
+ name: "inclusive",
382
+ type: "boolean",
383
+ default: true,
384
+ description: "Whether the tax is inclusive",
385
+ },
386
+ {
387
+ displayName: "Rate",
388
+ name: "rate",
389
+ type: "number",
390
+ default: 0.16,
391
+ description: "Tax rate",
392
+ },
393
+ {
394
+ displayName: "Type",
395
+ name: "type",
396
+ type: "string",
397
+ default: "IVA",
398
+ description: "Type of tax",
399
+ },
400
+ {
401
+ displayName: "Withholding",
402
+ name: "withholding",
403
+ type: "boolean",
404
+ default: false,
405
+ description: "Whether the tax is withholding",
406
+ },
407
+ ],
408
+ },
409
+ ],
410
+ },
411
+ ],
412
+ },
413
+ ],
414
+ },
415
+ {
416
+ displayName: "Operation",
417
+ name: "operation",
418
+ type: "options",
419
+ noDataExpression: true,
420
+ displayOptions: {
421
+ show: {
422
+ resource: ["invoice"],
423
+ },
424
+ },
425
+ options: [
426
+ {
427
+ name: "Create",
428
+ value: "create",
429
+ description: "Create a new invoice",
430
+ action: "Create an invoice",
431
+ },
432
+ ],
433
+ default: "create",
434
+ },
435
+ {
436
+ displayName: "Return Files URLs",
437
+ name: "returnFilesUrls",
438
+ type: "boolean",
439
+ required: true,
440
+ displayOptions: {
441
+ show: {
442
+ operation: ["create"],
443
+ resource: ["invoice"],
444
+ },
445
+ },
446
+ default: true,
447
+ description: "Whether to return URLs for the generated files",
448
+ },
449
+ {
450
+ displayName: "Use",
451
+ name: "use",
452
+ type: "string",
453
+ required: true,
454
+ displayOptions: {
455
+ show: {
456
+ operation: ["create"],
457
+ resource: ["invoice"],
458
+ },
459
+ },
460
+ default: "G01",
461
+ description: "Use code for the invoice",
462
+ },
463
+ {
464
+ displayName: "Series",
465
+ name: "series",
466
+ type: "string",
467
+ required: true,
468
+ displayOptions: {
469
+ show: {
470
+ operation: ["create"],
471
+ resource: ["invoice"],
472
+ },
473
+ },
474
+ default: "",
475
+ description: "Series for the invoice",
476
+ },
477
+ {
478
+ displayName: "Payment Form",
479
+ name: "payment_form",
480
+ type: "options",
481
+ noDataExpression: true,
482
+ required: true,
483
+ displayOptions: {
484
+ show: {
485
+ operation: ["create"],
486
+ resource: ["invoice"],
487
+ },
488
+ },
489
+ options: [
490
+ {
491
+ name: "Efectivo (01)",
492
+ value: "01",
493
+ },
494
+ {
495
+ name: "Cheque nominativo (02)",
496
+ value: "02",
497
+ },
498
+ {
499
+ name: "Transferencia electrónica de fondos (03)",
500
+ value: "03",
501
+ },
502
+ {
503
+ name: "Tarjeta de crédito (04)",
504
+ value: "04",
505
+ },
506
+ {
507
+ name: "Monedero electrónico (05)",
508
+ value: "05",
509
+ },
510
+ {
511
+ name: "Dinero electrónico (06)",
512
+ value: "06",
513
+ },
514
+ {
515
+ name: "Vales de despensa (08)",
516
+ value: "08",
517
+ },
518
+ {
519
+ name: "Dación en pago (12)",
520
+ value: "12",
521
+ },
522
+ {
523
+ name: "Pago por subrogación (13)",
524
+ value: "13",
525
+ },
526
+ {
527
+ name: "Pago por consignación (14)",
528
+ value: "14",
529
+ },
530
+ {
531
+ name: "Condonación (15)",
532
+ value: "15",
533
+ },
534
+ {
535
+ name: "Compensación (17)",
536
+ value: "17",
537
+ },
538
+ {
539
+ name: "Novación (23)",
540
+ value: "23",
541
+ },
542
+ {
543
+ name: "Confusión (24)",
544
+ value: "24",
545
+ },
546
+ {
547
+ name: "Remisión de deuda (25)",
548
+ value: "25",
549
+ },
550
+ {
551
+ name: "Prescripción o caducidad (26)",
552
+ value: "26",
553
+ },
554
+ {
555
+ name: "A satisfacción del acreedor (27)",
556
+ value: "27",
557
+ },
558
+ {
559
+ name: "Tarjeta de débito (28)",
560
+ value: "28",
561
+ },
562
+ {
563
+ name: "Tarjeta de servicios (29)",
564
+ value: "29",
565
+ },
566
+ {
567
+ name: "Aplicación de anticipos (30)",
568
+ value: "30",
569
+ },
570
+ {
571
+ name: "Intermediario pagos (31)",
572
+ value: "31",
573
+ },
574
+ {
575
+ name: "Por definir (99)",
576
+ value: "99",
577
+ },
578
+ ],
579
+ default: "03",
580
+ description: "Payment form code",
581
+ },
582
+ {
583
+ displayName: "Invoice Type",
584
+ name: "invoiceType",
585
+ type: "options",
586
+ noDataExpression: true,
587
+ required: true,
588
+ displayOptions: {
589
+ show: {
590
+ operation: ["create"],
591
+ resource: ["invoice"],
592
+ },
593
+ },
594
+ options: [
595
+ {
596
+ name: "Ingreso (I)",
597
+ value: "I",
598
+ },
599
+ {
600
+ name: "Egreso (E)",
601
+ value: "E",
602
+ },
603
+ {
604
+ name: "Traslado (T)",
605
+ value: "T",
606
+ },
607
+ {
608
+ name: "Nómina (N)",
609
+ value: "N",
610
+ },
611
+ {
612
+ name: "Pago (P)",
613
+ value: "P",
614
+ },
615
+ ],
616
+ default: "I",
617
+ description: "Type of invoice",
618
+ },
619
+ {
620
+ displayName: "Currency",
621
+ name: "currency",
622
+ type: "options",
623
+ noDataExpression: true,
624
+ required: true,
625
+ displayOptions: {
626
+ show: {
627
+ operation: ["create"],
628
+ resource: ["invoice"],
629
+ },
630
+ },
631
+ options: [
632
+ {
633
+ name: "MXN - Mexican Peso",
634
+ value: "MXN",
635
+ },
636
+ {
637
+ name: "USD - US Dollar",
638
+ value: "USD",
639
+ },
640
+ {
641
+ name: "EUR - Euro",
642
+ value: "EUR",
643
+ },
644
+ ],
645
+ default: "MXN",
646
+ description: "Currency for the invoice",
647
+ },
648
+ {
649
+ displayName: "Payment Method",
650
+ name: "payment_method",
651
+ type: "options",
652
+ noDataExpression: true,
653
+ required: true,
654
+ displayOptions: {
655
+ show: {
656
+ operation: ["create"],
657
+ resource: ["invoice"],
658
+ },
659
+ },
660
+ options: [
661
+ {
662
+ name: "PUE - Pago en una sola exhibición",
663
+ value: "PUE",
664
+ },
665
+ {
666
+ name: "PPD - Pago en parcialidades o diferido",
667
+ value: "PPD",
668
+ },
669
+ ],
670
+ default: "PUE",
671
+ description: "Payment method code",
672
+ },
673
+ {
674
+ displayName: "Emails",
675
+ name: "emails",
676
+ type: "string",
677
+ typeOptions: {
678
+ multipleValues: true,
679
+ },
680
+ required: false,
681
+ displayOptions: {
682
+ show: {
683
+ operation: ["create"],
684
+ resource: ["invoice"],
685
+ },
686
+ },
687
+ default: [],
688
+ description: "Email addresses to send the invoice to",
689
+ },
690
+ {
691
+ displayName: "Client ID",
692
+ name: "clientId",
693
+ type: "string",
694
+ required: false,
695
+ displayOptions: {
696
+ show: {
697
+ operation: ["create"],
698
+ resource: ["invoice"],
699
+ },
700
+ hide: {
701
+ useClientObject: [true],
702
+ },
703
+ },
704
+ default: "",
705
+ description: "ID of an existing client",
706
+ },
707
+ {
708
+ displayName: "Use Client Object",
709
+ name: "useClientObject",
710
+ type: "boolean",
711
+ required: true,
712
+ displayOptions: {
713
+ show: {
714
+ operation: ["create"],
715
+ resource: ["invoice"],
716
+ },
717
+ },
718
+ default: false,
719
+ description: "Whether to specify client details instead of using a client ID",
720
+ },
721
+ {
722
+ displayName: "Client RFC",
723
+ name: "clientRfc",
724
+ type: "string",
725
+ required: true,
726
+ displayOptions: {
727
+ show: {
728
+ operation: ["create"],
729
+ resource: ["invoice"],
730
+ useClientObject: [true],
731
+ },
732
+ },
733
+ default: "",
734
+ description: "RFC of the client",
735
+ },
736
+ {
737
+ displayName: "Client Legal Name",
738
+ name: "clientLegalName",
739
+ type: "string",
740
+ required: true,
741
+ displayOptions: {
742
+ show: {
743
+ operation: ["create"],
744
+ resource: ["invoice"],
745
+ useClientObject: [true],
746
+ },
747
+ },
748
+ default: "",
749
+ description: "Legal name of the client",
750
+ },
751
+ {
752
+ displayName: "Client Tax System",
753
+ name: "clientTaxSystem",
754
+ type: "options",
755
+ noDataExpression: true,
756
+ required: true,
757
+ displayOptions: {
758
+ show: {
759
+ operation: ["create"],
760
+ resource: ["invoice"],
761
+ useClientObject: [true],
762
+ },
763
+ },
764
+ options: [
765
+ {
766
+ name: "General de Ley Personas Morales (601)",
767
+ value: "601",
768
+ },
769
+ {
770
+ name: "Personas Morales con Fines no Lucrativos (603)",
771
+ value: "603",
772
+ },
773
+ {
774
+ name: "Sueldos y Salarios e Ingresos Asimilados a Salarios (605)",
775
+ value: "605",
776
+ },
777
+ {
778
+ name: "Arrendamiento (606)",
779
+ value: "606",
780
+ },
781
+ {
782
+ name: "Régimen de Enajenación o Adquisición de Bienes (607)",
783
+ value: "607",
784
+ },
785
+ {
786
+ name: "Demás ingresos (608)",
787
+ value: "608",
788
+ },
789
+ {
790
+ name: "Residentes en el Extranjero sin Establecimiento Permanente en México (610)",
791
+ value: "610",
792
+ },
793
+ {
794
+ name: "Régimen de Incorporación Fiscal (612)",
795
+ value: "612",
796
+ },
797
+ {
798
+ name: "Actividades Agrícolas, Ganaderas, Silvícolas y Pesqueras (620)",
799
+ value: "620",
800
+ },
801
+ {
802
+ name: "Régimen Simplificado de Confianza (626)",
803
+ value: "626",
804
+ },
805
+ ],
806
+ default: "601",
807
+ description: "Tax system of the client",
808
+ },
809
+ {
810
+ displayName: "Client ZIP Code",
811
+ name: "clientZipCode",
812
+ type: "string",
813
+ required: false,
814
+ displayOptions: {
815
+ show: {
816
+ operation: ["create"],
817
+ resource: ["invoice"],
818
+ useClientObject: [true],
819
+ },
820
+ },
821
+ default: "",
822
+ description: "ZIP code of the client",
823
+ },
824
+ {
825
+ displayName: "Client Country",
826
+ name: "clientCountry",
827
+ type: "string",
828
+ required: true,
829
+ displayOptions: {
830
+ show: {
831
+ operation: ["create"],
832
+ resource: ["invoice"],
833
+ useClientObject: [true],
834
+ },
835
+ },
836
+ default: "MEX",
837
+ description: "Country code of the client (e.g., MEX for Mexico)",
838
+ },
839
+ {
840
+ displayName: "Metadata",
841
+ name: "metadata",
842
+ placeholder: "Add Metadata",
843
+ type: "fixedCollection",
844
+ typeOptions: {
845
+ multipleValues: true,
846
+ },
847
+ displayOptions: {
848
+ show: {
849
+ operation: ["create"],
850
+ resource: ["invoice"],
851
+ },
852
+ },
853
+ default: {},
854
+ options: [
855
+ {
856
+ name: "metadataValues",
857
+ displayName: "Metadata",
858
+ values: [
859
+ {
860
+ displayName: "Key",
861
+ name: "key",
862
+ type: "string",
863
+ default: "",
864
+ description: "Key of the metadata",
865
+ },
866
+ {
867
+ displayName: "Value",
868
+ name: "value",
869
+ type: "string",
870
+ default: "",
871
+ description: "Value of the metadata",
872
+ },
873
+ ],
874
+ },
875
+ ],
876
+ },
877
+ {
878
+ displayName: "Invoice Items",
879
+ name: "invoiceItems",
880
+ placeholder: "Add Invoice Item",
881
+ type: "fixedCollection",
882
+ typeOptions: {
883
+ multipleValues: true,
884
+ },
885
+ displayOptions: {
886
+ show: {
887
+ operation: ["create"],
888
+ resource: ["invoice"],
889
+ },
890
+ },
891
+ default: {},
892
+ options: [
893
+ {
894
+ name: "invoiceItemsValues",
895
+ displayName: "Item",
896
+ values: [
897
+ {
898
+ displayName: "Name",
899
+ name: "name",
900
+ type: "string",
901
+ default: "",
902
+ description: "Name of the item",
903
+ },
904
+ {
905
+ displayName: "Description",
906
+ name: "description",
907
+ type: "string",
908
+ default: "",
909
+ description: "Description of the item",
910
+ },
911
+ {
912
+ displayName: "Quantity",
913
+ name: "quantity",
914
+ type: "number",
915
+ default: 1,
916
+ description: "Quantity of the item",
917
+ },
918
+ {
919
+ displayName: "Total",
920
+ name: "total",
921
+ type: "number",
922
+ default: 0,
923
+ description: "Total amount for the item",
924
+ },
925
+ {
926
+ displayName: "Product Key",
927
+ name: "product_key",
928
+ type: "string",
929
+ default: "01010101",
930
+ description: "Product key for the item",
931
+ },
932
+ {
933
+ displayName: "Unit Key",
934
+ name: "unit_key",
935
+ type: "string",
936
+ default: "H87",
937
+ description: "Unit key for the item",
938
+ },
939
+ {
940
+ displayName: "Unit Name",
941
+ name: "unit_name",
942
+ type: "string",
943
+ default: "Unidad de Servicio",
944
+ description: "Unit name for the item",
945
+ },
946
+ {
947
+ displayName: "Taxes",
948
+ name: "taxes",
949
+ placeholder: "Add Tax",
950
+ type: "fixedCollection",
951
+ typeOptions: {
952
+ multipleValues: true,
953
+ },
954
+ default: {},
955
+ options: [
956
+ {
957
+ name: "taxesValues",
958
+ displayName: "Tax",
959
+ values: [
960
+ {
961
+ displayName: "Factor",
962
+ name: "factor",
963
+ type: "string",
964
+ default: "Tasa",
965
+ description: "Factor type for the tax",
966
+ },
967
+ {
968
+ displayName: "Inclusive",
969
+ name: "inclusive",
970
+ type: "boolean",
971
+ default: true,
972
+ description: "Whether the tax is inclusive",
973
+ },
974
+ {
975
+ displayName: "Rate",
976
+ name: "rate",
977
+ type: "number",
978
+ default: 0.16,
979
+ description: "Tax rate",
980
+ },
981
+ {
982
+ displayName: "Type",
983
+ name: "type",
984
+ type: "string",
985
+ default: "IVA",
986
+ description: "Type of tax",
987
+ },
988
+ {
989
+ displayName: "Withholding",
990
+ name: "withholding",
991
+ type: "boolean",
992
+ default: false,
993
+ description: "Whether the tax is withholding",
994
+ },
995
+ ],
996
+ },
997
+ ],
998
+ },
999
+ ],
1000
+ },
1001
+ ],
1002
+ },
1003
+ ],
1004
+ };
1005
+ }
1006
+ async execute() {
1007
+ const items = this.getInputData();
1008
+ const returnData = [];
1009
+ const resource = this.getNodeParameter("resource", 0);
1010
+ const operation = this.getNodeParameter("operation", 0);
1011
+ const credentials = await this.getCredentials("gigstackApi");
1012
+ let responseData;
1013
+ for (let i = 0; i < items.length; i++) {
1014
+ try {
1015
+ if (resource === "payment") {
1016
+ if (operation === "get") {
1017
+ const paymentId = this.getNodeParameter("paymentId", i);
1018
+ // Make API call
1019
+ const options = {
1020
+ method: "GET",
1021
+ url: `https://gigstack-cfdi-bjekv7t4.uc.gateway.dev/v1/payments/view?id=${paymentId}`,
1022
+ headers: {
1023
+ Authorization: `Bearer ${credentials.apiKey}`,
1024
+ },
1025
+ json: true,
1026
+ };
1027
+ responseData = await this.helpers.request(options);
1028
+ }
1029
+ if (operation === "register") {
1030
+ // Get parameters
1031
+ const paid = this.getNodeParameter("paid", i);
1032
+ const currency = this.getNodeParameter("currency", i);
1033
+ const paymentMethod = this.getNodeParameter("paymentMethod", i);
1034
+ const automateInvoiceOnComplete = this.getNodeParameter("automateInvoiceOnComplete", i);
1035
+ const clientId = this.getNodeParameter("clientId", i);
1036
+ const email = this.getNodeParameter("email", i);
1037
+ // Get items
1038
+ const itemsData = this.getNodeParameter("items.itemsValues", i, []);
1039
+ // Format items for API request
1040
+ const items = itemsData.map((item) => {
1041
+ const formattedItem = {
1042
+ description: item.description,
1043
+ discount: item.discount,
1044
+ product_key: item.product_key,
1045
+ unit_key: item.unit_key,
1046
+ unit_name: item.unit_name,
1047
+ quantity: item.quantity,
1048
+ amount: item.amount,
1049
+ };
1050
+ if (item.taxes &&
1051
+ item.taxes.taxesValues &&
1052
+ item.taxes.taxesValues.length > 0) {
1053
+ formattedItem.taxes = item.taxes.taxesValues.map((tax) => ({
1054
+ factor: tax.factor,
1055
+ inclusive: tax.inclusive,
1056
+ rate: tax.rate,
1057
+ type: tax.type,
1058
+ withholding: tax.withholding,
1059
+ }));
1060
+ }
1061
+ return formattedItem;
1062
+ });
1063
+ // Prepare request body
1064
+ const body = {
1065
+ paid,
1066
+ items,
1067
+ currency,
1068
+ paymentMethod,
1069
+ automateInvoiceOnComplete,
1070
+ clientId,
1071
+ email,
1072
+ };
1073
+ // Make API call
1074
+ const options = {
1075
+ method: "POST",
1076
+ url: "https://gigstack-cfdi-bjekv7t4.uc.gateway.dev/v1/payments/register",
1077
+ headers: {
1078
+ "Content-Type": "application/json",
1079
+ Authorization: `Bearer ${credentials.apiKey}`,
1080
+ },
1081
+ body,
1082
+ json: true,
1083
+ };
1084
+ responseData = await this.helpers.request(options);
1085
+ }
1086
+ }
1087
+ if (resource === "invoice") {
1088
+ if (operation === "create") {
1089
+ // Get parameters
1090
+ const returnFilesUrls = this.getNodeParameter("returnFilesUrls", i);
1091
+ const use = this.getNodeParameter("use", i);
1092
+ const series = this.getNodeParameter("series", i);
1093
+ const payment_form = this.getNodeParameter("payment_form", i);
1094
+ const invoiceType = this.getNodeParameter("invoiceType", i);
1095
+ const currency = this.getNodeParameter("currency", i);
1096
+ const payment_method = this.getNodeParameter("payment_method", i);
1097
+ const emails = this.getNodeParameter("emails", i, []);
1098
+ const useClientObject = this.getNodeParameter("useClientObject", i);
1099
+ // Get invoice items
1100
+ const invoiceItemsData = this.getNodeParameter("invoiceItems.invoiceItemsValues", i, []);
1101
+ // Format invoice items for API request
1102
+ const invoiceItems = invoiceItemsData.map((item) => {
1103
+ const formattedItem = {
1104
+ name: item.name,
1105
+ description: item.description,
1106
+ quantity: item.quantity,
1107
+ total: item.total,
1108
+ product_key: item.product_key,
1109
+ unit_key: item.unit_key,
1110
+ unit_name: item.unit_name,
1111
+ };
1112
+ if (item.taxes &&
1113
+ item.taxes.taxesValues &&
1114
+ item.taxes.taxesValues.length > 0) {
1115
+ formattedItem.taxes = item.taxes.taxesValues.map((tax) => ({
1116
+ factor: tax.factor,
1117
+ inclusive: tax.inclusive,
1118
+ rate: tax.rate,
1119
+ type: tax.type,
1120
+ withholding: tax.withholding,
1121
+ }));
1122
+ }
1123
+ return formattedItem;
1124
+ });
1125
+ // Get metadata
1126
+ const metadataData = this.getNodeParameter("metadata.metadataValues", i, []);
1127
+ // Format metadata for API request
1128
+ const metadata = {};
1129
+ if (metadataData.length > 0) {
1130
+ metadataData.forEach((item) => {
1131
+ metadata[item.key] = item.value;
1132
+ });
1133
+ }
1134
+ // Prepare request body
1135
+ const body = {
1136
+ returnFilesUrls,
1137
+ use,
1138
+ series,
1139
+ payment_form,
1140
+ type: "create_invoice",
1141
+ relation: null,
1142
+ emails,
1143
+ related: null,
1144
+ invoiceType,
1145
+ currency,
1146
+ export: null,
1147
+ payment_method,
1148
+ items: invoiceItems,
1149
+ metadata,
1150
+ };
1151
+ // Add client information
1152
+ if (useClientObject) {
1153
+ const clientRfc = this.getNodeParameter("clientRfc", i);
1154
+ const clientLegalName = this.getNodeParameter("clientLegalName", i);
1155
+ const clientTaxSystem = this.getNodeParameter("clientTaxSystem", i);
1156
+ const clientZipCode = this.getNodeParameter("clientZipCode", i, "");
1157
+ const clientCountry = this.getNodeParameter("clientCountry", i);
1158
+ body.client = {
1159
+ rfc: clientRfc,
1160
+ legal_name: clientLegalName,
1161
+ tax_system: {
1162
+ label: "",
1163
+ value: clientTaxSystem,
1164
+ },
1165
+ bcc: [],
1166
+ address: {
1167
+ zip: clientZipCode,
1168
+ country: clientCountry,
1169
+ },
1170
+ };
1171
+ }
1172
+ else {
1173
+ const clientId = this.getNodeParameter("clientId", i, "");
1174
+ if (clientId) {
1175
+ body.clientId = clientId;
1176
+ }
1177
+ }
1178
+ // Make API call
1179
+ const options = {
1180
+ method: "POST",
1181
+ url: "https://gigstack-cfdi-bjekv7t4.uc.gateway.dev/v1/invoices/create",
1182
+ headers: {
1183
+ "Content-Type": "application/json",
1184
+ Authorization: `Bearer ${credentials.apiKey}`,
1185
+ },
1186
+ body,
1187
+ json: true,
1188
+ };
1189
+ responseData = await this.helpers.request(options);
1190
+ }
1191
+ }
1192
+ const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
1193
+ returnData.push(...executionData);
1194
+ }
1195
+ catch (error) {
1196
+ if (this.continueOnFail()) {
1197
+ const executionErrorData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray({ error: error.message }), { itemData: { item: i } });
1198
+ returnData.push(...executionErrorData);
1199
+ continue;
1200
+ }
1201
+ throw error;
1202
+ }
1203
+ }
1204
+ return this.prepareOutputData(returnData);
1205
+ }
1206
+ }
1207
+ exports.Gigstack = Gigstack;