repzo 1.0.20 → 1.0.21

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