repzo 1.0.106 → 1.0.107

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -1,1698 +1,2715 @@
1
1
  import axios from "axios";
2
2
  import { v4 as uuid } from "uuid";
3
- class Repzo {
4
- constructor(apiKey, options) {
5
- this._end_points = {
6
- CLIENT: "client",
7
- PRODUCT: "product",
8
- VARIANT: "variant",
9
- CATEGORY: "product-category",
10
- SUB_CATEGORY: "product-sub-category",
11
- BRAND: "product-brand",
12
- PRODUCT_GROUP: "product-group",
13
- TAX: "tax",
14
- MEASUREUNIT: "measureunits",
15
- MEASUREUNIT_FAMILY: "measureunit-family",
16
- MEDIA: "media",
17
- PRICELIST: "pricelists",
18
- PRICELIST_ITEM: "pricelistsitems",
19
- TEAM: "teams",
20
- RETURN_REASON: "return-reason",
21
- REP: "rep",
22
- TAG: "tag",
23
- WAREHOUSE: "warehouse",
24
- ROUTE: "route",
25
- PRODUCT_MODIFIERS_GROUP: "product-modifiers-group",
26
- CHANNEL: "client-channel",
27
- SPECIALITY: "speciality",
28
- CLIENT_CONTACT: "client-contact",
29
- PAYMENT_TERM: "paymentterms",
30
- BANK: "banks",
31
- BANK_LIST: "bankslists",
32
- CUSTOM_STATUS: "custom-status",
33
- CUSTOM_LIST: "custom-list",
34
- CUSTOM_LIST_ITEM: "custom-list-item",
35
- INVENTORY_ADJUSTMENT_REASON: "inventory-adjustment-reason",
36
- WORKORDER: "workorder",
37
- SUPPLIER: "supplier",
38
- QUICK_CONVERT_TO_PDF: "quick-convert-to-pdf",
39
- VISIT: "visit",
40
- INVOICE: "fullinvoices",
41
- PROFORMA: "proforma",
42
- PAYMENT: "payments",
43
- REFUND: "refund",
44
- SETTLEMENT: "settlement",
45
- CHECK: "checks",
46
- DAY: "day",
47
- RECEIVING_MATERIAL: "receiving-material",
48
- ADJUST_ACCOUNT: "adjust-account",
49
- TRANSFER: "transfer",
50
- MSL: "msl",
51
- MSL_PRODUCT: "msl-products",
52
- MEDIA_STORAGE: "media-storage",
53
- STORECHECK_TEMPLATE: "storecheck-template",
54
- ACTIVITY_STORECHECK: "activity-storecheck",
55
- ADJUST_INVENTORY: "adjust-inventory",
56
- INVENTORY: "inventory",
57
- INTEGRATION_APP: "integration-app",
58
- JOIN_ACTIONS_WEBHOOK: "svix-integration",
59
- INTEGRATION_ACTION_LOG: "integration-action-log",
60
- INTEGRATION_COMMAND_LOG: "integration-command-log",
61
- PATCH_ACTION: "patch-action",
62
- UPDATE_INTEGRATION_META: "update-integration-meta",
63
- ASSET_PART_TYPE: "asset-part-type",
64
- ASSET_PART: "asset-part",
65
- ASSET_PART_UNIT: "asset-part-unit",
66
- ASSET_PART_RECEIVAL: "asset-part-receival",
67
- ASSET_PART_TRANSFER: "asset-part-transfer",
68
- RETURN_ASSET_PART_UNIT: "return-asset-part-unit",
69
- STORE_ASSET_PART_UNIT: "store-asset-part-unit",
70
- OCR_INVOICE_JOB_TEMPLATE: "ocr-invoice-job-template",
71
- OCR_INVOICE_JOB_GROUP: "ocr-invoice-job-group",
72
- ACTIVITY_AI_SALES_ORDER: "activity-ai-sales-order",
73
- OCR_INVOICE_JOB: "ocr-invoice-job",
74
- OCR_INVOICE_JOB_PAGE: "ocr-invoice-job-page",
75
- };
76
- this.END_POINTS = this._end_points;
77
- this.client = {
78
- _path: this._end_points.CLIENT,
79
- find: async (params) => {
80
- let res = await this._fetch(this.svAPIEndpoint, this.client._path, params);
81
- return res;
82
- },
83
- get: async (id, params) => {
84
- return await this._fetch(this.svAPIEndpoint, this.client._path + `/${id}`, params);
85
- },
86
- create: async (body) => {
87
- let res = await this._create(this.svAPIEndpoint, this.client._path, body);
88
- return res;
89
- },
90
- update: async (id, body) => {
91
- let res = await this._update(this.svAPIEndpoint, this.client._path + `/${id}`, body);
92
- return res;
93
- },
94
- remove: async (id) => {
95
- let res = await this._delete(this.svAPIEndpoint, this.client._path + `/${id}`);
96
- return res;
97
- },
98
- };
99
- this.product = {
100
- _path: this._end_points.PRODUCT,
101
- find: async (params) => {
102
- let res = await this._fetch(this.svAPIEndpoint, this.product._path, params);
103
- return res;
104
- },
105
- get: async (id, params) => {
106
- return await this._fetch(this.svAPIEndpoint, this.product._path + `/${id}`, params);
107
- },
108
- create: async (body) => {
109
- let res = await this._create(this.svAPIEndpoint, this.product._path, body);
110
- return res;
111
- },
112
- update: async (id, body) => {
113
- let res = await this._update(this.svAPIEndpoint, this.product._path + `/${id}`, body);
114
- return res;
115
- },
116
- remove: async (id) => {
117
- let res = await this._delete(this.svAPIEndpoint, this.product._path + `/${id}`);
118
- return res;
119
- },
120
- };
121
- this.variant = {
122
- _path: this._end_points.VARIANT,
123
- find: async (params) => {
124
- let res = await this._fetch(this.svAPIEndpoint, this.variant._path, params);
125
- return res;
126
- },
127
- get: async (id, params) => {
128
- return await this._fetch(this.svAPIEndpoint, this.variant._path + `/${id}`, params);
129
- },
130
- create: async (body) => {
131
- let res = await this._create(this.svAPIEndpoint, this.variant._path, body);
132
- return res;
133
- },
134
- update: async (id, body) => {
135
- let res = await this._update(this.svAPIEndpoint, this.variant._path + `/${id}`, body);
136
- return res;
137
- },
138
- remove: async (id) => {
139
- let res = await this._delete(this.svAPIEndpoint, this.variant._path + `/${id}`);
140
- return res;
141
- },
142
- };
143
- this.category = {
144
- _path: this._end_points.CATEGORY,
145
- find: async (params) => {
146
- let res = await this._fetch(this.svAPIEndpoint, this.category._path, params);
147
- return res;
148
- },
149
- get: async (id) => {
150
- return await this._fetch(this.svAPIEndpoint, this.category._path + `/${id}`);
151
- },
152
- create: async (body) => {
153
- let res = await this._create(this.svAPIEndpoint, this.category._path, body);
154
- return res;
155
- },
156
- update: async (id, body) => {
157
- let res = await this._update(this.svAPIEndpoint, this.category._path + `/${id}`, body);
158
- return res;
159
- },
160
- remove: async (id) => {
161
- let res = await this._delete(this.svAPIEndpoint, this.category._path + `/${id}`);
162
- return res;
163
- },
164
- };
165
- this.sub_category = {
166
- _path: this._end_points.SUB_CATEGORY,
167
- find: async (params) => {
168
- let res = await this._fetch(this.svAPIEndpoint, this.sub_category._path, params);
169
- return res;
170
- },
171
- get: async (id, params) => {
172
- return await this._fetch(this.svAPIEndpoint, this.sub_category._path + `/${id}`, params);
173
- },
174
- create: async (body) => {
175
- let res = await this._create(this.svAPIEndpoint, this.sub_category._path, body);
176
- return res;
177
- },
178
- update: async (id, body) => {
179
- let res = await this._update(this.svAPIEndpoint, this.sub_category._path + `/${id}`, body);
180
- return res;
181
- },
182
- remove: async (id) => {
183
- let res = await this._delete(this.svAPIEndpoint, this.sub_category._path + `/${id}`);
184
- return res;
185
- },
186
- };
187
- this.brand = {
188
- _path: this._end_points.BRAND,
189
- find: async (params) => {
190
- let res = await this._fetch(this.svAPIEndpoint, this.brand._path, params);
191
- return res;
192
- },
193
- get: async (id) => {
194
- return await this._fetch(this.svAPIEndpoint, this.brand._path + `/${id}`);
195
- },
196
- create: async (body) => {
197
- let res = await this._create(this.svAPIEndpoint, this.brand._path, body);
198
- return res;
199
- },
200
- update: async (id, body) => {
201
- let res = await this._update(this.svAPIEndpoint, this.brand._path + `/${id}`, body);
202
- return res;
203
- },
204
- remove: async (id) => {
205
- let res = await this._delete(this.svAPIEndpoint, this.brand._path + `/${id}`);
206
- return res;
207
- },
208
- };
209
- this.product_group = {
210
- _path: this._end_points.PRODUCT_GROUP,
211
- find: async (params) => {
212
- let res = await this._fetch(this.svAPIEndpoint, this.product_group._path, params);
213
- return res;
214
- },
215
- get: async (id) => {
216
- return await this._fetch(this.svAPIEndpoint, this.product_group._path + `/${id}`);
217
- },
218
- create: async (body) => {
219
- let res = await this._create(this.svAPIEndpoint, this.product_group._path, body);
220
- return res;
221
- },
222
- update: async (id, body) => {
223
- let res = await this._update(this.svAPIEndpoint, this.product_group._path + `/${id}`, body);
224
- return res;
225
- },
226
- remove: async (id) => {
227
- let res = await this._delete(this.svAPIEndpoint, this.product_group._path + `/${id}`);
228
- return res;
229
- },
230
- };
231
- this.tax = {
232
- _path: this._end_points.TAX,
233
- find: async (params) => {
234
- let res = await this._fetch(this.svAPIEndpoint, this.tax._path, params);
235
- return res;
236
- },
237
- get: async (id) => {
238
- return await this._fetch(this.svAPIEndpoint, this.tax._path + `/${id}`);
239
- },
240
- create: async (body) => {
241
- let res = await this._create(this.svAPIEndpoint, this.tax._path, body);
242
- return res;
243
- },
244
- update: async (id, body) => {
245
- let res = await this._update(this.svAPIEndpoint, this.tax._path + `/${id}`, body);
246
- return res;
247
- },
248
- remove: async (id) => {
249
- let res = await this._delete(this.svAPIEndpoint, this.tax._path + `/${id}`);
250
- return res;
251
- },
252
- };
253
- this.measureunit = {
254
- _path: this._end_points.MEASUREUNIT,
255
- find: async (params) => {
256
- let res = await this._fetch(this.svAPIEndpoint, this.measureunit._path, params);
257
- return res;
258
- },
259
- get: async (id) => {
260
- return await this._fetch(this.svAPIEndpoint, this.measureunit._path + `/${id}`);
261
- },
262
- create: async (body) => {
263
- let res = await this._create(this.svAPIEndpoint, this.measureunit._path, body);
264
- return res;
265
- },
266
- update: async (id, body) => {
267
- let res = await this._update(this.svAPIEndpoint, this.measureunit._path + `/${id}`, body);
268
- return res;
269
- },
270
- remove: async (id) => {
271
- let res = await this._delete(this.svAPIEndpoint, this.measureunit._path + `/${id}`);
272
- return res;
273
- },
274
- };
275
- this.measureunitFamily = {
276
- _path: this._end_points.MEASUREUNIT_FAMILY,
277
- find: async (params) => {
278
- let res = await this._fetch(this.svAPIEndpoint, this.measureunitFamily._path, params);
279
- return res;
280
- },
281
- get: async (id) => {
282
- return await this._fetch(this.svAPIEndpoint, this.measureunitFamily._path + `/${id}`);
283
- },
284
- create: async (body) => {
285
- let res = await this._create(this.svAPIEndpoint, this.measureunitFamily._path, body);
286
- return res;
287
- },
288
- update: async (id, body) => {
289
- let res = await this._update(this.svAPIEndpoint, this.measureunitFamily._path + `/${id}`, body);
290
- return res;
291
- },
292
- remove: async (id) => {
293
- let res = await this._delete(this.svAPIEndpoint, this.measureunitFamily._path + `/${id}`);
294
- return res;
295
- },
296
- };
297
- this.media = {
298
- _path: this._end_points.MEDIA,
299
- find: async (params) => {
300
- let res = await this._fetch(this.svAPIEndpoint, this.media._path, params);
301
- return res;
302
- },
303
- get: async (id) => {
304
- return await this._fetch(this.svAPIEndpoint, this.media._path + `/${id}`);
305
- },
306
- create: async (body) => {
307
- let res = await this._create(this.svAPIEndpoint, this.media._path, body);
308
- return res;
309
- },
310
- update: async (id, body) => {
311
- let res = await this._update(this.svAPIEndpoint, this.media._path + `/${id}`, body);
312
- return res;
313
- },
314
- remove: async (id) => {
315
- let res = await this._delete(this.svAPIEndpoint, this.media._path + `/${id}`);
316
- return res;
317
- },
318
- };
319
- this.priceList = {
320
- _path: this._end_points.PRICELIST,
321
- find: async (params) => {
322
- let res = await this._fetch(this.svAPIEndpoint, this.priceList._path, params);
323
- return res;
324
- },
325
- get: async (id) => {
326
- return await this._fetch(this.svAPIEndpoint, this.priceList._path + `/${id}`);
327
- },
328
- create: async (body) => {
329
- let res = await this._create(this.svAPIEndpoint, this.priceList._path, body);
330
- return res;
331
- },
332
- update: async (id, body) => {
333
- let res = await this._update(this.svAPIEndpoint, this.priceList._path + `/${id}`, body);
334
- return res;
335
- },
336
- remove: async (id) => {
337
- let res = await this._delete(this.svAPIEndpoint, this.priceList._path + `/${id}`);
338
- return res;
339
- },
340
- };
341
- this.priceListItem = {
342
- _path: this._end_points.PRICELIST_ITEM,
343
- find: async (params) => {
344
- let res = await this._fetch(this.svAPIEndpoint, this.priceListItem._path, params);
345
- return res;
346
- },
347
- get: async (id) => {
348
- return await this._fetch(this.svAPIEndpoint, this.priceListItem._path + `/${id}`);
349
- },
350
- create: async (body) => {
351
- let res = await this._create(this.svAPIEndpoint, this.priceListItem._path, body);
352
- return res;
353
- },
354
- update: async (id, body) => {
355
- let res = await this._update(this.svAPIEndpoint, this.priceListItem._path + `/${id}`, body);
356
- return res;
357
- },
358
- remove: async (id) => {
359
- let res = await this._delete(this.svAPIEndpoint, this.priceListItem._path + `/${id}`);
360
- return res;
361
- },
362
- };
363
- this.team = {
364
- _path: this._end_points.TEAM,
365
- find: async (params) => {
366
- let res = await this._fetch(this.svAPIEndpoint, this.team._path, params);
367
- return res;
368
- },
369
- get: async (id) => {
370
- return await this._fetch(this.svAPIEndpoint, this.team._path + `/${id}`);
371
- },
372
- create: async (body) => {
373
- let res = await this._create(this.svAPIEndpoint, this.team._path, body);
374
- return res;
375
- },
376
- update: async (id, body) => {
377
- let res = await this._update(this.svAPIEndpoint, this.team._path + `/${id}`, body);
378
- return res;
379
- },
380
- remove: async (id) => {
381
- let res = await this._delete(this.svAPIEndpoint, this.team._path + `/${id}`);
382
- return res;
383
- },
384
- };
385
- this.returnReason = {
386
- _path: this._end_points.RETURN_REASON,
387
- find: async (params) => {
388
- let res = await this._fetch(this.svAPIEndpoint, this.returnReason._path, params);
389
- return res;
390
- },
391
- get: async (id) => {
392
- return await this._fetch(this.svAPIEndpoint, this.returnReason._path + `/${id}`);
393
- },
394
- create: async (body) => {
395
- let res = await this._create(this.svAPIEndpoint, this.returnReason._path, body);
396
- return res;
397
- },
398
- update: async (id, body) => {
399
- let res = await this._update(this.svAPIEndpoint, this.returnReason._path + `/${id}`, body);
400
- return res;
401
- },
402
- remove: async (id) => {
403
- let res = await this._delete(this.svAPIEndpoint, this.returnReason._path + `/${id}`);
404
- return res;
405
- },
406
- };
407
- this.rep = {
408
- _path: this._end_points.REP,
409
- find: async (params) => {
410
- let res = await this._fetch(this.svAPIEndpoint, this.rep._path, params);
411
- return res;
412
- },
413
- get: async (id, params) => {
414
- return await this._fetch(this.svAPIEndpoint, this.rep._path + `/${id}`, params);
415
- },
416
- create: async (body) => {
417
- let res = await this._create(this.svAPIEndpoint, this.rep._path, body);
418
- return res;
419
- },
420
- update: async (id, body) => {
421
- let res = await this._update(this.svAPIEndpoint, this.rep._path + `/${id}`, body);
422
- return res;
423
- },
424
- remove: async (id) => {
425
- let res = await this._delete(this.svAPIEndpoint, this.rep._path + `/${id}`);
426
- return res;
427
- },
428
- };
429
- this.tag = {
430
- _path: this._end_points.TAG,
431
- find: async (params) => {
432
- let res = await this._fetch(this.svAPIEndpoint, this.tag._path, params);
433
- return res;
434
- },
435
- get: async (id) => {
436
- return await this._fetch(this.svAPIEndpoint, this.tag._path + `/${id}`);
437
- },
438
- create: async (body) => {
439
- let res = await this._create(this.svAPIEndpoint, this.tag._path, body);
440
- return res;
441
- },
442
- update: async (id, body) => {
443
- let res = await this._update(this.svAPIEndpoint, this.tag._path + `/${id}`, body);
444
- return res;
445
- },
446
- remove: async (id) => {
447
- let res = await this._delete(this.svAPIEndpoint, this.tag._path + `/${id}`);
448
- return res;
449
- },
450
- };
451
- this.warehouse = {
452
- _path: this._end_points.WAREHOUSE,
453
- find: async (params) => {
454
- let res = await this._fetch(this.svAPIEndpoint, this.warehouse._path, params);
455
- return res;
456
- },
457
- get: async (id) => {
458
- return await this._fetch(this.svAPIEndpoint, this.warehouse._path + `/${id}`);
459
- },
460
- create: async (body) => {
461
- let res = await this._create(this.svAPIEndpoint, this.warehouse._path, body);
462
- return res;
463
- },
464
- update: async (id, body) => {
465
- let res = await this._update(this.svAPIEndpoint, this.warehouse._path + `/${id}`, body);
466
- return res;
467
- },
468
- remove: async (id) => {
469
- let res = await this._delete(this.svAPIEndpoint, this.warehouse._path + `/${id}`);
470
- return res;
471
- },
472
- };
473
- this.route = {
474
- _path: this._end_points.ROUTE,
475
- find: async (params) => {
476
- let res = await this._fetch(this.svAPIEndpoint, this.route._path, params);
477
- return res;
478
- },
479
- get: async (id) => {
480
- return await this._fetch(this.svAPIEndpoint, this.route._path + `/${id}`);
481
- },
482
- create: async (body) => {
483
- let res = await this._create(this.svAPIEndpoint, this.route._path, body);
484
- return res;
485
- },
486
- update: async (id, body) => {
487
- let res = await this._update(this.svAPIEndpoint, this.route._path + `/${id}`, body);
488
- return res;
489
- },
490
- remove: async (id) => {
491
- let res = await this._delete(this.svAPIEndpoint, this.route._path + `/${id}`);
492
- return res;
493
- },
494
- };
495
- this.productModifiersGroup = {
496
- _path: this._end_points.PRODUCT_MODIFIERS_GROUP,
497
- find: async (params) => {
498
- let res = await this._fetch(this.svAPIEndpoint, this.productModifiersGroup._path, params);
499
- return res;
500
- },
501
- get: async (id) => {
502
- return await this._fetch(this.svAPIEndpoint, this.productModifiersGroup._path + `/${id}`);
503
- },
504
- create: async (body) => {
505
- let res = await this._create(this.svAPIEndpoint, this.productModifiersGroup._path, body);
506
- return res;
507
- },
508
- update: async (id, body) => {
509
- let res = await this._update(this.svAPIEndpoint, this.productModifiersGroup._path + `/${id}`, body);
510
- return res;
511
- },
512
- remove: async (id) => {
513
- let res = await this._delete(this.svAPIEndpoint, this.productModifiersGroup._path + `/${id}`);
514
- return res;
515
- },
516
- };
517
- this.channel = {
518
- _path: this._end_points.CHANNEL,
519
- find: async (params) => {
520
- let res = await this._fetch(this.svAPIEndpoint, this.channel._path, params);
521
- return res;
522
- },
523
- get: async (id) => {
524
- return await this._fetch(this.svAPIEndpoint, this.channel._path + `/${id}`);
525
- },
526
- create: async (body) => {
527
- let res = await this._create(this.svAPIEndpoint, this.channel._path, body);
528
- return res;
529
- },
530
- update: async (id, body) => {
531
- let res = await this._update(this.svAPIEndpoint, this.channel._path + `/${id}`, body);
532
- return res;
533
- },
534
- remove: async (id) => {
535
- let res = await this._delete(this.svAPIEndpoint, this.channel._path + `/${id}`);
536
- return res;
537
- },
538
- };
539
- this.speciality = {
540
- _path: this._end_points.SPECIALITY,
541
- find: async (params) => {
542
- let res = await this._fetch(this.svAPIEndpoint, this.speciality._path, params);
543
- return res;
544
- },
545
- get: async (id) => {
546
- return await this._fetch(this.svAPIEndpoint, this.speciality._path + `/${id}`);
547
- },
548
- create: async (body) => {
549
- let res = await this._create(this.svAPIEndpoint, this.speciality._path, body);
550
- return res;
551
- },
552
- update: async (id, body) => {
553
- let res = await this._update(this.svAPIEndpoint, this.speciality._path + `/${id}`, body);
554
- return res;
555
- },
556
- remove: async (id) => {
557
- let res = await this._delete(this.svAPIEndpoint, this.speciality._path + `/${id}`);
558
- return res;
559
- },
560
- };
561
- this.clientContact = {
562
- _path: this._end_points.CLIENT_CONTACT,
563
- find: async (params) => {
564
- let res = await this._fetch(this.svAPIEndpoint, this.clientContact._path, params);
565
- return res;
566
- },
567
- get: async (id) => {
568
- return await this._fetch(this.svAPIEndpoint, this.clientContact._path + `/${id}`);
569
- },
570
- create: async (body) => {
571
- let res = await this._create(this.svAPIEndpoint, this.clientContact._path, body);
572
- return res;
573
- },
574
- update: async (id, body) => {
575
- let res = await this._update(this.svAPIEndpoint, this.clientContact._path + `/${id}`, body);
576
- return res;
577
- },
578
- remove: async (id) => {
579
- let res = await this._delete(this.svAPIEndpoint, this.clientContact._path + `/${id}`);
580
- return res;
581
- },
582
- };
583
- this.paymentTerm = {
584
- _path: this._end_points.PAYMENT_TERM,
585
- find: async (params) => {
586
- let res = await this._fetch(this.svAPIEndpoint, this.paymentTerm._path, params);
587
- return res;
588
- },
589
- get: async (id) => {
590
- return await this._fetch(this.svAPIEndpoint, this.paymentTerm._path + `/${id}`);
591
- },
592
- create: async (body) => {
593
- let res = await this._create(this.svAPIEndpoint, this.paymentTerm._path, body);
594
- return res;
595
- },
596
- update: async (id, body) => {
597
- let res = await this._update(this.svAPIEndpoint, this.paymentTerm._path + `/${id}`, body);
598
- return res;
599
- },
600
- remove: async (id) => {
601
- let res = await this._delete(this.svAPIEndpoint, this.paymentTerm._path + `/${id}`);
602
- return res;
603
- },
604
- };
605
- this.bank = {
606
- _path: this._end_points.BANK,
607
- find: async (params) => {
608
- let res = await this._fetch(this.svAPIEndpoint, this.bank._path, params);
609
- return res;
610
- },
611
- get: async (id) => {
612
- return await this._fetch(this.svAPIEndpoint, this.bank._path + `/${id}`);
613
- },
614
- create: async (body) => {
615
- let res = await this._create(this.svAPIEndpoint, this.bank._path, body);
616
- return res;
617
- },
618
- update: async (id, body) => {
619
- let res = await this._update(this.svAPIEndpoint, this.bank._path + `/${id}`, body);
620
- return res;
621
- },
622
- };
623
- this.bank_list = {
624
- _path: this._end_points.BANK_LIST,
625
- find: async (params) => {
626
- let res = await this._fetch(this.svAPIEndpoint, this.bank_list._path, params);
627
- return res;
628
- },
629
- get: async (id) => {
630
- return await this._fetch(this.svAPIEndpoint, this.bank_list._path + `/${id}`);
631
- },
632
- create: async (body) => {
633
- let res = await this._create(this.svAPIEndpoint, this.bank_list._path, body);
634
- return res;
635
- },
636
- update: async (id, body) => {
637
- let res = await this._update(this.svAPIEndpoint, this.bank_list._path + `/${id}`, body);
638
- return res;
639
- },
640
- };
641
- this.customStatus = {
642
- _path: this._end_points.CUSTOM_STATUS,
643
- find: async (params) => {
644
- let res = await this._fetch(this.svAPIEndpoint, this.customStatus._path, params);
645
- return res;
646
- },
647
- get: async (id) => {
648
- return await this._fetch(this.svAPIEndpoint, this.customStatus._path + `/${id}`);
649
- },
650
- create: async (body) => {
651
- let res = await this._create(this.svAPIEndpoint, this.customStatus._path, body);
652
- return res;
653
- },
654
- update: async (id, body) => {
655
- let res = await this._update(this.svAPIEndpoint, this.customStatus._path + `/${id}`, body);
656
- return res;
657
- },
658
- remove: async (id) => {
659
- let res = await this._delete(this.svAPIEndpoint, this.customStatus._path + `/${id}`);
660
- return res;
661
- },
662
- };
663
- this.customList = {
664
- _path: this._end_points.CUSTOM_LIST,
665
- find: async (params) => {
666
- let res = await this._fetch(this.svAPIEndpoint, this.customList._path, params);
667
- return res;
668
- },
669
- get: async (id, params) => {
670
- return await this._fetch(this.svAPIEndpoint, this.customList._path + `/${id}`, params);
671
- },
672
- create: async (body) => {
673
- let res = await this._create(this.svAPIEndpoint, this.customList._path, body);
674
- return res;
675
- },
676
- update: async (id, body) => {
677
- let res = await this._update(this.svAPIEndpoint, this.customList._path + `/${id}`, body);
678
- return res;
679
- },
680
- remove: async (id) => {
681
- let res = await this._delete(this.svAPIEndpoint, this.customList._path + `/${id}`);
682
- return res;
683
- },
684
- };
685
- this.customListItem = {
686
- _path: this._end_points.CUSTOM_LIST_ITEM,
687
- find: async (params) => {
688
- let res = await this._fetch(this.svAPIEndpoint, this.customListItem._path, params);
689
- return res;
690
- },
691
- get: async (id, params) => {
692
- return await this._fetch(this.svAPIEndpoint, this.customListItem._path + `/${id}`, params);
693
- },
694
- create: async (body) => {
695
- let res = await this._create(this.svAPIEndpoint, this.customListItem._path, body);
696
- return res;
697
- },
698
- update: async (id, body) => {
699
- let res = await this._update(this.svAPIEndpoint, this.customListItem._path + `/${id}`, body);
700
- return res;
701
- },
702
- remove: async (id) => {
703
- let res = await this._delete(this.svAPIEndpoint, this.customListItem._path + `/${id}`);
704
- return res;
705
- },
706
- };
707
- this.inventoryAdjustmentReason = {
708
- _path: this._end_points.INVENTORY_ADJUSTMENT_REASON,
709
- find: async (params) => {
710
- let res = await this._fetch(this.svAPIEndpoint, this.inventoryAdjustmentReason._path, params);
711
- return res;
712
- },
713
- get: async (id) => {
714
- return await this._fetch(this.svAPIEndpoint, this.inventoryAdjustmentReason._path + `/${id}`);
715
- },
716
- create: async (body) => {
717
- let res = await this._create(this.svAPIEndpoint, this.inventoryAdjustmentReason._path, body);
718
- return res;
719
- },
720
- update: async (id, body) => {
721
- let res = await this._update(this.svAPIEndpoint, this.customListItem._path + `/${id}`, body);
722
- return res;
723
- },
724
- remove: async (id) => {
725
- let res = await this._delete(this.svAPIEndpoint, this.inventoryAdjustmentReason._path + `/${id}`);
726
- return res;
727
- },
728
- };
729
- this.workorder = {
730
- _path: this._end_points.WORKORDER,
731
- find: async (params) => {
732
- let res = await this._fetch(this.svAPIEndpoint, this.workorder._path, params);
733
- return res;
734
- },
735
- get: async (id, params) => {
736
- return await this._fetch(this.svAPIEndpoint, this.workorder._path + `/${id}`, params);
737
- },
738
- };
739
- this.supplier = {
740
- _path: this._end_points.SUPPLIER,
741
- find: async (params) => {
742
- let res = await this._fetch(this.svAPIEndpoint, this.supplier._path, params);
743
- return res;
744
- },
745
- get: async (id, params) => {
746
- return await this._fetch(this.svAPIEndpoint, this.supplier._path + `/${id}`, params);
747
- },
748
- create: async (body) => {
749
- let res = await this._create(this.svAPIEndpoint, this.supplier._path, body);
750
- return res;
751
- },
752
- update: async (id, body) => {
753
- let res = await this._update(this.svAPIEndpoint, this.supplier._path + `/${id}`, body);
754
- return res;
755
- },
756
- };
757
- this.quickConvertToPdf = {
758
- _path: this._end_points.QUICK_CONVERT_TO_PDF,
759
- find: async (params) => {
760
- let res = await this._fetch(this.svAPIEndpoint, this.quickConvertToPdf._path, params);
761
- return res;
762
- },
763
- get: async (id, params) => {
764
- return await this._fetch(this.svAPIEndpoint, this.quickConvertToPdf._path + `/${id}`, params);
765
- },
766
- create: async (body) => {
767
- let res = await this._create(this.svAPIEndpoint, this.quickConvertToPdf._path, body);
768
- return res;
769
- },
770
- remove: async (id) => {
771
- let res = await this._delete(this.svAPIEndpoint, this.quickConvertToPdf._path + `/${id}`);
772
- return res;
773
- },
774
- };
775
- this.visit = {
776
- _path: this._end_points.VISIT,
777
- find: async (params) => {
778
- let res = await this._fetch(this.svAPIEndpoint, this.visit._path, params);
779
- return res;
780
- },
781
- get: async (id, params) => {
782
- return await this._fetch(this.svAPIEndpoint, this.visit._path + `/${id}`, params);
783
- },
784
- create: async (body) => {
785
- let res = await this._create(this.svAPIEndpoint, this.visit._path, body);
786
- return res;
787
- },
788
- update: async (id, body) => {
789
- let res = await this._update(this.svAPIEndpoint, this.visit._path + `/${id}`, body);
790
- return res;
791
- },
792
- };
793
- this.invoice = {
794
- _path: this._end_points.INVOICE,
795
- find: async (params) => {
796
- let res = await this._fetch(this.svAPIEndpoint, this.invoice._path, params);
797
- return res;
798
- },
799
- get: async (id, params) => {
800
- return await this._fetch(this.svAPIEndpoint, this.invoice._path + `/${id}`, params);
801
- },
802
- create: async (body) => {
803
- let res = await this._create(this.svAPIEndpoint, this.invoice._path, body);
804
- return res;
805
- },
806
- update: async (id, body) => {
807
- let res = await this._update(this.svAPIEndpoint, this.invoice._path + `/${id}`, body);
808
- return res;
809
- },
810
- };
811
- this.proforma = {
812
- _path: this._end_points.PROFORMA,
813
- find: async (params) => {
814
- let res = await this._fetch(this.svAPIEndpoint, this.proforma._path, params);
815
- return res;
816
- },
817
- get: async (id, params) => {
818
- return await this._fetch(this.svAPIEndpoint, this.proforma._path + `/${id}`, params);
819
- },
820
- create: async (body) => {
821
- let res = await this._create(this.svAPIEndpoint, this.proforma._path, body);
822
- return res;
823
- },
824
- update: async (id, body) => {
825
- let res = await this._update(this.svAPIEndpoint, this.proforma._path + `/${id}`, body);
826
- return res;
827
- },
828
- };
829
- this.payment = {
830
- _path: this._end_points.PAYMENT,
831
- find: async (params) => {
832
- let res = await this._fetch(this.svAPIEndpoint, this.payment._path, params);
833
- return res;
834
- },
835
- get: async (id, params) => {
836
- return await this._fetch(this.svAPIEndpoint, this.payment._path + `/${id}`, params);
837
- },
838
- create: async (body) => {
839
- let res = await this._create(this.svAPIEndpoint, this.payment._path, body);
840
- return res;
841
- },
842
- update: async (id, body) => {
843
- let res = await this._update(this.svAPIEndpoint, this.payment._path + `/${id}`, body);
844
- return res;
845
- },
846
- };
847
- this.refund = {
848
- _path: this._end_points.REFUND,
849
- find: async (params) => {
850
- let res = await this._fetch(this.svAPIEndpoint, this.refund._path, params);
851
- return res;
852
- },
853
- get: async (id, params) => {
854
- return await this._fetch(this.svAPIEndpoint, this.refund._path + `/${id}`, params);
855
- },
856
- create: async (body) => {
857
- let res = await this._create(this.svAPIEndpoint, this.refund._path, body);
858
- return res;
859
- },
860
- update: async (id, body) => {
861
- let res = await this._update(this.svAPIEndpoint, this.refund._path + `/${id}`, body);
862
- return res;
863
- },
864
- };
865
- this.settlement = {
866
- _path: this._end_points.SETTLEMENT,
867
- find: async (params) => {
868
- let res = await this._fetch(this.svAPIEndpoint, this.settlement._path, params);
869
- return res;
870
- },
871
- get: async (id, params) => {
872
- return await this._fetch(this.svAPIEndpoint, this.settlement._path + `/${id}`, params);
873
- },
874
- create: async (body) => {
875
- let res = await this._create(this.svAPIEndpoint, this.settlement._path, body);
876
- return res;
877
- },
878
- };
879
- this.check = {
880
- _path: this._end_points.CHECK,
881
- find: async (params) => {
882
- let res = await this._fetch(this.svAPIEndpoint, this.check._path, params);
883
- return res;
884
- },
885
- get: async (id, params) => {
886
- return await this._fetch(this.svAPIEndpoint, this.check._path + `/${id}`, params);
887
- },
888
- create: async (body) => {
889
- let res = await this._create(this.svAPIEndpoint, this.check._path, body);
890
- return res;
891
- },
892
- };
893
- this.day = {
894
- _path: this._end_points.DAY,
895
- find: async (params) => {
896
- let res = await this._fetch(this.svAPIEndpoint, this.day._path, params);
897
- return res;
898
- },
899
- get: async (id, params) => {
900
- return await this._fetch(this.svAPIEndpoint, this.day._path + `/${id}`, params);
901
- },
902
- create: async (body) => {
903
- let res = await this._create(this.svAPIEndpoint, this.day._path, body);
904
- return res;
905
- },
906
- };
907
- this.receivingMaterial = {
908
- _path: this._end_points.RECEIVING_MATERIAL,
909
- find: async (params) => {
910
- let res = await this._fetch(this.svAPIEndpoint, this.receivingMaterial._path, params);
911
- return res;
912
- },
913
- get: async (id, params) => {
914
- return await this._fetch(this.svAPIEndpoint, this.receivingMaterial._path + `/${id}`, params);
915
- },
916
- create: async (body) => {
917
- let res = await this._create(this.svAPIEndpoint, this.receivingMaterial._path, body);
918
- return res;
919
- },
920
- update: async (id, body) => {
921
- let res = await this._update(this.svAPIEndpoint, this.receivingMaterial._path + `/${id}`, body);
922
- return res;
923
- },
924
- };
925
- this.adjustAccount = {
926
- _path: this._end_points.ADJUST_ACCOUNT,
927
- find: async (params) => {
928
- let res = await this._fetch(this.svAPIEndpoint, this.adjustAccount._path, params);
929
- return res;
930
- },
931
- get: async (id, params) => {
932
- return await this._fetch(this.svAPIEndpoint, this.adjustAccount._path + `/${id}`, params);
933
- },
934
- create: async (body) => {
935
- let res = await this._create(this.svAPIEndpoint, this.adjustAccount._path, body);
936
- return res;
937
- },
938
- };
939
- this.transfer = {
940
- _path: this._end_points.TRANSFER,
941
- find: async (params) => {
942
- let res = await this._fetch(this.svAPIEndpoint, this.transfer._path, params);
943
- return res;
944
- },
945
- get: async (id, params) => {
946
- return await this._fetch(this.svAPIEndpoint, this.transfer._path + `/${id}`, params);
947
- },
948
- create: async (body) => {
949
- let res = await this._create(this.svAPIEndpoint, this.transfer._path, body);
950
- return res;
951
- },
952
- update: async (id, body) => {
953
- let res = await this._update(this.svAPIEndpoint, this.transfer._path + `/${id}`, body);
954
- return res;
955
- },
956
- };
957
- this.msl = {
958
- _path: this._end_points.MSL,
959
- find: async (params) => {
960
- let res = await this._fetch(this.svAPIEndpoint, this.msl._path, params);
961
- return res;
962
- },
963
- get: async (id, params) => {
964
- return await this._fetch(this.svAPIEndpoint, this.msl._path + `/${id}`, params);
965
- },
966
- create: async (body) => {
967
- let res = await this._create(this.svAPIEndpoint, this.msl._path, body);
968
- return res;
969
- },
970
- update: async (id, body) => {
971
- let res = await this._update(this.svAPIEndpoint, this.msl._path + `/${id}`, body);
972
- return res;
973
- },
974
- remove: async (id) => {
975
- let res = await this._delete(this.svAPIEndpoint, this.msl._path + `/${id}`);
976
- return res;
977
- },
978
- };
979
- this.mslProduct = {
980
- _path: this._end_points.MSL_PRODUCT,
981
- find: async (params) => {
982
- let res = await this._fetch(this.svAPIEndpoint, this.mslProduct._path, params);
983
- return res;
984
- },
985
- get: async (id, params) => {
986
- return await this._fetch(this.svAPIEndpoint, this.mslProduct._path + `/${id}`, params);
987
- },
988
- create: async (body) => {
989
- let res = await this._create(this.svAPIEndpoint, this.mslProduct._path, body);
990
- return res;
991
- },
992
- update: async (id, body) => {
993
- let res = await this._update(this.svAPIEndpoint, this.mslProduct._path + `/${id}`, body);
994
- return res;
995
- },
996
- remove: async (id) => {
997
- let res = await this._delete(this.svAPIEndpoint, this.mslProduct._path + `/${id}`);
998
- return res;
999
- },
1000
- };
1001
- this.mediaStorage = {
1002
- _path: this._end_points.MEDIA_STORAGE,
1003
- find: async (params) => {
1004
- let res = await this._fetch(this.svAPIEndpoint, this.mediaStorage._path, params);
1005
- return res;
1006
- },
1007
- get: async (id, params) => {
1008
- return await this._fetch(this.svAPIEndpoint, this.mediaStorage._path + `/${id}`, params);
1009
- },
1010
- create: async (body) => {
1011
- let res = await this._create(this.svAPIEndpoint, this.mediaStorage._path, body);
1012
- return res;
1013
- },
1014
- update: async (id, body) => {
1015
- let res = await this._update(this.svAPIEndpoint, this.mediaStorage._path + `/${id}`, body);
1016
- return res;
1017
- },
1018
- remove: async (id) => {
1019
- let res = await this._delete(this.svAPIEndpoint, this.mediaStorage._path + `/${id}`);
1020
- return res;
1021
- },
1022
- };
1023
- this.storecheckTemplate = {
1024
- _path: this._end_points.STORECHECK_TEMPLATE,
1025
- find: async (params) => {
1026
- let res = await this._fetch(this.svAPIEndpoint, this.storecheckTemplate._path, params);
1027
- return res;
1028
- },
1029
- get: async (id, params) => {
1030
- return await this._fetch(this.svAPIEndpoint, this.storecheckTemplate._path + `/${id}`, params);
1031
- },
1032
- create: async (body) => {
1033
- let res = await this._create(this.svAPIEndpoint, this.storecheckTemplate._path, body);
1034
- return res;
1035
- },
1036
- update: async (id, body) => {
1037
- let res = await this._update(this.svAPIEndpoint, this.storecheckTemplate._path + `/${id}`, body);
1038
- return res;
1039
- },
1040
- remove: async (id) => {
1041
- let res = await this._delete(this.svAPIEndpoint, this.storecheckTemplate._path + `/${id}`);
1042
- return res;
1043
- },
1044
- };
1045
- this.activityStorecheck = {
1046
- _path: this._end_points.ACTIVITY_STORECHECK,
1047
- find: async (params) => {
1048
- let res = await this._fetch(this.svAPIEndpoint, this.activityStorecheck._path, params);
1049
- return res;
1050
- },
1051
- get: async (id, params) => {
1052
- return await this._fetch(this.svAPIEndpoint, this.activityStorecheck._path + `/${id}`, params);
1053
- },
1054
- create: async (body) => {
1055
- let res = await this._create(this.svAPIEndpoint, this.activityStorecheck._path, body);
1056
- return res;
1057
- },
1058
- update: async (id, body) => {
1059
- let res = await this._update(this.svAPIEndpoint, this.activityStorecheck._path + `/${id}`, body);
1060
- return res;
1061
- },
1062
- };
1063
- this.adjustInventory = {
1064
- _path: this._end_points.ADJUST_INVENTORY,
1065
- find: async (params) => {
1066
- let res = await this._fetch(this.svAPIEndpoint, this.adjustInventory._path, params);
1067
- return res;
1068
- },
1069
- get: async (id, params) => {
1070
- return await this._fetch(this.svAPIEndpoint, this.adjustInventory._path + `/${id}`, params);
1071
- },
1072
- create: async (body) => {
1073
- let res = await this._create(this.svAPIEndpoint, this.adjustInventory._path, body);
1074
- return res;
1075
- },
1076
- };
1077
- this.inventory = {
1078
- _path: this._end_points.INVENTORY,
1079
- find: async (params) => {
1080
- let res = await this._fetch(this.svAPIEndpoint, this.inventory._path, params);
1081
- return res;
1082
- },
1083
- };
1084
- this.integrationApp = {
1085
- _path: this._end_points.INTEGRATION_APP,
1086
- find: async (params) => {
1087
- let res = await this._fetch(this.svAPIEndpoint, this.integrationApp._path, params);
1088
- return res;
1089
- },
1090
- get: async (id, params) => {
1091
- return await this._fetch(this.svAPIEndpoint, this.integrationApp._path + `/${id}`, params);
1092
- },
1093
- create: async (body) => {
1094
- let res = await this._create(this.svAPIEndpoint, this.integrationApp._path, body);
1095
- return res;
1096
- },
1097
- update: async (id, body) => {
1098
- let res = await this._update(this.svAPIEndpoint, this.integrationApp._path + `/${id}`, body);
1099
- return res;
1100
- },
1101
- };
1102
- this.joinActionsWebHook = {
1103
- _path: this._end_points.JOIN_ACTIONS_WEBHOOK,
1104
- update: async (id, body) => {
1105
- let res = await this._update(this.svAPIEndpoint, this.joinActionsWebHook._path, body);
1106
- return res;
1107
- },
1108
- };
1109
- this.patchAction = {
1110
- _path: this._end_points.PATCH_ACTION,
1111
- create: async (body, params) => {
1112
- const res = await this._create(this.svAPIEndpoint, this.patchAction._path, body, params);
1113
- return res;
1114
- },
1115
- update: async (body) => {
1116
- const res = await this._update(this.svAPIEndpoint, this.patchAction._path, body);
1117
- return res;
1118
- },
1119
- };
1120
- this.updateIntegrationMeta = {
1121
- _path: this._end_points.UPDATE_INTEGRATION_META,
1122
- create: async (body, params) => {
1123
- let res = await this._create(this.svAPIEndpoint, this.updateIntegrationMeta._path, body, params);
1124
- return res;
1125
- },
1126
- };
1127
- this.assetPartType = {
1128
- _path: this._end_points.ASSET_PART_TYPE,
1129
- find: async (params) => {
1130
- let res = await this._fetch(this.svAPIEndpoint, this.assetPartType._path, params);
1131
- return res;
1132
- },
1133
- get: async (id) => {
1134
- return await this._fetch(this.svAPIEndpoint, this.assetPartType._path + `/${id}`);
1135
- },
1136
- create: async (body) => {
1137
- let res = await this._create(this.svAPIEndpoint, this.assetPartType._path, body);
1138
- return res;
1139
- },
1140
- update: async (id, body) => {
1141
- let res = await this._update(this.svAPIEndpoint, this.assetPartType._path + `/${id}`, body);
1142
- return res;
1143
- },
1144
- remove: async (id) => {
1145
- let res = await this._delete(this.svAPIEndpoint, this.assetPartType._path + `/${id}`);
1146
- return res;
1147
- },
1148
- };
1149
- this.assetPart = {
1150
- _path: this._end_points.ASSET_PART,
1151
- find: async (params) => {
1152
- let res = await this._fetch(this.svAPIEndpoint, this.assetPart._path, params);
1153
- return res;
1154
- },
1155
- get: async (id, params) => {
1156
- return await this._fetch(this.svAPIEndpoint, this.assetPart._path + `/${id}`, params);
1157
- },
1158
- create: async (body) => {
1159
- let res = await this._create(this.svAPIEndpoint, this.assetPart._path, body);
1160
- return res;
1161
- },
1162
- update: async (id, body) => {
1163
- let res = await this._update(this.svAPIEndpoint, this.assetPart._path + `/${id}`, body);
1164
- return res;
1165
- },
1166
- remove: async (id) => {
1167
- let res = await this._delete(this.svAPIEndpoint, this.assetPart._path + `/${id}`);
1168
- return res;
1169
- },
1170
- };
1171
- this.assetPartUnit = {
1172
- _path: this._end_points.ASSET_PART_UNIT,
1173
- find: async (params) => {
1174
- let res = await this._fetch(this.svAPIEndpoint, this.assetPartUnit._path, params);
1175
- return res;
1176
- },
1177
- get: async (id, params) => {
1178
- return await this._fetch(this.svAPIEndpoint, this.assetPartUnit._path + `/${id}`, params);
1179
- },
1180
- update: async (id, body) => {
1181
- let res = await this._update(this.svAPIEndpoint, this.assetPartUnit._path + `/${id}`, body);
1182
- return res;
1183
- },
1184
- };
1185
- this.assetPartReceival = {
1186
- _path: this._end_points.ASSET_PART_RECEIVAL,
1187
- find: async (params) => {
1188
- let res = await this._fetch(this.svAPIEndpoint, this.assetPartReceival._path, params);
1189
- return res;
1190
- },
1191
- get: async (id, params) => {
1192
- return await this._fetch(this.svAPIEndpoint, this.assetPartReceival._path + `/${id}`, params);
1193
- },
1194
- create: async (body) => {
1195
- let res = await this._create(this.svAPIEndpoint, this.assetPartReceival._path, body);
1196
- return res;
1197
- },
1198
- update: async (id, body) => {
1199
- let res = await this._update(this.svAPIEndpoint, this.assetPartReceival._path + `/${id}`, body);
1200
- return res;
1201
- },
1202
- patch: async (params, body) => {
1203
- let res = await this._patch(this.svAPIEndpoint, this.assetPartReceival._path, body, params);
1204
- return res;
1205
- },
1206
- };
1207
- this.assetPartTransfer = {
1208
- _path: this._end_points.ASSET_PART_TRANSFER,
1209
- find: async (params) => {
1210
- let res = await this._fetch(this.svAPIEndpoint, this.assetPartTransfer._path, params);
1211
- return res;
1212
- },
1213
- get: async (id, params) => {
1214
- return await this._fetch(this.svAPIEndpoint, this.assetPartTransfer._path + `/${id}`, params);
1215
- },
1216
- create: async (body) => {
1217
- let res = await this._create(this.svAPIEndpoint, this.assetPartTransfer._path, body);
1218
- return res;
1219
- },
1220
- update: async (id, body) => {
1221
- let res = await this._update(this.svAPIEndpoint, this.assetPartTransfer._path + `/${id}`, body);
1222
- return res;
1223
- },
1224
- patch: async (params, body) => {
1225
- let res = await this._patch(this.svAPIEndpoint, this.assetPartTransfer._path, body, params);
1226
- return res;
1227
- },
1228
- };
1229
- this.returnAssetPartUnit = {
1230
- _path: this._end_points.RETURN_ASSET_PART_UNIT,
1231
- find: async (params) => {
1232
- let res = await this._fetch(this.svAPIEndpoint, this.returnAssetPartUnit._path, params);
1233
- return res;
1234
- },
1235
- get: async (id, params) => {
1236
- return await this._fetch(this.svAPIEndpoint, this.returnAssetPartUnit._path + `/${id}`, params);
1237
- },
1238
- create: async (body) => {
1239
- let res = await this._create(this.svAPIEndpoint, this.returnAssetPartUnit._path, body);
1240
- return res;
1241
- },
1242
- update: async (id, body) => {
1243
- let res = await this._update(this.svAPIEndpoint, this.returnAssetPartUnit._path + `/${id}`, body);
1244
- return res;
1245
- },
1246
- patch: async (params, body) => {
1247
- let res = await this._patch(this.svAPIEndpoint, this.returnAssetPartUnit._path, body, params);
1248
- return res;
1249
- },
1250
- };
1251
- this.storeAssetPartUnit = {
1252
- _path: this._end_points.STORE_ASSET_PART_UNIT,
1253
- find: async (params) => {
1254
- let res = await this._fetch(this.svAPIEndpoint, this.storeAssetPartUnit._path, params);
1255
- return res;
1256
- },
1257
- get: async (id, params) => {
1258
- return await this._fetch(this.svAPIEndpoint, this.storeAssetPartUnit._path + `/${id}`, params);
1259
- },
1260
- create: async (body) => {
1261
- let res = await this._create(this.svAPIEndpoint, this.storeAssetPartUnit._path, body);
1262
- return res;
1263
- },
1264
- update: async (id, body) => {
1265
- let res = await this._update(this.svAPIEndpoint, this.storeAssetPartUnit._path + `/${id}`, body);
1266
- return res;
1267
- },
1268
- patch: async (params, body) => {
1269
- let res = await this._patch(this.svAPIEndpoint, this.storeAssetPartUnit._path, body, params);
1270
- return res;
1271
- },
1272
- };
1273
- this.ocrInvoiceJobTemplate = {
1274
- _path: this._end_points.OCR_INVOICE_JOB_TEMPLATE,
1275
- find: async (params) => {
1276
- let res = await this._fetch(this.svAPIEndpoint, this.ocrInvoiceJobTemplate._path, params);
1277
- return res;
1278
- },
1279
- get: async (id) => {
1280
- return await this._fetch(this.svAPIEndpoint, this.ocrInvoiceJobTemplate._path + `/${id}`);
1281
- },
1282
- create: async (body) => {
1283
- let res = await this._create(this.svAPIEndpoint, this.ocrInvoiceJobTemplate._path, body);
1284
- return res;
1285
- },
1286
- update: async (id, body) => {
1287
- let res = await this._update(this.svAPIEndpoint, this.ocrInvoiceJobTemplate._path + `/${id}`, body);
1288
- return res;
1289
- },
1290
- };
1291
- this.ocrInvoiceJobGroup = {
1292
- _path: this._end_points.OCR_INVOICE_JOB_GROUP,
1293
- find: async (params) => {
1294
- let res = await this._fetch(this.svAPIEndpoint, this.ocrInvoiceJobGroup._path, params);
1295
- return res;
1296
- },
1297
- get: async (id) => {
1298
- return await this._fetch(this.svAPIEndpoint, this.ocrInvoiceJobGroup._path + `/${id}`);
1299
- },
1300
- create: async (body) => {
1301
- let res = await this._create(this.svAPIEndpoint, this.ocrInvoiceJobGroup._path, body);
1302
- return res;
1303
- },
1304
- };
1305
- this.activityAiSalesOrder = {
1306
- _path: this._end_points.ACTIVITY_AI_SALES_ORDER,
1307
- find: async (params) => {
1308
- let res = await this._fetch(this.svAPIEndpoint, this.activityAiSalesOrder._path, params);
1309
- return res;
1310
- },
1311
- get: async (id) => {
1312
- return await this._fetch(this.svAPIEndpoint, this.activityAiSalesOrder._path + `/${id}`);
1313
- },
1314
- create: async (body) => {
1315
- let res = await this._create(this.svAPIEndpoint, this.activityAiSalesOrder._path, body);
1316
- return res;
1317
- },
1318
- };
1319
- this.ocrInvoiceJob = {
1320
- _path: this._end_points.OCR_INVOICE_JOB,
1321
- find: async (params) => {
1322
- let res = await this._fetch(this.svAPIEndpoint, this.ocrInvoiceJob._path, params);
1323
- return res;
1324
- },
1325
- get: async (id) => {
1326
- return await this._fetch(this.svAPIEndpoint, this.ocrInvoiceJob._path + `/${id}`);
1327
- },
1328
- };
1329
- this.ocrInvoiceJobPage = {
1330
- _path: this._end_points.OCR_INVOICE_JOB_PAGE,
1331
- find: async (params) => {
1332
- let res = await this._fetch(this.svAPIEndpoint, this.ocrInvoiceJobPage._path, params);
1333
- return res;
1334
- },
1335
- get: async (id) => {
1336
- return await this._fetch(this.svAPIEndpoint, this.ocrInvoiceJobPage._path + `/${id}`);
1337
- },
1338
- update: async (id, body) => {
1339
- let res = await this._update(this.svAPIEndpoint, this.ocrInvoiceJobPage._path + `/${id}`, body);
1340
- return res;
1341
- },
1342
- };
1343
- this.svAPIEndpoint =
1344
- !options?.env || options?.env == "production"
1345
- ? "https://sv.api.repzo.me"
1346
- : options?.env == "staging"
1347
- ? "https://staging.sv.api.repzo.me"
1348
- : options?.env == "local"
1349
- ? "http://localhost:3030"
1350
- : "";
1351
- this.headers = {
1352
- "api-key": apiKey,
1353
- "Content-Type": "application/json",
1354
- Accept: "application/json",
1355
- };
1356
- if (options?.headers)
1357
- Object.assign(this.headers, options.headers);
1358
- if (options?.timeout) {
1359
- this.timeout = options.timeout;
1360
- }
1361
- else {
1362
- this.timeout = 180000;
1363
- }
1364
- }
1365
- async _fetch(baseUrl, path, params) {
1366
- let res = await axios.get(`${baseUrl}/${path}`, {
1367
- params,
1368
- headers: this.headers,
1369
- timeout: this.timeout,
1370
- });
1371
- return res.data;
1372
- }
1373
- async _create(baseUrl, path, body, params) {
1374
- let res = await axios.post(`${baseUrl}/${path}`, body, {
1375
- params,
1376
- headers: this.headers,
1377
- timeout: this.timeout,
1378
- });
1379
- return res.data;
1380
- }
1381
- async _update(baseUrl, path, body, params) {
1382
- let res = await axios.put(`${baseUrl}/${path}`, body, {
1383
- params,
1384
- headers: this.headers,
1385
- timeout: this.timeout,
1386
- });
1387
- return res.data;
1388
- }
1389
- async _patch(baseUrl, path, body, params) {
1390
- let res = await axios.put(`${baseUrl}/${path}`, body, {
1391
- params,
1392
- headers: this.headers,
1393
- timeout: this.timeout,
1394
- });
1395
- return res.data;
1396
- }
1397
- async _delete(baseUrl, path, params) {
1398
- let res = await axios.delete(`${baseUrl}/${path}`, {
1399
- params,
1400
- headers: this.headers,
1401
- timeout: this.timeout,
1402
- });
1403
- return res.data;
3
+ export default class Repzo {
4
+ constructor(apiKey, options) {
5
+ this._end_points = {
6
+ CLIENT: "client",
7
+ PRODUCT: "product",
8
+ VARIANT: "variant",
9
+ CATEGORY: "product-category",
10
+ SUB_CATEGORY: "product-sub-category",
11
+ BRAND: "product-brand",
12
+ PRODUCT_GROUP: "product-group",
13
+ TAX: "tax",
14
+ MEASUREUNIT: "measureunits",
15
+ MEASUREUNIT_FAMILY: "measureunit-family",
16
+ MEDIA: "media",
17
+ PRICELIST: "pricelists",
18
+ PRICELIST_ITEM: "pricelistsitems",
19
+ TEAM: "teams",
20
+ RETURN_REASON: "return-reason",
21
+ REP: "rep",
22
+ TAG: "tag",
23
+ WAREHOUSE: "warehouse",
24
+ ROUTE: "route",
25
+ PRODUCT_MODIFIERS_GROUP: "product-modifiers-group",
26
+ CHANNEL: "client-channel",
27
+ SPECIALITY: "speciality",
28
+ CLIENT_CONTACT: "client-contact",
29
+ PAYMENT_TERM: "paymentterms",
30
+ BANK: "banks",
31
+ BANK_LIST: "bankslists",
32
+ CUSTOM_STATUS: "custom-status",
33
+ CUSTOM_LIST: "custom-list",
34
+ CUSTOM_LIST_ITEM: "custom-list-item",
35
+ INVENTORY_ADJUSTMENT_REASON: "inventory-adjustment-reason",
36
+ WORKORDER: "workorder",
37
+ SUPPLIER: "supplier",
38
+ QUICK_CONVERT_TO_PDF: "quick-convert-to-pdf",
39
+ VISIT: "visit",
40
+ INVOICE: "fullinvoices",
41
+ PROFORMA: "proforma",
42
+ PAYMENT: "payments",
43
+ REFUND: "refund",
44
+ SETTLEMENT: "settlement",
45
+ CHECK: "checks",
46
+ DAY: "day",
47
+ RECEIVING_MATERIAL: "receiving-material",
48
+ ADJUST_ACCOUNT: "adjust-account",
49
+ TRANSFER: "transfer",
50
+ MSL: "msl",
51
+ MSL_PRODUCT: "msl-products",
52
+ MEDIA_STORAGE: "media-storage",
53
+ STORECHECK_TEMPLATE: "storecheck-template",
54
+ ACTIVITY_STORECHECK: "activity-storecheck",
55
+ ADJUST_INVENTORY: "adjust-inventory",
56
+ INVENTORY: "inventory",
57
+ INTEGRATION_APP: "integration-app",
58
+ JOIN_ACTIONS_WEBHOOK: "svix-integration",
59
+ INTEGRATION_ACTION_LOG: "integration-action-log",
60
+ INTEGRATION_COMMAND_LOG: "integration-command-log",
61
+ PATCH_ACTION: "patch-action",
62
+ UPDATE_INTEGRATION_META: "update-integration-meta",
63
+ ASSET_PART_TYPE: "asset-part-type",
64
+ ASSET_PART: "asset-part",
65
+ ASSET_PART_UNIT: "asset-part-unit",
66
+ ASSET_PART_RECEIVAL: "asset-part-receival",
67
+ ASSET_PART_TRANSFER: "asset-part-transfer",
68
+ RETURN_ASSET_PART_UNIT: "return-asset-part-unit",
69
+ STORE_ASSET_PART_UNIT: "store-asset-part-unit",
70
+ OCR_INVOICE_JOB_TEMPLATE: "ocr-invoice-job-template",
71
+ OCR_INVOICE_JOB_GROUP: "ocr-invoice-job-group",
72
+ ACTIVITY_AI_SALES_ORDER: "activity-ai-sales-order",
73
+ OCR_INVOICE_JOB: "ocr-invoice-job",
74
+ OCR_INVOICE_JOB_PAGE: "ocr-invoice-job-page",
75
+ };
76
+ this.END_POINTS = this._end_points;
77
+ this.client = {
78
+ _path: this._end_points.CLIENT,
79
+ find: async (params) => {
80
+ let res = await this._fetch(
81
+ this.svAPIEndpoint,
82
+ this.client._path,
83
+ params
84
+ );
85
+ return res;
86
+ },
87
+ get: async (id, params) => {
88
+ return await this._fetch(
89
+ this.svAPIEndpoint,
90
+ this.client._path + `/${id}`,
91
+ params
92
+ );
93
+ },
94
+ create: async (body) => {
95
+ let res = await this._create(
96
+ this.svAPIEndpoint,
97
+ this.client._path,
98
+ body
99
+ );
100
+ return res;
101
+ },
102
+ update: async (id, body) => {
103
+ let res = await this._update(
104
+ this.svAPIEndpoint,
105
+ this.client._path + `/${id}`,
106
+ body
107
+ );
108
+ return res;
109
+ },
110
+ remove: async (id) => {
111
+ let res = await this._delete(
112
+ this.svAPIEndpoint,
113
+ this.client._path + `/${id}`
114
+ );
115
+ return res;
116
+ },
117
+ };
118
+ this.product = {
119
+ _path: this._end_points.PRODUCT,
120
+ find: async (params) => {
121
+ let res = await this._fetch(
122
+ this.svAPIEndpoint,
123
+ this.product._path,
124
+ params
125
+ );
126
+ return res;
127
+ },
128
+ get: async (id, params) => {
129
+ return await this._fetch(
130
+ this.svAPIEndpoint,
131
+ this.product._path + `/${id}`,
132
+ params
133
+ );
134
+ },
135
+ create: async (body) => {
136
+ let res = await this._create(
137
+ this.svAPIEndpoint,
138
+ this.product._path,
139
+ body
140
+ );
141
+ return res;
142
+ },
143
+ update: async (id, body) => {
144
+ let res = await this._update(
145
+ this.svAPIEndpoint,
146
+ this.product._path + `/${id}`,
147
+ body
148
+ );
149
+ return res;
150
+ },
151
+ remove: async (id) => {
152
+ let res = await this._delete(
153
+ this.svAPIEndpoint,
154
+ this.product._path + `/${id}`
155
+ );
156
+ return res;
157
+ },
158
+ };
159
+ this.variant = {
160
+ _path: this._end_points.VARIANT,
161
+ find: async (params) => {
162
+ let res = await this._fetch(
163
+ this.svAPIEndpoint,
164
+ this.variant._path,
165
+ params
166
+ );
167
+ return res;
168
+ },
169
+ get: async (id, params) => {
170
+ return await this._fetch(
171
+ this.svAPIEndpoint,
172
+ this.variant._path + `/${id}`,
173
+ params
174
+ );
175
+ },
176
+ create: async (body) => {
177
+ let res = await this._create(
178
+ this.svAPIEndpoint,
179
+ this.variant._path,
180
+ body
181
+ );
182
+ return res;
183
+ },
184
+ update: async (id, body) => {
185
+ let res = await this._update(
186
+ this.svAPIEndpoint,
187
+ this.variant._path + `/${id}`,
188
+ body
189
+ );
190
+ return res;
191
+ },
192
+ remove: async (id) => {
193
+ let res = await this._delete(
194
+ this.svAPIEndpoint,
195
+ this.variant._path + `/${id}`
196
+ );
197
+ return res;
198
+ },
199
+ };
200
+ this.category = {
201
+ _path: this._end_points.CATEGORY,
202
+ find: async (params) => {
203
+ let res = await this._fetch(
204
+ this.svAPIEndpoint,
205
+ this.category._path,
206
+ params
207
+ );
208
+ return res;
209
+ },
210
+ get: async (id) => {
211
+ return await this._fetch(
212
+ this.svAPIEndpoint,
213
+ this.category._path + `/${id}`
214
+ );
215
+ },
216
+ create: async (body) => {
217
+ let res = await this._create(
218
+ this.svAPIEndpoint,
219
+ this.category._path,
220
+ body
221
+ );
222
+ return res;
223
+ },
224
+ update: async (id, body) => {
225
+ let res = await this._update(
226
+ this.svAPIEndpoint,
227
+ this.category._path + `/${id}`,
228
+ body
229
+ );
230
+ return res;
231
+ },
232
+ remove: async (id) => {
233
+ let res = await this._delete(
234
+ this.svAPIEndpoint,
235
+ this.category._path + `/${id}`
236
+ );
237
+ return res;
238
+ },
239
+ };
240
+ this.sub_category = {
241
+ _path: this._end_points.SUB_CATEGORY,
242
+ find: async (params) => {
243
+ let res = await this._fetch(
244
+ this.svAPIEndpoint,
245
+ this.sub_category._path,
246
+ params
247
+ );
248
+ return res;
249
+ },
250
+ get: async (id, params) => {
251
+ return await this._fetch(
252
+ this.svAPIEndpoint,
253
+ this.sub_category._path + `/${id}`,
254
+ params
255
+ );
256
+ },
257
+ create: async (body) => {
258
+ let res = await this._create(
259
+ this.svAPIEndpoint,
260
+ this.sub_category._path,
261
+ body
262
+ );
263
+ return res;
264
+ },
265
+ update: async (id, body) => {
266
+ let res = await this._update(
267
+ this.svAPIEndpoint,
268
+ this.sub_category._path + `/${id}`,
269
+ body
270
+ );
271
+ return res;
272
+ },
273
+ remove: async (id) => {
274
+ let res = await this._delete(
275
+ this.svAPIEndpoint,
276
+ this.sub_category._path + `/${id}`
277
+ );
278
+ return res;
279
+ },
280
+ };
281
+ this.brand = {
282
+ _path: this._end_points.BRAND,
283
+ find: async (params) => {
284
+ let res = await this._fetch(
285
+ this.svAPIEndpoint,
286
+ this.brand._path,
287
+ params
288
+ );
289
+ return res;
290
+ },
291
+ get: async (id) => {
292
+ return await this._fetch(
293
+ this.svAPIEndpoint,
294
+ this.brand._path + `/${id}`
295
+ );
296
+ },
297
+ create: async (body) => {
298
+ let res = await this._create(
299
+ this.svAPIEndpoint,
300
+ this.brand._path,
301
+ body
302
+ );
303
+ return res;
304
+ },
305
+ update: async (id, body) => {
306
+ let res = await this._update(
307
+ this.svAPIEndpoint,
308
+ this.brand._path + `/${id}`,
309
+ body
310
+ );
311
+ return res;
312
+ },
313
+ remove: async (id) => {
314
+ let res = await this._delete(
315
+ this.svAPIEndpoint,
316
+ this.brand._path + `/${id}`
317
+ );
318
+ return res;
319
+ },
320
+ };
321
+ this.product_group = {
322
+ _path: this._end_points.PRODUCT_GROUP,
323
+ find: async (params) => {
324
+ let res = await this._fetch(
325
+ this.svAPIEndpoint,
326
+ this.product_group._path,
327
+ params
328
+ );
329
+ return res;
330
+ },
331
+ get: async (id) => {
332
+ return await this._fetch(
333
+ this.svAPIEndpoint,
334
+ this.product_group._path + `/${id}`
335
+ );
336
+ },
337
+ create: async (body) => {
338
+ let res = await this._create(
339
+ this.svAPIEndpoint,
340
+ this.product_group._path,
341
+ body
342
+ );
343
+ return res;
344
+ },
345
+ update: async (id, body) => {
346
+ let res = await this._update(
347
+ this.svAPIEndpoint,
348
+ this.product_group._path + `/${id}`,
349
+ body
350
+ );
351
+ return res;
352
+ },
353
+ remove: async (id) => {
354
+ let res = await this._delete(
355
+ this.svAPIEndpoint,
356
+ this.product_group._path + `/${id}`
357
+ );
358
+ return res;
359
+ },
360
+ };
361
+ this.tax = {
362
+ _path: this._end_points.TAX,
363
+ find: async (params) => {
364
+ let res = await this._fetch(this.svAPIEndpoint, this.tax._path, params);
365
+ return res;
366
+ },
367
+ get: async (id) => {
368
+ return await this._fetch(this.svAPIEndpoint, this.tax._path + `/${id}`);
369
+ },
370
+ create: async (body) => {
371
+ let res = await this._create(this.svAPIEndpoint, this.tax._path, body);
372
+ return res;
373
+ },
374
+ update: async (id, body) => {
375
+ let res = await this._update(
376
+ this.svAPIEndpoint,
377
+ this.tax._path + `/${id}`,
378
+ body
379
+ );
380
+ return res;
381
+ },
382
+ remove: async (id) => {
383
+ let res = await this._delete(
384
+ this.svAPIEndpoint,
385
+ this.tax._path + `/${id}`
386
+ );
387
+ return res;
388
+ },
389
+ };
390
+ this.measureunit = {
391
+ _path: this._end_points.MEASUREUNIT,
392
+ find: async (params) => {
393
+ let res = await this._fetch(
394
+ this.svAPIEndpoint,
395
+ this.measureunit._path,
396
+ params
397
+ );
398
+ return res;
399
+ },
400
+ get: async (id) => {
401
+ return await this._fetch(
402
+ this.svAPIEndpoint,
403
+ this.measureunit._path + `/${id}`
404
+ );
405
+ },
406
+ create: async (body) => {
407
+ let res = await this._create(
408
+ this.svAPIEndpoint,
409
+ this.measureunit._path,
410
+ body
411
+ );
412
+ return res;
413
+ },
414
+ update: async (id, body) => {
415
+ let res = await this._update(
416
+ this.svAPIEndpoint,
417
+ this.measureunit._path + `/${id}`,
418
+ body
419
+ );
420
+ return res;
421
+ },
422
+ remove: async (id) => {
423
+ let res = await this._delete(
424
+ this.svAPIEndpoint,
425
+ this.measureunit._path + `/${id}`
426
+ );
427
+ return res;
428
+ },
429
+ };
430
+ this.measureunitFamily = {
431
+ _path: this._end_points.MEASUREUNIT_FAMILY,
432
+ find: async (params) => {
433
+ let res = await this._fetch(
434
+ this.svAPIEndpoint,
435
+ this.measureunitFamily._path,
436
+ params
437
+ );
438
+ return res;
439
+ },
440
+ get: async (id) => {
441
+ return await this._fetch(
442
+ this.svAPIEndpoint,
443
+ this.measureunitFamily._path + `/${id}`
444
+ );
445
+ },
446
+ create: async (body) => {
447
+ let res = await this._create(
448
+ this.svAPIEndpoint,
449
+ this.measureunitFamily._path,
450
+ body
451
+ );
452
+ return res;
453
+ },
454
+ update: async (id, body) => {
455
+ let res = await this._update(
456
+ this.svAPIEndpoint,
457
+ this.measureunitFamily._path + `/${id}`,
458
+ body
459
+ );
460
+ return res;
461
+ },
462
+ remove: async (id) => {
463
+ let res = await this._delete(
464
+ this.svAPIEndpoint,
465
+ this.measureunitFamily._path + `/${id}`
466
+ );
467
+ return res;
468
+ },
469
+ };
470
+ this.media = {
471
+ _path: this._end_points.MEDIA,
472
+ find: async (params) => {
473
+ let res = await this._fetch(
474
+ this.svAPIEndpoint,
475
+ this.media._path,
476
+ params
477
+ );
478
+ return res;
479
+ },
480
+ get: async (id) => {
481
+ return await this._fetch(
482
+ this.svAPIEndpoint,
483
+ this.media._path + `/${id}`
484
+ );
485
+ },
486
+ create: async (body) => {
487
+ let res = await this._create(
488
+ this.svAPIEndpoint,
489
+ this.media._path,
490
+ body
491
+ );
492
+ return res;
493
+ },
494
+ update: async (id, body) => {
495
+ let res = await this._update(
496
+ this.svAPIEndpoint,
497
+ this.media._path + `/${id}`,
498
+ body
499
+ );
500
+ return res;
501
+ },
502
+ remove: async (id) => {
503
+ let res = await this._delete(
504
+ this.svAPIEndpoint,
505
+ this.media._path + `/${id}`
506
+ );
507
+ return res;
508
+ },
509
+ };
510
+ this.priceList = {
511
+ _path: this._end_points.PRICELIST,
512
+ find: async (params) => {
513
+ let res = await this._fetch(
514
+ this.svAPIEndpoint,
515
+ this.priceList._path,
516
+ params
517
+ );
518
+ return res;
519
+ },
520
+ get: async (id) => {
521
+ return await this._fetch(
522
+ this.svAPIEndpoint,
523
+ this.priceList._path + `/${id}`
524
+ );
525
+ },
526
+ create: async (body) => {
527
+ let res = await this._create(
528
+ this.svAPIEndpoint,
529
+ this.priceList._path,
530
+ body
531
+ );
532
+ return res;
533
+ },
534
+ update: async (id, body) => {
535
+ let res = await this._update(
536
+ this.svAPIEndpoint,
537
+ this.priceList._path + `/${id}`,
538
+ body
539
+ );
540
+ return res;
541
+ },
542
+ remove: async (id) => {
543
+ let res = await this._delete(
544
+ this.svAPIEndpoint,
545
+ this.priceList._path + `/${id}`
546
+ );
547
+ return res;
548
+ },
549
+ };
550
+ this.priceListItem = {
551
+ _path: this._end_points.PRICELIST_ITEM,
552
+ find: async (params) => {
553
+ let res = await this._fetch(
554
+ this.svAPIEndpoint,
555
+ this.priceListItem._path,
556
+ params
557
+ );
558
+ return res;
559
+ },
560
+ get: async (id) => {
561
+ return await this._fetch(
562
+ this.svAPIEndpoint,
563
+ this.priceListItem._path + `/${id}`
564
+ );
565
+ },
566
+ create: async (body) => {
567
+ let res = await this._create(
568
+ this.svAPIEndpoint,
569
+ this.priceListItem._path,
570
+ body
571
+ );
572
+ return res;
573
+ },
574
+ update: async (id, body) => {
575
+ let res = await this._update(
576
+ this.svAPIEndpoint,
577
+ this.priceListItem._path + `/${id}`,
578
+ body
579
+ );
580
+ return res;
581
+ },
582
+ remove: async (id) => {
583
+ let res = await this._delete(
584
+ this.svAPIEndpoint,
585
+ this.priceListItem._path + `/${id}`
586
+ );
587
+ return res;
588
+ },
589
+ };
590
+ this.team = {
591
+ _path: this._end_points.TEAM,
592
+ find: async (params) => {
593
+ let res = await this._fetch(
594
+ this.svAPIEndpoint,
595
+ this.team._path,
596
+ params
597
+ );
598
+ return res;
599
+ },
600
+ get: async (id) => {
601
+ return await this._fetch(
602
+ this.svAPIEndpoint,
603
+ this.team._path + `/${id}`
604
+ );
605
+ },
606
+ create: async (body) => {
607
+ let res = await this._create(this.svAPIEndpoint, this.team._path, body);
608
+ return res;
609
+ },
610
+ update: async (id, body) => {
611
+ let res = await this._update(
612
+ this.svAPIEndpoint,
613
+ this.team._path + `/${id}`,
614
+ body
615
+ );
616
+ return res;
617
+ },
618
+ remove: async (id) => {
619
+ let res = await this._delete(
620
+ this.svAPIEndpoint,
621
+ this.team._path + `/${id}`
622
+ );
623
+ return res;
624
+ },
625
+ };
626
+ this.returnReason = {
627
+ _path: this._end_points.RETURN_REASON,
628
+ find: async (params) => {
629
+ let res = await this._fetch(
630
+ this.svAPIEndpoint,
631
+ this.returnReason._path,
632
+ params
633
+ );
634
+ return res;
635
+ },
636
+ get: async (id) => {
637
+ return await this._fetch(
638
+ this.svAPIEndpoint,
639
+ this.returnReason._path + `/${id}`
640
+ );
641
+ },
642
+ create: async (body) => {
643
+ let res = await this._create(
644
+ this.svAPIEndpoint,
645
+ this.returnReason._path,
646
+ body
647
+ );
648
+ return res;
649
+ },
650
+ update: async (id, body) => {
651
+ let res = await this._update(
652
+ this.svAPIEndpoint,
653
+ this.returnReason._path + `/${id}`,
654
+ body
655
+ );
656
+ return res;
657
+ },
658
+ remove: async (id) => {
659
+ let res = await this._delete(
660
+ this.svAPIEndpoint,
661
+ this.returnReason._path + `/${id}`
662
+ );
663
+ return res;
664
+ },
665
+ };
666
+ this.rep = {
667
+ _path: this._end_points.REP,
668
+ find: async (params) => {
669
+ let res = await this._fetch(this.svAPIEndpoint, this.rep._path, params);
670
+ return res;
671
+ },
672
+ get: async (id, params) => {
673
+ return await this._fetch(
674
+ this.svAPIEndpoint,
675
+ this.rep._path + `/${id}`,
676
+ params
677
+ );
678
+ },
679
+ create: async (body) => {
680
+ let res = await this._create(this.svAPIEndpoint, this.rep._path, body);
681
+ return res;
682
+ },
683
+ update: async (id, body) => {
684
+ let res = await this._update(
685
+ this.svAPIEndpoint,
686
+ this.rep._path + `/${id}`,
687
+ body
688
+ );
689
+ return res;
690
+ },
691
+ remove: async (id) => {
692
+ let res = await this._delete(
693
+ this.svAPIEndpoint,
694
+ this.rep._path + `/${id}`
695
+ );
696
+ return res;
697
+ },
698
+ };
699
+ this.tag = {
700
+ _path: this._end_points.TAG,
701
+ find: async (params) => {
702
+ let res = await this._fetch(this.svAPIEndpoint, this.tag._path, params);
703
+ return res;
704
+ },
705
+ get: async (id) => {
706
+ return await this._fetch(this.svAPIEndpoint, this.tag._path + `/${id}`);
707
+ },
708
+ create: async (body) => {
709
+ let res = await this._create(this.svAPIEndpoint, this.tag._path, body);
710
+ return res;
711
+ },
712
+ update: async (id, body) => {
713
+ let res = await this._update(
714
+ this.svAPIEndpoint,
715
+ this.tag._path + `/${id}`,
716
+ body
717
+ );
718
+ return res;
719
+ },
720
+ remove: async (id) => {
721
+ let res = await this._delete(
722
+ this.svAPIEndpoint,
723
+ this.tag._path + `/${id}`
724
+ );
725
+ return res;
726
+ },
727
+ };
728
+ this.warehouse = {
729
+ _path: this._end_points.WAREHOUSE,
730
+ find: async (params) => {
731
+ let res = await this._fetch(
732
+ this.svAPIEndpoint,
733
+ this.warehouse._path,
734
+ params
735
+ );
736
+ return res;
737
+ },
738
+ get: async (id) => {
739
+ return await this._fetch(
740
+ this.svAPIEndpoint,
741
+ this.warehouse._path + `/${id}`
742
+ );
743
+ },
744
+ create: async (body) => {
745
+ let res = await this._create(
746
+ this.svAPIEndpoint,
747
+ this.warehouse._path,
748
+ body
749
+ );
750
+ return res;
751
+ },
752
+ update: async (id, body) => {
753
+ let res = await this._update(
754
+ this.svAPIEndpoint,
755
+ this.warehouse._path + `/${id}`,
756
+ body
757
+ );
758
+ return res;
759
+ },
760
+ remove: async (id) => {
761
+ let res = await this._delete(
762
+ this.svAPIEndpoint,
763
+ this.warehouse._path + `/${id}`
764
+ );
765
+ return res;
766
+ },
767
+ };
768
+ this.route = {
769
+ _path: this._end_points.ROUTE,
770
+ find: async (params) => {
771
+ let res = await this._fetch(
772
+ this.svAPIEndpoint,
773
+ this.route._path,
774
+ params
775
+ );
776
+ return res;
777
+ },
778
+ get: async (id) => {
779
+ return await this._fetch(
780
+ this.svAPIEndpoint,
781
+ this.route._path + `/${id}`
782
+ );
783
+ },
784
+ create: async (body) => {
785
+ let res = await this._create(
786
+ this.svAPIEndpoint,
787
+ this.route._path,
788
+ body
789
+ );
790
+ return res;
791
+ },
792
+ update: async (id, body) => {
793
+ let res = await this._update(
794
+ this.svAPIEndpoint,
795
+ this.route._path + `/${id}`,
796
+ body
797
+ );
798
+ return res;
799
+ },
800
+ remove: async (id) => {
801
+ let res = await this._delete(
802
+ this.svAPIEndpoint,
803
+ this.route._path + `/${id}`
804
+ );
805
+ return res;
806
+ },
807
+ };
808
+ this.productModifiersGroup = {
809
+ _path: this._end_points.PRODUCT_MODIFIERS_GROUP,
810
+ find: async (params) => {
811
+ let res = await this._fetch(
812
+ this.svAPIEndpoint,
813
+ this.productModifiersGroup._path,
814
+ params
815
+ );
816
+ return res;
817
+ },
818
+ get: async (id) => {
819
+ return await this._fetch(
820
+ this.svAPIEndpoint,
821
+ this.productModifiersGroup._path + `/${id}`
822
+ );
823
+ },
824
+ create: async (body) => {
825
+ let res = await this._create(
826
+ this.svAPIEndpoint,
827
+ this.productModifiersGroup._path,
828
+ body
829
+ );
830
+ return res;
831
+ },
832
+ update: async (id, body) => {
833
+ let res = await this._update(
834
+ this.svAPIEndpoint,
835
+ this.productModifiersGroup._path + `/${id}`,
836
+ body
837
+ );
838
+ return res;
839
+ },
840
+ remove: async (id) => {
841
+ let res = await this._delete(
842
+ this.svAPIEndpoint,
843
+ this.productModifiersGroup._path + `/${id}`
844
+ );
845
+ return res;
846
+ },
847
+ };
848
+ this.channel = {
849
+ _path: this._end_points.CHANNEL,
850
+ find: async (params) => {
851
+ let res = await this._fetch(
852
+ this.svAPIEndpoint,
853
+ this.channel._path,
854
+ params
855
+ );
856
+ return res;
857
+ },
858
+ get: async (id) => {
859
+ return await this._fetch(
860
+ this.svAPIEndpoint,
861
+ this.channel._path + `/${id}`
862
+ );
863
+ },
864
+ create: async (body) => {
865
+ let res = await this._create(
866
+ this.svAPIEndpoint,
867
+ this.channel._path,
868
+ body
869
+ );
870
+ return res;
871
+ },
872
+ update: async (id, body) => {
873
+ let res = await this._update(
874
+ this.svAPIEndpoint,
875
+ this.channel._path + `/${id}`,
876
+ body
877
+ );
878
+ return res;
879
+ },
880
+ remove: async (id) => {
881
+ let res = await this._delete(
882
+ this.svAPIEndpoint,
883
+ this.channel._path + `/${id}`
884
+ );
885
+ return res;
886
+ },
887
+ };
888
+ this.speciality = {
889
+ _path: this._end_points.SPECIALITY,
890
+ find: async (params) => {
891
+ let res = await this._fetch(
892
+ this.svAPIEndpoint,
893
+ this.speciality._path,
894
+ params
895
+ );
896
+ return res;
897
+ },
898
+ get: async (id) => {
899
+ return await this._fetch(
900
+ this.svAPIEndpoint,
901
+ this.speciality._path + `/${id}`
902
+ );
903
+ },
904
+ create: async (body) => {
905
+ let res = await this._create(
906
+ this.svAPIEndpoint,
907
+ this.speciality._path,
908
+ body
909
+ );
910
+ return res;
911
+ },
912
+ update: async (id, body) => {
913
+ let res = await this._update(
914
+ this.svAPIEndpoint,
915
+ this.speciality._path + `/${id}`,
916
+ body
917
+ );
918
+ return res;
919
+ },
920
+ remove: async (id) => {
921
+ let res = await this._delete(
922
+ this.svAPIEndpoint,
923
+ this.speciality._path + `/${id}`
924
+ );
925
+ return res;
926
+ },
927
+ };
928
+ this.clientContact = {
929
+ _path: this._end_points.CLIENT_CONTACT,
930
+ find: async (params) => {
931
+ let res = await this._fetch(
932
+ this.svAPIEndpoint,
933
+ this.clientContact._path,
934
+ params
935
+ );
936
+ return res;
937
+ },
938
+ get: async (id) => {
939
+ return await this._fetch(
940
+ this.svAPIEndpoint,
941
+ this.clientContact._path + `/${id}`
942
+ );
943
+ },
944
+ create: async (body) => {
945
+ let res = await this._create(
946
+ this.svAPIEndpoint,
947
+ this.clientContact._path,
948
+ body
949
+ );
950
+ return res;
951
+ },
952
+ update: async (id, body) => {
953
+ let res = await this._update(
954
+ this.svAPIEndpoint,
955
+ this.clientContact._path + `/${id}`,
956
+ body
957
+ );
958
+ return res;
959
+ },
960
+ remove: async (id) => {
961
+ let res = await this._delete(
962
+ this.svAPIEndpoint,
963
+ this.clientContact._path + `/${id}`
964
+ );
965
+ return res;
966
+ },
967
+ };
968
+ this.paymentTerm = {
969
+ _path: this._end_points.PAYMENT_TERM,
970
+ find: async (params) => {
971
+ let res = await this._fetch(
972
+ this.svAPIEndpoint,
973
+ this.paymentTerm._path,
974
+ params
975
+ );
976
+ return res;
977
+ },
978
+ get: async (id) => {
979
+ return await this._fetch(
980
+ this.svAPIEndpoint,
981
+ this.paymentTerm._path + `/${id}`
982
+ );
983
+ },
984
+ create: async (body) => {
985
+ let res = await this._create(
986
+ this.svAPIEndpoint,
987
+ this.paymentTerm._path,
988
+ body
989
+ );
990
+ return res;
991
+ },
992
+ update: async (id, body) => {
993
+ let res = await this._update(
994
+ this.svAPIEndpoint,
995
+ this.paymentTerm._path + `/${id}`,
996
+ body
997
+ );
998
+ return res;
999
+ },
1000
+ remove: async (id) => {
1001
+ let res = await this._delete(
1002
+ this.svAPIEndpoint,
1003
+ this.paymentTerm._path + `/${id}`
1004
+ );
1005
+ return res;
1006
+ },
1007
+ };
1008
+ this.bank = {
1009
+ _path: this._end_points.BANK,
1010
+ find: async (params) => {
1011
+ let res = await this._fetch(
1012
+ this.svAPIEndpoint,
1013
+ this.bank._path,
1014
+ params
1015
+ );
1016
+ return res;
1017
+ },
1018
+ get: async (id) => {
1019
+ return await this._fetch(
1020
+ this.svAPIEndpoint,
1021
+ this.bank._path + `/${id}`
1022
+ );
1023
+ },
1024
+ create: async (body) => {
1025
+ let res = await this._create(this.svAPIEndpoint, this.bank._path, body);
1026
+ return res;
1027
+ },
1028
+ update: async (id, body) => {
1029
+ let res = await this._update(
1030
+ this.svAPIEndpoint,
1031
+ this.bank._path + `/${id}`,
1032
+ body
1033
+ );
1034
+ return res;
1035
+ },
1036
+ };
1037
+ this.bank_list = {
1038
+ _path: this._end_points.BANK_LIST,
1039
+ find: async (params) => {
1040
+ let res = await this._fetch(
1041
+ this.svAPIEndpoint,
1042
+ this.bank_list._path,
1043
+ params
1044
+ );
1045
+ return res;
1046
+ },
1047
+ get: async (id) => {
1048
+ return await this._fetch(
1049
+ this.svAPIEndpoint,
1050
+ this.bank_list._path + `/${id}`
1051
+ );
1052
+ },
1053
+ create: async (body) => {
1054
+ let res = await this._create(
1055
+ this.svAPIEndpoint,
1056
+ this.bank_list._path,
1057
+ body
1058
+ );
1059
+ return res;
1060
+ },
1061
+ update: async (id, body) => {
1062
+ let res = await this._update(
1063
+ this.svAPIEndpoint,
1064
+ this.bank_list._path + `/${id}`,
1065
+ body
1066
+ );
1067
+ return res;
1068
+ },
1069
+ };
1070
+ this.customStatus = {
1071
+ _path: this._end_points.CUSTOM_STATUS,
1072
+ find: async (params) => {
1073
+ let res = await this._fetch(
1074
+ this.svAPIEndpoint,
1075
+ this.customStatus._path,
1076
+ params
1077
+ );
1078
+ return res;
1079
+ },
1080
+ get: async (id) => {
1081
+ return await this._fetch(
1082
+ this.svAPIEndpoint,
1083
+ this.customStatus._path + `/${id}`
1084
+ );
1085
+ },
1086
+ create: async (body) => {
1087
+ let res = await this._create(
1088
+ this.svAPIEndpoint,
1089
+ this.customStatus._path,
1090
+ body
1091
+ );
1092
+ return res;
1093
+ },
1094
+ update: async (id, body) => {
1095
+ let res = await this._update(
1096
+ this.svAPIEndpoint,
1097
+ this.customStatus._path + `/${id}`,
1098
+ body
1099
+ );
1100
+ return res;
1101
+ },
1102
+ remove: async (id) => {
1103
+ let res = await this._delete(
1104
+ this.svAPIEndpoint,
1105
+ this.customStatus._path + `/${id}`
1106
+ );
1107
+ return res;
1108
+ },
1109
+ };
1110
+ this.customList = {
1111
+ _path: this._end_points.CUSTOM_LIST,
1112
+ find: async (params) => {
1113
+ let res = await this._fetch(
1114
+ this.svAPIEndpoint,
1115
+ this.customList._path,
1116
+ params
1117
+ );
1118
+ return res;
1119
+ },
1120
+ get: async (id, params) => {
1121
+ return await this._fetch(
1122
+ this.svAPIEndpoint,
1123
+ this.customList._path + `/${id}`,
1124
+ params
1125
+ );
1126
+ },
1127
+ create: async (body) => {
1128
+ let res = await this._create(
1129
+ this.svAPIEndpoint,
1130
+ this.customList._path,
1131
+ body
1132
+ );
1133
+ return res;
1134
+ },
1135
+ update: async (id, body) => {
1136
+ let res = await this._update(
1137
+ this.svAPIEndpoint,
1138
+ this.customList._path + `/${id}`,
1139
+ body
1140
+ );
1141
+ return res;
1142
+ },
1143
+ remove: async (id) => {
1144
+ let res = await this._delete(
1145
+ this.svAPIEndpoint,
1146
+ this.customList._path + `/${id}`
1147
+ );
1148
+ return res;
1149
+ },
1150
+ };
1151
+ this.customListItem = {
1152
+ _path: this._end_points.CUSTOM_LIST_ITEM,
1153
+ find: async (params) => {
1154
+ let res = await this._fetch(
1155
+ this.svAPIEndpoint,
1156
+ this.customListItem._path,
1157
+ params
1158
+ );
1159
+ return res;
1160
+ },
1161
+ get: async (id, params) => {
1162
+ return await this._fetch(
1163
+ this.svAPIEndpoint,
1164
+ this.customListItem._path + `/${id}`,
1165
+ params
1166
+ );
1167
+ },
1168
+ create: async (body) => {
1169
+ let res = await this._create(
1170
+ this.svAPIEndpoint,
1171
+ this.customListItem._path,
1172
+ body
1173
+ );
1174
+ return res;
1175
+ },
1176
+ update: async (id, body) => {
1177
+ let res = await this._update(
1178
+ this.svAPIEndpoint,
1179
+ this.customListItem._path + `/${id}`,
1180
+ body
1181
+ );
1182
+ return res;
1183
+ },
1184
+ remove: async (id) => {
1185
+ let res = await this._delete(
1186
+ this.svAPIEndpoint,
1187
+ this.customListItem._path + `/${id}`
1188
+ );
1189
+ return res;
1190
+ },
1191
+ };
1192
+ this.inventoryAdjustmentReason = {
1193
+ _path: this._end_points.INVENTORY_ADJUSTMENT_REASON,
1194
+ find: async (params) => {
1195
+ let res = await this._fetch(
1196
+ this.svAPIEndpoint,
1197
+ this.inventoryAdjustmentReason._path,
1198
+ params
1199
+ );
1200
+ return res;
1201
+ },
1202
+ get: async (id) => {
1203
+ return await this._fetch(
1204
+ this.svAPIEndpoint,
1205
+ this.inventoryAdjustmentReason._path + `/${id}`
1206
+ );
1207
+ },
1208
+ create: async (body) => {
1209
+ let res = await this._create(
1210
+ this.svAPIEndpoint,
1211
+ this.inventoryAdjustmentReason._path,
1212
+ body
1213
+ );
1214
+ return res;
1215
+ },
1216
+ update: async (id, body) => {
1217
+ let res = await this._update(
1218
+ this.svAPIEndpoint,
1219
+ this.customListItem._path + `/${id}`,
1220
+ body
1221
+ );
1222
+ return res;
1223
+ },
1224
+ remove: async (id) => {
1225
+ let res = await this._delete(
1226
+ this.svAPIEndpoint,
1227
+ this.inventoryAdjustmentReason._path + `/${id}`
1228
+ );
1229
+ return res;
1230
+ },
1231
+ };
1232
+ this.workorder = {
1233
+ _path: this._end_points.WORKORDER,
1234
+ find: async (params) => {
1235
+ let res = await this._fetch(
1236
+ this.svAPIEndpoint,
1237
+ this.workorder._path,
1238
+ params
1239
+ );
1240
+ return res;
1241
+ },
1242
+ get: async (id, params) => {
1243
+ return await this._fetch(
1244
+ this.svAPIEndpoint,
1245
+ this.workorder._path + `/${id}`,
1246
+ params
1247
+ );
1248
+ },
1249
+ };
1250
+ this.supplier = {
1251
+ _path: this._end_points.SUPPLIER,
1252
+ find: async (params) => {
1253
+ let res = await this._fetch(
1254
+ this.svAPIEndpoint,
1255
+ this.supplier._path,
1256
+ params
1257
+ );
1258
+ return res;
1259
+ },
1260
+ get: async (id, params) => {
1261
+ return await this._fetch(
1262
+ this.svAPIEndpoint,
1263
+ this.supplier._path + `/${id}`,
1264
+ params
1265
+ );
1266
+ },
1267
+ create: async (body) => {
1268
+ let res = await this._create(
1269
+ this.svAPIEndpoint,
1270
+ this.supplier._path,
1271
+ body
1272
+ );
1273
+ return res;
1274
+ },
1275
+ update: async (id, body) => {
1276
+ let res = await this._update(
1277
+ this.svAPIEndpoint,
1278
+ this.supplier._path + `/${id}`,
1279
+ body
1280
+ );
1281
+ return res;
1282
+ },
1283
+ };
1284
+ this.quickConvertToPdf = {
1285
+ _path: this._end_points.QUICK_CONVERT_TO_PDF,
1286
+ find: async (params) => {
1287
+ let res = await this._fetch(
1288
+ this.svAPIEndpoint,
1289
+ this.quickConvertToPdf._path,
1290
+ params
1291
+ );
1292
+ return res;
1293
+ },
1294
+ get: async (id, params) => {
1295
+ return await this._fetch(
1296
+ this.svAPIEndpoint,
1297
+ this.quickConvertToPdf._path + `/${id}`,
1298
+ params
1299
+ );
1300
+ },
1301
+ create: async (body) => {
1302
+ let res = await this._create(
1303
+ this.svAPIEndpoint,
1304
+ this.quickConvertToPdf._path,
1305
+ body
1306
+ );
1307
+ return res;
1308
+ },
1309
+ remove: async (id) => {
1310
+ let res = await this._delete(
1311
+ this.svAPIEndpoint,
1312
+ this.quickConvertToPdf._path + `/${id}`
1313
+ );
1314
+ return res;
1315
+ },
1316
+ };
1317
+ this.visit = {
1318
+ _path: this._end_points.VISIT,
1319
+ find: async (params) => {
1320
+ let res = await this._fetch(
1321
+ this.svAPIEndpoint,
1322
+ this.visit._path,
1323
+ params
1324
+ );
1325
+ return res;
1326
+ },
1327
+ get: async (id, params) => {
1328
+ return await this._fetch(
1329
+ this.svAPIEndpoint,
1330
+ this.visit._path + `/${id}`,
1331
+ params
1332
+ );
1333
+ },
1334
+ create: async (body) => {
1335
+ let res = await this._create(
1336
+ this.svAPIEndpoint,
1337
+ this.visit._path,
1338
+ body
1339
+ );
1340
+ return res;
1341
+ },
1342
+ update: async (id, body) => {
1343
+ let res = await this._update(
1344
+ this.svAPIEndpoint,
1345
+ this.visit._path + `/${id}`,
1346
+ body
1347
+ );
1348
+ return res;
1349
+ },
1350
+ };
1351
+ this.invoice = {
1352
+ _path: this._end_points.INVOICE,
1353
+ find: async (params) => {
1354
+ let res = await this._fetch(
1355
+ this.svAPIEndpoint,
1356
+ this.invoice._path,
1357
+ params
1358
+ );
1359
+ return res;
1360
+ },
1361
+ get: async (id, params) => {
1362
+ return await this._fetch(
1363
+ this.svAPIEndpoint,
1364
+ this.invoice._path + `/${id}`,
1365
+ params
1366
+ );
1367
+ },
1368
+ create: async (body) => {
1369
+ let res = await this._create(
1370
+ this.svAPIEndpoint,
1371
+ this.invoice._path,
1372
+ body
1373
+ );
1374
+ return res;
1375
+ },
1376
+ update: async (id, body) => {
1377
+ let res = await this._update(
1378
+ this.svAPIEndpoint,
1379
+ this.invoice._path + `/${id}`,
1380
+ body
1381
+ );
1382
+ return res;
1383
+ },
1384
+ };
1385
+ this.proforma = {
1386
+ _path: this._end_points.PROFORMA,
1387
+ find: async (params) => {
1388
+ let res = await this._fetch(
1389
+ this.svAPIEndpoint,
1390
+ this.proforma._path,
1391
+ params
1392
+ );
1393
+ return res;
1394
+ },
1395
+ get: async (id, params) => {
1396
+ return await this._fetch(
1397
+ this.svAPIEndpoint,
1398
+ this.proforma._path + `/${id}`,
1399
+ params
1400
+ );
1401
+ },
1402
+ create: async (body) => {
1403
+ let res = await this._create(
1404
+ this.svAPIEndpoint,
1405
+ this.proforma._path,
1406
+ body
1407
+ );
1408
+ return res;
1409
+ },
1410
+ update: async (id, body) => {
1411
+ let res = await this._update(
1412
+ this.svAPIEndpoint,
1413
+ this.proforma._path + `/${id}`,
1414
+ body
1415
+ );
1416
+ return res;
1417
+ },
1418
+ };
1419
+ this.payment = {
1420
+ _path: this._end_points.PAYMENT,
1421
+ find: async (params) => {
1422
+ let res = await this._fetch(
1423
+ this.svAPIEndpoint,
1424
+ this.payment._path,
1425
+ params
1426
+ );
1427
+ return res;
1428
+ },
1429
+ get: async (id, params) => {
1430
+ return await this._fetch(
1431
+ this.svAPIEndpoint,
1432
+ this.payment._path + `/${id}`,
1433
+ params
1434
+ );
1435
+ },
1436
+ create: async (body) => {
1437
+ let res = await this._create(
1438
+ this.svAPIEndpoint,
1439
+ this.payment._path,
1440
+ body
1441
+ );
1442
+ return res;
1443
+ },
1444
+ update: async (id, body) => {
1445
+ let res = await this._update(
1446
+ this.svAPIEndpoint,
1447
+ this.payment._path + `/${id}`,
1448
+ body
1449
+ );
1450
+ return res;
1451
+ },
1452
+ };
1453
+ this.refund = {
1454
+ _path: this._end_points.REFUND,
1455
+ find: async (params) => {
1456
+ let res = await this._fetch(
1457
+ this.svAPIEndpoint,
1458
+ this.refund._path,
1459
+ params
1460
+ );
1461
+ return res;
1462
+ },
1463
+ get: async (id, params) => {
1464
+ return await this._fetch(
1465
+ this.svAPIEndpoint,
1466
+ this.refund._path + `/${id}`,
1467
+ params
1468
+ );
1469
+ },
1470
+ create: async (body) => {
1471
+ let res = await this._create(
1472
+ this.svAPIEndpoint,
1473
+ this.refund._path,
1474
+ body
1475
+ );
1476
+ return res;
1477
+ },
1478
+ update: async (id, body) => {
1479
+ let res = await this._update(
1480
+ this.svAPIEndpoint,
1481
+ this.refund._path + `/${id}`,
1482
+ body
1483
+ );
1484
+ return res;
1485
+ },
1486
+ };
1487
+ this.settlement = {
1488
+ _path: this._end_points.SETTLEMENT,
1489
+ find: async (params) => {
1490
+ let res = await this._fetch(
1491
+ this.svAPIEndpoint,
1492
+ this.settlement._path,
1493
+ params
1494
+ );
1495
+ return res;
1496
+ },
1497
+ get: async (id, params) => {
1498
+ return await this._fetch(
1499
+ this.svAPIEndpoint,
1500
+ this.settlement._path + `/${id}`,
1501
+ params
1502
+ );
1503
+ },
1504
+ create: async (body) => {
1505
+ let res = await this._create(
1506
+ this.svAPIEndpoint,
1507
+ this.settlement._path,
1508
+ body
1509
+ );
1510
+ return res;
1511
+ },
1512
+ };
1513
+ this.check = {
1514
+ _path: this._end_points.CHECK,
1515
+ find: async (params) => {
1516
+ let res = await this._fetch(
1517
+ this.svAPIEndpoint,
1518
+ this.check._path,
1519
+ params
1520
+ );
1521
+ return res;
1522
+ },
1523
+ get: async (id, params) => {
1524
+ return await this._fetch(
1525
+ this.svAPIEndpoint,
1526
+ this.check._path + `/${id}`,
1527
+ params
1528
+ );
1529
+ },
1530
+ create: async (body) => {
1531
+ let res = await this._create(
1532
+ this.svAPIEndpoint,
1533
+ this.check._path,
1534
+ body
1535
+ );
1536
+ return res;
1537
+ },
1538
+ };
1539
+ this.day = {
1540
+ _path: this._end_points.DAY,
1541
+ find: async (params) => {
1542
+ let res = await this._fetch(this.svAPIEndpoint, this.day._path, params);
1543
+ return res;
1544
+ },
1545
+ get: async (id, params) => {
1546
+ return await this._fetch(
1547
+ this.svAPIEndpoint,
1548
+ this.day._path + `/${id}`,
1549
+ params
1550
+ );
1551
+ },
1552
+ create: async (body) => {
1553
+ let res = await this._create(this.svAPIEndpoint, this.day._path, body);
1554
+ return res;
1555
+ },
1556
+ };
1557
+ this.receivingMaterial = {
1558
+ _path: this._end_points.RECEIVING_MATERIAL,
1559
+ find: async (params) => {
1560
+ let res = await this._fetch(
1561
+ this.svAPIEndpoint,
1562
+ this.receivingMaterial._path,
1563
+ params
1564
+ );
1565
+ return res;
1566
+ },
1567
+ get: async (id, params) => {
1568
+ return await this._fetch(
1569
+ this.svAPIEndpoint,
1570
+ this.receivingMaterial._path + `/${id}`,
1571
+ params
1572
+ );
1573
+ },
1574
+ create: async (body) => {
1575
+ let res = await this._create(
1576
+ this.svAPIEndpoint,
1577
+ this.receivingMaterial._path,
1578
+ body
1579
+ );
1580
+ return res;
1581
+ },
1582
+ update: async (id, body) => {
1583
+ let res = await this._update(
1584
+ this.svAPIEndpoint,
1585
+ this.receivingMaterial._path + `/${id}`,
1586
+ body
1587
+ );
1588
+ return res;
1589
+ },
1590
+ };
1591
+ this.adjustAccount = {
1592
+ _path: this._end_points.ADJUST_ACCOUNT,
1593
+ find: async (params) => {
1594
+ let res = await this._fetch(
1595
+ this.svAPIEndpoint,
1596
+ this.adjustAccount._path,
1597
+ params
1598
+ );
1599
+ return res;
1600
+ },
1601
+ get: async (id, params) => {
1602
+ return await this._fetch(
1603
+ this.svAPIEndpoint,
1604
+ this.adjustAccount._path + `/${id}`,
1605
+ params
1606
+ );
1607
+ },
1608
+ create: async (body) => {
1609
+ let res = await this._create(
1610
+ this.svAPIEndpoint,
1611
+ this.adjustAccount._path,
1612
+ body
1613
+ );
1614
+ return res;
1615
+ },
1616
+ };
1617
+ this.transfer = {
1618
+ _path: this._end_points.TRANSFER,
1619
+ find: async (params) => {
1620
+ let res = await this._fetch(
1621
+ this.svAPIEndpoint,
1622
+ this.transfer._path,
1623
+ params
1624
+ );
1625
+ return res;
1626
+ },
1627
+ get: async (id, params) => {
1628
+ return await this._fetch(
1629
+ this.svAPIEndpoint,
1630
+ this.transfer._path + `/${id}`,
1631
+ params
1632
+ );
1633
+ },
1634
+ create: async (body) => {
1635
+ let res = await this._create(
1636
+ this.svAPIEndpoint,
1637
+ this.transfer._path,
1638
+ body
1639
+ );
1640
+ return res;
1641
+ },
1642
+ update: async (id, body) => {
1643
+ let res = await this._update(
1644
+ this.svAPIEndpoint,
1645
+ this.transfer._path + `/${id}`,
1646
+ body
1647
+ );
1648
+ return res;
1649
+ },
1650
+ };
1651
+ this.msl = {
1652
+ _path: this._end_points.MSL,
1653
+ find: async (params) => {
1654
+ let res = await this._fetch(this.svAPIEndpoint, this.msl._path, params);
1655
+ return res;
1656
+ },
1657
+ get: async (id, params) => {
1658
+ return await this._fetch(
1659
+ this.svAPIEndpoint,
1660
+ this.msl._path + `/${id}`,
1661
+ params
1662
+ );
1663
+ },
1664
+ create: async (body) => {
1665
+ let res = await this._create(this.svAPIEndpoint, this.msl._path, body);
1666
+ return res;
1667
+ },
1668
+ update: async (id, body) => {
1669
+ let res = await this._update(
1670
+ this.svAPIEndpoint,
1671
+ this.msl._path + `/${id}`,
1672
+ body
1673
+ );
1674
+ return res;
1675
+ },
1676
+ remove: async (id) => {
1677
+ let res = await this._delete(
1678
+ this.svAPIEndpoint,
1679
+ this.msl._path + `/${id}`
1680
+ );
1681
+ return res;
1682
+ },
1683
+ };
1684
+ this.mslProduct = {
1685
+ _path: this._end_points.MSL_PRODUCT,
1686
+ find: async (params) => {
1687
+ let res = await this._fetch(
1688
+ this.svAPIEndpoint,
1689
+ this.mslProduct._path,
1690
+ params
1691
+ );
1692
+ return res;
1693
+ },
1694
+ get: async (id, params) => {
1695
+ return await this._fetch(
1696
+ this.svAPIEndpoint,
1697
+ this.mslProduct._path + `/${id}`,
1698
+ params
1699
+ );
1700
+ },
1701
+ create: async (body) => {
1702
+ let res = await this._create(
1703
+ this.svAPIEndpoint,
1704
+ this.mslProduct._path,
1705
+ body
1706
+ );
1707
+ return res;
1708
+ },
1709
+ update: async (id, body) => {
1710
+ let res = await this._update(
1711
+ this.svAPIEndpoint,
1712
+ this.mslProduct._path + `/${id}`,
1713
+ body
1714
+ );
1715
+ return res;
1716
+ },
1717
+ remove: async (id) => {
1718
+ let res = await this._delete(
1719
+ this.svAPIEndpoint,
1720
+ this.mslProduct._path + `/${id}`
1721
+ );
1722
+ return res;
1723
+ },
1724
+ };
1725
+ this.mediaStorage = {
1726
+ _path: this._end_points.MEDIA_STORAGE,
1727
+ find: async (params) => {
1728
+ let res = await this._fetch(
1729
+ this.svAPIEndpoint,
1730
+ this.mediaStorage._path,
1731
+ params
1732
+ );
1733
+ return res;
1734
+ },
1735
+ get: async (id, params) => {
1736
+ return await this._fetch(
1737
+ this.svAPIEndpoint,
1738
+ this.mediaStorage._path + `/${id}`,
1739
+ params
1740
+ );
1741
+ },
1742
+ create: async (body) => {
1743
+ let res = await this._create(
1744
+ this.svAPIEndpoint,
1745
+ this.mediaStorage._path,
1746
+ body
1747
+ );
1748
+ return res;
1749
+ },
1750
+ update: async (id, body) => {
1751
+ let res = await this._update(
1752
+ this.svAPIEndpoint,
1753
+ this.mediaStorage._path + `/${id}`,
1754
+ body
1755
+ );
1756
+ return res;
1757
+ },
1758
+ remove: async (id) => {
1759
+ let res = await this._delete(
1760
+ this.svAPIEndpoint,
1761
+ this.mediaStorage._path + `/${id}`
1762
+ );
1763
+ return res;
1764
+ },
1765
+ };
1766
+ this.storecheckTemplate = {
1767
+ _path: this._end_points.STORECHECK_TEMPLATE,
1768
+ find: async (params) => {
1769
+ let res = await this._fetch(
1770
+ this.svAPIEndpoint,
1771
+ this.storecheckTemplate._path,
1772
+ params
1773
+ );
1774
+ return res;
1775
+ },
1776
+ get: async (id, params) => {
1777
+ return await this._fetch(
1778
+ this.svAPIEndpoint,
1779
+ this.storecheckTemplate._path + `/${id}`,
1780
+ params
1781
+ );
1782
+ },
1783
+ create: async (body) => {
1784
+ let res = await this._create(
1785
+ this.svAPIEndpoint,
1786
+ this.storecheckTemplate._path,
1787
+ body
1788
+ );
1789
+ return res;
1790
+ },
1791
+ update: async (id, body) => {
1792
+ let res = await this._update(
1793
+ this.svAPIEndpoint,
1794
+ this.storecheckTemplate._path + `/${id}`,
1795
+ body
1796
+ );
1797
+ return res;
1798
+ },
1799
+ remove: async (id) => {
1800
+ let res = await this._delete(
1801
+ this.svAPIEndpoint,
1802
+ this.storecheckTemplate._path + `/${id}`
1803
+ );
1804
+ return res;
1805
+ },
1806
+ };
1807
+ this.activityStorecheck = {
1808
+ _path: this._end_points.ACTIVITY_STORECHECK,
1809
+ find: async (params) => {
1810
+ let res = await this._fetch(
1811
+ this.svAPIEndpoint,
1812
+ this.activityStorecheck._path,
1813
+ params
1814
+ );
1815
+ return res;
1816
+ },
1817
+ get: async (id, params) => {
1818
+ return await this._fetch(
1819
+ this.svAPIEndpoint,
1820
+ this.activityStorecheck._path + `/${id}`,
1821
+ params
1822
+ );
1823
+ },
1824
+ create: async (body) => {
1825
+ let res = await this._create(
1826
+ this.svAPIEndpoint,
1827
+ this.activityStorecheck._path,
1828
+ body
1829
+ );
1830
+ return res;
1831
+ },
1832
+ update: async (id, body) => {
1833
+ let res = await this._update(
1834
+ this.svAPIEndpoint,
1835
+ this.activityStorecheck._path + `/${id}`,
1836
+ body
1837
+ );
1838
+ return res;
1839
+ },
1840
+ };
1841
+ this.adjustInventory = {
1842
+ _path: this._end_points.ADJUST_INVENTORY,
1843
+ find: async (params) => {
1844
+ let res = await this._fetch(
1845
+ this.svAPIEndpoint,
1846
+ this.adjustInventory._path,
1847
+ params
1848
+ );
1849
+ return res;
1850
+ },
1851
+ get: async (id, params) => {
1852
+ return await this._fetch(
1853
+ this.svAPIEndpoint,
1854
+ this.adjustInventory._path + `/${id}`,
1855
+ params
1856
+ );
1857
+ },
1858
+ create: async (body) => {
1859
+ let res = await this._create(
1860
+ this.svAPIEndpoint,
1861
+ this.adjustInventory._path,
1862
+ body
1863
+ );
1864
+ return res;
1865
+ },
1866
+ };
1867
+ this.inventory = {
1868
+ _path: this._end_points.INVENTORY,
1869
+ find: async (params) => {
1870
+ let res = await this._fetch(
1871
+ this.svAPIEndpoint,
1872
+ this.inventory._path,
1873
+ params
1874
+ );
1875
+ return res;
1876
+ },
1877
+ };
1878
+ this.integrationApp = {
1879
+ _path: this._end_points.INTEGRATION_APP,
1880
+ find: async (params) => {
1881
+ let res = await this._fetch(
1882
+ this.svAPIEndpoint,
1883
+ this.integrationApp._path,
1884
+ params
1885
+ );
1886
+ return res;
1887
+ },
1888
+ get: async (id, params) => {
1889
+ return await this._fetch(
1890
+ this.svAPIEndpoint,
1891
+ this.integrationApp._path + `/${id}`,
1892
+ params
1893
+ );
1894
+ },
1895
+ create: async (body) => {
1896
+ let res = await this._create(
1897
+ this.svAPIEndpoint,
1898
+ this.integrationApp._path,
1899
+ body
1900
+ );
1901
+ return res;
1902
+ },
1903
+ update: async (id, body) => {
1904
+ let res = await this._update(
1905
+ this.svAPIEndpoint,
1906
+ this.integrationApp._path + `/${id}`,
1907
+ body
1908
+ );
1909
+ return res;
1910
+ },
1911
+ };
1912
+ this.joinActionsWebHook = {
1913
+ _path: this._end_points.JOIN_ACTIONS_WEBHOOK,
1914
+ update: async (id, body) => {
1915
+ let res = await this._update(
1916
+ this.svAPIEndpoint,
1917
+ this.joinActionsWebHook._path,
1918
+ body
1919
+ );
1920
+ return res;
1921
+ },
1922
+ };
1923
+ this.patchAction = {
1924
+ _path: this._end_points.PATCH_ACTION,
1925
+ create: async (body, params) => {
1926
+ const res = await this._create(
1927
+ this.svAPIEndpoint,
1928
+ this.patchAction._path,
1929
+ body,
1930
+ params
1931
+ );
1932
+ return res;
1933
+ },
1934
+ update: async (body) => {
1935
+ const res = await this._update(
1936
+ this.svAPIEndpoint,
1937
+ this.patchAction._path,
1938
+ body
1939
+ );
1940
+ return res;
1941
+ },
1942
+ };
1943
+ this.updateIntegrationMeta = {
1944
+ _path: this._end_points.UPDATE_INTEGRATION_META,
1945
+ create: async (body, params) => {
1946
+ let res = await this._create(
1947
+ this.svAPIEndpoint,
1948
+ this.updateIntegrationMeta._path,
1949
+ body,
1950
+ params
1951
+ );
1952
+ return res;
1953
+ },
1954
+ };
1955
+ this.assetPartType = {
1956
+ _path: this._end_points.ASSET_PART_TYPE,
1957
+ find: async (params) => {
1958
+ let res = await this._fetch(
1959
+ this.svAPIEndpoint,
1960
+ this.assetPartType._path,
1961
+ params
1962
+ );
1963
+ return res;
1964
+ },
1965
+ get: async (id) => {
1966
+ return await this._fetch(
1967
+ this.svAPIEndpoint,
1968
+ this.assetPartType._path + `/${id}`
1969
+ );
1970
+ },
1971
+ create: async (body) => {
1972
+ let res = await this._create(
1973
+ this.svAPIEndpoint,
1974
+ this.assetPartType._path,
1975
+ body
1976
+ );
1977
+ return res;
1978
+ },
1979
+ update: async (id, body) => {
1980
+ let res = await this._update(
1981
+ this.svAPIEndpoint,
1982
+ this.assetPartType._path + `/${id}`,
1983
+ body
1984
+ );
1985
+ return res;
1986
+ },
1987
+ remove: async (id) => {
1988
+ let res = await this._delete(
1989
+ this.svAPIEndpoint,
1990
+ this.assetPartType._path + `/${id}`
1991
+ );
1992
+ return res;
1993
+ },
1994
+ };
1995
+ this.assetPart = {
1996
+ _path: this._end_points.ASSET_PART,
1997
+ find: async (params) => {
1998
+ let res = await this._fetch(
1999
+ this.svAPIEndpoint,
2000
+ this.assetPart._path,
2001
+ params
2002
+ );
2003
+ return res;
2004
+ },
2005
+ get: async (id, params) => {
2006
+ return await this._fetch(
2007
+ this.svAPIEndpoint,
2008
+ this.assetPart._path + `/${id}`,
2009
+ params
2010
+ );
2011
+ },
2012
+ create: async (body) => {
2013
+ let res = await this._create(
2014
+ this.svAPIEndpoint,
2015
+ this.assetPart._path,
2016
+ body
2017
+ );
2018
+ return res;
2019
+ },
2020
+ update: async (id, body) => {
2021
+ let res = await this._update(
2022
+ this.svAPIEndpoint,
2023
+ this.assetPart._path + `/${id}`,
2024
+ body
2025
+ );
2026
+ return res;
2027
+ },
2028
+ remove: async (id) => {
2029
+ let res = await this._delete(
2030
+ this.svAPIEndpoint,
2031
+ this.assetPart._path + `/${id}`
2032
+ );
2033
+ return res;
2034
+ },
2035
+ };
2036
+ this.assetPartUnit = {
2037
+ _path: this._end_points.ASSET_PART_UNIT,
2038
+ find: async (params) => {
2039
+ let res = await this._fetch(
2040
+ this.svAPIEndpoint,
2041
+ this.assetPartUnit._path,
2042
+ params
2043
+ );
2044
+ return res;
2045
+ },
2046
+ get: async (id, params) => {
2047
+ return await this._fetch(
2048
+ this.svAPIEndpoint,
2049
+ this.assetPartUnit._path + `/${id}`,
2050
+ params
2051
+ );
2052
+ },
2053
+ update: async (id, body) => {
2054
+ let res = await this._update(
2055
+ this.svAPIEndpoint,
2056
+ this.assetPartUnit._path + `/${id}`,
2057
+ body
2058
+ );
2059
+ return res;
2060
+ },
2061
+ };
2062
+ this.assetPartReceival = {
2063
+ _path: this._end_points.ASSET_PART_RECEIVAL,
2064
+ find: async (params) => {
2065
+ let res = await this._fetch(
2066
+ this.svAPIEndpoint,
2067
+ this.assetPartReceival._path,
2068
+ params
2069
+ );
2070
+ return res;
2071
+ },
2072
+ get: async (id, params) => {
2073
+ return await this._fetch(
2074
+ this.svAPIEndpoint,
2075
+ this.assetPartReceival._path + `/${id}`,
2076
+ params
2077
+ );
2078
+ },
2079
+ create: async (body) => {
2080
+ let res = await this._create(
2081
+ this.svAPIEndpoint,
2082
+ this.assetPartReceival._path,
2083
+ body
2084
+ );
2085
+ return res;
2086
+ },
2087
+ update: async (id, body) => {
2088
+ let res = await this._update(
2089
+ this.svAPIEndpoint,
2090
+ this.assetPartReceival._path + `/${id}`,
2091
+ body
2092
+ );
2093
+ return res;
2094
+ },
2095
+ patch: async (params, body) => {
2096
+ let res = await this._patch(
2097
+ this.svAPIEndpoint,
2098
+ this.assetPartReceival._path,
2099
+ body,
2100
+ params
2101
+ );
2102
+ return res;
2103
+ },
2104
+ };
2105
+ this.assetPartTransfer = {
2106
+ _path: this._end_points.ASSET_PART_TRANSFER,
2107
+ find: async (params) => {
2108
+ let res = await this._fetch(
2109
+ this.svAPIEndpoint,
2110
+ this.assetPartTransfer._path,
2111
+ params
2112
+ );
2113
+ return res;
2114
+ },
2115
+ get: async (id, params) => {
2116
+ return await this._fetch(
2117
+ this.svAPIEndpoint,
2118
+ this.assetPartTransfer._path + `/${id}`,
2119
+ params
2120
+ );
2121
+ },
2122
+ create: async (body) => {
2123
+ let res = await this._create(
2124
+ this.svAPIEndpoint,
2125
+ this.assetPartTransfer._path,
2126
+ body
2127
+ );
2128
+ return res;
2129
+ },
2130
+ update: async (id, body) => {
2131
+ let res = await this._update(
2132
+ this.svAPIEndpoint,
2133
+ this.assetPartTransfer._path + `/${id}`,
2134
+ body
2135
+ );
2136
+ return res;
2137
+ },
2138
+ patch: async (params, body) => {
2139
+ let res = await this._patch(
2140
+ this.svAPIEndpoint,
2141
+ this.assetPartTransfer._path,
2142
+ body,
2143
+ params
2144
+ );
2145
+ return res;
2146
+ },
2147
+ };
2148
+ this.returnAssetPartUnit = {
2149
+ _path: this._end_points.RETURN_ASSET_PART_UNIT,
2150
+ find: async (params) => {
2151
+ let res = await this._fetch(
2152
+ this.svAPIEndpoint,
2153
+ this.returnAssetPartUnit._path,
2154
+ params
2155
+ );
2156
+ return res;
2157
+ },
2158
+ get: async (id, params) => {
2159
+ return await this._fetch(
2160
+ this.svAPIEndpoint,
2161
+ this.returnAssetPartUnit._path + `/${id}`,
2162
+ params
2163
+ );
2164
+ },
2165
+ create: async (body) => {
2166
+ let res = await this._create(
2167
+ this.svAPIEndpoint,
2168
+ this.returnAssetPartUnit._path,
2169
+ body
2170
+ );
2171
+ return res;
2172
+ },
2173
+ update: async (id, body) => {
2174
+ let res = await this._update(
2175
+ this.svAPIEndpoint,
2176
+ this.returnAssetPartUnit._path + `/${id}`,
2177
+ body
2178
+ );
2179
+ return res;
2180
+ },
2181
+ patch: async (params, body) => {
2182
+ let res = await this._patch(
2183
+ this.svAPIEndpoint,
2184
+ this.returnAssetPartUnit._path,
2185
+ body,
2186
+ params
2187
+ );
2188
+ return res;
2189
+ },
2190
+ };
2191
+ this.storeAssetPartUnit = {
2192
+ _path: this._end_points.STORE_ASSET_PART_UNIT,
2193
+ find: async (params) => {
2194
+ let res = await this._fetch(
2195
+ this.svAPIEndpoint,
2196
+ this.storeAssetPartUnit._path,
2197
+ params
2198
+ );
2199
+ return res;
2200
+ },
2201
+ get: async (id, params) => {
2202
+ return await this._fetch(
2203
+ this.svAPIEndpoint,
2204
+ this.storeAssetPartUnit._path + `/${id}`,
2205
+ params
2206
+ );
2207
+ },
2208
+ create: async (body) => {
2209
+ let res = await this._create(
2210
+ this.svAPIEndpoint,
2211
+ this.storeAssetPartUnit._path,
2212
+ body
2213
+ );
2214
+ return res;
2215
+ },
2216
+ update: async (id, body) => {
2217
+ let res = await this._update(
2218
+ this.svAPIEndpoint,
2219
+ this.storeAssetPartUnit._path + `/${id}`,
2220
+ body
2221
+ );
2222
+ return res;
2223
+ },
2224
+ patch: async (params, body) => {
2225
+ let res = await this._patch(
2226
+ this.svAPIEndpoint,
2227
+ this.storeAssetPartUnit._path,
2228
+ body,
2229
+ params
2230
+ );
2231
+ return res;
2232
+ },
2233
+ };
2234
+ this.ocrInvoiceJobTemplate = {
2235
+ _path: this._end_points.OCR_INVOICE_JOB_TEMPLATE,
2236
+ find: async (params) => {
2237
+ let res = await this._fetch(
2238
+ this.svAPIEndpoint,
2239
+ this.ocrInvoiceJobTemplate._path,
2240
+ params
2241
+ );
2242
+ return res;
2243
+ },
2244
+ get: async (id) => {
2245
+ return await this._fetch(
2246
+ this.svAPIEndpoint,
2247
+ this.ocrInvoiceJobTemplate._path + `/${id}`
2248
+ );
2249
+ },
2250
+ create: async (body) => {
2251
+ let res = await this._create(
2252
+ this.svAPIEndpoint,
2253
+ this.ocrInvoiceJobTemplate._path,
2254
+ body
2255
+ );
2256
+ return res;
2257
+ },
2258
+ update: async (id, body) => {
2259
+ let res = await this._update(
2260
+ this.svAPIEndpoint,
2261
+ this.ocrInvoiceJobTemplate._path + `/${id}`,
2262
+ body
2263
+ );
2264
+ return res;
2265
+ },
2266
+ };
2267
+ this.ocrInvoiceJobGroup = {
2268
+ _path: this._end_points.OCR_INVOICE_JOB_GROUP,
2269
+ find: async (params) => {
2270
+ let res = await this._fetch(
2271
+ this.svAPIEndpoint,
2272
+ this.ocrInvoiceJobGroup._path,
2273
+ params
2274
+ );
2275
+ return res;
2276
+ },
2277
+ get: async (id) => {
2278
+ return await this._fetch(
2279
+ this.svAPIEndpoint,
2280
+ this.ocrInvoiceJobGroup._path + `/${id}`
2281
+ );
2282
+ },
2283
+ create: async (body) => {
2284
+ let res = await this._create(
2285
+ this.svAPIEndpoint,
2286
+ this.ocrInvoiceJobGroup._path,
2287
+ body
2288
+ );
2289
+ return res;
2290
+ },
2291
+ };
2292
+ this.activityAiSalesOrder = {
2293
+ _path: this._end_points.ACTIVITY_AI_SALES_ORDER,
2294
+ find: async (params) => {
2295
+ let res = await this._fetch(
2296
+ this.svAPIEndpoint,
2297
+ this.activityAiSalesOrder._path,
2298
+ params
2299
+ );
2300
+ return res;
2301
+ },
2302
+ get: async (id) => {
2303
+ return await this._fetch(
2304
+ this.svAPIEndpoint,
2305
+ this.activityAiSalesOrder._path + `/${id}`
2306
+ );
2307
+ },
2308
+ create: async (body) => {
2309
+ let res = await this._create(
2310
+ this.svAPIEndpoint,
2311
+ this.activityAiSalesOrder._path,
2312
+ body
2313
+ );
2314
+ return res;
2315
+ },
2316
+ };
2317
+ this.ocrInvoiceJob = {
2318
+ _path: this._end_points.OCR_INVOICE_JOB,
2319
+ find: async (params) => {
2320
+ let res = await this._fetch(
2321
+ this.svAPIEndpoint,
2322
+ this.ocrInvoiceJob._path,
2323
+ params
2324
+ );
2325
+ return res;
2326
+ },
2327
+ get: async (id) => {
2328
+ return await this._fetch(
2329
+ this.svAPIEndpoint,
2330
+ this.ocrInvoiceJob._path + `/${id}`
2331
+ );
2332
+ },
2333
+ };
2334
+ this.ocrInvoiceJobPage = {
2335
+ _path: this._end_points.OCR_INVOICE_JOB_PAGE,
2336
+ find: async (params) => {
2337
+ let res = await this._fetch(
2338
+ this.svAPIEndpoint,
2339
+ this.ocrInvoiceJobPage._path,
2340
+ params
2341
+ );
2342
+ return res;
2343
+ },
2344
+ get: async (id) => {
2345
+ return await this._fetch(
2346
+ this.svAPIEndpoint,
2347
+ this.ocrInvoiceJobPage._path + `/${id}`
2348
+ );
2349
+ },
2350
+ update: async (id, body) => {
2351
+ let res = await this._update(
2352
+ this.svAPIEndpoint,
2353
+ this.ocrInvoiceJobPage._path + `/${id}`,
2354
+ body
2355
+ );
2356
+ return res;
2357
+ },
2358
+ };
2359
+ this.svAPIEndpoint =
2360
+ !options?.env || options?.env == "production"
2361
+ ? "https://sv.api.repzo.me"
2362
+ : options?.env == "staging"
2363
+ ? "https://staging.sv.api.repzo.me"
2364
+ : options?.env == "local"
2365
+ ? "http://localhost:3030"
2366
+ : "";
2367
+ this.headers = {
2368
+ "api-key": apiKey,
2369
+ "Content-Type": "application/json",
2370
+ Accept: "application/json",
2371
+ };
2372
+ if (options?.headers) Object.assign(this.headers, options.headers);
2373
+ if (options?.timeout) {
2374
+ this.timeout = options.timeout;
2375
+ } else {
2376
+ this.timeout = 180000;
1404
2377
  }
2378
+ }
2379
+ async _fetch(baseUrl, path, params) {
2380
+ let res = await axios.get(`${baseUrl}/${path}`, {
2381
+ params,
2382
+ headers: this.headers,
2383
+ timeout: this.timeout,
2384
+ });
2385
+ return res.data;
2386
+ }
2387
+ async _create(baseUrl, path, body, params) {
2388
+ let res = await axios.post(`${baseUrl}/${path}`, body, {
2389
+ params,
2390
+ headers: this.headers,
2391
+ timeout: this.timeout,
2392
+ });
2393
+ return res.data;
2394
+ }
2395
+ async _update(baseUrl, path, body, params) {
2396
+ let res = await axios.put(`${baseUrl}/${path}`, body, {
2397
+ params,
2398
+ headers: this.headers,
2399
+ timeout: this.timeout,
2400
+ });
2401
+ return res.data;
2402
+ }
2403
+ async _patch(baseUrl, path, body, params) {
2404
+ let res = await axios.put(`${baseUrl}/${path}`, body, {
2405
+ params,
2406
+ headers: this.headers,
2407
+ timeout: this.timeout,
2408
+ });
2409
+ return res.data;
2410
+ }
2411
+ async _delete(baseUrl, path, params) {
2412
+ let res = await axios.delete(`${baseUrl}/${path}`, {
2413
+ params,
2414
+ headers: this.headers,
2415
+ timeout: this.timeout,
2416
+ });
2417
+ return res.data;
2418
+ }
1405
2419
  }
1406
2420
  Repzo.ActionLogs = class {
1407
- constructor(superThis, sync_id) {
1408
- this.superThis = superThis;
1409
- this._path = "integration-action-log";
1410
- this.available_app_name = "";
1411
- this.available_app_id = "";
1412
- this.app_id = "";
1413
- this.action = "";
1414
- this.start_time = Date.now();
1415
- this.status = "processing";
1416
- this.message = "Log Created";
1417
- this.details = [];
1418
- this.sync_id = sync_id;
1419
- this.isOld = true;
1420
- }
1421
- async load(sync_id) {
1422
- const params = { sync_id: sync_id };
1423
- const res = await this.superThis._fetch(this.superThis.svAPIEndpoint, this._path, params);
1424
- if (!res?.data?.length)
1425
- throw new Error(`Action Log Not found, sync_id: ${sync_id}`);
1426
- const action_log = res.data[0];
1427
- this.sync_id = sync_id;
1428
- this.details = action_log.details;
1429
- this.status = action_log.status;
1430
- this.error = action_log.error;
1431
- this.start_time = action_log.start_time;
1432
- this.body = action_log.body;
1433
- this.meta = action_log.meta;
1434
- this.message = action_log.message;
1435
- this.app_id = action_log.app_id;
1436
- this.available_app_id = action_log.available_app_id;
1437
- this.available_app_name = action_log.available_app_name;
1438
- this.company_namespace = action_log.company_namespace;
1439
- this.action = action_log.action;
1440
- this.isOld = true;
1441
- return this;
1442
- }
1443
- setStatus(status, error) {
1444
- this.details.push({
1445
- timestamp: Date.now(),
1446
- content: `status was changed from ${this.status} to ${status}`,
1447
- });
1448
- this.status = status;
1449
- if (error) {
1450
- if (typeof error == "string") {
1451
- this.error = { message: error };
1452
- }
1453
- else if (error.message || error.response?.data) {
1454
- this.error = {
1455
- // json: error.toJSON ? error.toJSON() : undefined,
1456
- message: error.message,
1457
- responseData: error.response?.data,
1458
- };
1459
- }
1460
- else {
1461
- this.error = error;
1462
- }
1463
- return this;
1464
- }
1465
- return this;
1466
- }
1467
- setBody(body) {
1468
- this.body = body;
1469
- return this;
2421
+ constructor(superThis, sync_id) {
2422
+ this.superThis = superThis;
2423
+ this._path = "integration-action-log";
2424
+ this.available_app_name = "";
2425
+ this.available_app_id = "";
2426
+ this.app_id = "";
2427
+ this.action = "";
2428
+ this.start_time = Date.now();
2429
+ this.status = "processing";
2430
+ this.message = "Log Created";
2431
+ this.details = [];
2432
+ this.sync_id = sync_id;
2433
+ this.isOld = true;
2434
+ }
2435
+ async load(sync_id) {
2436
+ const params = { sync_id: sync_id };
2437
+ const res = await this.superThis._fetch(
2438
+ this.superThis.svAPIEndpoint,
2439
+ this._path,
2440
+ params
2441
+ );
2442
+ if (!res?.data?.length)
2443
+ throw new Error(`Action Log Not found, sync_id: ${sync_id}`);
2444
+ const action_log = res.data[0];
2445
+ this.sync_id = sync_id;
2446
+ this.details = action_log.details;
2447
+ this.status = action_log.status;
2448
+ this.error = action_log.error;
2449
+ this.start_time = action_log.start_time;
2450
+ this.body = action_log.body;
2451
+ this.meta = action_log.meta;
2452
+ this.message = action_log.message;
2453
+ this.app_id = action_log.app_id;
2454
+ this.available_app_id = action_log.available_app_id;
2455
+ this.available_app_name = action_log.available_app_name;
2456
+ this.company_namespace = action_log.company_namespace;
2457
+ this.action = action_log.action;
2458
+ this.isOld = true;
2459
+ return this;
2460
+ }
2461
+ setStatus(status, error) {
2462
+ this.details.push({
2463
+ timestamp: Date.now(),
2464
+ content: `status was changed from ${this.status} to ${status}`,
2465
+ });
2466
+ this.status = status;
2467
+ if (error) {
2468
+ if (typeof error == "string") {
2469
+ this.error = { message: error };
2470
+ } else if (error.message || error.response?.data) {
2471
+ this.error = {
2472
+ // json: error.toJSON ? error.toJSON() : undefined,
2473
+ message: error.message,
2474
+ responseData: error.response?.data,
2475
+ };
2476
+ } else {
2477
+ this.error = error;
2478
+ }
2479
+ return this;
1470
2480
  }
1471
- setMeta(meta) {
1472
- this.meta = meta;
1473
- return this;
1474
- }
1475
- async commit() {
1476
- let doc = {
1477
- available_app_name: this.available_app_name,
1478
- available_app_id: this.available_app_id,
1479
- app_id: this.app_id,
1480
- action: this.action,
1481
- company_namespace: this.company_namespace,
1482
- status: this.status,
1483
- error: this.error ? this.error : undefined,
1484
- start_time: this.start_time,
1485
- end_time: Date.now(),
1486
- total_time: Date.now() - this.start_time,
1487
- body: this.body,
1488
- meta: this.meta,
1489
- message: this.message,
1490
- details: this.details,
1491
- sync_id: this.sync_id,
1492
- };
1493
- try {
1494
- const res = await this.superThis._create(this.superThis.svAPIEndpoint, this._path, doc);
1495
- }
1496
- catch (e) {
1497
- console.error(e);
1498
- }
1499
- return this;
1500
- }
1501
- addDetail(detail, meta) {
1502
- let d = {
1503
- timestamp: Date.now(),
1504
- content: detail,
1505
- };
1506
- this.message = detail;
1507
- if (meta)
1508
- d.meta = meta;
1509
- this.details.push(d);
1510
- return this;
2481
+ return this;
2482
+ }
2483
+ setBody(body) {
2484
+ this.body = body;
2485
+ return this;
2486
+ }
2487
+ setMeta(meta) {
2488
+ this.meta = meta;
2489
+ return this;
2490
+ }
2491
+ async commit() {
2492
+ let doc = {
2493
+ available_app_name: this.available_app_name,
2494
+ available_app_id: this.available_app_id,
2495
+ app_id: this.app_id,
2496
+ action: this.action,
2497
+ company_namespace: this.company_namespace,
2498
+ status: this.status,
2499
+ error: this.error ? this.error : undefined,
2500
+ start_time: this.start_time,
2501
+ end_time: Date.now(),
2502
+ total_time: Date.now() - this.start_time,
2503
+ body: this.body,
2504
+ meta: this.meta,
2505
+ message: this.message,
2506
+ details: this.details,
2507
+ sync_id: this.sync_id,
2508
+ };
2509
+ try {
2510
+ const res = await this.superThis._create(
2511
+ this.superThis.svAPIEndpoint,
2512
+ this._path,
2513
+ doc
2514
+ );
2515
+ } catch (e) {
2516
+ console.error(e);
1511
2517
  }
2518
+ return this;
2519
+ }
2520
+ addDetail(detail, meta) {
2521
+ let d = {
2522
+ timestamp: Date.now(),
2523
+ content: detail,
2524
+ };
2525
+ this.message = detail;
2526
+ if (meta) d.meta = meta;
2527
+ this.details.push(d);
2528
+ return this;
2529
+ }
1512
2530
  };
1513
2531
  Repzo.CommandLog = class {
1514
- constructor(superThis, app, command, trigger) {
1515
- this.superThis = superThis;
1516
- this._path = "integration-command-log";
1517
- this.app_id = app._id;
1518
- this.available_app_id = app.available_app._id;
1519
- this.available_app_name = app.available_app.name;
1520
- this.company_namespace = app.company_namespace;
1521
- this.start_time = Date.now();
1522
- this.status = "received";
1523
- this.message = "Request received";
1524
- this.command = command;
1525
- this.details = [{ timestamp: Date.now(), content: "Request received" }];
1526
- this.sync_id = uuid();
1527
- this.isOld = false;
1528
- this.isPrioritized = false;
1529
- this.retries = 1;
1530
- this.trigger = trigger;
1531
- this.onGoing = true;
1532
- this.sync_details = [];
1533
- this.error_details = [];
1534
- }
1535
- async load(sync_id, retries) {
1536
- if (sync_id) {
1537
- const params = { sync_id: sync_id };
1538
- const res = await this.superThis._fetch(this.superThis.svAPIEndpoint, this._path, params);
1539
- if (!res?.data?.length)
1540
- throw new Error(`Command Log Not found, sync_id: ${sync_id}`);
1541
- const command_log = res.data[0];
1542
- if (command_log) {
1543
- this.sync_id = sync_id;
1544
- this.details = command_log.details;
1545
- this.status = command_log.status;
1546
- this.error = command_log.error;
1547
- this.start_time = command_log.start_time;
1548
- this.body = command_log.body;
1549
- this.meta = command_log.meta;
1550
- this.message = command_log.message;
1551
- this.retries =
1552
- retries !== undefined
1553
- ? retries
1554
- : command_log.retries || this.retries; // retries !== undefined ? retries : command_log.retries;
1555
- this.isOld = true;
1556
- this.failedAt = command_log.failedAt;
1557
- this.succeededAt = command_log.succeededAt;
1558
- this.skippedAt = command_log.skippedAt;
1559
- this.receivedAt = command_log.receivedAt;
1560
- this.processedAt = command_log.processedAt;
1561
- this.onGoing = command_log.onGoing || false;
1562
- this.trigger = command_log.trigger;
1563
- this.sync_details = command_log.sync_details;
1564
- this.error_details = command_log.error_details;
1565
- // this.priority = command_log.priority
1566
- // ? command_log.priority
1567
- // : this.priority
1568
- // ? this.priority
1569
- // : undefined;
1570
- }
1571
- }
1572
- return this;
1573
- }
1574
- setStatus(status, error) {
1575
- this.addDetail(`status was changed from ${this.status} to ${status}`);
1576
- this.status = status;
1577
- if (error) {
1578
- if (!this.error_details)
1579
- this.error_details = [];
1580
- if (typeof error == "string") {
1581
- this.error = { message: error };
1582
- }
1583
- else if (error.message || error.response?.data) {
1584
- this.error = {
1585
- // json: error.toJSON ? error.toJSON() : undefined,
1586
- message: error.message,
1587
- responseData: error.response?.data,
1588
- };
1589
- }
1590
- else {
1591
- this.error = error;
1592
- }
1593
- this.error_details = [
1594
- {
1595
- timestamp: Date.now(),
1596
- error: this.error,
1597
- },
1598
- ];
1599
- return this;
1600
- }
1601
- switch (status) {
1602
- case "fail":
1603
- this.failedAt = new Date();
1604
- this.onGoing = false;
1605
- break;
1606
- case "processing":
1607
- this.processedAt = new Date();
1608
- this.onGoing = true;
1609
- break;
1610
- case "queued":
1611
- this.queuedAt = new Date();
1612
- this.onGoing = true;
1613
- break;
1614
- case "received":
1615
- this.receivedAt = new Date();
1616
- this.onGoing = true;
1617
- break;
1618
- case "skipped":
1619
- this.skippedAt = new Date();
1620
- this.onGoing = false;
1621
- break;
1622
- case "success":
1623
- this.succeededAt = new Date();
1624
- this.onGoing = false;
1625
- break;
1626
- }
1627
- return this;
1628
- }
1629
- setBody(body) {
1630
- this.body = body;
1631
- if (!this.sync_details)
1632
- this.sync_details = [];
1633
- this.sync_details = [
1634
- {
1635
- timestamp: Date.now(),
1636
- body: this.body,
1637
- },
1638
- ];
1639
- return this;
2532
+ constructor(superThis, app, command, trigger) {
2533
+ this.superThis = superThis;
2534
+ this._path = "integration-command-log";
2535
+ this.app_id = app._id;
2536
+ this.available_app_id = app.available_app._id;
2537
+ this.available_app_name = app.available_app.name;
2538
+ this.company_namespace = app.company_namespace;
2539
+ this.start_time = Date.now();
2540
+ this.status = "received";
2541
+ this.message = "Request received";
2542
+ this.command = command;
2543
+ this.details = [{ timestamp: Date.now(), content: "Request received" }];
2544
+ this.sync_id = uuid();
2545
+ this.isOld = false;
2546
+ this.isPrioritized = false;
2547
+ this.retries = 1;
2548
+ this.trigger = trigger;
2549
+ this.onGoing = true;
2550
+ this.sync_details = [];
2551
+ this.error_details = [];
2552
+ }
2553
+ async load(sync_id, retries) {
2554
+ if (sync_id) {
2555
+ const params = { sync_id: sync_id };
2556
+ const res = await this.superThis._fetch(
2557
+ this.superThis.svAPIEndpoint,
2558
+ this._path,
2559
+ params
2560
+ );
2561
+ if (!res?.data?.length)
2562
+ throw new Error(`Command Log Not found, sync_id: ${sync_id}`);
2563
+ const command_log = res.data[0];
2564
+ if (command_log) {
2565
+ this.sync_id = sync_id;
2566
+ this.details = command_log.details;
2567
+ this.status = command_log.status;
2568
+ this.error = command_log.error;
2569
+ this.start_time = command_log.start_time;
2570
+ this.body = command_log.body;
2571
+ this.meta = command_log.meta;
2572
+ this.message = command_log.message;
2573
+ this.retries =
2574
+ retries !== undefined ? retries : command_log.retries || this.retries; // retries !== undefined ? retries : command_log.retries;
2575
+ this.isOld = true;
2576
+ this.failedAt = command_log.failedAt;
2577
+ this.succeededAt = command_log.succeededAt;
2578
+ this.skippedAt = command_log.skippedAt;
2579
+ this.receivedAt = command_log.receivedAt;
2580
+ this.processedAt = command_log.processedAt;
2581
+ this.onGoing = command_log.onGoing || false;
2582
+ this.trigger = command_log.trigger;
2583
+ this.sync_details = command_log.sync_details;
2584
+ this.error_details = command_log.error_details;
2585
+ // this.priority = command_log.priority
2586
+ // ? command_log.priority
2587
+ // : this.priority
2588
+ // ? this.priority
2589
+ // : undefined;
2590
+ }
1640
2591
  }
1641
- setMeta(meta) {
1642
- this.meta = meta;
1643
- return this;
2592
+ return this;
2593
+ }
2594
+ setStatus(status, error) {
2595
+ this.addDetail(`status was changed from ${this.status} to ${status}`);
2596
+ this.status = status;
2597
+ if (error) {
2598
+ if (!this.error_details) this.error_details = [];
2599
+ if (typeof error == "string") {
2600
+ this.error = { message: error };
2601
+ } else if (error.message || error.response?.data) {
2602
+ this.error = {
2603
+ // json: error.toJSON ? error.toJSON() : undefined,
2604
+ message: error.message,
2605
+ responseData: error.response?.data,
2606
+ };
2607
+ } else {
2608
+ this.error = error;
2609
+ }
2610
+ this.error_details = [
2611
+ {
2612
+ timestamp: Date.now(),
2613
+ error: this.error,
2614
+ },
2615
+ ];
2616
+ return this;
1644
2617
  }
1645
- async commit() {
1646
- let doc = {
1647
- available_app_name: this.available_app_name,
1648
- available_app_id: this.available_app_id,
1649
- app_id: this.app_id,
1650
- command: this.command,
1651
- status: this.status,
1652
- error: this.error ? this.error : undefined,
1653
- start_time: this.start_time,
1654
- end_time: Date.now(),
1655
- total_time: Date.now() - this.start_time,
1656
- company_namespace: this.company_namespace,
1657
- body: this.body,
1658
- meta: this.meta,
1659
- message: this.message,
1660
- details: this.details,
1661
- sync_id: this.sync_id,
1662
- // priority: this.priority ? this.priority : undefined,
1663
- queuedAt: this.queuedAt ? this.queuedAt : undefined,
1664
- failedAt: this.failedAt ? this.failedAt : undefined,
1665
- succeededAt: this.succeededAt ? this.succeededAt : undefined,
1666
- skippedAt: this.skippedAt ? this.skippedAt : undefined,
1667
- receivedAt: this.receivedAt ? this.receivedAt : undefined,
1668
- processedAt: this.processedAt ? this.processedAt : undefined,
1669
- onGoing: this.onGoing !== undefined ? this.onGoing : undefined,
1670
- retries: this.retries !== undefined ? this.retries : undefined,
1671
- trigger: this.trigger,
1672
- sync_details: this.sync_details,
1673
- error_details: this.error_details,
1674
- };
1675
- try {
1676
- const res = await this.superThis._create(this.superThis.svAPIEndpoint, this._path, doc);
1677
- this.isOld = true;
1678
- }
1679
- catch (e) {
1680
- console.error(e);
1681
- }
1682
- return this;
2618
+ switch (status) {
2619
+ case "fail":
2620
+ this.failedAt = new Date();
2621
+ this.onGoing = false;
2622
+ break;
2623
+ case "processing":
2624
+ this.processedAt = new Date();
2625
+ this.onGoing = true;
2626
+ break;
2627
+ case "queued":
2628
+ this.queuedAt = new Date();
2629
+ this.onGoing = true;
2630
+ break;
2631
+ case "received":
2632
+ this.receivedAt = new Date();
2633
+ this.onGoing = true;
2634
+ break;
2635
+ case "skipped":
2636
+ this.skippedAt = new Date();
2637
+ this.onGoing = false;
2638
+ break;
2639
+ case "success":
2640
+ this.succeededAt = new Date();
2641
+ this.onGoing = false;
2642
+ break;
1683
2643
  }
1684
- addDetail(detail, meta) {
1685
- if (!this.details)
1686
- this.details = [];
1687
- this.details = [
1688
- {
1689
- timestamp: Date.now(),
1690
- content: detail,
1691
- meta,
1692
- },
1693
- ];
1694
- this.message = detail;
1695
- return this;
2644
+ return this;
2645
+ }
2646
+ setBody(body) {
2647
+ this.body = body;
2648
+ if (!this.sync_details) this.sync_details = [];
2649
+ this.sync_details = [
2650
+ {
2651
+ timestamp: Date.now(),
2652
+ body: this.body,
2653
+ },
2654
+ ];
2655
+ return this;
2656
+ }
2657
+ setMeta(meta) {
2658
+ this.meta = meta;
2659
+ return this;
2660
+ }
2661
+ async commit() {
2662
+ let doc = {
2663
+ available_app_name: this.available_app_name,
2664
+ available_app_id: this.available_app_id,
2665
+ app_id: this.app_id,
2666
+ command: this.command,
2667
+ status: this.status,
2668
+ error: this.error ? this.error : undefined,
2669
+ start_time: this.start_time,
2670
+ end_time: Date.now(),
2671
+ total_time: Date.now() - this.start_time,
2672
+ company_namespace: this.company_namespace,
2673
+ body: this.body,
2674
+ meta: this.meta,
2675
+ message: this.message,
2676
+ details: this.details,
2677
+ sync_id: this.sync_id,
2678
+ // priority: this.priority ? this.priority : undefined,
2679
+ queuedAt: this.queuedAt ? this.queuedAt : undefined,
2680
+ failedAt: this.failedAt ? this.failedAt : undefined,
2681
+ succeededAt: this.succeededAt ? this.succeededAt : undefined,
2682
+ skippedAt: this.skippedAt ? this.skippedAt : undefined,
2683
+ receivedAt: this.receivedAt ? this.receivedAt : undefined,
2684
+ processedAt: this.processedAt ? this.processedAt : undefined,
2685
+ onGoing: this.onGoing !== undefined ? this.onGoing : undefined,
2686
+ retries: this.retries !== undefined ? this.retries : undefined,
2687
+ trigger: this.trigger,
2688
+ sync_details: this.sync_details,
2689
+ error_details: this.error_details,
2690
+ };
2691
+ try {
2692
+ const res = await this.superThis._create(
2693
+ this.superThis.svAPIEndpoint,
2694
+ this._path,
2695
+ doc
2696
+ );
2697
+ this.isOld = true;
2698
+ } catch (e) {
2699
+ console.error(e);
1696
2700
  }
2701
+ return this;
2702
+ }
2703
+ addDetail(detail, meta) {
2704
+ if (!this.details) this.details = [];
2705
+ this.details = [
2706
+ {
2707
+ timestamp: Date.now(),
2708
+ content: detail,
2709
+ meta,
2710
+ },
2711
+ ];
2712
+ this.message = detail;
2713
+ return this;
2714
+ }
1697
2715
  };
1698
- export default Repzo;