repzo 1.0.9 → 1.0.10
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 +289 -576
- package/lib/index.js +854 -1305
- package/lib/types/index.d.ts +3990 -4130
- package/lib/types/index.js +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1,1319 +1,868 @@
|
|
|
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
|
-
let res = await
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
},
|
|
626
|
-
get: async (id) => {
|
|
627
|
-
return await this._fetch(
|
|
628
|
-
this.svAPIEndpoint,
|
|
629
|
-
this.warehouse._path + `/${id}`
|
|
630
|
-
);
|
|
631
|
-
},
|
|
632
|
-
create: async (body) => {
|
|
633
|
-
let res = await this._create(
|
|
634
|
-
this.svAPIEndpoint,
|
|
635
|
-
this.warehouse._path,
|
|
636
|
-
body
|
|
637
|
-
);
|
|
638
|
-
return res;
|
|
639
|
-
},
|
|
640
|
-
update: async (id, body) => {
|
|
641
|
-
let res = await this._update(
|
|
642
|
-
this.svAPIEndpoint,
|
|
643
|
-
this.warehouse._path + `/${id}`,
|
|
644
|
-
body
|
|
645
|
-
);
|
|
646
|
-
return res;
|
|
647
|
-
},
|
|
648
|
-
remove: async (id) => {
|
|
649
|
-
let res = await this._delete(
|
|
650
|
-
this.svAPIEndpoint,
|
|
651
|
-
this.warehouse._path + `/${id}`
|
|
652
|
-
);
|
|
653
|
-
return res;
|
|
654
|
-
},
|
|
655
|
-
};
|
|
656
|
-
this.channel = {
|
|
657
|
-
_path: "/client-channel",
|
|
658
|
-
find: async (params) => {
|
|
659
|
-
let res = await this._fetch(
|
|
660
|
-
this.svAPIEndpoint,
|
|
661
|
-
this.channel._path,
|
|
662
|
-
params
|
|
663
|
-
);
|
|
664
|
-
return res;
|
|
665
|
-
},
|
|
666
|
-
get: async (id) => {
|
|
667
|
-
return await this._fetch(
|
|
668
|
-
this.svAPIEndpoint,
|
|
669
|
-
this.channel._path + `/${id}`
|
|
670
|
-
);
|
|
671
|
-
},
|
|
672
|
-
create: async (body) => {
|
|
673
|
-
let res = await this._create(
|
|
674
|
-
this.svAPIEndpoint,
|
|
675
|
-
this.channel._path,
|
|
676
|
-
body
|
|
677
|
-
);
|
|
678
|
-
return res;
|
|
679
|
-
},
|
|
680
|
-
update: async (id, body) => {
|
|
681
|
-
let res = await this._update(
|
|
682
|
-
this.svAPIEndpoint,
|
|
683
|
-
this.channel._path + `/${id}`,
|
|
684
|
-
body
|
|
685
|
-
);
|
|
686
|
-
return res;
|
|
687
|
-
},
|
|
688
|
-
remove: async (id) => {
|
|
689
|
-
let res = await this._delete(
|
|
690
|
-
this.svAPIEndpoint,
|
|
691
|
-
this.channel._path + `/${id}`
|
|
692
|
-
);
|
|
693
|
-
return res;
|
|
694
|
-
},
|
|
695
|
-
};
|
|
696
|
-
this.paymentTerm = {
|
|
697
|
-
_path: "/paymentterms",
|
|
698
|
-
find: async (params) => {
|
|
699
|
-
let res = await this._fetch(
|
|
700
|
-
this.svAPIEndpoint,
|
|
701
|
-
this.paymentTerm._path,
|
|
702
|
-
params
|
|
703
|
-
);
|
|
704
|
-
return res;
|
|
705
|
-
},
|
|
706
|
-
get: async (id) => {
|
|
707
|
-
return await this._fetch(
|
|
708
|
-
this.svAPIEndpoint,
|
|
709
|
-
this.paymentTerm._path + `/${id}`
|
|
710
|
-
);
|
|
711
|
-
},
|
|
712
|
-
create: async (body) => {
|
|
713
|
-
let res = await this._create(
|
|
714
|
-
this.svAPIEndpoint,
|
|
715
|
-
this.paymentTerm._path,
|
|
716
|
-
body
|
|
717
|
-
);
|
|
718
|
-
return res;
|
|
719
|
-
},
|
|
720
|
-
update: async (id, body) => {
|
|
721
|
-
let res = await this._update(
|
|
722
|
-
this.svAPIEndpoint,
|
|
723
|
-
this.paymentTerm._path + `/${id}`,
|
|
724
|
-
body
|
|
725
|
-
);
|
|
726
|
-
return res;
|
|
727
|
-
},
|
|
728
|
-
remove: async (id) => {
|
|
729
|
-
let res = await this._delete(
|
|
730
|
-
this.svAPIEndpoint,
|
|
731
|
-
this.paymentTerm._path + `/${id}`
|
|
732
|
-
);
|
|
733
|
-
return res;
|
|
734
|
-
},
|
|
735
|
-
};
|
|
736
|
-
this.bank = {
|
|
737
|
-
_path: "/banks",
|
|
738
|
-
find: async (params) => {
|
|
739
|
-
let res = await this._fetch(
|
|
740
|
-
this.svAPIEndpoint,
|
|
741
|
-
this.bank._path,
|
|
742
|
-
params
|
|
743
|
-
);
|
|
744
|
-
return res;
|
|
745
|
-
},
|
|
746
|
-
get: async (id) => {
|
|
747
|
-
return await this._fetch(
|
|
748
|
-
this.svAPIEndpoint,
|
|
749
|
-
this.bank._path + `/${id}`
|
|
750
|
-
);
|
|
751
|
-
},
|
|
752
|
-
create: async (body) => {
|
|
753
|
-
let res = await this._create(this.svAPIEndpoint, this.bank._path, body);
|
|
754
|
-
return res;
|
|
755
|
-
},
|
|
756
|
-
update: async (id, body) => {
|
|
757
|
-
let res = await this._update(
|
|
758
|
-
this.svAPIEndpoint,
|
|
759
|
-
this.bank._path + `/${id}`,
|
|
760
|
-
body
|
|
761
|
-
);
|
|
762
|
-
return res;
|
|
763
|
-
},
|
|
764
|
-
};
|
|
765
|
-
this.customStatus = {
|
|
766
|
-
_path: "/custom-status",
|
|
767
|
-
find: async (params) => {
|
|
768
|
-
let res = await this._fetch(
|
|
769
|
-
this.svAPIEndpoint,
|
|
770
|
-
this.customStatus._path,
|
|
771
|
-
params
|
|
772
|
-
);
|
|
773
|
-
return res;
|
|
774
|
-
},
|
|
775
|
-
get: async (id) => {
|
|
776
|
-
return await this._fetch(
|
|
777
|
-
this.svAPIEndpoint,
|
|
778
|
-
this.customStatus._path + `/${id}`
|
|
779
|
-
);
|
|
780
|
-
},
|
|
781
|
-
create: async (body) => {
|
|
782
|
-
let res = await this._create(
|
|
783
|
-
this.svAPIEndpoint,
|
|
784
|
-
this.customStatus._path,
|
|
785
|
-
body
|
|
786
|
-
);
|
|
787
|
-
return res;
|
|
788
|
-
},
|
|
789
|
-
update: async (id, body) => {
|
|
790
|
-
let res = await this._update(
|
|
791
|
-
this.svAPIEndpoint,
|
|
792
|
-
this.customStatus._path + `/${id}`,
|
|
793
|
-
body
|
|
794
|
-
);
|
|
795
|
-
return res;
|
|
796
|
-
},
|
|
797
|
-
remove: async (id) => {
|
|
798
|
-
let res = await this._delete(
|
|
799
|
-
this.svAPIEndpoint,
|
|
800
|
-
this.customStatus._path + `/${id}`
|
|
801
|
-
);
|
|
802
|
-
return res;
|
|
803
|
-
},
|
|
804
|
-
};
|
|
805
|
-
this.invoice = {
|
|
806
|
-
_path: "/fullinvoices",
|
|
807
|
-
find: async (params) => {
|
|
808
|
-
let res = await this._fetch(
|
|
809
|
-
this.svAPIEndpoint,
|
|
810
|
-
this.invoice._path,
|
|
811
|
-
params
|
|
812
|
-
);
|
|
813
|
-
return res;
|
|
814
|
-
},
|
|
815
|
-
get: async (id, params) => {
|
|
816
|
-
return await this._fetch(
|
|
817
|
-
this.svAPIEndpoint,
|
|
818
|
-
this.invoice._path + `/${id}`,
|
|
819
|
-
params
|
|
820
|
-
);
|
|
821
|
-
},
|
|
822
|
-
create: async (body) => {
|
|
823
|
-
let res = await this._create(
|
|
824
|
-
this.svAPIEndpoint,
|
|
825
|
-
this.invoice._path,
|
|
826
|
-
body
|
|
827
|
-
);
|
|
828
|
-
return res;
|
|
829
|
-
},
|
|
830
|
-
update: async (id, body) => {
|
|
831
|
-
let res = await this._update(
|
|
832
|
-
this.svAPIEndpoint,
|
|
833
|
-
this.invoice._path + `/${id}`,
|
|
834
|
-
body
|
|
835
|
-
);
|
|
836
|
-
return res;
|
|
837
|
-
},
|
|
838
|
-
};
|
|
839
|
-
this.proforma = {
|
|
840
|
-
_path: "/proforma",
|
|
841
|
-
find: async (params) => {
|
|
842
|
-
let res = await this._fetch(
|
|
843
|
-
this.svAPIEndpoint,
|
|
844
|
-
this.proforma._path,
|
|
845
|
-
params
|
|
846
|
-
);
|
|
847
|
-
return res;
|
|
848
|
-
},
|
|
849
|
-
get: async (id, params) => {
|
|
850
|
-
return await this._fetch(
|
|
851
|
-
this.svAPIEndpoint,
|
|
852
|
-
this.proforma._path + `/${id}`,
|
|
853
|
-
params
|
|
854
|
-
);
|
|
855
|
-
},
|
|
856
|
-
create: async (body) => {
|
|
857
|
-
let res = await this._create(
|
|
858
|
-
this.svAPIEndpoint,
|
|
859
|
-
this.proforma._path,
|
|
860
|
-
body
|
|
861
|
-
);
|
|
862
|
-
return res;
|
|
863
|
-
},
|
|
864
|
-
update: async (id, body) => {
|
|
865
|
-
let res = await this._update(
|
|
866
|
-
this.svAPIEndpoint,
|
|
867
|
-
this.proforma._path + `/${id}`,
|
|
868
|
-
body
|
|
869
|
-
);
|
|
870
|
-
return res;
|
|
871
|
-
},
|
|
872
|
-
};
|
|
873
|
-
this.payment = {
|
|
874
|
-
_path: "/payments",
|
|
875
|
-
find: async (params) => {
|
|
876
|
-
let res = await this._fetch(
|
|
877
|
-
this.svAPIEndpoint,
|
|
878
|
-
this.payment._path,
|
|
879
|
-
params
|
|
880
|
-
);
|
|
881
|
-
return res;
|
|
882
|
-
},
|
|
883
|
-
get: async (id, params) => {
|
|
884
|
-
return await this._fetch(
|
|
885
|
-
this.svAPIEndpoint,
|
|
886
|
-
this.payment._path + `/${id}`,
|
|
887
|
-
params
|
|
888
|
-
);
|
|
889
|
-
},
|
|
890
|
-
create: async (body) => {
|
|
891
|
-
let res = await this._create(
|
|
892
|
-
this.svAPIEndpoint,
|
|
893
|
-
this.payment._path,
|
|
894
|
-
body
|
|
895
|
-
);
|
|
896
|
-
return res;
|
|
897
|
-
},
|
|
898
|
-
update: async (id, body) => {
|
|
899
|
-
let res = await this._update(
|
|
900
|
-
this.svAPIEndpoint,
|
|
901
|
-
this.payment._path + `/${id}`,
|
|
902
|
-
body
|
|
903
|
-
);
|
|
904
|
-
return res;
|
|
905
|
-
},
|
|
906
|
-
};
|
|
907
|
-
this.transfer = {
|
|
908
|
-
_path: "/transfer",
|
|
909
|
-
find: async (params) => {
|
|
910
|
-
let res = await this._fetch(
|
|
911
|
-
this.svAPIEndpoint,
|
|
912
|
-
this.transfer._path,
|
|
913
|
-
params
|
|
914
|
-
);
|
|
915
|
-
return res;
|
|
916
|
-
},
|
|
917
|
-
get: async (id, params) => {
|
|
918
|
-
return await this._fetch(
|
|
919
|
-
this.svAPIEndpoint,
|
|
920
|
-
this.transfer._path + `/${id}`,
|
|
921
|
-
params
|
|
922
|
-
);
|
|
923
|
-
},
|
|
924
|
-
create: async (body) => {
|
|
925
|
-
let res = await this._create(
|
|
926
|
-
this.svAPIEndpoint,
|
|
927
|
-
this.transfer._path,
|
|
928
|
-
body
|
|
929
|
-
);
|
|
930
|
-
return res;
|
|
931
|
-
},
|
|
932
|
-
update: async (id, body) => {
|
|
933
|
-
let res = await this._update(
|
|
934
|
-
this.svAPIEndpoint,
|
|
935
|
-
this.transfer._path + `/${id}`,
|
|
936
|
-
body
|
|
937
|
-
);
|
|
938
|
-
return res;
|
|
939
|
-
},
|
|
940
|
-
};
|
|
941
|
-
this.adjustInventory = {
|
|
942
|
-
_path: "/adjust-inventory",
|
|
943
|
-
find: async (params) => {
|
|
944
|
-
let res = await this._fetch(
|
|
945
|
-
this.svAPIEndpoint,
|
|
946
|
-
this.adjustInventory._path,
|
|
947
|
-
params
|
|
948
|
-
);
|
|
949
|
-
return res;
|
|
950
|
-
},
|
|
951
|
-
get: async (id, params) => {
|
|
952
|
-
return await this._fetch(
|
|
953
|
-
this.svAPIEndpoint,
|
|
954
|
-
this.adjustInventory._path + `/${id}`,
|
|
955
|
-
params
|
|
956
|
-
);
|
|
957
|
-
},
|
|
958
|
-
create: async (body) => {
|
|
959
|
-
let res = await this._create(
|
|
960
|
-
this.svAPIEndpoint,
|
|
961
|
-
this.adjustInventory._path,
|
|
962
|
-
body
|
|
963
|
-
);
|
|
964
|
-
return res;
|
|
965
|
-
},
|
|
966
|
-
};
|
|
967
|
-
this.inventory = {
|
|
968
|
-
_path: "/inventory",
|
|
969
|
-
find: async (params) => {
|
|
970
|
-
let res = await this._fetch(
|
|
971
|
-
this.svAPIEndpoint,
|
|
972
|
-
this.inventory._path,
|
|
973
|
-
params
|
|
974
|
-
);
|
|
975
|
-
return res;
|
|
976
|
-
},
|
|
977
|
-
};
|
|
978
|
-
this.integrationApp = {
|
|
979
|
-
_path: "/integration-app",
|
|
980
|
-
find: async (params) => {
|
|
981
|
-
let res = await this._fetch(
|
|
982
|
-
this.svAPIEndpoint,
|
|
983
|
-
this.integrationApp._path,
|
|
984
|
-
params
|
|
985
|
-
);
|
|
986
|
-
return res;
|
|
987
|
-
},
|
|
988
|
-
get: async (id, params) => {
|
|
989
|
-
return await this._fetch(
|
|
990
|
-
this.svAPIEndpoint,
|
|
991
|
-
this.integrationApp._path + `/${id}`,
|
|
992
|
-
params
|
|
993
|
-
);
|
|
994
|
-
},
|
|
995
|
-
create: async (body) => {
|
|
996
|
-
let res = await this._create(
|
|
997
|
-
this.svAPIEndpoint,
|
|
998
|
-
this.integrationApp._path,
|
|
999
|
-
body
|
|
1000
|
-
);
|
|
1001
|
-
return res;
|
|
1002
|
-
},
|
|
1003
|
-
update: async (id, body) => {
|
|
1004
|
-
let res = await this._update(
|
|
1005
|
-
this.svAPIEndpoint,
|
|
1006
|
-
this.integrationApp._path + `/${id}`,
|
|
1007
|
-
body
|
|
1008
|
-
);
|
|
1009
|
-
return res;
|
|
1010
|
-
},
|
|
1011
|
-
};
|
|
1012
|
-
this.joinActionsWebHook = {
|
|
1013
|
-
_path: "/svix-integration",
|
|
1014
|
-
update: async (id, body) => {
|
|
1015
|
-
let res = await this._update(
|
|
1016
|
-
this.svAPIEndpoint,
|
|
1017
|
-
this.joinActionsWebHook._path,
|
|
1018
|
-
body
|
|
1019
|
-
);
|
|
1020
|
-
return res;
|
|
1021
|
-
},
|
|
1022
|
-
};
|
|
1023
|
-
this.svAPIEndpoint =
|
|
1024
|
-
!options?.env || options?.env == "production"
|
|
1025
|
-
? "https://sv.api.repzo.me"
|
|
1026
|
-
: options?.env == "staging"
|
|
1027
|
-
? "https://staging.sv.api.repzo.me"
|
|
1028
|
-
: options?.env == "local"
|
|
1029
|
-
? "http://localhost:3030"
|
|
1030
|
-
: "";
|
|
1031
|
-
this.headers = {
|
|
1032
|
-
"api-key": apiKey,
|
|
1033
|
-
"Content-Type": "application/json",
|
|
1034
|
-
Accept: "application/json",
|
|
1035
|
-
};
|
|
1036
|
-
if (options?.headers) Object.assign(this.headers, options.headers);
|
|
1037
|
-
}
|
|
1038
|
-
async _fetch(baseUrl, path, params) {
|
|
1039
|
-
let res = await axios.get(baseUrl + path, {
|
|
1040
|
-
params,
|
|
1041
|
-
headers: this.headers,
|
|
1042
|
-
});
|
|
1043
|
-
return res.data;
|
|
1044
|
-
}
|
|
1045
|
-
async _create(baseUrl, path, body, params) {
|
|
1046
|
-
let res = await axios.post(baseUrl + path, body, {
|
|
1047
|
-
params,
|
|
1048
|
-
headers: this.headers,
|
|
1049
|
-
});
|
|
1050
|
-
return res.data;
|
|
1051
|
-
}
|
|
1052
|
-
async _update(baseUrl, path, body, params) {
|
|
1053
|
-
let res = await axios.put(baseUrl + path, body, {
|
|
1054
|
-
params,
|
|
1055
|
-
headers: this.headers,
|
|
1056
|
-
});
|
|
1057
|
-
return res.data;
|
|
1058
|
-
}
|
|
1059
|
-
async _delete(baseUrl, path, params) {
|
|
1060
|
-
let res = await axios.delete(baseUrl + path, {
|
|
1061
|
-
params,
|
|
1062
|
-
headers: this.headers,
|
|
1063
|
-
});
|
|
1064
|
-
return res.data;
|
|
1065
|
-
}
|
|
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: "/pricelists",
|
|
271
|
+
find: async (params) => {
|
|
272
|
+
let res = await this._fetch(this.svAPIEndpoint, this.priceListItem._path, params);
|
|
273
|
+
return res;
|
|
274
|
+
},
|
|
275
|
+
get: async (id) => {
|
|
276
|
+
return await this._fetch(this.svAPIEndpoint, this.priceListItem._path + `/${id}`);
|
|
277
|
+
},
|
|
278
|
+
create: async (body) => {
|
|
279
|
+
let res = await this._create(this.svAPIEndpoint, this.priceListItem._path, body);
|
|
280
|
+
return res;
|
|
281
|
+
},
|
|
282
|
+
update: async (id, body) => {
|
|
283
|
+
let res = await this._update(this.svAPIEndpoint, this.priceListItem._path + `/${id}`, body);
|
|
284
|
+
return res;
|
|
285
|
+
},
|
|
286
|
+
remove: async (id) => {
|
|
287
|
+
let res = await this._delete(this.svAPIEndpoint, this.priceListItem._path + `/${id}`);
|
|
288
|
+
return res;
|
|
289
|
+
},
|
|
290
|
+
};
|
|
291
|
+
this.team = {
|
|
292
|
+
_path: "/teams",
|
|
293
|
+
find: async (params) => {
|
|
294
|
+
let res = await this._fetch(this.svAPIEndpoint, this.team._path, params);
|
|
295
|
+
return res;
|
|
296
|
+
},
|
|
297
|
+
get: async (id) => {
|
|
298
|
+
return await this._fetch(this.svAPIEndpoint, this.team._path + `/${id}`);
|
|
299
|
+
},
|
|
300
|
+
create: async (body) => {
|
|
301
|
+
let res = await this._create(this.svAPIEndpoint, this.team._path, body);
|
|
302
|
+
return res;
|
|
303
|
+
},
|
|
304
|
+
update: async (id, body) => {
|
|
305
|
+
let res = await this._update(this.svAPIEndpoint, this.team._path + `/${id}`, body);
|
|
306
|
+
return res;
|
|
307
|
+
},
|
|
308
|
+
remove: async (id) => {
|
|
309
|
+
let res = await this._delete(this.svAPIEndpoint, this.team._path + `/${id}`);
|
|
310
|
+
return res;
|
|
311
|
+
},
|
|
312
|
+
};
|
|
313
|
+
this.rep = {
|
|
314
|
+
_path: "/rep",
|
|
315
|
+
find: async (params) => {
|
|
316
|
+
let res = await this._fetch(this.svAPIEndpoint, this.rep._path, params);
|
|
317
|
+
return res;
|
|
318
|
+
},
|
|
319
|
+
get: async (id, params) => {
|
|
320
|
+
return await this._fetch(this.svAPIEndpoint, this.rep._path + `/${id}`, params);
|
|
321
|
+
},
|
|
322
|
+
create: async (body) => {
|
|
323
|
+
let res = await this._create(this.svAPIEndpoint, this.rep._path, body);
|
|
324
|
+
return res;
|
|
325
|
+
},
|
|
326
|
+
update: async (id, body) => {
|
|
327
|
+
let res = await this._update(this.svAPIEndpoint, this.rep._path + `/${id}`, body);
|
|
328
|
+
return res;
|
|
329
|
+
},
|
|
330
|
+
remove: async (id) => {
|
|
331
|
+
let res = await this._delete(this.svAPIEndpoint, this.rep._path + `/${id}`);
|
|
332
|
+
return res;
|
|
333
|
+
},
|
|
334
|
+
};
|
|
335
|
+
this.tag = {
|
|
336
|
+
_path: "/tag",
|
|
337
|
+
find: async (params) => {
|
|
338
|
+
let res = await this._fetch(this.svAPIEndpoint, this.tag._path, params);
|
|
339
|
+
return res;
|
|
340
|
+
},
|
|
341
|
+
get: async (id) => {
|
|
342
|
+
return await this._fetch(this.svAPIEndpoint, this.tag._path + `/${id}`);
|
|
343
|
+
},
|
|
344
|
+
create: async (body) => {
|
|
345
|
+
let res = await this._create(this.svAPIEndpoint, this.tag._path, body);
|
|
346
|
+
return res;
|
|
347
|
+
},
|
|
348
|
+
update: async (id, body) => {
|
|
349
|
+
let res = await this._update(this.svAPIEndpoint, this.tag._path + `/${id}`, body);
|
|
350
|
+
return res;
|
|
351
|
+
},
|
|
352
|
+
remove: async (id) => {
|
|
353
|
+
let res = await this._delete(this.svAPIEndpoint, this.tag._path + `/${id}`);
|
|
354
|
+
return res;
|
|
355
|
+
},
|
|
356
|
+
};
|
|
357
|
+
this.warehouse = {
|
|
358
|
+
_path: "/warehouse",
|
|
359
|
+
find: async (params) => {
|
|
360
|
+
let res = await this._fetch(this.svAPIEndpoint, this.warehouse._path, params);
|
|
361
|
+
return res;
|
|
362
|
+
},
|
|
363
|
+
get: async (id) => {
|
|
364
|
+
return await this._fetch(this.svAPIEndpoint, this.warehouse._path + `/${id}`);
|
|
365
|
+
},
|
|
366
|
+
create: async (body) => {
|
|
367
|
+
let res = await this._create(this.svAPIEndpoint, this.warehouse._path, body);
|
|
368
|
+
return res;
|
|
369
|
+
},
|
|
370
|
+
update: async (id, body) => {
|
|
371
|
+
let res = await this._update(this.svAPIEndpoint, this.warehouse._path + `/${id}`, body);
|
|
372
|
+
return res;
|
|
373
|
+
},
|
|
374
|
+
remove: async (id) => {
|
|
375
|
+
let res = await this._delete(this.svAPIEndpoint, this.warehouse._path + `/${id}`);
|
|
376
|
+
return res;
|
|
377
|
+
},
|
|
378
|
+
};
|
|
379
|
+
this.channel = {
|
|
380
|
+
_path: "/client-channel",
|
|
381
|
+
find: async (params) => {
|
|
382
|
+
let res = await this._fetch(this.svAPIEndpoint, this.channel._path, params);
|
|
383
|
+
return res;
|
|
384
|
+
},
|
|
385
|
+
get: async (id) => {
|
|
386
|
+
return await this._fetch(this.svAPIEndpoint, this.channel._path + `/${id}`);
|
|
387
|
+
},
|
|
388
|
+
create: async (body) => {
|
|
389
|
+
let res = await this._create(this.svAPIEndpoint, this.channel._path, body);
|
|
390
|
+
return res;
|
|
391
|
+
},
|
|
392
|
+
update: async (id, body) => {
|
|
393
|
+
let res = await this._update(this.svAPIEndpoint, this.channel._path + `/${id}`, body);
|
|
394
|
+
return res;
|
|
395
|
+
},
|
|
396
|
+
remove: async (id) => {
|
|
397
|
+
let res = await this._delete(this.svAPIEndpoint, this.channel._path + `/${id}`);
|
|
398
|
+
return res;
|
|
399
|
+
},
|
|
400
|
+
};
|
|
401
|
+
this.paymentTerm = {
|
|
402
|
+
_path: "/paymentterms",
|
|
403
|
+
find: async (params) => {
|
|
404
|
+
let res = await this._fetch(this.svAPIEndpoint, this.paymentTerm._path, params);
|
|
405
|
+
return res;
|
|
406
|
+
},
|
|
407
|
+
get: async (id) => {
|
|
408
|
+
return await this._fetch(this.svAPIEndpoint, this.paymentTerm._path + `/${id}`);
|
|
409
|
+
},
|
|
410
|
+
create: async (body) => {
|
|
411
|
+
let res = await this._create(this.svAPIEndpoint, this.paymentTerm._path, body);
|
|
412
|
+
return res;
|
|
413
|
+
},
|
|
414
|
+
update: async (id, body) => {
|
|
415
|
+
let res = await this._update(this.svAPIEndpoint, this.paymentTerm._path + `/${id}`, body);
|
|
416
|
+
return res;
|
|
417
|
+
},
|
|
418
|
+
remove: async (id) => {
|
|
419
|
+
let res = await this._delete(this.svAPIEndpoint, this.paymentTerm._path + `/${id}`);
|
|
420
|
+
return res;
|
|
421
|
+
},
|
|
422
|
+
};
|
|
423
|
+
this.bank = {
|
|
424
|
+
_path: "/banks",
|
|
425
|
+
find: async (params) => {
|
|
426
|
+
let res = await this._fetch(this.svAPIEndpoint, this.bank._path, params);
|
|
427
|
+
return res;
|
|
428
|
+
},
|
|
429
|
+
get: async (id) => {
|
|
430
|
+
return await this._fetch(this.svAPIEndpoint, this.bank._path + `/${id}`);
|
|
431
|
+
},
|
|
432
|
+
create: async (body) => {
|
|
433
|
+
let res = await this._create(this.svAPIEndpoint, this.bank._path, body);
|
|
434
|
+
return res;
|
|
435
|
+
},
|
|
436
|
+
update: async (id, body) => {
|
|
437
|
+
let res = await this._update(this.svAPIEndpoint, this.bank._path + `/${id}`, body);
|
|
438
|
+
return res;
|
|
439
|
+
},
|
|
440
|
+
};
|
|
441
|
+
this.customStatus = {
|
|
442
|
+
_path: "/custom-status",
|
|
443
|
+
find: async (params) => {
|
|
444
|
+
let res = await this._fetch(this.svAPIEndpoint, this.customStatus._path, params);
|
|
445
|
+
return res;
|
|
446
|
+
},
|
|
447
|
+
get: async (id) => {
|
|
448
|
+
return await this._fetch(this.svAPIEndpoint, this.customStatus._path + `/${id}`);
|
|
449
|
+
},
|
|
450
|
+
create: async (body) => {
|
|
451
|
+
let res = await this._create(this.svAPIEndpoint, this.customStatus._path, body);
|
|
452
|
+
return res;
|
|
453
|
+
},
|
|
454
|
+
update: async (id, body) => {
|
|
455
|
+
let res = await this._update(this.svAPIEndpoint, this.customStatus._path + `/${id}`, body);
|
|
456
|
+
return res;
|
|
457
|
+
},
|
|
458
|
+
remove: async (id) => {
|
|
459
|
+
let res = await this._delete(this.svAPIEndpoint, this.customStatus._path + `/${id}`);
|
|
460
|
+
return res;
|
|
461
|
+
},
|
|
462
|
+
};
|
|
463
|
+
this.invoice = {
|
|
464
|
+
_path: "/fullinvoices",
|
|
465
|
+
find: async (params) => {
|
|
466
|
+
let res = await this._fetch(this.svAPIEndpoint, this.invoice._path, params);
|
|
467
|
+
return res;
|
|
468
|
+
},
|
|
469
|
+
get: async (id, params) => {
|
|
470
|
+
return await this._fetch(this.svAPIEndpoint, this.invoice._path + `/${id}`, params);
|
|
471
|
+
},
|
|
472
|
+
create: async (body) => {
|
|
473
|
+
let res = await this._create(this.svAPIEndpoint, this.invoice._path, body);
|
|
474
|
+
return res;
|
|
475
|
+
},
|
|
476
|
+
update: async (id, body) => {
|
|
477
|
+
let res = await this._update(this.svAPIEndpoint, this.invoice._path + `/${id}`, body);
|
|
478
|
+
return res;
|
|
479
|
+
},
|
|
480
|
+
};
|
|
481
|
+
this.proforma = {
|
|
482
|
+
_path: "/proforma",
|
|
483
|
+
find: async (params) => {
|
|
484
|
+
let res = await this._fetch(this.svAPIEndpoint, this.proforma._path, params);
|
|
485
|
+
return res;
|
|
486
|
+
},
|
|
487
|
+
get: async (id, params) => {
|
|
488
|
+
return await this._fetch(this.svAPIEndpoint, this.proforma._path + `/${id}`, params);
|
|
489
|
+
},
|
|
490
|
+
create: async (body) => {
|
|
491
|
+
let res = await this._create(this.svAPIEndpoint, this.proforma._path, body);
|
|
492
|
+
return res;
|
|
493
|
+
},
|
|
494
|
+
update: async (id, body) => {
|
|
495
|
+
let res = await this._update(this.svAPIEndpoint, this.proforma._path + `/${id}`, body);
|
|
496
|
+
return res;
|
|
497
|
+
},
|
|
498
|
+
};
|
|
499
|
+
this.payment = {
|
|
500
|
+
_path: "/payments",
|
|
501
|
+
find: async (params) => {
|
|
502
|
+
let res = await this._fetch(this.svAPIEndpoint, this.payment._path, params);
|
|
503
|
+
return res;
|
|
504
|
+
},
|
|
505
|
+
get: async (id, params) => {
|
|
506
|
+
return await this._fetch(this.svAPIEndpoint, this.payment._path + `/${id}`, params);
|
|
507
|
+
},
|
|
508
|
+
create: async (body) => {
|
|
509
|
+
let res = await this._create(this.svAPIEndpoint, this.payment._path, body);
|
|
510
|
+
return res;
|
|
511
|
+
},
|
|
512
|
+
update: async (id, body) => {
|
|
513
|
+
let res = await this._update(this.svAPIEndpoint, this.payment._path + `/${id}`, body);
|
|
514
|
+
return res;
|
|
515
|
+
},
|
|
516
|
+
};
|
|
517
|
+
this.transfer = {
|
|
518
|
+
_path: "/transfer",
|
|
519
|
+
find: async (params) => {
|
|
520
|
+
let res = await this._fetch(this.svAPIEndpoint, this.transfer._path, params);
|
|
521
|
+
return res;
|
|
522
|
+
},
|
|
523
|
+
get: async (id, params) => {
|
|
524
|
+
return await this._fetch(this.svAPIEndpoint, this.transfer._path + `/${id}`, params);
|
|
525
|
+
},
|
|
526
|
+
create: async (body) => {
|
|
527
|
+
let res = await this._create(this.svAPIEndpoint, this.transfer._path, body);
|
|
528
|
+
return res;
|
|
529
|
+
},
|
|
530
|
+
update: async (id, body) => {
|
|
531
|
+
let res = await this._update(this.svAPIEndpoint, this.transfer._path + `/${id}`, body);
|
|
532
|
+
return res;
|
|
533
|
+
},
|
|
534
|
+
};
|
|
535
|
+
this.adjustInventory = {
|
|
536
|
+
_path: "/adjust-inventory",
|
|
537
|
+
find: async (params) => {
|
|
538
|
+
let res = await this._fetch(this.svAPIEndpoint, this.adjustInventory._path, params);
|
|
539
|
+
return res;
|
|
540
|
+
},
|
|
541
|
+
get: async (id, params) => {
|
|
542
|
+
return await this._fetch(this.svAPIEndpoint, this.adjustInventory._path + `/${id}`, params);
|
|
543
|
+
},
|
|
544
|
+
create: async (body) => {
|
|
545
|
+
let res = await this._create(this.svAPIEndpoint, this.adjustInventory._path, body);
|
|
546
|
+
return res;
|
|
547
|
+
},
|
|
548
|
+
};
|
|
549
|
+
this.inventory = {
|
|
550
|
+
_path: "/inventory",
|
|
551
|
+
find: async (params) => {
|
|
552
|
+
let res = await this._fetch(this.svAPIEndpoint, this.inventory._path, params);
|
|
553
|
+
return res;
|
|
554
|
+
},
|
|
555
|
+
};
|
|
556
|
+
this.integrationApp = {
|
|
557
|
+
_path: "/integration-app",
|
|
558
|
+
find: async (params) => {
|
|
559
|
+
let res = await this._fetch(this.svAPIEndpoint, this.integrationApp._path, params);
|
|
560
|
+
return res;
|
|
561
|
+
},
|
|
562
|
+
get: async (id, params) => {
|
|
563
|
+
return await this._fetch(this.svAPIEndpoint, this.integrationApp._path + `/${id}`, params);
|
|
564
|
+
},
|
|
565
|
+
create: async (body) => {
|
|
566
|
+
let res = await this._create(this.svAPIEndpoint, this.integrationApp._path, body);
|
|
567
|
+
return res;
|
|
568
|
+
},
|
|
569
|
+
update: async (id, body) => {
|
|
570
|
+
let res = await this._update(this.svAPIEndpoint, this.integrationApp._path + `/${id}`, body);
|
|
571
|
+
return res;
|
|
572
|
+
},
|
|
573
|
+
};
|
|
574
|
+
this.joinActionsWebHook = {
|
|
575
|
+
_path: "/svix-integration",
|
|
576
|
+
update: async (id, body) => {
|
|
577
|
+
let res = await this._update(this.svAPIEndpoint, this.joinActionsWebHook._path, body);
|
|
578
|
+
return res;
|
|
579
|
+
},
|
|
580
|
+
};
|
|
581
|
+
this.svAPIEndpoint =
|
|
582
|
+
!options?.env || options?.env == "production"
|
|
583
|
+
? "https://sv.api.repzo.me"
|
|
584
|
+
: options?.env == "staging"
|
|
585
|
+
? "https://staging.sv.api.repzo.me"
|
|
586
|
+
: options?.env == "local"
|
|
587
|
+
? "http://localhost:3030"
|
|
588
|
+
: "";
|
|
589
|
+
this.headers = {
|
|
590
|
+
"api-key": apiKey,
|
|
591
|
+
"Content-Type": "application/json",
|
|
592
|
+
Accept: "application/json",
|
|
593
|
+
};
|
|
594
|
+
if (options?.headers)
|
|
595
|
+
Object.assign(this.headers, options.headers);
|
|
596
|
+
}
|
|
597
|
+
async _fetch(baseUrl, path, params) {
|
|
598
|
+
let res = await axios.get(baseUrl + path, {
|
|
599
|
+
params,
|
|
600
|
+
headers: this.headers,
|
|
601
|
+
});
|
|
602
|
+
return res.data;
|
|
603
|
+
}
|
|
604
|
+
async _create(baseUrl, path, body, params) {
|
|
605
|
+
let res = await axios.post(baseUrl + path, body, {
|
|
606
|
+
params,
|
|
607
|
+
headers: this.headers,
|
|
608
|
+
});
|
|
609
|
+
return res.data;
|
|
610
|
+
}
|
|
611
|
+
async _update(baseUrl, path, body, params) {
|
|
612
|
+
let res = await axios.put(baseUrl + path, body, {
|
|
613
|
+
params,
|
|
614
|
+
headers: this.headers,
|
|
615
|
+
});
|
|
616
|
+
return res.data;
|
|
617
|
+
}
|
|
618
|
+
async _delete(baseUrl, path, params) {
|
|
619
|
+
let res = await axios.delete(baseUrl + path, {
|
|
620
|
+
params,
|
|
621
|
+
headers: this.headers,
|
|
622
|
+
});
|
|
623
|
+
return res.data;
|
|
624
|
+
}
|
|
1066
625
|
}
|
|
1067
626
|
Repzo.ActionLogs = class {
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
}
|
|
1082
|
-
async load(sync_id) {
|
|
1083
|
-
console.log(sync_id);
|
|
1084
|
-
const params = { sync_id: sync_id };
|
|
1085
|
-
const res = await this.superThis._fetch(
|
|
1086
|
-
this.superThis.svAPIEndpoint,
|
|
1087
|
-
this._path,
|
|
1088
|
-
params
|
|
1089
|
-
);
|
|
1090
|
-
if (res?.data?.length)
|
|
1091
|
-
throw new Error(`Command Log Not found, sync_id: ${sync_id}`);
|
|
1092
|
-
const action_log = res.data[0];
|
|
1093
|
-
this.sync_id = sync_id;
|
|
1094
|
-
this.details = action_log.details;
|
|
1095
|
-
this.status = action_log.status;
|
|
1096
|
-
this.error = action_log.error;
|
|
1097
|
-
this.start_time = action_log.start_time;
|
|
1098
|
-
this.body = action_log.body;
|
|
1099
|
-
this.meta = action_log.meta;
|
|
1100
|
-
this.message = action_log.message;
|
|
1101
|
-
this.app_id = action_log._id;
|
|
1102
|
-
this.available_app_id = action_log.available_app_id;
|
|
1103
|
-
this.available_app_name = action_log.available_app_name;
|
|
1104
|
-
this.company_namespace = action_log.company_namespace;
|
|
1105
|
-
this.action = action_log.action;
|
|
1106
|
-
this.isOld = true;
|
|
1107
|
-
return this;
|
|
1108
|
-
}
|
|
1109
|
-
setStatus(status, error) {
|
|
1110
|
-
this.details.push({
|
|
1111
|
-
timestamp: Date.now(),
|
|
1112
|
-
content: `status was changed from ${this.status} to ${status}`,
|
|
1113
|
-
});
|
|
1114
|
-
this.status = status;
|
|
1115
|
-
if (error) {
|
|
1116
|
-
this.error = error;
|
|
1117
|
-
}
|
|
1118
|
-
return this;
|
|
1119
|
-
}
|
|
1120
|
-
setBody(body) {
|
|
1121
|
-
this.body = body;
|
|
1122
|
-
return this;
|
|
1123
|
-
}
|
|
1124
|
-
setMeta(meta) {
|
|
1125
|
-
this.meta = meta;
|
|
1126
|
-
return this;
|
|
1127
|
-
}
|
|
1128
|
-
async commit() {
|
|
1129
|
-
let doc = {
|
|
1130
|
-
available_app_name: this.available_app_name,
|
|
1131
|
-
available_app_id: this.available_app_id,
|
|
1132
|
-
app_id: this.app_id,
|
|
1133
|
-
action: this.action,
|
|
1134
|
-
company_namespace: this.company_namespace,
|
|
1135
|
-
status: this.status,
|
|
1136
|
-
error: this.error ? this.error : undefined,
|
|
1137
|
-
start_time: this.start_time,
|
|
1138
|
-
end_time: Date.now(),
|
|
1139
|
-
total_time: Date.now() - this.start_time,
|
|
1140
|
-
body: this.body,
|
|
1141
|
-
meta: this.meta,
|
|
1142
|
-
message: this.message,
|
|
1143
|
-
details: this.details,
|
|
1144
|
-
sync_id: this.sync_id,
|
|
1145
|
-
};
|
|
1146
|
-
try {
|
|
1147
|
-
const res = await this.superThis._create(
|
|
1148
|
-
this.superThis.svAPIEndpoint,
|
|
1149
|
-
this._path,
|
|
1150
|
-
doc
|
|
1151
|
-
);
|
|
1152
|
-
} catch (e) {
|
|
1153
|
-
console.error(e);
|
|
627
|
+
constructor(superThis, sync_id) {
|
|
628
|
+
this.superThis = superThis;
|
|
629
|
+
this._path = "/integration-action-log";
|
|
630
|
+
this.available_app_name = "";
|
|
631
|
+
this.available_app_id = "";
|
|
632
|
+
this.app_id = "";
|
|
633
|
+
this.action = "";
|
|
634
|
+
this.start_time = Date.now();
|
|
635
|
+
this.status = "processing";
|
|
636
|
+
this.message = "Log Created";
|
|
637
|
+
this.details = [];
|
|
638
|
+
this.sync_id = sync_id;
|
|
639
|
+
this.isOld = true;
|
|
1154
640
|
}
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
this.message = detail;
|
|
1163
|
-
if (meta) d.meta = meta;
|
|
1164
|
-
this.details.push(d);
|
|
1165
|
-
return this;
|
|
1166
|
-
}
|
|
1167
|
-
};
|
|
1168
|
-
Repzo.CommandLog = class {
|
|
1169
|
-
constructor(superThis, app, command, trigger) {
|
|
1170
|
-
this.superThis = superThis;
|
|
1171
|
-
this._path = "/integration-command-log";
|
|
1172
|
-
this.app_id = app._id;
|
|
1173
|
-
this.available_app_id = app.available_app._id;
|
|
1174
|
-
this.available_app_name = app.available_app.name;
|
|
1175
|
-
this.company_namespace = app.company_namespace;
|
|
1176
|
-
this.start_time = Date.now();
|
|
1177
|
-
this.status = "received";
|
|
1178
|
-
this.message = "Request received";
|
|
1179
|
-
this.command = command;
|
|
1180
|
-
this.details = [{ timestamp: Date.now(), content: "Request received" }];
|
|
1181
|
-
this.sync_id = uuid();
|
|
1182
|
-
this.isOld = false;
|
|
1183
|
-
this.isPrioritized = false;
|
|
1184
|
-
this.retries = 1;
|
|
1185
|
-
this.trigger = trigger;
|
|
1186
|
-
this.onGoing = true;
|
|
1187
|
-
}
|
|
1188
|
-
async load(sync_id, retries) {
|
|
1189
|
-
if (sync_id) {
|
|
1190
|
-
const params = { sync_id: sync_id };
|
|
1191
|
-
const res = await this.superThis._fetch(
|
|
1192
|
-
this.superThis.svAPIEndpoint,
|
|
1193
|
-
this._path,
|
|
1194
|
-
params
|
|
1195
|
-
);
|
|
1196
|
-
if (res?.data?.length)
|
|
1197
|
-
throw new Error(`Command Log Not found, sync_id: ${sync_id}`);
|
|
1198
|
-
const command_log = res.data[0];
|
|
1199
|
-
if (command_log) {
|
|
641
|
+
async load(sync_id) {
|
|
642
|
+
console.log(sync_id);
|
|
643
|
+
const params = { sync_id: sync_id };
|
|
644
|
+
const res = await this.superThis._fetch(this.superThis.svAPIEndpoint, this._path, params);
|
|
645
|
+
if (res?.data?.length)
|
|
646
|
+
throw new Error(`Command Log Not found, sync_id: ${sync_id}`);
|
|
647
|
+
const action_log = res.data[0];
|
|
1200
648
|
this.sync_id = sync_id;
|
|
1201
|
-
this.details =
|
|
1202
|
-
this.status =
|
|
1203
|
-
this.error =
|
|
1204
|
-
this.start_time =
|
|
1205
|
-
this.body =
|
|
1206
|
-
this.meta =
|
|
1207
|
-
this.message =
|
|
1208
|
-
this.
|
|
1209
|
-
|
|
649
|
+
this.details = action_log.details;
|
|
650
|
+
this.status = action_log.status;
|
|
651
|
+
this.error = action_log.error;
|
|
652
|
+
this.start_time = action_log.start_time;
|
|
653
|
+
this.body = action_log.body;
|
|
654
|
+
this.meta = action_log.meta;
|
|
655
|
+
this.message = action_log.message;
|
|
656
|
+
this.app_id = action_log._id;
|
|
657
|
+
this.available_app_id = action_log.available_app_id;
|
|
658
|
+
this.available_app_name = action_log.available_app_name;
|
|
659
|
+
this.company_namespace = action_log.company_namespace;
|
|
660
|
+
this.action = action_log.action;
|
|
1210
661
|
this.isOld = true;
|
|
1211
|
-
this
|
|
1212
|
-
this.succeededAt = command_log.succeededAt;
|
|
1213
|
-
this.skippedAt = command_log.skippedAt;
|
|
1214
|
-
this.receivedAt = command_log.receivedAt;
|
|
1215
|
-
this.processedAt = command_log.processedAt;
|
|
1216
|
-
this.onGoing = command_log.onGoing || false;
|
|
1217
|
-
this.trigger = command_log.trigger;
|
|
1218
|
-
// this.priority = command_log.priority
|
|
1219
|
-
// ? command_log.priority
|
|
1220
|
-
// : this.priority
|
|
1221
|
-
// ? this.priority
|
|
1222
|
-
// : undefined;
|
|
1223
|
-
}
|
|
662
|
+
return this;
|
|
1224
663
|
}
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
664
|
+
setStatus(status, error) {
|
|
665
|
+
this.details.push({
|
|
666
|
+
timestamp: Date.now(),
|
|
667
|
+
content: `status was changed from ${this.status} to ${status}`,
|
|
668
|
+
});
|
|
669
|
+
this.status = status;
|
|
670
|
+
if (error) {
|
|
671
|
+
this.error = error;
|
|
672
|
+
}
|
|
673
|
+
return this;
|
|
1232
674
|
}
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
this
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
this
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
675
|
+
setBody(body) {
|
|
676
|
+
this.body = body;
|
|
677
|
+
return this;
|
|
678
|
+
}
|
|
679
|
+
setMeta(meta) {
|
|
680
|
+
this.meta = meta;
|
|
681
|
+
return this;
|
|
682
|
+
}
|
|
683
|
+
async commit() {
|
|
684
|
+
let doc = {
|
|
685
|
+
available_app_name: this.available_app_name,
|
|
686
|
+
available_app_id: this.available_app_id,
|
|
687
|
+
app_id: this.app_id,
|
|
688
|
+
action: this.action,
|
|
689
|
+
company_namespace: this.company_namespace,
|
|
690
|
+
status: this.status,
|
|
691
|
+
error: this.error ? this.error : undefined,
|
|
692
|
+
start_time: this.start_time,
|
|
693
|
+
end_time: Date.now(),
|
|
694
|
+
total_time: Date.now() - this.start_time,
|
|
695
|
+
body: this.body,
|
|
696
|
+
meta: this.meta,
|
|
697
|
+
message: this.message,
|
|
698
|
+
details: this.details,
|
|
699
|
+
sync_id: this.sync_id,
|
|
700
|
+
};
|
|
701
|
+
try {
|
|
702
|
+
const res = await this.superThis._create(this.superThis.svAPIEndpoint, this._path, doc);
|
|
703
|
+
}
|
|
704
|
+
catch (e) {
|
|
705
|
+
console.error(e);
|
|
706
|
+
}
|
|
707
|
+
return this;
|
|
708
|
+
}
|
|
709
|
+
addDetail(detail, meta) {
|
|
710
|
+
let d = {
|
|
711
|
+
timestamp: Date.now(),
|
|
712
|
+
content: detail,
|
|
713
|
+
};
|
|
714
|
+
this.message = detail;
|
|
715
|
+
if (meta)
|
|
716
|
+
d.meta = meta;
|
|
717
|
+
this.details.push(d);
|
|
718
|
+
return this;
|
|
719
|
+
}
|
|
720
|
+
};
|
|
721
|
+
Repzo.CommandLog = class {
|
|
722
|
+
constructor(superThis, app, command, trigger) {
|
|
723
|
+
this.superThis = superThis;
|
|
724
|
+
this._path = "/integration-command-log";
|
|
725
|
+
this.app_id = app._id;
|
|
726
|
+
this.available_app_id = app.available_app._id;
|
|
727
|
+
this.available_app_name = app.available_app.name;
|
|
728
|
+
this.company_namespace = app.company_namespace;
|
|
729
|
+
this.start_time = Date.now();
|
|
730
|
+
this.status = "received";
|
|
731
|
+
this.message = "Request received";
|
|
732
|
+
this.command = command;
|
|
733
|
+
this.details = [{ timestamp: Date.now(), content: "Request received" }];
|
|
734
|
+
this.sync_id = uuid();
|
|
735
|
+
this.isOld = false;
|
|
736
|
+
this.isPrioritized = false;
|
|
737
|
+
this.retries = 1;
|
|
738
|
+
this.trigger = trigger;
|
|
1248
739
|
this.onGoing = true;
|
|
1249
|
-
break;
|
|
1250
|
-
case "skipped":
|
|
1251
|
-
this.skippedAt = new Date();
|
|
1252
|
-
this.onGoing = false;
|
|
1253
|
-
break;
|
|
1254
|
-
case "success":
|
|
1255
|
-
this.succeededAt = new Date();
|
|
1256
|
-
this.onGoing = false;
|
|
1257
|
-
break;
|
|
1258
740
|
}
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
741
|
+
async load(sync_id, retries) {
|
|
742
|
+
if (sync_id) {
|
|
743
|
+
const params = { sync_id: sync_id };
|
|
744
|
+
const res = await this.superThis._fetch(this.superThis.svAPIEndpoint, this._path, params);
|
|
745
|
+
if (res?.data?.length)
|
|
746
|
+
throw new Error(`Command Log Not found, sync_id: ${sync_id}`);
|
|
747
|
+
const command_log = res.data[0];
|
|
748
|
+
if (command_log) {
|
|
749
|
+
this.sync_id = sync_id;
|
|
750
|
+
this.details = command_log.details;
|
|
751
|
+
this.status = command_log.status;
|
|
752
|
+
this.error = command_log.error;
|
|
753
|
+
this.start_time = command_log.start_time;
|
|
754
|
+
this.body = command_log.body;
|
|
755
|
+
this.meta = command_log.meta;
|
|
756
|
+
this.message = command_log.message;
|
|
757
|
+
this.retries =
|
|
758
|
+
retries !== undefined
|
|
759
|
+
? retries
|
|
760
|
+
: command_log.retries || this.retries; // retries !== undefined ? retries : command_log.retries;
|
|
761
|
+
this.isOld = true;
|
|
762
|
+
this.failedAt = command_log.failedAt;
|
|
763
|
+
this.succeededAt = command_log.succeededAt;
|
|
764
|
+
this.skippedAt = command_log.skippedAt;
|
|
765
|
+
this.receivedAt = command_log.receivedAt;
|
|
766
|
+
this.processedAt = command_log.processedAt;
|
|
767
|
+
this.onGoing = command_log.onGoing || false;
|
|
768
|
+
this.trigger = command_log.trigger;
|
|
769
|
+
// this.priority = command_log.priority
|
|
770
|
+
// ? command_log.priority
|
|
771
|
+
// : this.priority
|
|
772
|
+
// ? this.priority
|
|
773
|
+
// : undefined;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
return this;
|
|
777
|
+
}
|
|
778
|
+
setStatus(status, error) {
|
|
779
|
+
this.addDetail(`status was changed from ${this.status} to ${status}`);
|
|
780
|
+
this.status = status;
|
|
781
|
+
if (error) {
|
|
782
|
+
this.error = error;
|
|
783
|
+
}
|
|
784
|
+
switch (status) {
|
|
785
|
+
case "fail":
|
|
786
|
+
this.failedAt = new Date();
|
|
787
|
+
this.onGoing = false;
|
|
788
|
+
break;
|
|
789
|
+
case "processing":
|
|
790
|
+
this.processedAt = new Date();
|
|
791
|
+
this.onGoing = true;
|
|
792
|
+
break;
|
|
793
|
+
case "queued":
|
|
794
|
+
this.queuedAt = new Date();
|
|
795
|
+
this.onGoing = true;
|
|
796
|
+
break;
|
|
797
|
+
case "received":
|
|
798
|
+
this.receivedAt = new Date();
|
|
799
|
+
this.onGoing = true;
|
|
800
|
+
break;
|
|
801
|
+
case "skipped":
|
|
802
|
+
this.skippedAt = new Date();
|
|
803
|
+
this.onGoing = false;
|
|
804
|
+
break;
|
|
805
|
+
case "success":
|
|
806
|
+
this.succeededAt = new Date();
|
|
807
|
+
this.onGoing = false;
|
|
808
|
+
break;
|
|
809
|
+
}
|
|
810
|
+
return this;
|
|
811
|
+
}
|
|
812
|
+
setBody(body) {
|
|
813
|
+
this.body = body;
|
|
814
|
+
return this;
|
|
815
|
+
}
|
|
816
|
+
setMeta(meta) {
|
|
817
|
+
this.meta = meta;
|
|
818
|
+
return this;
|
|
819
|
+
}
|
|
820
|
+
async commit() {
|
|
821
|
+
let doc = {
|
|
822
|
+
available_app_name: this.available_app_name,
|
|
823
|
+
available_app_id: this.available_app_id,
|
|
824
|
+
app_id: this.app_id,
|
|
825
|
+
command: this.command,
|
|
826
|
+
status: this.status,
|
|
827
|
+
error: this.error ? this.error : undefined,
|
|
828
|
+
start_time: this.start_time,
|
|
829
|
+
end_time: Date.now(),
|
|
830
|
+
total_time: Date.now() - this.start_time,
|
|
831
|
+
company_namespace: this.company_namespace,
|
|
832
|
+
body: this.body,
|
|
833
|
+
meta: this.meta,
|
|
834
|
+
message: this.message,
|
|
835
|
+
details: this.details,
|
|
836
|
+
sync_id: this.sync_id,
|
|
837
|
+
// priority: this.priority ? this.priority : undefined,
|
|
838
|
+
queuedAt: this.queuedAt ? this.queuedAt : undefined,
|
|
839
|
+
failedAt: this.failedAt ? this.failedAt : undefined,
|
|
840
|
+
succeededAt: this.succeededAt ? this.succeededAt : undefined,
|
|
841
|
+
skippedAt: this.skippedAt ? this.skippedAt : undefined,
|
|
842
|
+
receivedAt: this.receivedAt ? this.receivedAt : undefined,
|
|
843
|
+
processedAt: this.processedAt ? this.processedAt : undefined,
|
|
844
|
+
onGoing: this.onGoing !== undefined ? this.onGoing : undefined,
|
|
845
|
+
retries: this.retries !== undefined ? this.retries : undefined,
|
|
846
|
+
trigger: this.trigger,
|
|
847
|
+
};
|
|
848
|
+
try {
|
|
849
|
+
const res = await this.superThis._create(this.superThis.svAPIEndpoint, this._path, doc);
|
|
850
|
+
this.isOld = true;
|
|
851
|
+
}
|
|
852
|
+
catch (e) {
|
|
853
|
+
console.error(e);
|
|
854
|
+
}
|
|
855
|
+
return this;
|
|
856
|
+
}
|
|
857
|
+
addDetail(detail, meta) {
|
|
858
|
+
let d = {
|
|
859
|
+
timestamp: Date.now(),
|
|
860
|
+
content: detail,
|
|
861
|
+
};
|
|
862
|
+
this.message = detail;
|
|
863
|
+
if (meta)
|
|
864
|
+
d.meta = meta;
|
|
865
|
+
this.details.push(d);
|
|
866
|
+
return this;
|
|
1306
867
|
}
|
|
1307
|
-
return this;
|
|
1308
|
-
}
|
|
1309
|
-
addDetail(detail, meta) {
|
|
1310
|
-
let d = {
|
|
1311
|
-
timestamp: Date.now(),
|
|
1312
|
-
content: detail,
|
|
1313
|
-
};
|
|
1314
|
-
this.message = detail;
|
|
1315
|
-
if (meta) d.meta = meta;
|
|
1316
|
-
this.details.push(d);
|
|
1317
|
-
return this;
|
|
1318
|
-
}
|
|
1319
868
|
};
|