repzo 1.0.44 → 1.0.45
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 +349 -705
- package/lib/index.js +1022 -1589
- package/lib/types/index.d.ts +5215 -5575
- package/package.json +1 -1
- package/src/types/index.ts +2 -1
package/lib/index.js
CHANGED
|
@@ -1,1604 +1,1037 @@
|
|
|
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
|
-
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.speciality = {
|
|
697
|
-
_path: "/speciality",
|
|
698
|
-
find: async (params) => {
|
|
699
|
-
let res = await this._fetch(
|
|
700
|
-
this.svAPIEndpoint,
|
|
701
|
-
this.speciality._path,
|
|
702
|
-
params
|
|
703
|
-
);
|
|
704
|
-
return res;
|
|
705
|
-
},
|
|
706
|
-
get: async (id) => {
|
|
707
|
-
return await this._fetch(
|
|
708
|
-
this.svAPIEndpoint,
|
|
709
|
-
this.speciality._path + `/${id}`
|
|
710
|
-
);
|
|
711
|
-
},
|
|
712
|
-
create: async (body) => {
|
|
713
|
-
let res = await this._create(
|
|
714
|
-
this.svAPIEndpoint,
|
|
715
|
-
this.speciality._path,
|
|
716
|
-
body
|
|
717
|
-
);
|
|
718
|
-
return res;
|
|
719
|
-
},
|
|
720
|
-
update: async (id, body) => {
|
|
721
|
-
let res = await this._update(
|
|
722
|
-
this.svAPIEndpoint,
|
|
723
|
-
this.speciality._path + `/${id}`,
|
|
724
|
-
body
|
|
725
|
-
);
|
|
726
|
-
return res;
|
|
727
|
-
},
|
|
728
|
-
remove: async (id) => {
|
|
729
|
-
let res = await this._delete(
|
|
730
|
-
this.svAPIEndpoint,
|
|
731
|
-
this.speciality._path + `/${id}`
|
|
732
|
-
);
|
|
733
|
-
return res;
|
|
734
|
-
},
|
|
735
|
-
};
|
|
736
|
-
this.clientContact = {
|
|
737
|
-
_path: "/client-contact",
|
|
738
|
-
find: async (params) => {
|
|
739
|
-
let res = await this._fetch(
|
|
740
|
-
this.svAPIEndpoint,
|
|
741
|
-
this.clientContact._path,
|
|
742
|
-
params
|
|
743
|
-
);
|
|
744
|
-
return res;
|
|
745
|
-
},
|
|
746
|
-
get: async (id) => {
|
|
747
|
-
return await this._fetch(
|
|
748
|
-
this.svAPIEndpoint,
|
|
749
|
-
this.clientContact._path + `/${id}`
|
|
750
|
-
);
|
|
751
|
-
},
|
|
752
|
-
create: async (body) => {
|
|
753
|
-
let res = await this._create(
|
|
754
|
-
this.svAPIEndpoint,
|
|
755
|
-
this.clientContact._path,
|
|
756
|
-
body
|
|
757
|
-
);
|
|
758
|
-
return res;
|
|
759
|
-
},
|
|
760
|
-
update: async (id, body) => {
|
|
761
|
-
let res = await this._update(
|
|
762
|
-
this.svAPIEndpoint,
|
|
763
|
-
this.clientContact._path + `/${id}`,
|
|
764
|
-
body
|
|
765
|
-
);
|
|
766
|
-
return res;
|
|
767
|
-
},
|
|
768
|
-
remove: async (id) => {
|
|
769
|
-
let res = await this._delete(
|
|
770
|
-
this.svAPIEndpoint,
|
|
771
|
-
this.clientContact._path + `/${id}`
|
|
772
|
-
);
|
|
773
|
-
return res;
|
|
774
|
-
},
|
|
775
|
-
};
|
|
776
|
-
this.paymentTerm = {
|
|
777
|
-
_path: "/paymentterms",
|
|
778
|
-
find: async (params) => {
|
|
779
|
-
let res = await this._fetch(
|
|
780
|
-
this.svAPIEndpoint,
|
|
781
|
-
this.paymentTerm._path,
|
|
782
|
-
params
|
|
783
|
-
);
|
|
784
|
-
return res;
|
|
785
|
-
},
|
|
786
|
-
get: async (id) => {
|
|
787
|
-
return await this._fetch(
|
|
788
|
-
this.svAPIEndpoint,
|
|
789
|
-
this.paymentTerm._path + `/${id}`
|
|
790
|
-
);
|
|
791
|
-
},
|
|
792
|
-
create: async (body) => {
|
|
793
|
-
let res = await this._create(
|
|
794
|
-
this.svAPIEndpoint,
|
|
795
|
-
this.paymentTerm._path,
|
|
796
|
-
body
|
|
797
|
-
);
|
|
798
|
-
return res;
|
|
799
|
-
},
|
|
800
|
-
update: async (id, body) => {
|
|
801
|
-
let res = await this._update(
|
|
802
|
-
this.svAPIEndpoint,
|
|
803
|
-
this.paymentTerm._path + `/${id}`,
|
|
804
|
-
body
|
|
805
|
-
);
|
|
806
|
-
return res;
|
|
807
|
-
},
|
|
808
|
-
remove: async (id) => {
|
|
809
|
-
let res = await this._delete(
|
|
810
|
-
this.svAPIEndpoint,
|
|
811
|
-
this.paymentTerm._path + `/${id}`
|
|
812
|
-
);
|
|
813
|
-
return res;
|
|
814
|
-
},
|
|
815
|
-
};
|
|
816
|
-
this.bank = {
|
|
817
|
-
_path: "/banks",
|
|
818
|
-
find: async (params) => {
|
|
819
|
-
let res = await this._fetch(
|
|
820
|
-
this.svAPIEndpoint,
|
|
821
|
-
this.bank._path,
|
|
822
|
-
params
|
|
823
|
-
);
|
|
824
|
-
return res;
|
|
825
|
-
},
|
|
826
|
-
get: async (id) => {
|
|
827
|
-
return await this._fetch(
|
|
828
|
-
this.svAPIEndpoint,
|
|
829
|
-
this.bank._path + `/${id}`
|
|
830
|
-
);
|
|
831
|
-
},
|
|
832
|
-
create: async (body) => {
|
|
833
|
-
let res = await this._create(this.svAPIEndpoint, this.bank._path, body);
|
|
834
|
-
return res;
|
|
835
|
-
},
|
|
836
|
-
update: async (id, body) => {
|
|
837
|
-
let res = await this._update(
|
|
838
|
-
this.svAPIEndpoint,
|
|
839
|
-
this.bank._path + `/${id}`,
|
|
840
|
-
body
|
|
841
|
-
);
|
|
842
|
-
return res;
|
|
843
|
-
},
|
|
844
|
-
};
|
|
845
|
-
this.bank_list = {
|
|
846
|
-
_path: "/bankslists",
|
|
847
|
-
find: async (params) => {
|
|
848
|
-
let res = await this._fetch(
|
|
849
|
-
this.svAPIEndpoint,
|
|
850
|
-
this.bank_list._path,
|
|
851
|
-
params
|
|
852
|
-
);
|
|
853
|
-
return res;
|
|
854
|
-
},
|
|
855
|
-
get: async (id) => {
|
|
856
|
-
return await this._fetch(
|
|
857
|
-
this.svAPIEndpoint,
|
|
858
|
-
this.bank_list._path + `/${id}`
|
|
859
|
-
);
|
|
860
|
-
},
|
|
861
|
-
create: async (body) => {
|
|
862
|
-
let res = await this._create(
|
|
863
|
-
this.svAPIEndpoint,
|
|
864
|
-
this.bank_list._path,
|
|
865
|
-
body
|
|
866
|
-
);
|
|
867
|
-
return res;
|
|
868
|
-
},
|
|
869
|
-
update: async (id, body) => {
|
|
870
|
-
let res = await this._update(
|
|
871
|
-
this.svAPIEndpoint,
|
|
872
|
-
this.bank_list._path + `/${id}`,
|
|
873
|
-
body
|
|
874
|
-
);
|
|
875
|
-
return res;
|
|
876
|
-
},
|
|
877
|
-
};
|
|
878
|
-
this.customStatus = {
|
|
879
|
-
_path: "/custom-status",
|
|
880
|
-
find: async (params) => {
|
|
881
|
-
let res = await this._fetch(
|
|
882
|
-
this.svAPIEndpoint,
|
|
883
|
-
this.customStatus._path,
|
|
884
|
-
params
|
|
885
|
-
);
|
|
886
|
-
return res;
|
|
887
|
-
},
|
|
888
|
-
get: async (id) => {
|
|
889
|
-
return await this._fetch(
|
|
890
|
-
this.svAPIEndpoint,
|
|
891
|
-
this.customStatus._path + `/${id}`
|
|
892
|
-
);
|
|
893
|
-
},
|
|
894
|
-
create: async (body) => {
|
|
895
|
-
let res = await this._create(
|
|
896
|
-
this.svAPIEndpoint,
|
|
897
|
-
this.customStatus._path,
|
|
898
|
-
body
|
|
899
|
-
);
|
|
900
|
-
return res;
|
|
901
|
-
},
|
|
902
|
-
update: async (id, body) => {
|
|
903
|
-
let res = await this._update(
|
|
904
|
-
this.svAPIEndpoint,
|
|
905
|
-
this.customStatus._path + `/${id}`,
|
|
906
|
-
body
|
|
907
|
-
);
|
|
908
|
-
return res;
|
|
909
|
-
},
|
|
910
|
-
remove: async (id) => {
|
|
911
|
-
let res = await this._delete(
|
|
912
|
-
this.svAPIEndpoint,
|
|
913
|
-
this.customStatus._path + `/${id}`
|
|
914
|
-
);
|
|
915
|
-
return res;
|
|
916
|
-
},
|
|
917
|
-
};
|
|
918
|
-
this.workorder = {
|
|
919
|
-
_path: "/workorder",
|
|
920
|
-
find: async (params) => {
|
|
921
|
-
let res = await this._fetch(
|
|
922
|
-
this.svAPIEndpoint,
|
|
923
|
-
this.workorder._path,
|
|
924
|
-
params
|
|
925
|
-
);
|
|
926
|
-
return res;
|
|
927
|
-
},
|
|
928
|
-
get: async (id, params) => {
|
|
929
|
-
return await this._fetch(
|
|
930
|
-
this.svAPIEndpoint,
|
|
931
|
-
this.workorder._path + `/${id}`,
|
|
932
|
-
params
|
|
933
|
-
);
|
|
934
|
-
},
|
|
935
|
-
};
|
|
936
|
-
this.quickConvertToPdf = {
|
|
937
|
-
_path: "/quick-convert-to-pdf",
|
|
938
|
-
find: async (params) => {
|
|
939
|
-
let res = await this._fetch(
|
|
940
|
-
this.svAPIEndpoint,
|
|
941
|
-
this.quickConvertToPdf._path,
|
|
942
|
-
params
|
|
943
|
-
);
|
|
944
|
-
return res;
|
|
945
|
-
},
|
|
946
|
-
get: async (id, params) => {
|
|
947
|
-
return await this._fetch(
|
|
948
|
-
this.svAPIEndpoint,
|
|
949
|
-
this.quickConvertToPdf._path + `/${id}`,
|
|
950
|
-
params
|
|
951
|
-
);
|
|
952
|
-
},
|
|
953
|
-
create: async (body) => {
|
|
954
|
-
let res = await this._create(
|
|
955
|
-
this.svAPIEndpoint,
|
|
956
|
-
this.quickConvertToPdf._path,
|
|
957
|
-
body
|
|
958
|
-
);
|
|
959
|
-
return res;
|
|
960
|
-
},
|
|
961
|
-
remove: async (id) => {
|
|
962
|
-
let res = await this._delete(
|
|
963
|
-
this.svAPIEndpoint,
|
|
964
|
-
this.quickConvertToPdf._path + `/${id}`
|
|
965
|
-
);
|
|
966
|
-
return res;
|
|
967
|
-
},
|
|
968
|
-
};
|
|
969
|
-
this.visit = {
|
|
970
|
-
_path: "/visit",
|
|
971
|
-
find: async (params) => {
|
|
972
|
-
let res = await this._fetch(
|
|
973
|
-
this.svAPIEndpoint,
|
|
974
|
-
this.visit._path,
|
|
975
|
-
params
|
|
976
|
-
);
|
|
977
|
-
return res;
|
|
978
|
-
},
|
|
979
|
-
get: async (id, params) => {
|
|
980
|
-
return await this._fetch(
|
|
981
|
-
this.svAPIEndpoint,
|
|
982
|
-
this.visit._path + `/${id}`,
|
|
983
|
-
params
|
|
984
|
-
);
|
|
985
|
-
},
|
|
986
|
-
create: async (body) => {
|
|
987
|
-
let res = await this._create(
|
|
988
|
-
this.svAPIEndpoint,
|
|
989
|
-
this.visit._path,
|
|
990
|
-
body
|
|
991
|
-
);
|
|
992
|
-
return res;
|
|
993
|
-
},
|
|
994
|
-
update: async (id, body) => {
|
|
995
|
-
let res = await this._update(
|
|
996
|
-
this.svAPIEndpoint,
|
|
997
|
-
this.visit._path + `/${id}`,
|
|
998
|
-
body
|
|
999
|
-
);
|
|
1000
|
-
return res;
|
|
1001
|
-
},
|
|
1002
|
-
};
|
|
1003
|
-
this.invoice = {
|
|
1004
|
-
_path: "/fullinvoices",
|
|
1005
|
-
find: async (params) => {
|
|
1006
|
-
let res = await this._fetch(
|
|
1007
|
-
this.svAPIEndpoint,
|
|
1008
|
-
this.invoice._path,
|
|
1009
|
-
params
|
|
1010
|
-
);
|
|
1011
|
-
return res;
|
|
1012
|
-
},
|
|
1013
|
-
get: async (id, params) => {
|
|
1014
|
-
return await this._fetch(
|
|
1015
|
-
this.svAPIEndpoint,
|
|
1016
|
-
this.invoice._path + `/${id}`,
|
|
1017
|
-
params
|
|
1018
|
-
);
|
|
1019
|
-
},
|
|
1020
|
-
create: async (body) => {
|
|
1021
|
-
let res = await this._create(
|
|
1022
|
-
this.svAPIEndpoint,
|
|
1023
|
-
this.invoice._path,
|
|
1024
|
-
body
|
|
1025
|
-
);
|
|
1026
|
-
return res;
|
|
1027
|
-
},
|
|
1028
|
-
update: async (id, body) => {
|
|
1029
|
-
let res = await this._update(
|
|
1030
|
-
this.svAPIEndpoint,
|
|
1031
|
-
this.invoice._path + `/${id}`,
|
|
1032
|
-
body
|
|
1033
|
-
);
|
|
1034
|
-
return res;
|
|
1035
|
-
},
|
|
1036
|
-
};
|
|
1037
|
-
this.proforma = {
|
|
1038
|
-
_path: "/proforma",
|
|
1039
|
-
find: async (params) => {
|
|
1040
|
-
let res = await this._fetch(
|
|
1041
|
-
this.svAPIEndpoint,
|
|
1042
|
-
this.proforma._path,
|
|
1043
|
-
params
|
|
1044
|
-
);
|
|
1045
|
-
return res;
|
|
1046
|
-
},
|
|
1047
|
-
get: async (id, params) => {
|
|
1048
|
-
return await this._fetch(
|
|
1049
|
-
this.svAPIEndpoint,
|
|
1050
|
-
this.proforma._path + `/${id}`,
|
|
1051
|
-
params
|
|
1052
|
-
);
|
|
1053
|
-
},
|
|
1054
|
-
create: async (body) => {
|
|
1055
|
-
let res = await this._create(
|
|
1056
|
-
this.svAPIEndpoint,
|
|
1057
|
-
this.proforma._path,
|
|
1058
|
-
body
|
|
1059
|
-
);
|
|
1060
|
-
return res;
|
|
1061
|
-
},
|
|
1062
|
-
update: async (id, body) => {
|
|
1063
|
-
let res = await this._update(
|
|
1064
|
-
this.svAPIEndpoint,
|
|
1065
|
-
this.proforma._path + `/${id}`,
|
|
1066
|
-
body
|
|
1067
|
-
);
|
|
1068
|
-
return res;
|
|
1069
|
-
},
|
|
1070
|
-
};
|
|
1071
|
-
this.payment = {
|
|
1072
|
-
_path: "/payments",
|
|
1073
|
-
find: async (params) => {
|
|
1074
|
-
let res = await this._fetch(
|
|
1075
|
-
this.svAPIEndpoint,
|
|
1076
|
-
this.payment._path,
|
|
1077
|
-
params
|
|
1078
|
-
);
|
|
1079
|
-
return res;
|
|
1080
|
-
},
|
|
1081
|
-
get: async (id, params) => {
|
|
1082
|
-
return await this._fetch(
|
|
1083
|
-
this.svAPIEndpoint,
|
|
1084
|
-
this.payment._path + `/${id}`,
|
|
1085
|
-
params
|
|
1086
|
-
);
|
|
1087
|
-
},
|
|
1088
|
-
create: async (body) => {
|
|
1089
|
-
let res = await this._create(
|
|
1090
|
-
this.svAPIEndpoint,
|
|
1091
|
-
this.payment._path,
|
|
1092
|
-
body
|
|
1093
|
-
);
|
|
1094
|
-
return res;
|
|
1095
|
-
},
|
|
1096
|
-
update: async (id, body) => {
|
|
1097
|
-
let res = await this._update(
|
|
1098
|
-
this.svAPIEndpoint,
|
|
1099
|
-
this.payment._path + `/${id}`,
|
|
1100
|
-
body
|
|
1101
|
-
);
|
|
1102
|
-
return res;
|
|
1103
|
-
},
|
|
1104
|
-
};
|
|
1105
|
-
this.refund = {
|
|
1106
|
-
_path: "/refund",
|
|
1107
|
-
find: async (params) => {
|
|
1108
|
-
let res = await this._fetch(
|
|
1109
|
-
this.svAPIEndpoint,
|
|
1110
|
-
this.refund._path,
|
|
1111
|
-
params
|
|
1112
|
-
);
|
|
1113
|
-
return res;
|
|
1114
|
-
},
|
|
1115
|
-
get: async (id, params) => {
|
|
1116
|
-
return await this._fetch(
|
|
1117
|
-
this.svAPIEndpoint,
|
|
1118
|
-
this.refund._path + `/${id}`,
|
|
1119
|
-
params
|
|
1120
|
-
);
|
|
1121
|
-
},
|
|
1122
|
-
create: async (body) => {
|
|
1123
|
-
let res = await this._create(
|
|
1124
|
-
this.svAPIEndpoint,
|
|
1125
|
-
this.refund._path,
|
|
1126
|
-
body
|
|
1127
|
-
);
|
|
1128
|
-
return res;
|
|
1129
|
-
},
|
|
1130
|
-
update: async (id, body) => {
|
|
1131
|
-
let res = await this._update(
|
|
1132
|
-
this.svAPIEndpoint,
|
|
1133
|
-
this.refund._path + `/${id}`,
|
|
1134
|
-
body
|
|
1135
|
-
);
|
|
1136
|
-
return res;
|
|
1137
|
-
},
|
|
1138
|
-
};
|
|
1139
|
-
this.transfer = {
|
|
1140
|
-
_path: "/transfer",
|
|
1141
|
-
find: async (params) => {
|
|
1142
|
-
let res = await this._fetch(
|
|
1143
|
-
this.svAPIEndpoint,
|
|
1144
|
-
this.transfer._path,
|
|
1145
|
-
params
|
|
1146
|
-
);
|
|
1147
|
-
return res;
|
|
1148
|
-
},
|
|
1149
|
-
get: async (id, params) => {
|
|
1150
|
-
return await this._fetch(
|
|
1151
|
-
this.svAPIEndpoint,
|
|
1152
|
-
this.transfer._path + `/${id}`,
|
|
1153
|
-
params
|
|
1154
|
-
);
|
|
1155
|
-
},
|
|
1156
|
-
create: async (body) => {
|
|
1157
|
-
let res = await this._create(
|
|
1158
|
-
this.svAPIEndpoint,
|
|
1159
|
-
this.transfer._path,
|
|
1160
|
-
body
|
|
1161
|
-
);
|
|
1162
|
-
return res;
|
|
1163
|
-
},
|
|
1164
|
-
update: async (id, body) => {
|
|
1165
|
-
let res = await this._update(
|
|
1166
|
-
this.svAPIEndpoint,
|
|
1167
|
-
this.transfer._path + `/${id}`,
|
|
1168
|
-
body
|
|
1169
|
-
);
|
|
1170
|
-
return res;
|
|
1171
|
-
},
|
|
1172
|
-
};
|
|
1173
|
-
this.adjustInventory = {
|
|
1174
|
-
_path: "/adjust-inventory",
|
|
1175
|
-
find: async (params) => {
|
|
1176
|
-
let res = await this._fetch(
|
|
1177
|
-
this.svAPIEndpoint,
|
|
1178
|
-
this.adjustInventory._path,
|
|
1179
|
-
params
|
|
1180
|
-
);
|
|
1181
|
-
return res;
|
|
1182
|
-
},
|
|
1183
|
-
get: async (id, params) => {
|
|
1184
|
-
return await this._fetch(
|
|
1185
|
-
this.svAPIEndpoint,
|
|
1186
|
-
this.adjustInventory._path + `/${id}`,
|
|
1187
|
-
params
|
|
1188
|
-
);
|
|
1189
|
-
},
|
|
1190
|
-
create: async (body) => {
|
|
1191
|
-
let res = await this._create(
|
|
1192
|
-
this.svAPIEndpoint,
|
|
1193
|
-
this.adjustInventory._path,
|
|
1194
|
-
body
|
|
1195
|
-
);
|
|
1196
|
-
return res;
|
|
1197
|
-
},
|
|
1198
|
-
};
|
|
1199
|
-
this.inventory = {
|
|
1200
|
-
_path: "/inventory",
|
|
1201
|
-
find: async (params) => {
|
|
1202
|
-
let res = await this._fetch(
|
|
1203
|
-
this.svAPIEndpoint,
|
|
1204
|
-
this.inventory._path,
|
|
1205
|
-
params
|
|
1206
|
-
);
|
|
1207
|
-
return res;
|
|
1208
|
-
},
|
|
1209
|
-
};
|
|
1210
|
-
this.integrationApp = {
|
|
1211
|
-
_path: "/integration-app",
|
|
1212
|
-
find: async (params) => {
|
|
1213
|
-
let res = await this._fetch(
|
|
1214
|
-
this.svAPIEndpoint,
|
|
1215
|
-
this.integrationApp._path,
|
|
1216
|
-
params
|
|
1217
|
-
);
|
|
1218
|
-
return res;
|
|
1219
|
-
},
|
|
1220
|
-
get: async (id, params) => {
|
|
1221
|
-
return await this._fetch(
|
|
1222
|
-
this.svAPIEndpoint,
|
|
1223
|
-
this.integrationApp._path + `/${id}`,
|
|
1224
|
-
params
|
|
1225
|
-
);
|
|
1226
|
-
},
|
|
1227
|
-
create: async (body) => {
|
|
1228
|
-
let res = await this._create(
|
|
1229
|
-
this.svAPIEndpoint,
|
|
1230
|
-
this.integrationApp._path,
|
|
1231
|
-
body
|
|
1232
|
-
);
|
|
1233
|
-
return res;
|
|
1234
|
-
},
|
|
1235
|
-
update: async (id, body) => {
|
|
1236
|
-
let res = await this._update(
|
|
1237
|
-
this.svAPIEndpoint,
|
|
1238
|
-
this.integrationApp._path + `/${id}`,
|
|
1239
|
-
body
|
|
1240
|
-
);
|
|
1241
|
-
return res;
|
|
1242
|
-
},
|
|
1243
|
-
};
|
|
1244
|
-
this.joinActionsWebHook = {
|
|
1245
|
-
_path: "/svix-integration",
|
|
1246
|
-
update: async (id, body) => {
|
|
1247
|
-
let res = await this._update(
|
|
1248
|
-
this.svAPIEndpoint,
|
|
1249
|
-
this.joinActionsWebHook._path,
|
|
1250
|
-
body
|
|
1251
|
-
);
|
|
1252
|
-
return res;
|
|
1253
|
-
},
|
|
1254
|
-
};
|
|
1255
|
-
this.patchAction = {
|
|
1256
|
-
_path: "/patch-action",
|
|
1257
|
-
create: async (body, params) => {
|
|
1258
|
-
const res = await this._create(
|
|
1259
|
-
this.svAPIEndpoint,
|
|
1260
|
-
this.patchAction._path,
|
|
1261
|
-
body,
|
|
1262
|
-
params
|
|
1263
|
-
);
|
|
1264
|
-
return res;
|
|
1265
|
-
},
|
|
1266
|
-
update: async (body) => {
|
|
1267
|
-
const res = await this._update(
|
|
1268
|
-
this.svAPIEndpoint,
|
|
1269
|
-
this.patchAction._path,
|
|
1270
|
-
body
|
|
1271
|
-
);
|
|
1272
|
-
return res;
|
|
1273
|
-
},
|
|
1274
|
-
};
|
|
1275
|
-
this.updateIntegrationMeta = {
|
|
1276
|
-
_path: "/update-integration-meta",
|
|
1277
|
-
create: async (body, params) => {
|
|
1278
|
-
let res = await this._create(
|
|
1279
|
-
this.svAPIEndpoint,
|
|
1280
|
-
this.updateIntegrationMeta._path,
|
|
1281
|
-
body,
|
|
1282
|
-
params
|
|
1283
|
-
);
|
|
1284
|
-
return res;
|
|
1285
|
-
},
|
|
1286
|
-
};
|
|
1287
|
-
this.svAPIEndpoint =
|
|
1288
|
-
!options?.env || options?.env == "production"
|
|
1289
|
-
? "https://sv.api.repzo.me"
|
|
1290
|
-
: options?.env == "staging"
|
|
1291
|
-
? "https://staging.sv.api.repzo.me"
|
|
1292
|
-
: options?.env == "local"
|
|
1293
|
-
? "http://localhost:3030"
|
|
1294
|
-
: "";
|
|
1295
|
-
this.headers = {
|
|
1296
|
-
"api-key": apiKey,
|
|
1297
|
-
"Content-Type": "application/json",
|
|
1298
|
-
Accept: "application/json",
|
|
1299
|
-
};
|
|
1300
|
-
if (options?.headers) Object.assign(this.headers, options.headers);
|
|
1301
|
-
}
|
|
1302
|
-
async _fetch(baseUrl, path, params) {
|
|
1303
|
-
let res = await axios.get(baseUrl + path, {
|
|
1304
|
-
params,
|
|
1305
|
-
headers: this.headers,
|
|
1306
|
-
});
|
|
1307
|
-
return res.data;
|
|
1308
|
-
}
|
|
1309
|
-
async _create(baseUrl, path, body, params) {
|
|
1310
|
-
let res = await axios.post(baseUrl + path, body, {
|
|
1311
|
-
params,
|
|
1312
|
-
headers: this.headers,
|
|
1313
|
-
});
|
|
1314
|
-
return res.data;
|
|
1315
|
-
}
|
|
1316
|
-
async _update(baseUrl, path, body, params) {
|
|
1317
|
-
let res = await axios.put(baseUrl + path, body, {
|
|
1318
|
-
params,
|
|
1319
|
-
headers: this.headers,
|
|
1320
|
-
});
|
|
1321
|
-
return res.data;
|
|
1322
|
-
}
|
|
1323
|
-
async _delete(baseUrl, path, params) {
|
|
1324
|
-
let res = await axios.delete(baseUrl + path, {
|
|
1325
|
-
params,
|
|
1326
|
-
headers: this.headers,
|
|
1327
|
-
});
|
|
1328
|
-
return res.data;
|
|
1329
|
-
}
|
|
1330
|
-
}
|
|
1331
|
-
Repzo.ActionLogs = class {
|
|
1332
|
-
constructor(superThis, sync_id) {
|
|
1333
|
-
this.superThis = superThis;
|
|
1334
|
-
this._path = "/integration-action-log";
|
|
1335
|
-
this.available_app_name = "";
|
|
1336
|
-
this.available_app_id = "";
|
|
1337
|
-
this.app_id = "";
|
|
1338
|
-
this.action = "";
|
|
1339
|
-
this.start_time = Date.now();
|
|
1340
|
-
this.status = "processing";
|
|
1341
|
-
this.message = "Log Created";
|
|
1342
|
-
this.details = [];
|
|
1343
|
-
this.sync_id = sync_id;
|
|
1344
|
-
this.isOld = true;
|
|
1345
|
-
}
|
|
1346
|
-
async load(sync_id) {
|
|
1347
|
-
const params = { sync_id: sync_id };
|
|
1348
|
-
const res = await this.superThis._fetch(
|
|
1349
|
-
this.superThis.svAPIEndpoint,
|
|
1350
|
-
this._path,
|
|
1351
|
-
params
|
|
1352
|
-
);
|
|
1353
|
-
if (!res?.data?.length)
|
|
1354
|
-
throw new Error(`Action Log Not found, sync_id: ${sync_id}`);
|
|
1355
|
-
const action_log = res.data[0];
|
|
1356
|
-
this.sync_id = sync_id;
|
|
1357
|
-
this.details = action_log.details;
|
|
1358
|
-
this.status = action_log.status;
|
|
1359
|
-
this.error = action_log.error;
|
|
1360
|
-
this.start_time = action_log.start_time;
|
|
1361
|
-
this.body = action_log.body;
|
|
1362
|
-
this.meta = action_log.meta;
|
|
1363
|
-
this.message = action_log.message;
|
|
1364
|
-
this.app_id = action_log.app_id;
|
|
1365
|
-
this.available_app_id = action_log.available_app_id;
|
|
1366
|
-
this.available_app_name = action_log.available_app_name;
|
|
1367
|
-
this.company_namespace = action_log.company_namespace;
|
|
1368
|
-
this.action = action_log.action;
|
|
1369
|
-
this.isOld = true;
|
|
1370
|
-
return this;
|
|
1371
|
-
}
|
|
1372
|
-
setStatus(status, error) {
|
|
1373
|
-
this.details.push({
|
|
1374
|
-
timestamp: Date.now(),
|
|
1375
|
-
content: `status was changed from ${this.status} to ${status}`,
|
|
1376
|
-
});
|
|
1377
|
-
this.status = status;
|
|
1378
|
-
if (error) {
|
|
1379
|
-
if (typeof error == "string") {
|
|
1380
|
-
this.error = { message: error };
|
|
1381
|
-
} else if (error.message || error.response?.data) {
|
|
1382
|
-
this.error = {
|
|
1383
|
-
// json: error.toJSON ? error.toJSON() : undefined,
|
|
1384
|
-
message: error.message,
|
|
1385
|
-
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.speciality = {
|
|
402
|
+
_path: "/speciality",
|
|
403
|
+
find: async (params) => {
|
|
404
|
+
let res = await this._fetch(this.svAPIEndpoint, this.speciality._path, params);
|
|
405
|
+
return res;
|
|
406
|
+
},
|
|
407
|
+
get: async (id) => {
|
|
408
|
+
return await this._fetch(this.svAPIEndpoint, this.speciality._path + `/${id}`);
|
|
409
|
+
},
|
|
410
|
+
create: async (body) => {
|
|
411
|
+
let res = await this._create(this.svAPIEndpoint, this.speciality._path, body);
|
|
412
|
+
return res;
|
|
413
|
+
},
|
|
414
|
+
update: async (id, body) => {
|
|
415
|
+
let res = await this._update(this.svAPIEndpoint, this.speciality._path + `/${id}`, body);
|
|
416
|
+
return res;
|
|
417
|
+
},
|
|
418
|
+
remove: async (id) => {
|
|
419
|
+
let res = await this._delete(this.svAPIEndpoint, this.speciality._path + `/${id}`);
|
|
420
|
+
return res;
|
|
421
|
+
},
|
|
422
|
+
};
|
|
423
|
+
this.clientContact = {
|
|
424
|
+
_path: "/client-contact",
|
|
425
|
+
find: async (params) => {
|
|
426
|
+
let res = await this._fetch(this.svAPIEndpoint, this.clientContact._path, params);
|
|
427
|
+
return res;
|
|
428
|
+
},
|
|
429
|
+
get: async (id) => {
|
|
430
|
+
return await this._fetch(this.svAPIEndpoint, this.clientContact._path + `/${id}`);
|
|
431
|
+
},
|
|
432
|
+
create: async (body) => {
|
|
433
|
+
let res = await this._create(this.svAPIEndpoint, this.clientContact._path, body);
|
|
434
|
+
return res;
|
|
435
|
+
},
|
|
436
|
+
update: async (id, body) => {
|
|
437
|
+
let res = await this._update(this.svAPIEndpoint, this.clientContact._path + `/${id}`, body);
|
|
438
|
+
return res;
|
|
439
|
+
},
|
|
440
|
+
remove: async (id) => {
|
|
441
|
+
let res = await this._delete(this.svAPIEndpoint, this.clientContact._path + `/${id}`);
|
|
442
|
+
return res;
|
|
443
|
+
},
|
|
444
|
+
};
|
|
445
|
+
this.paymentTerm = {
|
|
446
|
+
_path: "/paymentterms",
|
|
447
|
+
find: async (params) => {
|
|
448
|
+
let res = await this._fetch(this.svAPIEndpoint, this.paymentTerm._path, params);
|
|
449
|
+
return res;
|
|
450
|
+
},
|
|
451
|
+
get: async (id) => {
|
|
452
|
+
return await this._fetch(this.svAPIEndpoint, this.paymentTerm._path + `/${id}`);
|
|
453
|
+
},
|
|
454
|
+
create: async (body) => {
|
|
455
|
+
let res = await this._create(this.svAPIEndpoint, this.paymentTerm._path, body);
|
|
456
|
+
return res;
|
|
457
|
+
},
|
|
458
|
+
update: async (id, body) => {
|
|
459
|
+
let res = await this._update(this.svAPIEndpoint, this.paymentTerm._path + `/${id}`, body);
|
|
460
|
+
return res;
|
|
461
|
+
},
|
|
462
|
+
remove: async (id) => {
|
|
463
|
+
let res = await this._delete(this.svAPIEndpoint, this.paymentTerm._path + `/${id}`);
|
|
464
|
+
return res;
|
|
465
|
+
},
|
|
466
|
+
};
|
|
467
|
+
this.bank = {
|
|
468
|
+
_path: "/banks",
|
|
469
|
+
find: async (params) => {
|
|
470
|
+
let res = await this._fetch(this.svAPIEndpoint, this.bank._path, params);
|
|
471
|
+
return res;
|
|
472
|
+
},
|
|
473
|
+
get: async (id) => {
|
|
474
|
+
return await this._fetch(this.svAPIEndpoint, this.bank._path + `/${id}`);
|
|
475
|
+
},
|
|
476
|
+
create: async (body) => {
|
|
477
|
+
let res = await this._create(this.svAPIEndpoint, this.bank._path, body);
|
|
478
|
+
return res;
|
|
479
|
+
},
|
|
480
|
+
update: async (id, body) => {
|
|
481
|
+
let res = await this._update(this.svAPIEndpoint, this.bank._path + `/${id}`, body);
|
|
482
|
+
return res;
|
|
483
|
+
},
|
|
484
|
+
};
|
|
485
|
+
this.bank_list = {
|
|
486
|
+
_path: "/bankslists",
|
|
487
|
+
find: async (params) => {
|
|
488
|
+
let res = await this._fetch(this.svAPIEndpoint, this.bank_list._path, params);
|
|
489
|
+
return res;
|
|
490
|
+
},
|
|
491
|
+
get: async (id) => {
|
|
492
|
+
return await this._fetch(this.svAPIEndpoint, this.bank_list._path + `/${id}`);
|
|
493
|
+
},
|
|
494
|
+
create: async (body) => {
|
|
495
|
+
let res = await this._create(this.svAPIEndpoint, this.bank_list._path, body);
|
|
496
|
+
return res;
|
|
497
|
+
},
|
|
498
|
+
update: async (id, body) => {
|
|
499
|
+
let res = await this._update(this.svAPIEndpoint, this.bank_list._path + `/${id}`, body);
|
|
500
|
+
return res;
|
|
501
|
+
},
|
|
502
|
+
};
|
|
503
|
+
this.customStatus = {
|
|
504
|
+
_path: "/custom-status",
|
|
505
|
+
find: async (params) => {
|
|
506
|
+
let res = await this._fetch(this.svAPIEndpoint, this.customStatus._path, params);
|
|
507
|
+
return res;
|
|
508
|
+
},
|
|
509
|
+
get: async (id) => {
|
|
510
|
+
return await this._fetch(this.svAPIEndpoint, this.customStatus._path + `/${id}`);
|
|
511
|
+
},
|
|
512
|
+
create: async (body) => {
|
|
513
|
+
let res = await this._create(this.svAPIEndpoint, this.customStatus._path, body);
|
|
514
|
+
return res;
|
|
515
|
+
},
|
|
516
|
+
update: async (id, body) => {
|
|
517
|
+
let res = await this._update(this.svAPIEndpoint, this.customStatus._path + `/${id}`, body);
|
|
518
|
+
return res;
|
|
519
|
+
},
|
|
520
|
+
remove: async (id) => {
|
|
521
|
+
let res = await this._delete(this.svAPIEndpoint, this.customStatus._path + `/${id}`);
|
|
522
|
+
return res;
|
|
523
|
+
},
|
|
524
|
+
};
|
|
525
|
+
this.workorder = {
|
|
526
|
+
_path: "/workorder",
|
|
527
|
+
find: async (params) => {
|
|
528
|
+
let res = await this._fetch(this.svAPIEndpoint, this.workorder._path, params);
|
|
529
|
+
return res;
|
|
530
|
+
},
|
|
531
|
+
get: async (id, params) => {
|
|
532
|
+
return await this._fetch(this.svAPIEndpoint, this.workorder._path + `/${id}`, params);
|
|
533
|
+
},
|
|
534
|
+
};
|
|
535
|
+
this.quickConvertToPdf = {
|
|
536
|
+
_path: "/quick-convert-to-pdf",
|
|
537
|
+
find: async (params) => {
|
|
538
|
+
let res = await this._fetch(this.svAPIEndpoint, this.quickConvertToPdf._path, params);
|
|
539
|
+
return res;
|
|
540
|
+
},
|
|
541
|
+
get: async (id, params) => {
|
|
542
|
+
return await this._fetch(this.svAPIEndpoint, this.quickConvertToPdf._path + `/${id}`, params);
|
|
543
|
+
},
|
|
544
|
+
create: async (body) => {
|
|
545
|
+
let res = await this._create(this.svAPIEndpoint, this.quickConvertToPdf._path, body);
|
|
546
|
+
return res;
|
|
547
|
+
},
|
|
548
|
+
remove: async (id) => {
|
|
549
|
+
let res = await this._delete(this.svAPIEndpoint, this.quickConvertToPdf._path + `/${id}`);
|
|
550
|
+
return res;
|
|
551
|
+
},
|
|
552
|
+
};
|
|
553
|
+
this.visit = {
|
|
554
|
+
_path: "/visit",
|
|
555
|
+
find: async (params) => {
|
|
556
|
+
let res = await this._fetch(this.svAPIEndpoint, this.visit._path, params);
|
|
557
|
+
return res;
|
|
558
|
+
},
|
|
559
|
+
get: async (id, params) => {
|
|
560
|
+
return await this._fetch(this.svAPIEndpoint, this.visit._path + `/${id}`, params);
|
|
561
|
+
},
|
|
562
|
+
create: async (body) => {
|
|
563
|
+
let res = await this._create(this.svAPIEndpoint, this.visit._path, body);
|
|
564
|
+
return res;
|
|
565
|
+
},
|
|
566
|
+
update: async (id, body) => {
|
|
567
|
+
let res = await this._update(this.svAPIEndpoint, this.visit._path + `/${id}`, body);
|
|
568
|
+
return res;
|
|
569
|
+
},
|
|
570
|
+
};
|
|
571
|
+
this.invoice = {
|
|
572
|
+
_path: "/fullinvoices",
|
|
573
|
+
find: async (params) => {
|
|
574
|
+
let res = await this._fetch(this.svAPIEndpoint, this.invoice._path, params);
|
|
575
|
+
return res;
|
|
576
|
+
},
|
|
577
|
+
get: async (id, params) => {
|
|
578
|
+
return await this._fetch(this.svAPIEndpoint, this.invoice._path + `/${id}`, params);
|
|
579
|
+
},
|
|
580
|
+
create: async (body) => {
|
|
581
|
+
let res = await this._create(this.svAPIEndpoint, this.invoice._path, body);
|
|
582
|
+
return res;
|
|
583
|
+
},
|
|
584
|
+
update: async (id, body) => {
|
|
585
|
+
let res = await this._update(this.svAPIEndpoint, this.invoice._path + `/${id}`, body);
|
|
586
|
+
return res;
|
|
587
|
+
},
|
|
588
|
+
};
|
|
589
|
+
this.proforma = {
|
|
590
|
+
_path: "/proforma",
|
|
591
|
+
find: async (params) => {
|
|
592
|
+
let res = await this._fetch(this.svAPIEndpoint, this.proforma._path, params);
|
|
593
|
+
return res;
|
|
594
|
+
},
|
|
595
|
+
get: async (id, params) => {
|
|
596
|
+
return await this._fetch(this.svAPIEndpoint, this.proforma._path + `/${id}`, params);
|
|
597
|
+
},
|
|
598
|
+
create: async (body) => {
|
|
599
|
+
let res = await this._create(this.svAPIEndpoint, this.proforma._path, body);
|
|
600
|
+
return res;
|
|
601
|
+
},
|
|
602
|
+
update: async (id, body) => {
|
|
603
|
+
let res = await this._update(this.svAPIEndpoint, this.proforma._path + `/${id}`, body);
|
|
604
|
+
return res;
|
|
605
|
+
},
|
|
606
|
+
};
|
|
607
|
+
this.payment = {
|
|
608
|
+
_path: "/payments",
|
|
609
|
+
find: async (params) => {
|
|
610
|
+
let res = await this._fetch(this.svAPIEndpoint, this.payment._path, params);
|
|
611
|
+
return res;
|
|
612
|
+
},
|
|
613
|
+
get: async (id, params) => {
|
|
614
|
+
return await this._fetch(this.svAPIEndpoint, this.payment._path + `/${id}`, params);
|
|
615
|
+
},
|
|
616
|
+
create: async (body) => {
|
|
617
|
+
let res = await this._create(this.svAPIEndpoint, this.payment._path, body);
|
|
618
|
+
return res;
|
|
619
|
+
},
|
|
620
|
+
update: async (id, body) => {
|
|
621
|
+
let res = await this._update(this.svAPIEndpoint, this.payment._path + `/${id}`, body);
|
|
622
|
+
return res;
|
|
623
|
+
},
|
|
624
|
+
};
|
|
625
|
+
this.refund = {
|
|
626
|
+
_path: "/refund",
|
|
627
|
+
find: async (params) => {
|
|
628
|
+
let res = await this._fetch(this.svAPIEndpoint, this.refund._path, params);
|
|
629
|
+
return res;
|
|
630
|
+
},
|
|
631
|
+
get: async (id, params) => {
|
|
632
|
+
return await this._fetch(this.svAPIEndpoint, this.refund._path + `/${id}`, params);
|
|
633
|
+
},
|
|
634
|
+
create: async (body) => {
|
|
635
|
+
let res = await this._create(this.svAPIEndpoint, this.refund._path, body);
|
|
636
|
+
return res;
|
|
637
|
+
},
|
|
638
|
+
update: async (id, body) => {
|
|
639
|
+
let res = await this._update(this.svAPIEndpoint, this.refund._path + `/${id}`, body);
|
|
640
|
+
return res;
|
|
641
|
+
},
|
|
642
|
+
};
|
|
643
|
+
this.transfer = {
|
|
644
|
+
_path: "/transfer",
|
|
645
|
+
find: async (params) => {
|
|
646
|
+
let res = await this._fetch(this.svAPIEndpoint, this.transfer._path, params);
|
|
647
|
+
return res;
|
|
648
|
+
},
|
|
649
|
+
get: async (id, params) => {
|
|
650
|
+
return await this._fetch(this.svAPIEndpoint, this.transfer._path + `/${id}`, params);
|
|
651
|
+
},
|
|
652
|
+
create: async (body) => {
|
|
653
|
+
let res = await this._create(this.svAPIEndpoint, this.transfer._path, body);
|
|
654
|
+
return res;
|
|
655
|
+
},
|
|
656
|
+
update: async (id, body) => {
|
|
657
|
+
let res = await this._update(this.svAPIEndpoint, this.transfer._path + `/${id}`, body);
|
|
658
|
+
return res;
|
|
659
|
+
},
|
|
1386
660
|
};
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
661
|
+
this.adjustInventory = {
|
|
662
|
+
_path: "/adjust-inventory",
|
|
663
|
+
find: async (params) => {
|
|
664
|
+
let res = await this._fetch(this.svAPIEndpoint, this.adjustInventory._path, params);
|
|
665
|
+
return res;
|
|
666
|
+
},
|
|
667
|
+
get: async (id, params) => {
|
|
668
|
+
return await this._fetch(this.svAPIEndpoint, this.adjustInventory._path + `/${id}`, params);
|
|
669
|
+
},
|
|
670
|
+
create: async (body) => {
|
|
671
|
+
let res = await this._create(this.svAPIEndpoint, this.adjustInventory._path, body);
|
|
672
|
+
return res;
|
|
673
|
+
},
|
|
674
|
+
};
|
|
675
|
+
this.inventory = {
|
|
676
|
+
_path: "/inventory",
|
|
677
|
+
find: async (params) => {
|
|
678
|
+
let res = await this._fetch(this.svAPIEndpoint, this.inventory._path, params);
|
|
679
|
+
return res;
|
|
680
|
+
},
|
|
681
|
+
};
|
|
682
|
+
this.integrationApp = {
|
|
683
|
+
_path: "/integration-app",
|
|
684
|
+
find: async (params) => {
|
|
685
|
+
let res = await this._fetch(this.svAPIEndpoint, this.integrationApp._path, params);
|
|
686
|
+
return res;
|
|
687
|
+
},
|
|
688
|
+
get: async (id, params) => {
|
|
689
|
+
return await this._fetch(this.svAPIEndpoint, this.integrationApp._path + `/${id}`, params);
|
|
690
|
+
},
|
|
691
|
+
create: async (body) => {
|
|
692
|
+
let res = await this._create(this.svAPIEndpoint, this.integrationApp._path, body);
|
|
693
|
+
return res;
|
|
694
|
+
},
|
|
695
|
+
update: async (id, body) => {
|
|
696
|
+
let res = await this._update(this.svAPIEndpoint, this.integrationApp._path + `/${id}`, body);
|
|
697
|
+
return res;
|
|
698
|
+
},
|
|
699
|
+
};
|
|
700
|
+
this.joinActionsWebHook = {
|
|
701
|
+
_path: "/svix-integration",
|
|
702
|
+
update: async (id, body) => {
|
|
703
|
+
let res = await this._update(this.svAPIEndpoint, this.joinActionsWebHook._path, body);
|
|
704
|
+
return res;
|
|
705
|
+
},
|
|
706
|
+
};
|
|
707
|
+
this.patchAction = {
|
|
708
|
+
_path: "/patch-action",
|
|
709
|
+
create: async (body, params) => {
|
|
710
|
+
const res = await this._create(this.svAPIEndpoint, this.patchAction._path, body, params);
|
|
711
|
+
return res;
|
|
712
|
+
},
|
|
713
|
+
update: async (body) => {
|
|
714
|
+
const res = await this._update(this.svAPIEndpoint, this.patchAction._path, body);
|
|
715
|
+
return res;
|
|
716
|
+
},
|
|
717
|
+
};
|
|
718
|
+
this.updateIntegrationMeta = {
|
|
719
|
+
_path: "/update-integration-meta",
|
|
720
|
+
create: async (body, params) => {
|
|
721
|
+
let res = await this._create(this.svAPIEndpoint, this.updateIntegrationMeta._path, body, params);
|
|
722
|
+
return res;
|
|
723
|
+
},
|
|
724
|
+
};
|
|
725
|
+
this.svAPIEndpoint =
|
|
726
|
+
!options?.env || options?.env == "production"
|
|
727
|
+
? "https://sv.api.repzo.me"
|
|
728
|
+
: options?.env == "staging"
|
|
729
|
+
? "https://staging.sv.api.repzo.me"
|
|
730
|
+
: options?.env == "local"
|
|
731
|
+
? "http://localhost:3030"
|
|
732
|
+
: "";
|
|
733
|
+
this.headers = {
|
|
734
|
+
"api-key": apiKey,
|
|
735
|
+
"Content-Type": "application/json",
|
|
736
|
+
Accept: "application/json",
|
|
737
|
+
};
|
|
738
|
+
if (options?.headers)
|
|
739
|
+
Object.assign(this.headers, options.headers);
|
|
1391
740
|
}
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
setMeta(meta) {
|
|
1399
|
-
this.meta = meta;
|
|
1400
|
-
return this;
|
|
1401
|
-
}
|
|
1402
|
-
async commit() {
|
|
1403
|
-
let doc = {
|
|
1404
|
-
available_app_name: this.available_app_name,
|
|
1405
|
-
available_app_id: this.available_app_id,
|
|
1406
|
-
app_id: this.app_id,
|
|
1407
|
-
action: this.action,
|
|
1408
|
-
company_namespace: this.company_namespace,
|
|
1409
|
-
status: this.status,
|
|
1410
|
-
error: this.error ? this.error : undefined,
|
|
1411
|
-
start_time: this.start_time,
|
|
1412
|
-
end_time: Date.now(),
|
|
1413
|
-
total_time: Date.now() - this.start_time,
|
|
1414
|
-
body: this.body,
|
|
1415
|
-
meta: this.meta,
|
|
1416
|
-
message: this.message,
|
|
1417
|
-
details: this.details,
|
|
1418
|
-
sync_id: this.sync_id,
|
|
1419
|
-
};
|
|
1420
|
-
try {
|
|
1421
|
-
const res = await this.superThis._create(
|
|
1422
|
-
this.superThis.svAPIEndpoint,
|
|
1423
|
-
this._path,
|
|
1424
|
-
doc
|
|
1425
|
-
);
|
|
1426
|
-
} catch (e) {
|
|
1427
|
-
console.error(e);
|
|
741
|
+
async _fetch(baseUrl, path, params) {
|
|
742
|
+
let res = await axios.get(baseUrl + path, {
|
|
743
|
+
params,
|
|
744
|
+
headers: this.headers,
|
|
745
|
+
});
|
|
746
|
+
return res.data;
|
|
1428
747
|
}
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
}
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
params
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
const command_log = res.data[0];
|
|
1473
|
-
if (command_log) {
|
|
748
|
+
async _create(baseUrl, path, body, params) {
|
|
749
|
+
let res = await axios.post(baseUrl + path, body, {
|
|
750
|
+
params,
|
|
751
|
+
headers: this.headers,
|
|
752
|
+
});
|
|
753
|
+
return res.data;
|
|
754
|
+
}
|
|
755
|
+
async _update(baseUrl, path, body, params) {
|
|
756
|
+
let res = await axios.put(baseUrl + path, body, {
|
|
757
|
+
params,
|
|
758
|
+
headers: this.headers,
|
|
759
|
+
});
|
|
760
|
+
return res.data;
|
|
761
|
+
}
|
|
762
|
+
async _delete(baseUrl, path, params) {
|
|
763
|
+
let res = await axios.delete(baseUrl + path, {
|
|
764
|
+
params,
|
|
765
|
+
headers: this.headers,
|
|
766
|
+
});
|
|
767
|
+
return res.data;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
Repzo.ActionLogs = class {
|
|
771
|
+
constructor(superThis, sync_id) {
|
|
772
|
+
this.superThis = superThis;
|
|
773
|
+
this._path = "/integration-action-log";
|
|
774
|
+
this.available_app_name = "";
|
|
775
|
+
this.available_app_id = "";
|
|
776
|
+
this.app_id = "";
|
|
777
|
+
this.action = "";
|
|
778
|
+
this.start_time = Date.now();
|
|
779
|
+
this.status = "processing";
|
|
780
|
+
this.message = "Log Created";
|
|
781
|
+
this.details = [];
|
|
782
|
+
this.sync_id = sync_id;
|
|
783
|
+
this.isOld = true;
|
|
784
|
+
}
|
|
785
|
+
async load(sync_id) {
|
|
786
|
+
const params = { sync_id: sync_id };
|
|
787
|
+
const res = await this.superThis._fetch(this.superThis.svAPIEndpoint, this._path, params);
|
|
788
|
+
if (!res?.data?.length)
|
|
789
|
+
throw new Error(`Action Log Not found, sync_id: ${sync_id}`);
|
|
790
|
+
const action_log = res.data[0];
|
|
1474
791
|
this.sync_id = sync_id;
|
|
1475
|
-
this.details =
|
|
1476
|
-
this.status =
|
|
1477
|
-
this.error =
|
|
1478
|
-
this.start_time =
|
|
1479
|
-
this.body =
|
|
1480
|
-
this.meta =
|
|
1481
|
-
this.message =
|
|
1482
|
-
this.
|
|
1483
|
-
|
|
792
|
+
this.details = action_log.details;
|
|
793
|
+
this.status = action_log.status;
|
|
794
|
+
this.error = action_log.error;
|
|
795
|
+
this.start_time = action_log.start_time;
|
|
796
|
+
this.body = action_log.body;
|
|
797
|
+
this.meta = action_log.meta;
|
|
798
|
+
this.message = action_log.message;
|
|
799
|
+
this.app_id = action_log.app_id;
|
|
800
|
+
this.available_app_id = action_log.available_app_id;
|
|
801
|
+
this.available_app_name = action_log.available_app_name;
|
|
802
|
+
this.company_namespace = action_log.company_namespace;
|
|
803
|
+
this.action = action_log.action;
|
|
1484
804
|
this.isOld = true;
|
|
1485
|
-
this
|
|
1486
|
-
this.succeededAt = command_log.succeededAt;
|
|
1487
|
-
this.skippedAt = command_log.skippedAt;
|
|
1488
|
-
this.receivedAt = command_log.receivedAt;
|
|
1489
|
-
this.processedAt = command_log.processedAt;
|
|
1490
|
-
this.onGoing = command_log.onGoing || false;
|
|
1491
|
-
this.trigger = command_log.trigger;
|
|
1492
|
-
// this.priority = command_log.priority
|
|
1493
|
-
// ? command_log.priority
|
|
1494
|
-
// : this.priority
|
|
1495
|
-
// ? this.priority
|
|
1496
|
-
// : undefined;
|
|
1497
|
-
}
|
|
805
|
+
return this;
|
|
1498
806
|
}
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
807
|
+
setStatus(status, error) {
|
|
808
|
+
this.details.push({
|
|
809
|
+
timestamp: Date.now(),
|
|
810
|
+
content: `status was changed from ${this.status} to ${status}`,
|
|
811
|
+
});
|
|
812
|
+
this.status = status;
|
|
813
|
+
if (error) {
|
|
814
|
+
if (typeof error == "string") {
|
|
815
|
+
this.error = { message: error };
|
|
816
|
+
}
|
|
817
|
+
else if (error.message || error.response?.data) {
|
|
818
|
+
this.error = {
|
|
819
|
+
// json: error.toJSON ? error.toJSON() : undefined,
|
|
820
|
+
message: error.message,
|
|
821
|
+
responseData: error.response?.data,
|
|
822
|
+
};
|
|
823
|
+
}
|
|
824
|
+
else {
|
|
825
|
+
this.error = error;
|
|
826
|
+
}
|
|
827
|
+
return this;
|
|
828
|
+
}
|
|
829
|
+
return this;
|
|
830
|
+
}
|
|
831
|
+
setBody(body) {
|
|
832
|
+
this.body = body;
|
|
833
|
+
return this;
|
|
834
|
+
}
|
|
835
|
+
setMeta(meta) {
|
|
836
|
+
this.meta = meta;
|
|
837
|
+
return this;
|
|
838
|
+
}
|
|
839
|
+
async commit() {
|
|
840
|
+
let doc = {
|
|
841
|
+
available_app_name: this.available_app_name,
|
|
842
|
+
available_app_id: this.available_app_id,
|
|
843
|
+
app_id: this.app_id,
|
|
844
|
+
action: this.action,
|
|
845
|
+
company_namespace: this.company_namespace,
|
|
846
|
+
status: this.status,
|
|
847
|
+
error: this.error ? this.error : undefined,
|
|
848
|
+
start_time: this.start_time,
|
|
849
|
+
end_time: Date.now(),
|
|
850
|
+
total_time: Date.now() - this.start_time,
|
|
851
|
+
body: this.body,
|
|
852
|
+
meta: this.meta,
|
|
853
|
+
message: this.message,
|
|
854
|
+
details: this.details,
|
|
855
|
+
sync_id: this.sync_id,
|
|
1512
856
|
};
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
857
|
+
try {
|
|
858
|
+
const res = await this.superThis._create(this.superThis.svAPIEndpoint, this._path, doc);
|
|
859
|
+
}
|
|
860
|
+
catch (e) {
|
|
861
|
+
console.error(e);
|
|
862
|
+
}
|
|
863
|
+
return this;
|
|
1517
864
|
}
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
this.
|
|
865
|
+
addDetail(detail, meta) {
|
|
866
|
+
let d = {
|
|
867
|
+
timestamp: Date.now(),
|
|
868
|
+
content: detail,
|
|
869
|
+
};
|
|
870
|
+
this.message = detail;
|
|
871
|
+
if (meta)
|
|
872
|
+
d.meta = meta;
|
|
873
|
+
this.details.push(d);
|
|
874
|
+
return this;
|
|
875
|
+
}
|
|
876
|
+
};
|
|
877
|
+
Repzo.CommandLog = class {
|
|
878
|
+
constructor(superThis, app, command, trigger) {
|
|
879
|
+
this.superThis = superThis;
|
|
880
|
+
this._path = "/integration-command-log";
|
|
881
|
+
this.app_id = app._id;
|
|
882
|
+
this.available_app_id = app.available_app._id;
|
|
883
|
+
this.available_app_name = app.available_app.name;
|
|
884
|
+
this.company_namespace = app.company_namespace;
|
|
885
|
+
this.start_time = Date.now();
|
|
886
|
+
this.status = "received";
|
|
887
|
+
this.message = "Request received";
|
|
888
|
+
this.command = command;
|
|
889
|
+
this.details = [{ timestamp: Date.now(), content: "Request received" }];
|
|
890
|
+
this.sync_id = uuid();
|
|
891
|
+
this.isOld = false;
|
|
892
|
+
this.isPrioritized = false;
|
|
893
|
+
this.retries = 1;
|
|
894
|
+
this.trigger = trigger;
|
|
1533
895
|
this.onGoing = true;
|
|
1534
|
-
break;
|
|
1535
|
-
case "skipped":
|
|
1536
|
-
this.skippedAt = new Date();
|
|
1537
|
-
this.onGoing = false;
|
|
1538
|
-
break;
|
|
1539
|
-
case "success":
|
|
1540
|
-
this.succeededAt = new Date();
|
|
1541
|
-
this.onGoing = false;
|
|
1542
|
-
break;
|
|
1543
896
|
}
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
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
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
897
|
+
async load(sync_id, retries) {
|
|
898
|
+
if (sync_id) {
|
|
899
|
+
const params = { sync_id: sync_id };
|
|
900
|
+
const res = await this.superThis._fetch(this.superThis.svAPIEndpoint, this._path, params);
|
|
901
|
+
if (!res?.data?.length)
|
|
902
|
+
throw new Error(`Command Log Not found, sync_id: ${sync_id}`);
|
|
903
|
+
const command_log = res.data[0];
|
|
904
|
+
if (command_log) {
|
|
905
|
+
this.sync_id = sync_id;
|
|
906
|
+
this.details = command_log.details;
|
|
907
|
+
this.status = command_log.status;
|
|
908
|
+
this.error = command_log.error;
|
|
909
|
+
this.start_time = command_log.start_time;
|
|
910
|
+
this.body = command_log.body;
|
|
911
|
+
this.meta = command_log.meta;
|
|
912
|
+
this.message = command_log.message;
|
|
913
|
+
this.retries =
|
|
914
|
+
retries !== undefined
|
|
915
|
+
? retries
|
|
916
|
+
: command_log.retries || this.retries; // retries !== undefined ? retries : command_log.retries;
|
|
917
|
+
this.isOld = true;
|
|
918
|
+
this.failedAt = command_log.failedAt;
|
|
919
|
+
this.succeededAt = command_log.succeededAt;
|
|
920
|
+
this.skippedAt = command_log.skippedAt;
|
|
921
|
+
this.receivedAt = command_log.receivedAt;
|
|
922
|
+
this.processedAt = command_log.processedAt;
|
|
923
|
+
this.onGoing = command_log.onGoing || false;
|
|
924
|
+
this.trigger = command_log.trigger;
|
|
925
|
+
// this.priority = command_log.priority
|
|
926
|
+
// ? command_log.priority
|
|
927
|
+
// : this.priority
|
|
928
|
+
// ? this.priority
|
|
929
|
+
// : undefined;
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
return this;
|
|
933
|
+
}
|
|
934
|
+
setStatus(status, error) {
|
|
935
|
+
this.addDetail(`status was changed from ${this.status} to ${status}`);
|
|
936
|
+
this.status = status;
|
|
937
|
+
if (error) {
|
|
938
|
+
if (typeof error == "string") {
|
|
939
|
+
this.error = { message: error };
|
|
940
|
+
}
|
|
941
|
+
else if (error.message || error.response?.data) {
|
|
942
|
+
this.error = {
|
|
943
|
+
// json: error.toJSON ? error.toJSON() : undefined,
|
|
944
|
+
message: error.message,
|
|
945
|
+
responseData: error.response?.data,
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
else {
|
|
949
|
+
this.error = error;
|
|
950
|
+
}
|
|
951
|
+
return this;
|
|
952
|
+
}
|
|
953
|
+
switch (status) {
|
|
954
|
+
case "fail":
|
|
955
|
+
this.failedAt = new Date();
|
|
956
|
+
this.onGoing = false;
|
|
957
|
+
break;
|
|
958
|
+
case "processing":
|
|
959
|
+
this.processedAt = new Date();
|
|
960
|
+
this.onGoing = true;
|
|
961
|
+
break;
|
|
962
|
+
case "queued":
|
|
963
|
+
this.queuedAt = new Date();
|
|
964
|
+
this.onGoing = true;
|
|
965
|
+
break;
|
|
966
|
+
case "received":
|
|
967
|
+
this.receivedAt = new Date();
|
|
968
|
+
this.onGoing = true;
|
|
969
|
+
break;
|
|
970
|
+
case "skipped":
|
|
971
|
+
this.skippedAt = new Date();
|
|
972
|
+
this.onGoing = false;
|
|
973
|
+
break;
|
|
974
|
+
case "success":
|
|
975
|
+
this.succeededAt = new Date();
|
|
976
|
+
this.onGoing = false;
|
|
977
|
+
break;
|
|
978
|
+
}
|
|
979
|
+
return this;
|
|
980
|
+
}
|
|
981
|
+
setBody(body) {
|
|
982
|
+
this.body = body;
|
|
983
|
+
return this;
|
|
984
|
+
}
|
|
985
|
+
setMeta(meta) {
|
|
986
|
+
this.meta = meta;
|
|
987
|
+
return this;
|
|
988
|
+
}
|
|
989
|
+
async commit() {
|
|
990
|
+
let doc = {
|
|
991
|
+
available_app_name: this.available_app_name,
|
|
992
|
+
available_app_id: this.available_app_id,
|
|
993
|
+
app_id: this.app_id,
|
|
994
|
+
command: this.command,
|
|
995
|
+
status: this.status,
|
|
996
|
+
error: this.error ? this.error : undefined,
|
|
997
|
+
start_time: this.start_time,
|
|
998
|
+
end_time: Date.now(),
|
|
999
|
+
total_time: Date.now() - this.start_time,
|
|
1000
|
+
company_namespace: this.company_namespace,
|
|
1001
|
+
body: this.body,
|
|
1002
|
+
meta: this.meta,
|
|
1003
|
+
message: this.message,
|
|
1004
|
+
details: this.details,
|
|
1005
|
+
sync_id: this.sync_id,
|
|
1006
|
+
// priority: this.priority ? this.priority : undefined,
|
|
1007
|
+
queuedAt: this.queuedAt ? this.queuedAt : undefined,
|
|
1008
|
+
failedAt: this.failedAt ? this.failedAt : undefined,
|
|
1009
|
+
succeededAt: this.succeededAt ? this.succeededAt : undefined,
|
|
1010
|
+
skippedAt: this.skippedAt ? this.skippedAt : undefined,
|
|
1011
|
+
receivedAt: this.receivedAt ? this.receivedAt : undefined,
|
|
1012
|
+
processedAt: this.processedAt ? this.processedAt : undefined,
|
|
1013
|
+
onGoing: this.onGoing !== undefined ? this.onGoing : undefined,
|
|
1014
|
+
retries: this.retries !== undefined ? this.retries : undefined,
|
|
1015
|
+
trigger: this.trigger,
|
|
1016
|
+
};
|
|
1017
|
+
try {
|
|
1018
|
+
const res = await this.superThis._create(this.superThis.svAPIEndpoint, this._path, doc);
|
|
1019
|
+
this.isOld = true;
|
|
1020
|
+
}
|
|
1021
|
+
catch (e) {
|
|
1022
|
+
console.error(e);
|
|
1023
|
+
}
|
|
1024
|
+
return this;
|
|
1025
|
+
}
|
|
1026
|
+
addDetail(detail, meta) {
|
|
1027
|
+
let d = {
|
|
1028
|
+
timestamp: Date.now(),
|
|
1029
|
+
content: detail,
|
|
1030
|
+
};
|
|
1031
|
+
this.message = detail;
|
|
1032
|
+
if (meta)
|
|
1033
|
+
d.meta = meta;
|
|
1034
|
+
this.details.push(d);
|
|
1035
|
+
return this;
|
|
1591
1036
|
}
|
|
1592
|
-
return this;
|
|
1593
|
-
}
|
|
1594
|
-
addDetail(detail, meta) {
|
|
1595
|
-
let d = {
|
|
1596
|
-
timestamp: Date.now(),
|
|
1597
|
-
content: detail,
|
|
1598
|
-
};
|
|
1599
|
-
this.message = detail;
|
|
1600
|
-
if (meta) d.meta = meta;
|
|
1601
|
-
this.details.push(d);
|
|
1602
|
-
return this;
|
|
1603
|
-
}
|
|
1604
1037
|
};
|