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