repzo 1.0.24 → 1.0.25

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.
package/lib/index.js CHANGED
@@ -1,1439 +1,957 @@
1
1
  import axios from "axios";
2
2
  import { v4 as uuid } from "uuid";
3
3
  export default class Repzo {
4
- constructor(apiKey, options) {
5
- this.client = {
6
- _path: "/client",
7
- find: async (params) => {
8
- let res = await this._fetch(
9
- this.svAPIEndpoint,
10
- this.client._path,
11
- params
12
- );
13
- return res;
14
- },
15
- get: async (id, params) => {
16
- return await this._fetch(
17
- this.svAPIEndpoint,
18
- this.client._path + `/${id}`,
19
- params
20
- );
21
- },
22
- create: async (body) => {
23
- let res = await this._create(
24
- this.svAPIEndpoint,
25
- this.client._path,
26
- body
27
- );
28
- return res;
29
- },
30
- update: async (id, body) => {
31
- let res = await this._update(
32
- this.svAPIEndpoint,
33
- this.client._path + `/${id}`,
34
- body
35
- );
36
- return res;
37
- },
38
- remove: async (id) => {
39
- let res = await this._delete(
40
- this.svAPIEndpoint,
41
- this.client._path + `/${id}`
42
- );
43
- return res;
44
- },
45
- };
46
- this.product = {
47
- _path: "/product",
48
- find: async (params) => {
49
- let res = await this._fetch(
50
- this.svAPIEndpoint,
51
- this.product._path,
52
- params
53
- );
54
- return res;
55
- },
56
- get: async (id, params) => {
57
- return await this._fetch(
58
- this.svAPIEndpoint,
59
- this.product._path + `/${id}`,
60
- params
61
- );
62
- },
63
- create: async (body) => {
64
- let res = await this._create(
65
- this.svAPIEndpoint,
66
- this.product._path,
67
- body
68
- );
69
- return res;
70
- },
71
- update: async (id, body) => {
72
- let res = await this._update(
73
- this.svAPIEndpoint,
74
- this.product._path + `/${id}`,
75
- body
76
- );
77
- return res;
78
- },
79
- remove: async (id) => {
80
- let res = await this._delete(
81
- this.svAPIEndpoint,
82
- this.product._path + `/${id}`
83
- );
84
- return res;
85
- },
86
- };
87
- this.variant = {
88
- _path: "/variant",
89
- find: async (params) => {
90
- let res = await this._fetch(
91
- this.svAPIEndpoint,
92
- this.variant._path,
93
- params
94
- );
95
- return res;
96
- },
97
- get: async (id, params) => {
98
- return await this._fetch(
99
- this.svAPIEndpoint,
100
- this.variant._path + `/${id}`,
101
- params
102
- );
103
- },
104
- create: async (body) => {
105
- let res = await this._create(
106
- this.svAPIEndpoint,
107
- this.variant._path,
108
- body
109
- );
110
- return res;
111
- },
112
- update: async (id, body) => {
113
- let res = await this._update(
114
- this.svAPIEndpoint,
115
- this.variant._path + `/${id}`,
116
- body
117
- );
118
- return res;
119
- },
120
- remove: async (id) => {
121
- let res = await this._delete(
122
- this.svAPIEndpoint,
123
- this.variant._path + `/${id}`
124
- );
125
- return res;
126
- },
127
- };
128
- this.category = {
129
- _path: "/product-category",
130
- find: async (params) => {
131
- let res = await this._fetch(
132
- this.svAPIEndpoint,
133
- this.category._path,
134
- params
135
- );
136
- return res;
137
- },
138
- get: async (id) => {
139
- return await this._fetch(
140
- this.svAPIEndpoint,
141
- this.category._path + `/${id}`
142
- );
143
- },
144
- create: async (body) => {
145
- let res = await this._create(
146
- this.svAPIEndpoint,
147
- this.category._path,
148
- body
149
- );
150
- return res;
151
- },
152
- update: async (id, body) => {
153
- let res = await this._update(
154
- this.svAPIEndpoint,
155
- this.category._path + `/${id}`,
156
- body
157
- );
158
- return res;
159
- },
160
- remove: async (id) => {
161
- let res = await this._delete(
162
- this.svAPIEndpoint,
163
- this.category._path + `/${id}`
164
- );
165
- return res;
166
- },
167
- };
168
- this.sub_category = {
169
- _path: "/product-sub-category",
170
- find: async (params) => {
171
- let res = await this._fetch(
172
- this.svAPIEndpoint,
173
- this.sub_category._path,
174
- params
175
- );
176
- return res;
177
- },
178
- get: async (id, params) => {
179
- return await this._fetch(
180
- this.svAPIEndpoint,
181
- this.sub_category._path + `/${id}`,
182
- params
183
- );
184
- },
185
- create: async (body) => {
186
- let res = await this._create(
187
- this.svAPIEndpoint,
188
- this.sub_category._path,
189
- body
190
- );
191
- return res;
192
- },
193
- update: async (id, body) => {
194
- let res = await this._update(
195
- this.svAPIEndpoint,
196
- this.sub_category._path + `/${id}`,
197
- body
198
- );
199
- return res;
200
- },
201
- remove: async (id) => {
202
- let res = await this._delete(
203
- this.svAPIEndpoint,
204
- this.sub_category._path + `/${id}`
205
- );
206
- return res;
207
- },
208
- };
209
- this.brand = {
210
- _path: "/product-brand",
211
- find: async (params) => {
212
- let res = await this._fetch(
213
- this.svAPIEndpoint,
214
- this.brand._path,
215
- params
216
- );
217
- return res;
218
- },
219
- get: async (id) => {
220
- return await this._fetch(
221
- this.svAPIEndpoint,
222
- this.brand._path + `/${id}`
223
- );
224
- },
225
- create: async (body) => {
226
- let res = await this._create(
227
- this.svAPIEndpoint,
228
- this.brand._path,
229
- body
230
- );
231
- return res;
232
- },
233
- update: async (id, body) => {
234
- let res = await this._update(
235
- this.svAPIEndpoint,
236
- this.brand._path + `/${id}`,
237
- body
238
- );
239
- return res;
240
- },
241
- remove: async (id) => {
242
- let res = await this._delete(
243
- this.svAPIEndpoint,
244
- this.brand._path + `/${id}`
245
- );
246
- return res;
247
- },
248
- };
249
- this.product_group = {
250
- _path: "/product-group",
251
- find: async (params) => {
252
- let res = await this._fetch(
253
- this.svAPIEndpoint,
254
- this.product_group._path,
255
- params
256
- );
257
- return res;
258
- },
259
- get: async (id) => {
260
- return await this._fetch(
261
- this.svAPIEndpoint,
262
- this.product_group._path + `/${id}`
263
- );
264
- },
265
- create: async (body) => {
266
- let res = await this._create(
267
- this.svAPIEndpoint,
268
- this.product_group._path,
269
- body
270
- );
271
- return res;
272
- },
273
- update: async (id, body) => {
274
- let res = await this._update(
275
- this.svAPIEndpoint,
276
- this.product_group._path + `/${id}`,
277
- body
278
- );
279
- return res;
280
- },
281
- remove: async (id) => {
282
- let res = await this._delete(
283
- this.svAPIEndpoint,
284
- this.product_group._path + `/${id}`
285
- );
286
- return res;
287
- },
288
- };
289
- this.tax = {
290
- _path: "/tax",
291
- find: async (params) => {
292
- let res = await this._fetch(this.svAPIEndpoint, this.tax._path, params);
293
- return res;
294
- },
295
- get: async (id) => {
296
- return await this._fetch(this.svAPIEndpoint, this.tax._path + `/${id}`);
297
- },
298
- create: async (body) => {
299
- let res = await this._create(this.svAPIEndpoint, this.tax._path, body);
300
- return res;
301
- },
302
- update: async (id, body) => {
303
- let res = await this._update(
304
- this.svAPIEndpoint,
305
- this.tax._path + `/${id}`,
306
- body
307
- );
308
- return res;
309
- },
310
- remove: async (id) => {
311
- let res = await this._delete(
312
- this.svAPIEndpoint,
313
- this.tax._path + `/${id}`
314
- );
315
- return res;
316
- },
317
- };
318
- this.measureunit = {
319
- _path: "/measureunits",
320
- find: async (params) => {
321
- let res = await this._fetch(
322
- this.svAPIEndpoint,
323
- this.measureunit._path,
324
- params
325
- );
326
- return res;
327
- },
328
- get: async (id) => {
329
- return await this._fetch(
330
- this.svAPIEndpoint,
331
- this.measureunit._path + `/${id}`
332
- );
333
- },
334
- create: async (body) => {
335
- let res = await this._create(
336
- this.svAPIEndpoint,
337
- this.measureunit._path,
338
- body
339
- );
340
- return res;
341
- },
342
- update: async (id, body) => {
343
- let res = await this._update(
344
- this.svAPIEndpoint,
345
- this.measureunit._path + `/${id}`,
346
- body
347
- );
348
- return res;
349
- },
350
- remove: async (id) => {
351
- let res = await this._delete(
352
- this.svAPIEndpoint,
353
- this.measureunit._path + `/${id}`
354
- );
355
- return res;
356
- },
357
- };
358
- this.measureunitFamily = {
359
- _path: "/measureunit-family",
360
- find: async (params) => {
361
- let res = await this._fetch(
362
- this.svAPIEndpoint,
363
- this.measureunitFamily._path,
364
- params
365
- );
366
- return res;
367
- },
368
- get: async (id) => {
369
- return await this._fetch(
370
- this.svAPIEndpoint,
371
- this.measureunitFamily._path + `/${id}`
372
- );
373
- },
374
- create: async (body) => {
375
- let res = await this._create(
376
- this.svAPIEndpoint,
377
- this.measureunitFamily._path,
378
- body
379
- );
380
- return res;
381
- },
382
- update: async (id, body) => {
383
- let res = await this._update(
384
- this.svAPIEndpoint,
385
- this.measureunitFamily._path + `/${id}`,
386
- body
387
- );
388
- return res;
389
- },
390
- remove: async (id) => {
391
- let res = await this._delete(
392
- this.svAPIEndpoint,
393
- this.measureunitFamily._path + `/${id}`
394
- );
395
- return res;
396
- },
397
- };
398
- this.media = {
399
- _path: "/media",
400
- find: async (params) => {
401
- let res = await this._fetch(
402
- this.svAPIEndpoint,
403
- this.media._path,
404
- params
405
- );
406
- return res;
407
- },
408
- get: async (id) => {
409
- return await this._fetch(
410
- this.svAPIEndpoint,
411
- this.media._path + `/${id}`
412
- );
413
- },
414
- create: async (body) => {
415
- let res = await this._create(
416
- this.svAPIEndpoint,
417
- this.media._path,
418
- body
419
- );
420
- return res;
421
- },
422
- update: async (id, body) => {
423
- let res = await this._update(
424
- this.svAPIEndpoint,
425
- this.media._path + `/${id}`,
426
- body
427
- );
428
- return res;
429
- },
430
- remove: async (id) => {
431
- let res = await this._delete(
432
- this.svAPIEndpoint,
433
- this.media._path + `/${id}`
434
- );
435
- return res;
436
- },
437
- };
438
- this.priceList = {
439
- _path: "/pricelists",
440
- find: async (params) => {
441
- let res = await this._fetch(
442
- this.svAPIEndpoint,
443
- this.priceList._path,
444
- params
445
- );
446
- return res;
447
- },
448
- get: async (id) => {
449
- return await this._fetch(
450
- this.svAPIEndpoint,
451
- this.priceList._path + `/${id}`
452
- );
453
- },
454
- create: async (body) => {
455
- let res = await this._create(
456
- this.svAPIEndpoint,
457
- this.priceList._path,
458
- body
459
- );
460
- return res;
461
- },
462
- update: async (id, body) => {
463
- let res = await this._update(
464
- this.svAPIEndpoint,
465
- this.priceList._path + `/${id}`,
466
- body
467
- );
468
- return res;
469
- },
470
- remove: async (id) => {
471
- let res = await this._delete(
472
- this.svAPIEndpoint,
473
- this.priceList._path + `/${id}`
474
- );
475
- return res;
476
- },
477
- };
478
- this.priceListItem = {
479
- _path: "/pricelistsitems",
480
- find: async (params) => {
481
- let res = await this._fetch(
482
- this.svAPIEndpoint,
483
- this.priceListItem._path,
484
- params
485
- );
486
- return res;
487
- },
488
- get: async (id) => {
489
- return await this._fetch(
490
- this.svAPIEndpoint,
491
- this.priceListItem._path + `/${id}`
492
- );
493
- },
494
- create: async (body) => {
495
- let res = await this._create(
496
- this.svAPIEndpoint,
497
- this.priceListItem._path,
498
- body
499
- );
500
- return res;
501
- },
502
- update: async (id, body) => {
503
- let res = await this._update(
504
- this.svAPIEndpoint,
505
- this.priceListItem._path + `/${id}`,
506
- body
507
- );
508
- return res;
509
- },
510
- remove: async (id) => {
511
- let res = await this._delete(
512
- this.svAPIEndpoint,
513
- this.priceListItem._path + `/${id}`
514
- );
515
- return res;
516
- },
517
- };
518
- this.team = {
519
- _path: "/teams",
520
- find: async (params) => {
521
- let res = await this._fetch(
522
- this.svAPIEndpoint,
523
- this.team._path,
524
- params
525
- );
526
- return res;
527
- },
528
- get: async (id) => {
529
- return await this._fetch(
530
- this.svAPIEndpoint,
531
- this.team._path + `/${id}`
532
- );
533
- },
534
- create: async (body) => {
535
- let res = await this._create(this.svAPIEndpoint, this.team._path, body);
536
- return res;
537
- },
538
- update: async (id, body) => {
539
- let res = await this._update(
540
- this.svAPIEndpoint,
541
- this.team._path + `/${id}`,
542
- body
543
- );
544
- return res;
545
- },
546
- remove: async (id) => {
547
- let res = await this._delete(
548
- this.svAPIEndpoint,
549
- this.team._path + `/${id}`
550
- );
551
- return res;
552
- },
553
- };
554
- this.rep = {
555
- _path: "/rep",
556
- find: async (params) => {
557
- let res = await this._fetch(this.svAPIEndpoint, this.rep._path, params);
558
- return res;
559
- },
560
- get: async (id, params) => {
561
- return await this._fetch(
562
- this.svAPIEndpoint,
563
- this.rep._path + `/${id}`,
564
- params
565
- );
566
- },
567
- create: async (body) => {
568
- let res = await this._create(this.svAPIEndpoint, this.rep._path, body);
569
- return res;
570
- },
571
- update: async (id, body) => {
572
- let res = await this._update(
573
- this.svAPIEndpoint,
574
- this.rep._path + `/${id}`,
575
- body
576
- );
577
- return res;
578
- },
579
- remove: async (id) => {
580
- let res = await this._delete(
581
- this.svAPIEndpoint,
582
- this.rep._path + `/${id}`
583
- );
584
- return res;
585
- },
586
- };
587
- this.tag = {
588
- _path: "/tag",
589
- find: async (params) => {
590
- let res = await this._fetch(this.svAPIEndpoint, this.tag._path, params);
591
- return res;
592
- },
593
- get: async (id) => {
594
- return await this._fetch(this.svAPIEndpoint, this.tag._path + `/${id}`);
595
- },
596
- create: async (body) => {
597
- let res = await this._create(this.svAPIEndpoint, this.tag._path, body);
598
- return res;
599
- },
600
- update: async (id, body) => {
601
- let res = await this._update(
602
- this.svAPIEndpoint,
603
- this.tag._path + `/${id}`,
604
- body
605
- );
606
- return res;
607
- },
608
- remove: async (id) => {
609
- let res = await this._delete(
610
- this.svAPIEndpoint,
611
- this.tag._path + `/${id}`
612
- );
613
- return res;
614
- },
615
- };
616
- this.warehouse = {
617
- _path: "/warehouse",
618
- find: async (params) => {
619
- let res = await this._fetch(
620
- this.svAPIEndpoint,
621
- this.warehouse._path,
622
- params
623
- );
624
- return res;
625
- },
626
- get: async (id) => {
627
- return await this._fetch(
628
- this.svAPIEndpoint,
629
- this.warehouse._path + `/${id}`
630
- );
631
- },
632
- create: async (body) => {
633
- let res = await this._create(
634
- this.svAPIEndpoint,
635
- this.warehouse._path,
636
- body
637
- );
638
- return res;
639
- },
640
- update: async (id, body) => {
641
- let res = await this._update(
642
- this.svAPIEndpoint,
643
- this.warehouse._path + `/${id}`,
644
- body
645
- );
646
- return res;
647
- },
648
- remove: async (id) => {
649
- let res = await this._delete(
650
- this.svAPIEndpoint,
651
- this.warehouse._path + `/${id}`
652
- );
653
- return res;
654
- },
655
- };
656
- this.channel = {
657
- _path: "/client-channel",
658
- find: async (params) => {
659
- let res = await this._fetch(
660
- this.svAPIEndpoint,
661
- this.channel._path,
662
- params
663
- );
664
- return res;
665
- },
666
- get: async (id) => {
667
- return await this._fetch(
668
- this.svAPIEndpoint,
669
- this.channel._path + `/${id}`
670
- );
671
- },
672
- create: async (body) => {
673
- let res = await this._create(
674
- this.svAPIEndpoint,
675
- this.channel._path,
676
- body
677
- );
678
- return res;
679
- },
680
- update: async (id, body) => {
681
- let res = await this._update(
682
- this.svAPIEndpoint,
683
- this.channel._path + `/${id}`,
684
- body
685
- );
686
- return res;
687
- },
688
- remove: async (id) => {
689
- let res = await this._delete(
690
- this.svAPIEndpoint,
691
- this.channel._path + `/${id}`
692
- );
693
- return res;
694
- },
695
- };
696
- this.paymentTerm = {
697
- _path: "/paymentterms",
698
- find: async (params) => {
699
- let res = await this._fetch(
700
- this.svAPIEndpoint,
701
- this.paymentTerm._path,
702
- params
703
- );
704
- return res;
705
- },
706
- get: async (id) => {
707
- return await this._fetch(
708
- this.svAPIEndpoint,
709
- this.paymentTerm._path + `/${id}`
710
- );
711
- },
712
- create: async (body) => {
713
- let res = await this._create(
714
- this.svAPIEndpoint,
715
- this.paymentTerm._path,
716
- body
717
- );
718
- return res;
719
- },
720
- update: async (id, body) => {
721
- let res = await this._update(
722
- this.svAPIEndpoint,
723
- this.paymentTerm._path + `/${id}`,
724
- body
725
- );
726
- return res;
727
- },
728
- remove: async (id) => {
729
- let res = await this._delete(
730
- this.svAPIEndpoint,
731
- this.paymentTerm._path + `/${id}`
732
- );
733
- return res;
734
- },
735
- };
736
- this.bank = {
737
- _path: "/banks",
738
- find: async (params) => {
739
- let res = await this._fetch(
740
- this.svAPIEndpoint,
741
- this.bank._path,
742
- params
743
- );
744
- return res;
745
- },
746
- get: async (id) => {
747
- return await this._fetch(
748
- this.svAPIEndpoint,
749
- this.bank._path + `/${id}`
750
- );
751
- },
752
- create: async (body) => {
753
- let res = await this._create(this.svAPIEndpoint, this.bank._path, body);
754
- return res;
755
- },
756
- update: async (id, body) => {
757
- let res = await this._update(
758
- this.svAPIEndpoint,
759
- this.bank._path + `/${id}`,
760
- body
761
- );
762
- return res;
763
- },
764
- };
765
- this.bank_list = {
766
- _path: "/bankslists",
767
- find: async (params) => {
768
- let res = await this._fetch(
769
- this.svAPIEndpoint,
770
- this.bank_list._path,
771
- params
772
- );
773
- return res;
774
- },
775
- get: async (id) => {
776
- return await this._fetch(
777
- this.svAPIEndpoint,
778
- this.bank_list._path + `/${id}`
779
- );
780
- },
781
- create: async (body) => {
782
- let res = await this._create(
783
- this.svAPIEndpoint,
784
- this.bank_list._path,
785
- body
786
- );
787
- return res;
788
- },
789
- update: async (id, body) => {
790
- let res = await this._update(
791
- this.svAPIEndpoint,
792
- this.bank_list._path + `/${id}`,
793
- body
794
- );
795
- return res;
796
- },
797
- };
798
- this.customStatus = {
799
- _path: "/custom-status",
800
- find: async (params) => {
801
- let res = await this._fetch(
802
- this.svAPIEndpoint,
803
- this.customStatus._path,
804
- params
805
- );
806
- return res;
807
- },
808
- get: async (id) => {
809
- return await this._fetch(
810
- this.svAPIEndpoint,
811
- this.customStatus._path + `/${id}`
812
- );
813
- },
814
- create: async (body) => {
815
- let res = await this._create(
816
- this.svAPIEndpoint,
817
- this.customStatus._path,
818
- body
819
- );
820
- return res;
821
- },
822
- update: async (id, body) => {
823
- let res = await this._update(
824
- this.svAPIEndpoint,
825
- this.customStatus._path + `/${id}`,
826
- body
827
- );
828
- return res;
829
- },
830
- remove: async (id) => {
831
- let res = await this._delete(
832
- this.svAPIEndpoint,
833
- this.customStatus._path + `/${id}`
834
- );
835
- return res;
836
- },
837
- };
838
- this.invoice = {
839
- _path: "/fullinvoices",
840
- find: async (params) => {
841
- let res = await this._fetch(
842
- this.svAPIEndpoint,
843
- this.invoice._path,
844
- params
845
- );
846
- return res;
847
- },
848
- get: async (id, params) => {
849
- return await this._fetch(
850
- this.svAPIEndpoint,
851
- this.invoice._path + `/${id}`,
852
- params
853
- );
854
- },
855
- create: async (body) => {
856
- let res = await this._create(
857
- this.svAPIEndpoint,
858
- this.invoice._path,
859
- body
860
- );
861
- return res;
862
- },
863
- update: async (id, body) => {
864
- let res = await this._update(
865
- this.svAPIEndpoint,
866
- this.invoice._path + `/${id}`,
867
- body
868
- );
869
- return res;
870
- },
871
- };
872
- this.proforma = {
873
- _path: "/proforma",
874
- find: async (params) => {
875
- let res = await this._fetch(
876
- this.svAPIEndpoint,
877
- this.proforma._path,
878
- params
879
- );
880
- return res;
881
- },
882
- get: async (id, params) => {
883
- return await this._fetch(
884
- this.svAPIEndpoint,
885
- this.proforma._path + `/${id}`,
886
- params
887
- );
888
- },
889
- create: async (body) => {
890
- let res = await this._create(
891
- this.svAPIEndpoint,
892
- this.proforma._path,
893
- body
894
- );
895
- return res;
896
- },
897
- update: async (id, body) => {
898
- let res = await this._update(
899
- this.svAPIEndpoint,
900
- this.proforma._path + `/${id}`,
901
- body
902
- );
903
- return res;
904
- },
905
- };
906
- this.payment = {
907
- _path: "/payments",
908
- find: async (params) => {
909
- let res = await this._fetch(
910
- this.svAPIEndpoint,
911
- this.payment._path,
912
- params
913
- );
914
- return res;
915
- },
916
- get: async (id, params) => {
917
- return await this._fetch(
918
- this.svAPIEndpoint,
919
- this.payment._path + `/${id}`,
920
- params
921
- );
922
- },
923
- create: async (body) => {
924
- let res = await this._create(
925
- this.svAPIEndpoint,
926
- this.payment._path,
927
- body
928
- );
929
- return res;
930
- },
931
- update: async (id, body) => {
932
- let res = await this._update(
933
- this.svAPIEndpoint,
934
- this.payment._path + `/${id}`,
935
- body
936
- );
937
- return res;
938
- },
939
- };
940
- this.refund = {
941
- _path: "/refund",
942
- find: async (params) => {
943
- let res = await this._fetch(
944
- this.svAPIEndpoint,
945
- this.refund._path,
946
- params
947
- );
948
- return res;
949
- },
950
- get: async (id, params) => {
951
- return await this._fetch(
952
- this.svAPIEndpoint,
953
- this.refund._path + `/${id}`,
954
- params
955
- );
956
- },
957
- create: async (body) => {
958
- let res = await this._create(
959
- this.svAPIEndpoint,
960
- this.refund._path,
961
- body
962
- );
963
- return res;
964
- },
965
- update: async (id, body) => {
966
- let res = await this._update(
967
- this.svAPIEndpoint,
968
- this.refund._path + `/${id}`,
969
- body
970
- );
971
- return res;
972
- },
973
- };
974
- this.transfer = {
975
- _path: "/transfer",
976
- find: async (params) => {
977
- let res = await this._fetch(
978
- this.svAPIEndpoint,
979
- this.transfer._path,
980
- params
981
- );
982
- return res;
983
- },
984
- get: async (id, params) => {
985
- return await this._fetch(
986
- this.svAPIEndpoint,
987
- this.transfer._path + `/${id}`,
988
- params
989
- );
990
- },
991
- create: async (body) => {
992
- let res = await this._create(
993
- this.svAPIEndpoint,
994
- this.transfer._path,
995
- body
996
- );
997
- return res;
998
- },
999
- update: async (id, body) => {
1000
- let res = await this._update(
1001
- this.svAPIEndpoint,
1002
- this.transfer._path + `/${id}`,
1003
- body
1004
- );
1005
- return res;
1006
- },
1007
- };
1008
- this.adjustInventory = {
1009
- _path: "/adjust-inventory",
1010
- find: async (params) => {
1011
- let res = await this._fetch(
1012
- this.svAPIEndpoint,
1013
- this.adjustInventory._path,
1014
- params
1015
- );
1016
- return res;
1017
- },
1018
- get: async (id, params) => {
1019
- return await this._fetch(
1020
- this.svAPIEndpoint,
1021
- this.adjustInventory._path + `/${id}`,
1022
- params
1023
- );
1024
- },
1025
- create: async (body) => {
1026
- let res = await this._create(
1027
- this.svAPIEndpoint,
1028
- this.adjustInventory._path,
1029
- body
1030
- );
1031
- return res;
1032
- },
1033
- };
1034
- this.inventory = {
1035
- _path: "/inventory",
1036
- find: async (params) => {
1037
- let res = await this._fetch(
1038
- this.svAPIEndpoint,
1039
- this.inventory._path,
1040
- params
1041
- );
1042
- return res;
1043
- },
1044
- };
1045
- this.integrationApp = {
1046
- _path: "/integration-app",
1047
- find: async (params) => {
1048
- let res = await this._fetch(
1049
- this.svAPIEndpoint,
1050
- this.integrationApp._path,
1051
- params
1052
- );
1053
- return res;
1054
- },
1055
- get: async (id, params) => {
1056
- return await this._fetch(
1057
- this.svAPIEndpoint,
1058
- this.integrationApp._path + `/${id}`,
1059
- params
1060
- );
1061
- },
1062
- create: async (body) => {
1063
- let res = await this._create(
1064
- this.svAPIEndpoint,
1065
- this.integrationApp._path,
1066
- body
1067
- );
1068
- return res;
1069
- },
1070
- update: async (id, body) => {
1071
- let res = await this._update(
1072
- this.svAPIEndpoint,
1073
- this.integrationApp._path + `/${id}`,
1074
- body
1075
- );
1076
- return res;
1077
- },
1078
- };
1079
- this.joinActionsWebHook = {
1080
- _path: "/svix-integration",
1081
- update: async (id, body) => {
1082
- let res = await this._update(
1083
- this.svAPIEndpoint,
1084
- this.joinActionsWebHook._path,
1085
- body
1086
- );
1087
- return res;
1088
- },
1089
- };
1090
- this.patchAction = {
1091
- _path: "/patch-action",
1092
- create: async (body, params) => {
1093
- const res = await this._create(
1094
- this.svAPIEndpoint,
1095
- this.patchAction._path,
1096
- body,
1097
- params
1098
- );
1099
- return res;
1100
- },
1101
- update: async (body) => {
1102
- const res = await this._update(
1103
- this.svAPIEndpoint,
1104
- this.patchAction._path,
1105
- body
1106
- );
1107
- return res;
1108
- },
1109
- };
1110
- this.updateIntegrationMeta = {
1111
- _path: "/update-integration-meta",
1112
- create: async (body, params) => {
1113
- let res = await this._create(
1114
- this.svAPIEndpoint,
1115
- this.updateIntegrationMeta._path,
1116
- body,
1117
- params
1118
- );
1119
- return res;
1120
- },
1121
- };
1122
- this.svAPIEndpoint =
1123
- !options?.env || options?.env == "production"
1124
- ? "https://sv.api.repzo.me"
1125
- : options?.env == "staging"
1126
- ? "https://staging.sv.api.repzo.me"
1127
- : options?.env == "local"
1128
- ? "http://localhost:3030"
1129
- : "";
1130
- this.headers = {
1131
- "api-key": apiKey,
1132
- "Content-Type": "application/json",
1133
- Accept: "application/json",
1134
- };
1135
- if (options?.headers) Object.assign(this.headers, options.headers);
1136
- }
1137
- async _fetch(baseUrl, path, params) {
1138
- let res = await axios.get(baseUrl + path, {
1139
- params,
1140
- headers: this.headers,
1141
- });
1142
- return res.data;
1143
- }
1144
- async _create(baseUrl, path, body, params) {
1145
- let res = await axios.post(baseUrl + path, body, {
1146
- params,
1147
- headers: this.headers,
1148
- });
1149
- return res.data;
1150
- }
1151
- async _update(baseUrl, path, body, params) {
1152
- let res = await axios.put(baseUrl + path, body, {
1153
- params,
1154
- headers: this.headers,
1155
- });
1156
- return res.data;
1157
- }
1158
- async _delete(baseUrl, path, params) {
1159
- let res = await axios.delete(baseUrl + path, {
1160
- params,
1161
- headers: this.headers,
1162
- });
1163
- return res.data;
1164
- }
1165
- }
1166
- Repzo.ActionLogs = class {
1167
- constructor(superThis, sync_id) {
1168
- this.superThis = superThis;
1169
- this._path = "/integration-action-log";
1170
- this.available_app_name = "";
1171
- this.available_app_id = "";
1172
- this.app_id = "";
1173
- this.action = "";
1174
- this.start_time = Date.now();
1175
- this.status = "processing";
1176
- this.message = "Log Created";
1177
- this.details = [];
1178
- this.sync_id = sync_id;
1179
- this.isOld = true;
1180
- }
1181
- async load(sync_id) {
1182
- const params = { sync_id: sync_id };
1183
- const res = await this.superThis._fetch(
1184
- this.superThis.svAPIEndpoint,
1185
- this._path,
1186
- params
1187
- );
1188
- if (!res?.data?.length)
1189
- throw new Error(`Action Log Not found, sync_id: ${sync_id}`);
1190
- const action_log = res.data[0];
1191
- this.sync_id = sync_id;
1192
- this.details = action_log.details;
1193
- this.status = action_log.status;
1194
- this.error = action_log.error;
1195
- this.start_time = action_log.start_time;
1196
- this.body = action_log.body;
1197
- this.meta = action_log.meta;
1198
- this.message = action_log.message;
1199
- this.app_id = action_log.app_id;
1200
- this.available_app_id = action_log.available_app_id;
1201
- this.available_app_name = action_log.available_app_name;
1202
- this.company_namespace = action_log.company_namespace;
1203
- this.action = action_log.action;
1204
- this.isOld = true;
1205
- return this;
1206
- }
1207
- setStatus(status, error) {
1208
- this.details.push({
1209
- timestamp: Date.now(),
1210
- content: `status was changed from ${this.status} to ${status}`,
1211
- });
1212
- this.status = status;
1213
- if (error) {
1214
- if (typeof error == "string") {
1215
- this.error = { message: error };
1216
- } else if (error.message || error.response?.data) {
1217
- this.error = {
1218
- // json: error.toJSON ? error.toJSON() : undefined,
1219
- message: error.message,
1220
- responseData: error.response?.data,
4
+ constructor(apiKey, options) {
5
+ this.client = {
6
+ _path: "/client",
7
+ find: async (params) => {
8
+ let res = await this._fetch(this.svAPIEndpoint, this.client._path, params);
9
+ return res;
10
+ },
11
+ get: async (id, params) => {
12
+ return await this._fetch(this.svAPIEndpoint, this.client._path + `/${id}`, params);
13
+ },
14
+ create: async (body) => {
15
+ let res = await this._create(this.svAPIEndpoint, this.client._path, body);
16
+ return res;
17
+ },
18
+ update: async (id, body) => {
19
+ let res = await this._update(this.svAPIEndpoint, this.client._path + `/${id}`, body);
20
+ return res;
21
+ },
22
+ remove: async (id) => {
23
+ let res = await this._delete(this.svAPIEndpoint, this.client._path + `/${id}`);
24
+ return res;
25
+ },
26
+ };
27
+ this.product = {
28
+ _path: "/product",
29
+ find: async (params) => {
30
+ let res = await this._fetch(this.svAPIEndpoint, this.product._path, params);
31
+ return res;
32
+ },
33
+ get: async (id, params) => {
34
+ return await this._fetch(this.svAPIEndpoint, this.product._path + `/${id}`, params);
35
+ },
36
+ create: async (body) => {
37
+ let res = await this._create(this.svAPIEndpoint, this.product._path, body);
38
+ return res;
39
+ },
40
+ update: async (id, body) => {
41
+ let res = await this._update(this.svAPIEndpoint, this.product._path + `/${id}`, body);
42
+ return res;
43
+ },
44
+ remove: async (id) => {
45
+ let res = await this._delete(this.svAPIEndpoint, this.product._path + `/${id}`);
46
+ return res;
47
+ },
48
+ };
49
+ this.variant = {
50
+ _path: "/variant",
51
+ find: async (params) => {
52
+ let res = await this._fetch(this.svAPIEndpoint, this.variant._path, params);
53
+ return res;
54
+ },
55
+ get: async (id, params) => {
56
+ return await this._fetch(this.svAPIEndpoint, this.variant._path + `/${id}`, params);
57
+ },
58
+ create: async (body) => {
59
+ let res = await this._create(this.svAPIEndpoint, this.variant._path, body);
60
+ return res;
61
+ },
62
+ update: async (id, body) => {
63
+ let res = await this._update(this.svAPIEndpoint, this.variant._path + `/${id}`, body);
64
+ return res;
65
+ },
66
+ remove: async (id) => {
67
+ let res = await this._delete(this.svAPIEndpoint, this.variant._path + `/${id}`);
68
+ return res;
69
+ },
70
+ };
71
+ this.category = {
72
+ _path: "/product-category",
73
+ find: async (params) => {
74
+ let res = await this._fetch(this.svAPIEndpoint, this.category._path, params);
75
+ return res;
76
+ },
77
+ get: async (id) => {
78
+ return await this._fetch(this.svAPIEndpoint, this.category._path + `/${id}`);
79
+ },
80
+ create: async (body) => {
81
+ let res = await this._create(this.svAPIEndpoint, this.category._path, body);
82
+ return res;
83
+ },
84
+ update: async (id, body) => {
85
+ let res = await this._update(this.svAPIEndpoint, this.category._path + `/${id}`, body);
86
+ return res;
87
+ },
88
+ remove: async (id) => {
89
+ let res = await this._delete(this.svAPIEndpoint, this.category._path + `/${id}`);
90
+ return res;
91
+ },
92
+ };
93
+ this.sub_category = {
94
+ _path: "/product-sub-category",
95
+ find: async (params) => {
96
+ let res = await this._fetch(this.svAPIEndpoint, this.sub_category._path, params);
97
+ return res;
98
+ },
99
+ get: async (id, params) => {
100
+ return await this._fetch(this.svAPIEndpoint, this.sub_category._path + `/${id}`, params);
101
+ },
102
+ create: async (body) => {
103
+ let res = await this._create(this.svAPIEndpoint, this.sub_category._path, body);
104
+ return res;
105
+ },
106
+ update: async (id, body) => {
107
+ let res = await this._update(this.svAPIEndpoint, this.sub_category._path + `/${id}`, body);
108
+ return res;
109
+ },
110
+ remove: async (id) => {
111
+ let res = await this._delete(this.svAPIEndpoint, this.sub_category._path + `/${id}`);
112
+ return res;
113
+ },
114
+ };
115
+ this.brand = {
116
+ _path: "/product-brand",
117
+ find: async (params) => {
118
+ let res = await this._fetch(this.svAPIEndpoint, this.brand._path, params);
119
+ return res;
120
+ },
121
+ get: async (id) => {
122
+ return await this._fetch(this.svAPIEndpoint, this.brand._path + `/${id}`);
123
+ },
124
+ create: async (body) => {
125
+ let res = await this._create(this.svAPIEndpoint, this.brand._path, body);
126
+ return res;
127
+ },
128
+ update: async (id, body) => {
129
+ let res = await this._update(this.svAPIEndpoint, this.brand._path + `/${id}`, body);
130
+ return res;
131
+ },
132
+ remove: async (id) => {
133
+ let res = await this._delete(this.svAPIEndpoint, this.brand._path + `/${id}`);
134
+ return res;
135
+ },
136
+ };
137
+ this.product_group = {
138
+ _path: "/product-group",
139
+ find: async (params) => {
140
+ let res = await this._fetch(this.svAPIEndpoint, this.product_group._path, params);
141
+ return res;
142
+ },
143
+ get: async (id) => {
144
+ return await this._fetch(this.svAPIEndpoint, this.product_group._path + `/${id}`);
145
+ },
146
+ create: async (body) => {
147
+ let res = await this._create(this.svAPIEndpoint, this.product_group._path, body);
148
+ return res;
149
+ },
150
+ update: async (id, body) => {
151
+ let res = await this._update(this.svAPIEndpoint, this.product_group._path + `/${id}`, body);
152
+ return res;
153
+ },
154
+ remove: async (id) => {
155
+ let res = await this._delete(this.svAPIEndpoint, this.product_group._path + `/${id}`);
156
+ return res;
157
+ },
158
+ };
159
+ this.tax = {
160
+ _path: "/tax",
161
+ find: async (params) => {
162
+ let res = await this._fetch(this.svAPIEndpoint, this.tax._path, params);
163
+ return res;
164
+ },
165
+ get: async (id) => {
166
+ return await this._fetch(this.svAPIEndpoint, this.tax._path + `/${id}`);
167
+ },
168
+ create: async (body) => {
169
+ let res = await this._create(this.svAPIEndpoint, this.tax._path, body);
170
+ return res;
171
+ },
172
+ update: async (id, body) => {
173
+ let res = await this._update(this.svAPIEndpoint, this.tax._path + `/${id}`, body);
174
+ return res;
175
+ },
176
+ remove: async (id) => {
177
+ let res = await this._delete(this.svAPIEndpoint, this.tax._path + `/${id}`);
178
+ return res;
179
+ },
180
+ };
181
+ this.measureunit = {
182
+ _path: "/measureunits",
183
+ find: async (params) => {
184
+ let res = await this._fetch(this.svAPIEndpoint, this.measureunit._path, params);
185
+ return res;
186
+ },
187
+ get: async (id) => {
188
+ return await this._fetch(this.svAPIEndpoint, this.measureunit._path + `/${id}`);
189
+ },
190
+ create: async (body) => {
191
+ let res = await this._create(this.svAPIEndpoint, this.measureunit._path, body);
192
+ return res;
193
+ },
194
+ update: async (id, body) => {
195
+ let res = await this._update(this.svAPIEndpoint, this.measureunit._path + `/${id}`, body);
196
+ return res;
197
+ },
198
+ remove: async (id) => {
199
+ let res = await this._delete(this.svAPIEndpoint, this.measureunit._path + `/${id}`);
200
+ return res;
201
+ },
202
+ };
203
+ this.measureunitFamily = {
204
+ _path: "/measureunit-family",
205
+ find: async (params) => {
206
+ let res = await this._fetch(this.svAPIEndpoint, this.measureunitFamily._path, params);
207
+ return res;
208
+ },
209
+ get: async (id) => {
210
+ return await this._fetch(this.svAPIEndpoint, this.measureunitFamily._path + `/${id}`);
211
+ },
212
+ create: async (body) => {
213
+ let res = await this._create(this.svAPIEndpoint, this.measureunitFamily._path, body);
214
+ return res;
215
+ },
216
+ update: async (id, body) => {
217
+ let res = await this._update(this.svAPIEndpoint, this.measureunitFamily._path + `/${id}`, body);
218
+ return res;
219
+ },
220
+ remove: async (id) => {
221
+ let res = await this._delete(this.svAPIEndpoint, this.measureunitFamily._path + `/${id}`);
222
+ return res;
223
+ },
224
+ };
225
+ this.media = {
226
+ _path: "/media",
227
+ find: async (params) => {
228
+ let res = await this._fetch(this.svAPIEndpoint, this.media._path, params);
229
+ return res;
230
+ },
231
+ get: async (id) => {
232
+ return await this._fetch(this.svAPIEndpoint, this.media._path + `/${id}`);
233
+ },
234
+ create: async (body) => {
235
+ let res = await this._create(this.svAPIEndpoint, this.media._path, body);
236
+ return res;
237
+ },
238
+ update: async (id, body) => {
239
+ let res = await this._update(this.svAPIEndpoint, this.media._path + `/${id}`, body);
240
+ return res;
241
+ },
242
+ remove: async (id) => {
243
+ let res = await this._delete(this.svAPIEndpoint, this.media._path + `/${id}`);
244
+ return res;
245
+ },
246
+ };
247
+ this.priceList = {
248
+ _path: "/pricelists",
249
+ find: async (params) => {
250
+ let res = await this._fetch(this.svAPIEndpoint, this.priceList._path, params);
251
+ return res;
252
+ },
253
+ get: async (id) => {
254
+ return await this._fetch(this.svAPIEndpoint, this.priceList._path + `/${id}`);
255
+ },
256
+ create: async (body) => {
257
+ let res = await this._create(this.svAPIEndpoint, this.priceList._path, body);
258
+ return res;
259
+ },
260
+ update: async (id, body) => {
261
+ let res = await this._update(this.svAPIEndpoint, this.priceList._path + `/${id}`, body);
262
+ return res;
263
+ },
264
+ remove: async (id) => {
265
+ let res = await this._delete(this.svAPIEndpoint, this.priceList._path + `/${id}`);
266
+ return res;
267
+ },
268
+ };
269
+ this.priceListItem = {
270
+ _path: "/pricelistsitems",
271
+ find: async (params) => {
272
+ let res = await this._fetch(this.svAPIEndpoint, this.priceListItem._path, params);
273
+ return res;
274
+ },
275
+ get: async (id) => {
276
+ return await this._fetch(this.svAPIEndpoint, this.priceListItem._path + `/${id}`);
277
+ },
278
+ create: async (body) => {
279
+ let res = await this._create(this.svAPIEndpoint, this.priceListItem._path, body);
280
+ return res;
281
+ },
282
+ update: async (id, body) => {
283
+ let res = await this._update(this.svAPIEndpoint, this.priceListItem._path + `/${id}`, body);
284
+ return res;
285
+ },
286
+ remove: async (id) => {
287
+ let res = await this._delete(this.svAPIEndpoint, this.priceListItem._path + `/${id}`);
288
+ return res;
289
+ },
290
+ };
291
+ this.team = {
292
+ _path: "/teams",
293
+ find: async (params) => {
294
+ let res = await this._fetch(this.svAPIEndpoint, this.team._path, params);
295
+ return res;
296
+ },
297
+ get: async (id) => {
298
+ return await this._fetch(this.svAPIEndpoint, this.team._path + `/${id}`);
299
+ },
300
+ create: async (body) => {
301
+ let res = await this._create(this.svAPIEndpoint, this.team._path, body);
302
+ return res;
303
+ },
304
+ update: async (id, body) => {
305
+ let res = await this._update(this.svAPIEndpoint, this.team._path + `/${id}`, body);
306
+ return res;
307
+ },
308
+ remove: async (id) => {
309
+ let res = await this._delete(this.svAPIEndpoint, this.team._path + `/${id}`);
310
+ return res;
311
+ },
312
+ };
313
+ this.rep = {
314
+ _path: "/rep",
315
+ find: async (params) => {
316
+ let res = await this._fetch(this.svAPIEndpoint, this.rep._path, params);
317
+ return res;
318
+ },
319
+ get: async (id, params) => {
320
+ return await this._fetch(this.svAPIEndpoint, this.rep._path + `/${id}`, params);
321
+ },
322
+ create: async (body) => {
323
+ let res = await this._create(this.svAPIEndpoint, this.rep._path, body);
324
+ return res;
325
+ },
326
+ update: async (id, body) => {
327
+ let res = await this._update(this.svAPIEndpoint, this.rep._path + `/${id}`, body);
328
+ return res;
329
+ },
330
+ remove: async (id) => {
331
+ let res = await this._delete(this.svAPIEndpoint, this.rep._path + `/${id}`);
332
+ return res;
333
+ },
334
+ };
335
+ this.tag = {
336
+ _path: "/tag",
337
+ find: async (params) => {
338
+ let res = await this._fetch(this.svAPIEndpoint, this.tag._path, params);
339
+ return res;
340
+ },
341
+ get: async (id) => {
342
+ return await this._fetch(this.svAPIEndpoint, this.tag._path + `/${id}`);
343
+ },
344
+ create: async (body) => {
345
+ let res = await this._create(this.svAPIEndpoint, this.tag._path, body);
346
+ return res;
347
+ },
348
+ update: async (id, body) => {
349
+ let res = await this._update(this.svAPIEndpoint, this.tag._path + `/${id}`, body);
350
+ return res;
351
+ },
352
+ remove: async (id) => {
353
+ let res = await this._delete(this.svAPIEndpoint, this.tag._path + `/${id}`);
354
+ return res;
355
+ },
356
+ };
357
+ this.warehouse = {
358
+ _path: "/warehouse",
359
+ find: async (params) => {
360
+ let res = await this._fetch(this.svAPIEndpoint, this.warehouse._path, params);
361
+ return res;
362
+ },
363
+ get: async (id) => {
364
+ return await this._fetch(this.svAPIEndpoint, this.warehouse._path + `/${id}`);
365
+ },
366
+ create: async (body) => {
367
+ let res = await this._create(this.svAPIEndpoint, this.warehouse._path, body);
368
+ return res;
369
+ },
370
+ update: async (id, body) => {
371
+ let res = await this._update(this.svAPIEndpoint, this.warehouse._path + `/${id}`, body);
372
+ return res;
373
+ },
374
+ remove: async (id) => {
375
+ let res = await this._delete(this.svAPIEndpoint, this.warehouse._path + `/${id}`);
376
+ return res;
377
+ },
378
+ };
379
+ this.channel = {
380
+ _path: "/client-channel",
381
+ find: async (params) => {
382
+ let res = await this._fetch(this.svAPIEndpoint, this.channel._path, params);
383
+ return res;
384
+ },
385
+ get: async (id) => {
386
+ return await this._fetch(this.svAPIEndpoint, this.channel._path + `/${id}`);
387
+ },
388
+ create: async (body) => {
389
+ let res = await this._create(this.svAPIEndpoint, this.channel._path, body);
390
+ return res;
391
+ },
392
+ update: async (id, body) => {
393
+ let res = await this._update(this.svAPIEndpoint, this.channel._path + `/${id}`, body);
394
+ return res;
395
+ },
396
+ remove: async (id) => {
397
+ let res = await this._delete(this.svAPIEndpoint, this.channel._path + `/${id}`);
398
+ return res;
399
+ },
400
+ };
401
+ this.paymentTerm = {
402
+ _path: "/paymentterms",
403
+ find: async (params) => {
404
+ let res = await this._fetch(this.svAPIEndpoint, this.paymentTerm._path, params);
405
+ return res;
406
+ },
407
+ get: async (id) => {
408
+ return await this._fetch(this.svAPIEndpoint, this.paymentTerm._path + `/${id}`);
409
+ },
410
+ create: async (body) => {
411
+ let res = await this._create(this.svAPIEndpoint, this.paymentTerm._path, body);
412
+ return res;
413
+ },
414
+ update: async (id, body) => {
415
+ let res = await this._update(this.svAPIEndpoint, this.paymentTerm._path + `/${id}`, body);
416
+ return res;
417
+ },
418
+ remove: async (id) => {
419
+ let res = await this._delete(this.svAPIEndpoint, this.paymentTerm._path + `/${id}`);
420
+ return res;
421
+ },
422
+ };
423
+ this.bank = {
424
+ _path: "/banks",
425
+ find: async (params) => {
426
+ let res = await this._fetch(this.svAPIEndpoint, this.bank._path, params);
427
+ return res;
428
+ },
429
+ get: async (id) => {
430
+ return await this._fetch(this.svAPIEndpoint, this.bank._path + `/${id}`);
431
+ },
432
+ create: async (body) => {
433
+ let res = await this._create(this.svAPIEndpoint, this.bank._path, body);
434
+ return res;
435
+ },
436
+ update: async (id, body) => {
437
+ let res = await this._update(this.svAPIEndpoint, this.bank._path + `/${id}`, body);
438
+ return res;
439
+ },
440
+ };
441
+ this.bank_list = {
442
+ _path: "/bankslists",
443
+ find: async (params) => {
444
+ let res = await this._fetch(this.svAPIEndpoint, this.bank_list._path, params);
445
+ return res;
446
+ },
447
+ get: async (id) => {
448
+ return await this._fetch(this.svAPIEndpoint, this.bank_list._path + `/${id}`);
449
+ },
450
+ create: async (body) => {
451
+ let res = await this._create(this.svAPIEndpoint, this.bank_list._path, body);
452
+ return res;
453
+ },
454
+ update: async (id, body) => {
455
+ let res = await this._update(this.svAPIEndpoint, this.bank_list._path + `/${id}`, body);
456
+ return res;
457
+ },
458
+ };
459
+ this.customStatus = {
460
+ _path: "/custom-status",
461
+ find: async (params) => {
462
+ let res = await this._fetch(this.svAPIEndpoint, this.customStatus._path, params);
463
+ return res;
464
+ },
465
+ get: async (id) => {
466
+ return await this._fetch(this.svAPIEndpoint, this.customStatus._path + `/${id}`);
467
+ },
468
+ create: async (body) => {
469
+ let res = await this._create(this.svAPIEndpoint, this.customStatus._path, body);
470
+ return res;
471
+ },
472
+ update: async (id, body) => {
473
+ let res = await this._update(this.svAPIEndpoint, this.customStatus._path + `/${id}`, body);
474
+ return res;
475
+ },
476
+ remove: async (id) => {
477
+ let res = await this._delete(this.svAPIEndpoint, this.customStatus._path + `/${id}`);
478
+ return res;
479
+ },
480
+ };
481
+ this.workorder = {
482
+ _path: "/workorder",
483
+ find: async (params) => {
484
+ let res = await this._fetch(this.svAPIEndpoint, this.workorder._path, params);
485
+ return res;
486
+ },
487
+ get: async (id, params) => {
488
+ return await this._fetch(this.svAPIEndpoint, this.workorder._path + `/${id}`, params);
489
+ },
490
+ };
491
+ this.invoice = {
492
+ _path: "/fullinvoices",
493
+ find: async (params) => {
494
+ let res = await this._fetch(this.svAPIEndpoint, this.invoice._path, params);
495
+ return res;
496
+ },
497
+ get: async (id, params) => {
498
+ return await this._fetch(this.svAPIEndpoint, this.invoice._path + `/${id}`, params);
499
+ },
500
+ create: async (body) => {
501
+ let res = await this._create(this.svAPIEndpoint, this.invoice._path, body);
502
+ return res;
503
+ },
504
+ update: async (id, body) => {
505
+ let res = await this._update(this.svAPIEndpoint, this.invoice._path + `/${id}`, body);
506
+ return res;
507
+ },
508
+ };
509
+ this.proforma = {
510
+ _path: "/proforma",
511
+ find: async (params) => {
512
+ let res = await this._fetch(this.svAPIEndpoint, this.proforma._path, params);
513
+ return res;
514
+ },
515
+ get: async (id, params) => {
516
+ return await this._fetch(this.svAPIEndpoint, this.proforma._path + `/${id}`, params);
517
+ },
518
+ create: async (body) => {
519
+ let res = await this._create(this.svAPIEndpoint, this.proforma._path, body);
520
+ return res;
521
+ },
522
+ update: async (id, body) => {
523
+ let res = await this._update(this.svAPIEndpoint, this.proforma._path + `/${id}`, body);
524
+ return res;
525
+ },
526
+ };
527
+ this.payment = {
528
+ _path: "/payments",
529
+ find: async (params) => {
530
+ let res = await this._fetch(this.svAPIEndpoint, this.payment._path, params);
531
+ return res;
532
+ },
533
+ get: async (id, params) => {
534
+ return await this._fetch(this.svAPIEndpoint, this.payment._path + `/${id}`, params);
535
+ },
536
+ create: async (body) => {
537
+ let res = await this._create(this.svAPIEndpoint, this.payment._path, body);
538
+ return res;
539
+ },
540
+ update: async (id, body) => {
541
+ let res = await this._update(this.svAPIEndpoint, this.payment._path + `/${id}`, body);
542
+ return res;
543
+ },
544
+ };
545
+ this.refund = {
546
+ _path: "/refund",
547
+ find: async (params) => {
548
+ let res = await this._fetch(this.svAPIEndpoint, this.refund._path, params);
549
+ return res;
550
+ },
551
+ get: async (id, params) => {
552
+ return await this._fetch(this.svAPIEndpoint, this.refund._path + `/${id}`, params);
553
+ },
554
+ create: async (body) => {
555
+ let res = await this._create(this.svAPIEndpoint, this.refund._path, body);
556
+ return res;
557
+ },
558
+ update: async (id, body) => {
559
+ let res = await this._update(this.svAPIEndpoint, this.refund._path + `/${id}`, body);
560
+ return res;
561
+ },
562
+ };
563
+ this.transfer = {
564
+ _path: "/transfer",
565
+ find: async (params) => {
566
+ let res = await this._fetch(this.svAPIEndpoint, this.transfer._path, params);
567
+ return res;
568
+ },
569
+ get: async (id, params) => {
570
+ return await this._fetch(this.svAPIEndpoint, this.transfer._path + `/${id}`, params);
571
+ },
572
+ create: async (body) => {
573
+ let res = await this._create(this.svAPIEndpoint, this.transfer._path, body);
574
+ return res;
575
+ },
576
+ update: async (id, body) => {
577
+ let res = await this._update(this.svAPIEndpoint, this.transfer._path + `/${id}`, body);
578
+ return res;
579
+ },
580
+ };
581
+ this.adjustInventory = {
582
+ _path: "/adjust-inventory",
583
+ find: async (params) => {
584
+ let res = await this._fetch(this.svAPIEndpoint, this.adjustInventory._path, params);
585
+ return res;
586
+ },
587
+ get: async (id, params) => {
588
+ return await this._fetch(this.svAPIEndpoint, this.adjustInventory._path + `/${id}`, params);
589
+ },
590
+ create: async (body) => {
591
+ let res = await this._create(this.svAPIEndpoint, this.adjustInventory._path, body);
592
+ return res;
593
+ },
594
+ };
595
+ this.inventory = {
596
+ _path: "/inventory",
597
+ find: async (params) => {
598
+ let res = await this._fetch(this.svAPIEndpoint, this.inventory._path, params);
599
+ return res;
600
+ },
1221
601
  };
1222
- } else {
1223
- this.error = error;
1224
- }
1225
- return this;
602
+ this.integrationApp = {
603
+ _path: "/integration-app",
604
+ find: async (params) => {
605
+ let res = await this._fetch(this.svAPIEndpoint, this.integrationApp._path, params);
606
+ return res;
607
+ },
608
+ get: async (id, params) => {
609
+ return await this._fetch(this.svAPIEndpoint, this.integrationApp._path + `/${id}`, params);
610
+ },
611
+ create: async (body) => {
612
+ let res = await this._create(this.svAPIEndpoint, this.integrationApp._path, body);
613
+ return res;
614
+ },
615
+ update: async (id, body) => {
616
+ let res = await this._update(this.svAPIEndpoint, this.integrationApp._path + `/${id}`, body);
617
+ return res;
618
+ },
619
+ };
620
+ this.joinActionsWebHook = {
621
+ _path: "/svix-integration",
622
+ update: async (id, body) => {
623
+ let res = await this._update(this.svAPIEndpoint, this.joinActionsWebHook._path, body);
624
+ return res;
625
+ },
626
+ };
627
+ this.patchAction = {
628
+ _path: "/patch-action",
629
+ create: async (body, params) => {
630
+ const res = await this._create(this.svAPIEndpoint, this.patchAction._path, body, params);
631
+ return res;
632
+ },
633
+ update: async (body) => {
634
+ const res = await this._update(this.svAPIEndpoint, this.patchAction._path, body);
635
+ return res;
636
+ },
637
+ };
638
+ this.updateIntegrationMeta = {
639
+ _path: "/update-integration-meta",
640
+ create: async (body, params) => {
641
+ let res = await this._create(this.svAPIEndpoint, this.updateIntegrationMeta._path, body, params);
642
+ return res;
643
+ },
644
+ };
645
+ this.svAPIEndpoint =
646
+ !options?.env || options?.env == "production"
647
+ ? "https://sv.api.repzo.me"
648
+ : options?.env == "staging"
649
+ ? "https://staging.sv.api.repzo.me"
650
+ : options?.env == "local"
651
+ ? "http://localhost:3030"
652
+ : "";
653
+ this.headers = {
654
+ "api-key": apiKey,
655
+ "Content-Type": "application/json",
656
+ Accept: "application/json",
657
+ };
658
+ if (options?.headers)
659
+ Object.assign(this.headers, options.headers);
1226
660
  }
1227
- return this;
1228
- }
1229
- setBody(body) {
1230
- this.body = body;
1231
- return this;
1232
- }
1233
- setMeta(meta) {
1234
- this.meta = meta;
1235
- return this;
1236
- }
1237
- async commit() {
1238
- let doc = {
1239
- available_app_name: this.available_app_name,
1240
- available_app_id: this.available_app_id,
1241
- app_id: this.app_id,
1242
- action: this.action,
1243
- company_namespace: this.company_namespace,
1244
- status: this.status,
1245
- error: this.error ? this.error : undefined,
1246
- start_time: this.start_time,
1247
- end_time: Date.now(),
1248
- total_time: Date.now() - this.start_time,
1249
- body: this.body,
1250
- meta: this.meta,
1251
- message: this.message,
1252
- details: this.details,
1253
- sync_id: this.sync_id,
1254
- };
1255
- try {
1256
- const res = await this.superThis._create(
1257
- this.superThis.svAPIEndpoint,
1258
- this._path,
1259
- doc
1260
- );
1261
- } catch (e) {
1262
- console.error(e);
661
+ async _fetch(baseUrl, path, params) {
662
+ let res = await axios.get(baseUrl + path, {
663
+ params,
664
+ headers: this.headers,
665
+ });
666
+ return res.data;
1263
667
  }
1264
- return this;
1265
- }
1266
- addDetail(detail, meta) {
1267
- let d = {
1268
- timestamp: Date.now(),
1269
- content: detail,
1270
- };
1271
- this.message = detail;
1272
- if (meta) d.meta = meta;
1273
- this.details.push(d);
1274
- return this;
1275
- }
1276
- };
1277
- Repzo.CommandLog = class {
1278
- constructor(superThis, app, command, trigger) {
1279
- this.superThis = superThis;
1280
- this._path = "/integration-command-log";
1281
- this.app_id = app._id;
1282
- this.available_app_id = app.available_app._id;
1283
- this.available_app_name = app.available_app.name;
1284
- this.company_namespace = app.company_namespace;
1285
- this.start_time = Date.now();
1286
- this.status = "received";
1287
- this.message = "Request received";
1288
- this.command = command;
1289
- this.details = [{ timestamp: Date.now(), content: "Request received" }];
1290
- this.sync_id = uuid();
1291
- this.isOld = false;
1292
- this.isPrioritized = false;
1293
- this.retries = 1;
1294
- this.trigger = trigger;
1295
- this.onGoing = true;
1296
- }
1297
- async load(sync_id, retries) {
1298
- if (sync_id) {
1299
- const params = { sync_id: sync_id };
1300
- const res = await this.superThis._fetch(
1301
- this.superThis.svAPIEndpoint,
1302
- this._path,
1303
- params
1304
- );
1305
- if (!res?.data?.length)
1306
- throw new Error(`Command Log Not found, sync_id: ${sync_id}`);
1307
- const command_log = res.data[0];
1308
- if (command_log) {
668
+ async _create(baseUrl, path, body, params) {
669
+ let res = await axios.post(baseUrl + path, body, {
670
+ params,
671
+ headers: this.headers,
672
+ });
673
+ return res.data;
674
+ }
675
+ async _update(baseUrl, path, body, params) {
676
+ let res = await axios.put(baseUrl + path, body, {
677
+ params,
678
+ headers: this.headers,
679
+ });
680
+ return res.data;
681
+ }
682
+ async _delete(baseUrl, path, params) {
683
+ let res = await axios.delete(baseUrl + path, {
684
+ params,
685
+ headers: this.headers,
686
+ });
687
+ return res.data;
688
+ }
689
+ }
690
+ Repzo.ActionLogs = class {
691
+ constructor(superThis, sync_id) {
692
+ this.superThis = superThis;
693
+ this._path = "/integration-action-log";
694
+ this.available_app_name = "";
695
+ this.available_app_id = "";
696
+ this.app_id = "";
697
+ this.action = "";
698
+ this.start_time = Date.now();
699
+ this.status = "processing";
700
+ this.message = "Log Created";
701
+ this.details = [];
1309
702
  this.sync_id = sync_id;
1310
- this.details = command_log.details;
1311
- this.status = command_log.status;
1312
- this.error = command_log.error;
1313
- this.start_time = command_log.start_time;
1314
- this.body = command_log.body;
1315
- this.meta = command_log.meta;
1316
- this.message = command_log.message;
1317
- this.retries =
1318
- retries !== undefined ? retries : command_log.retries || this.retries; // retries !== undefined ? retries : command_log.retries;
1319
703
  this.isOld = true;
1320
- this.failedAt = command_log.failedAt;
1321
- this.succeededAt = command_log.succeededAt;
1322
- this.skippedAt = command_log.skippedAt;
1323
- this.receivedAt = command_log.receivedAt;
1324
- this.processedAt = command_log.processedAt;
1325
- this.onGoing = command_log.onGoing || false;
1326
- this.trigger = command_log.trigger;
1327
- // this.priority = command_log.priority
1328
- // ? command_log.priority
1329
- // : this.priority
1330
- // ? this.priority
1331
- // : undefined;
1332
- }
1333
704
  }
1334
- return this;
1335
- }
1336
- setStatus(status, error) {
1337
- this.addDetail(`status was changed from ${this.status} to ${status}`);
1338
- this.status = status;
1339
- if (error) {
1340
- if (typeof error == "string") {
1341
- this.error = { message: error };
1342
- } else if (error.message || error.response?.data) {
1343
- this.error = {
1344
- // json: error.toJSON ? error.toJSON() : undefined,
1345
- message: error.message,
1346
- responseData: error.response?.data,
705
+ async load(sync_id) {
706
+ const params = { sync_id: sync_id };
707
+ const res = await this.superThis._fetch(this.superThis.svAPIEndpoint, this._path, params);
708
+ if (!res?.data?.length)
709
+ throw new Error(`Action Log Not found, sync_id: ${sync_id}`);
710
+ const action_log = res.data[0];
711
+ this.sync_id = sync_id;
712
+ this.details = action_log.details;
713
+ this.status = action_log.status;
714
+ this.error = action_log.error;
715
+ this.start_time = action_log.start_time;
716
+ this.body = action_log.body;
717
+ this.meta = action_log.meta;
718
+ this.message = action_log.message;
719
+ this.app_id = action_log.app_id;
720
+ this.available_app_id = action_log.available_app_id;
721
+ this.available_app_name = action_log.available_app_name;
722
+ this.company_namespace = action_log.company_namespace;
723
+ this.action = action_log.action;
724
+ this.isOld = true;
725
+ return this;
726
+ }
727
+ setStatus(status, error) {
728
+ this.details.push({
729
+ timestamp: Date.now(),
730
+ content: `status was changed from ${this.status} to ${status}`,
731
+ });
732
+ this.status = status;
733
+ if (error) {
734
+ if (typeof error == "string") {
735
+ this.error = { message: error };
736
+ }
737
+ else if (error.message || error.response?.data) {
738
+ this.error = {
739
+ // json: error.toJSON ? error.toJSON() : undefined,
740
+ message: error.message,
741
+ responseData: error.response?.data,
742
+ };
743
+ }
744
+ else {
745
+ this.error = error;
746
+ }
747
+ return this;
748
+ }
749
+ return this;
750
+ }
751
+ setBody(body) {
752
+ this.body = body;
753
+ return this;
754
+ }
755
+ setMeta(meta) {
756
+ this.meta = meta;
757
+ return this;
758
+ }
759
+ async commit() {
760
+ let doc = {
761
+ available_app_name: this.available_app_name,
762
+ available_app_id: this.available_app_id,
763
+ app_id: this.app_id,
764
+ action: this.action,
765
+ company_namespace: this.company_namespace,
766
+ status: this.status,
767
+ error: this.error ? this.error : undefined,
768
+ start_time: this.start_time,
769
+ end_time: Date.now(),
770
+ total_time: Date.now() - this.start_time,
771
+ body: this.body,
772
+ meta: this.meta,
773
+ message: this.message,
774
+ details: this.details,
775
+ sync_id: this.sync_id,
1347
776
  };
1348
- } else {
1349
- this.error = error;
1350
- }
1351
- return this;
777
+ try {
778
+ const res = await this.superThis._create(this.superThis.svAPIEndpoint, this._path, doc);
779
+ }
780
+ catch (e) {
781
+ console.error(e);
782
+ }
783
+ return this;
1352
784
  }
1353
- switch (status) {
1354
- case "fail":
1355
- this.failedAt = new Date();
1356
- this.onGoing = false;
1357
- break;
1358
- case "processing":
1359
- this.processedAt = new Date();
1360
- this.onGoing = true;
1361
- break;
1362
- case "queued":
1363
- this.queuedAt = new Date();
1364
- this.onGoing = true;
1365
- break;
1366
- case "received":
1367
- this.receivedAt = new Date();
785
+ addDetail(detail, meta) {
786
+ let d = {
787
+ timestamp: Date.now(),
788
+ content: detail,
789
+ };
790
+ this.message = detail;
791
+ if (meta)
792
+ d.meta = meta;
793
+ this.details.push(d);
794
+ return this;
795
+ }
796
+ };
797
+ Repzo.CommandLog = class {
798
+ constructor(superThis, app, command, trigger) {
799
+ this.superThis = superThis;
800
+ this._path = "/integration-command-log";
801
+ this.app_id = app._id;
802
+ this.available_app_id = app.available_app._id;
803
+ this.available_app_name = app.available_app.name;
804
+ this.company_namespace = app.company_namespace;
805
+ this.start_time = Date.now();
806
+ this.status = "received";
807
+ this.message = "Request received";
808
+ this.command = command;
809
+ this.details = [{ timestamp: Date.now(), content: "Request received" }];
810
+ this.sync_id = uuid();
811
+ this.isOld = false;
812
+ this.isPrioritized = false;
813
+ this.retries = 1;
814
+ this.trigger = trigger;
1368
815
  this.onGoing = true;
1369
- break;
1370
- case "skipped":
1371
- this.skippedAt = new Date();
1372
- this.onGoing = false;
1373
- break;
1374
- case "success":
1375
- this.succeededAt = new Date();
1376
- this.onGoing = false;
1377
- break;
1378
816
  }
1379
- return this;
1380
- }
1381
- setBody(body) {
1382
- this.body = body;
1383
- return this;
1384
- }
1385
- setMeta(meta) {
1386
- this.meta = meta;
1387
- return this;
1388
- }
1389
- async commit() {
1390
- let doc = {
1391
- available_app_name: this.available_app_name,
1392
- available_app_id: this.available_app_id,
1393
- app_id: this.app_id,
1394
- command: this.command,
1395
- status: this.status,
1396
- error: this.error ? this.error : undefined,
1397
- start_time: this.start_time,
1398
- end_time: Date.now(),
1399
- total_time: Date.now() - this.start_time,
1400
- company_namespace: this.company_namespace,
1401
- body: this.body,
1402
- meta: this.meta,
1403
- message: this.message,
1404
- details: this.details,
1405
- sync_id: this.sync_id,
1406
- // priority: this.priority ? this.priority : undefined,
1407
- queuedAt: this.queuedAt ? this.queuedAt : undefined,
1408
- failedAt: this.failedAt ? this.failedAt : undefined,
1409
- succeededAt: this.succeededAt ? this.succeededAt : undefined,
1410
- skippedAt: this.skippedAt ? this.skippedAt : undefined,
1411
- receivedAt: this.receivedAt ? this.receivedAt : undefined,
1412
- processedAt: this.processedAt ? this.processedAt : undefined,
1413
- onGoing: this.onGoing !== undefined ? this.onGoing : undefined,
1414
- retries: this.retries !== undefined ? this.retries : undefined,
1415
- trigger: this.trigger,
1416
- };
1417
- try {
1418
- const res = await this.superThis._create(
1419
- this.superThis.svAPIEndpoint,
1420
- this._path,
1421
- doc
1422
- );
1423
- this.isOld = true;
1424
- } catch (e) {
1425
- console.error(e);
817
+ async load(sync_id, retries) {
818
+ if (sync_id) {
819
+ const params = { sync_id: sync_id };
820
+ const res = await this.superThis._fetch(this.superThis.svAPIEndpoint, this._path, params);
821
+ if (!res?.data?.length)
822
+ throw new Error(`Command Log Not found, sync_id: ${sync_id}`);
823
+ const command_log = res.data[0];
824
+ if (command_log) {
825
+ this.sync_id = sync_id;
826
+ this.details = command_log.details;
827
+ this.status = command_log.status;
828
+ this.error = command_log.error;
829
+ this.start_time = command_log.start_time;
830
+ this.body = command_log.body;
831
+ this.meta = command_log.meta;
832
+ this.message = command_log.message;
833
+ this.retries =
834
+ retries !== undefined
835
+ ? retries
836
+ : command_log.retries || this.retries; // retries !== undefined ? retries : command_log.retries;
837
+ this.isOld = true;
838
+ this.failedAt = command_log.failedAt;
839
+ this.succeededAt = command_log.succeededAt;
840
+ this.skippedAt = command_log.skippedAt;
841
+ this.receivedAt = command_log.receivedAt;
842
+ this.processedAt = command_log.processedAt;
843
+ this.onGoing = command_log.onGoing || false;
844
+ this.trigger = command_log.trigger;
845
+ // this.priority = command_log.priority
846
+ // ? command_log.priority
847
+ // : this.priority
848
+ // ? this.priority
849
+ // : undefined;
850
+ }
851
+ }
852
+ return this;
853
+ }
854
+ setStatus(status, error) {
855
+ this.addDetail(`status was changed from ${this.status} to ${status}`);
856
+ this.status = status;
857
+ if (error) {
858
+ if (typeof error == "string") {
859
+ this.error = { message: error };
860
+ }
861
+ else if (error.message || error.response?.data) {
862
+ this.error = {
863
+ // json: error.toJSON ? error.toJSON() : undefined,
864
+ message: error.message,
865
+ responseData: error.response?.data,
866
+ };
867
+ }
868
+ else {
869
+ this.error = error;
870
+ }
871
+ return this;
872
+ }
873
+ switch (status) {
874
+ case "fail":
875
+ this.failedAt = new Date();
876
+ this.onGoing = false;
877
+ break;
878
+ case "processing":
879
+ this.processedAt = new Date();
880
+ this.onGoing = true;
881
+ break;
882
+ case "queued":
883
+ this.queuedAt = new Date();
884
+ this.onGoing = true;
885
+ break;
886
+ case "received":
887
+ this.receivedAt = new Date();
888
+ this.onGoing = true;
889
+ break;
890
+ case "skipped":
891
+ this.skippedAt = new Date();
892
+ this.onGoing = false;
893
+ break;
894
+ case "success":
895
+ this.succeededAt = new Date();
896
+ this.onGoing = false;
897
+ break;
898
+ }
899
+ return this;
900
+ }
901
+ setBody(body) {
902
+ this.body = body;
903
+ return this;
904
+ }
905
+ setMeta(meta) {
906
+ this.meta = meta;
907
+ return this;
908
+ }
909
+ async commit() {
910
+ let doc = {
911
+ available_app_name: this.available_app_name,
912
+ available_app_id: this.available_app_id,
913
+ app_id: this.app_id,
914
+ command: this.command,
915
+ status: this.status,
916
+ error: this.error ? this.error : undefined,
917
+ start_time: this.start_time,
918
+ end_time: Date.now(),
919
+ total_time: Date.now() - this.start_time,
920
+ company_namespace: this.company_namespace,
921
+ body: this.body,
922
+ meta: this.meta,
923
+ message: this.message,
924
+ details: this.details,
925
+ sync_id: this.sync_id,
926
+ // priority: this.priority ? this.priority : undefined,
927
+ queuedAt: this.queuedAt ? this.queuedAt : undefined,
928
+ failedAt: this.failedAt ? this.failedAt : undefined,
929
+ succeededAt: this.succeededAt ? this.succeededAt : undefined,
930
+ skippedAt: this.skippedAt ? this.skippedAt : undefined,
931
+ receivedAt: this.receivedAt ? this.receivedAt : undefined,
932
+ processedAt: this.processedAt ? this.processedAt : undefined,
933
+ onGoing: this.onGoing !== undefined ? this.onGoing : undefined,
934
+ retries: this.retries !== undefined ? this.retries : undefined,
935
+ trigger: this.trigger,
936
+ };
937
+ try {
938
+ const res = await this.superThis._create(this.superThis.svAPIEndpoint, this._path, doc);
939
+ this.isOld = true;
940
+ }
941
+ catch (e) {
942
+ console.error(e);
943
+ }
944
+ return this;
945
+ }
946
+ addDetail(detail, meta) {
947
+ let d = {
948
+ timestamp: Date.now(),
949
+ content: detail,
950
+ };
951
+ this.message = detail;
952
+ if (meta)
953
+ d.meta = meta;
954
+ this.details.push(d);
955
+ return this;
1426
956
  }
1427
- return this;
1428
- }
1429
- addDetail(detail, meta) {
1430
- let d = {
1431
- timestamp: Date.now(),
1432
- content: detail,
1433
- };
1434
- this.message = detail;
1435
- if (meta) d.meta = meta;
1436
- this.details.push(d);
1437
- return this;
1438
- }
1439
957
  };