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