@dotdev/harmony-sdk 1.0.6
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/README.md +88 -0
- package/dist/HarmonyAPI.d.ts +37 -0
- package/dist/HarmonyAPI.js +113 -0
- package/dist/errors/index.d.ts +15 -0
- package/dist/errors/index.js +18 -0
- package/dist/helpers/index.d.ts +50 -0
- package/dist/helpers/index.js +167 -0
- package/dist/helpers/index.spec.d.ts +1 -0
- package/dist/helpers/index.spec.js +147 -0
- package/dist/helpers/mapper.d.ts +2 -0
- package/dist/helpers/mapper.js +28 -0
- package/dist/helpers/utils.d.ts +71 -0
- package/dist/helpers/utils.js +133 -0
- package/dist/helpers/utils.spec.d.ts +1 -0
- package/dist/helpers/utils.spec.js +96 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/modules/auth/auth.module.d.ts +7 -0
- package/dist/modules/auth/auth.module.js +42 -0
- package/dist/modules/auth/auth.module.spec.d.ts +1 -0
- package/dist/modules/auth/auth.module.spec.js +55 -0
- package/dist/modules/auth/index.d.ts +2 -0
- package/dist/modules/auth/index.js +2 -0
- package/dist/modules/auth/types/index.d.ts +7 -0
- package/dist/modules/auth/types/index.js +1 -0
- package/dist/modules/carrier/carrier.module.d.ts +10 -0
- package/dist/modules/carrier/carrier.module.js +39 -0
- package/dist/modules/carrier/carrier.module.spec.d.ts +1 -0
- package/dist/modules/carrier/carrier.module.spec.js +187 -0
- package/dist/modules/carrier/index.d.ts +3 -0
- package/dist/modules/carrier/index.js +3 -0
- package/dist/modules/carrier/mappings/index.d.ts +5 -0
- package/dist/modules/carrier/mappings/index.js +36 -0
- package/dist/modules/carrier/types/index.d.ts +42 -0
- package/dist/modules/carrier/types/index.js +2 -0
- package/dist/modules/diary/diary.module.d.ts +9 -0
- package/dist/modules/diary/diary.module.js +28 -0
- package/dist/modules/diary/index.d.ts +3 -0
- package/dist/modules/diary/index.js +3 -0
- package/dist/modules/diary/mappings/diary.mapper.d.ts +4 -0
- package/dist/modules/diary/mappings/diary.mapper.js +101 -0
- package/dist/modules/diary/mappings/diary.mapper.spec.d.ts +1 -0
- package/dist/modules/diary/mappings/diary.mapper.spec.js +18 -0
- package/dist/modules/diary/mappings/index.d.ts +1 -0
- package/dist/modules/diary/mappings/index.js +1 -0
- package/dist/modules/diary/types/diary.interface.d.ts +138 -0
- package/dist/modules/diary/types/diary.interface.js +24 -0
- package/dist/modules/diary/types/index.d.ts +1 -0
- package/dist/modules/diary/types/index.js +1 -0
- package/dist/modules/gift-voucher/gift-voucher.module.d.ts +12 -0
- package/dist/modules/gift-voucher/gift-voucher.module.js +55 -0
- package/dist/modules/gift-voucher/gift-voucher.module.spec.d.ts +1 -0
- package/dist/modules/gift-voucher/gift-voucher.module.spec.js +296 -0
- package/dist/modules/gift-voucher/index.d.ts +1 -0
- package/dist/modules/gift-voucher/index.js +1 -0
- package/dist/modules/gift-voucher/mappings/index.d.ts +6 -0
- package/dist/modules/gift-voucher/mappings/index.js +70 -0
- package/dist/modules/gift-voucher/mappings/index.spec.d.ts +1 -0
- package/dist/modules/gift-voucher/mappings/index.spec.js +21 -0
- package/dist/modules/gift-voucher/types/index.d.ts +92 -0
- package/dist/modules/gift-voucher/types/index.js +1 -0
- package/dist/modules/index.d.ts +8 -0
- package/dist/modules/index.js +8 -0
- package/dist/modules/point-of-sale/index.d.ts +3 -0
- package/dist/modules/point-of-sale/index.js +3 -0
- package/dist/modules/point-of-sale/mappings/index.d.ts +1 -0
- package/dist/modules/point-of-sale/mappings/index.js +1 -0
- package/dist/modules/point-of-sale/mappings/process-sale-order.mapper.d.ts +6 -0
- package/dist/modules/point-of-sale/mappings/process-sale-order.mapper.js +142 -0
- package/dist/modules/point-of-sale/point-of-sale.module.d.ts +43 -0
- package/dist/modules/point-of-sale/point-of-sale.module.js +64 -0
- package/dist/modules/point-of-sale/point-of-sale.module.spec.d.ts +1 -0
- package/dist/modules/point-of-sale/point-of-sale.module.spec.js +205 -0
- package/dist/modules/point-of-sale/types/cancel-existing-sales-order.interface.d.ts +13 -0
- package/dist/modules/point-of-sale/types/cancel-existing-sales-order.interface.js +1 -0
- package/dist/modules/point-of-sale/types/index.d.ts +124 -0
- package/dist/modules/point-of-sale/types/index.js +31 -0
- package/dist/modules/point-of-sale/types/modify-existing-sales-order.interface.d.ts +12 -0
- package/dist/modules/point-of-sale/types/modify-existing-sales-order.interface.js +1 -0
- package/dist/modules/point-of-sale/types/process-returns.interface.d.ts +17 -0
- package/dist/modules/point-of-sale/types/process-returns.interface.js +1 -0
- package/dist/modules/point-of-sale/types/process-sale-order.interface.d.ts +67 -0
- package/dist/modules/point-of-sale/types/process-sale-order.interface.js +1 -0
- package/dist/modules/shared/index.d.ts +1 -0
- package/dist/modules/shared/index.js +1 -0
- package/dist/modules/shared/types/index.d.ts +93 -0
- package/dist/modules/shared/types/index.js +53 -0
- package/dist/modules/stock-level-lookup/index.d.ts +3 -0
- package/dist/modules/stock-level-lookup/index.js +3 -0
- package/dist/modules/stock-level-lookup/mappings/index.d.ts +1 -0
- package/dist/modules/stock-level-lookup/mappings/index.js +1 -0
- package/dist/modules/stock-level-lookup/mappings/stock-level-lookup.mapper.d.ts +4 -0
- package/dist/modules/stock-level-lookup/mappings/stock-level-lookup.mapper.js +78 -0
- package/dist/modules/stock-level-lookup/mappings/stock-level-lookup.mapper.spec.d.ts +1 -0
- package/dist/modules/stock-level-lookup/mappings/stock-level-lookup.mapper.spec.js +57 -0
- package/dist/modules/stock-level-lookup/stock-level-lookup.module.d.ts +10 -0
- package/dist/modules/stock-level-lookup/stock-level-lookup.module.js +39 -0
- package/dist/modules/stock-level-lookup/stock-level-lookup.module.spec.d.ts +1 -0
- package/dist/modules/stock-level-lookup/stock-level-lookup.module.spec.js +317 -0
- package/dist/modules/stock-level-lookup/types/index.d.ts +1 -0
- package/dist/modules/stock-level-lookup/types/index.js +1 -0
- package/dist/modules/stock-level-lookup/types/stock-level-lookup.interface.d.ts +162 -0
- package/dist/modules/stock-level-lookup/types/stock-level-lookup.interface.js +61 -0
- package/dist/modules/stock-lookup/index.d.ts +3 -0
- package/dist/modules/stock-lookup/index.js +3 -0
- package/dist/modules/stock-lookup/mappings/index.d.ts +1 -0
- package/dist/modules/stock-lookup/mappings/index.js +1 -0
- package/dist/modules/stock-lookup/mappings/stock-lookup.mapper.d.ts +22 -0
- package/dist/modules/stock-lookup/mappings/stock-lookup.mapper.js +156 -0
- package/dist/modules/stock-lookup/mappings/stock-lookup.mapper.spec.d.ts +1 -0
- package/dist/modules/stock-lookup/mappings/stock-lookup.mapper.spec.js +92 -0
- package/dist/modules/stock-lookup/stock-lookup.module.d.ts +65 -0
- package/dist/modules/stock-lookup/stock-lookup.module.js +141 -0
- package/dist/modules/stock-lookup/stock-lookup.module.spec.d.ts +1 -0
- package/dist/modules/stock-lookup/stock-lookup.module.spec.js +419 -0
- package/dist/modules/stock-lookup/types/index.d.ts +1 -0
- package/dist/modules/stock-lookup/types/index.js +1 -0
- package/dist/modules/stock-lookup/types/stock-lookup.interface.d.ts +242 -0
- package/dist/modules/stock-lookup/types/stock-lookup.interface.js +82 -0
- package/dist/modules/stock-lookup/types/stock-lookup.interface.spec.d.ts +1 -0
- package/dist/modules/stock-lookup/types/stock-lookup.interface.spec.js +76 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +6 -0
- package/package.json +39 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { checkParamLimits, Utils } from "../../../helpers";
|
|
2
|
+
import { STOCK_LOOKUP_REQUEST_PARAMS_LIMIT, StockLookupRequestBody, } from "../types/stock-lookup.interface";
|
|
3
|
+
/**
|
|
4
|
+
* Map response of SizeGridLookup API call from Harmony into internal SizeGrid interface
|
|
5
|
+
*
|
|
6
|
+
* @export
|
|
7
|
+
* @param {SizeGridRaw} src response in raw format from Harmony API
|
|
8
|
+
* @returns {SizeGrid} SizeGrid object which follows internal naming conventions
|
|
9
|
+
*/
|
|
10
|
+
export function mapSizeGrid(src) {
|
|
11
|
+
return {
|
|
12
|
+
namekey: (src?.namekey ?? [])[0],
|
|
13
|
+
description1: (src?.description_1 ?? [])[0],
|
|
14
|
+
description2: (src?.description_2 ?? [])[0],
|
|
15
|
+
size1: (src?.size_1 ?? [])[0],
|
|
16
|
+
size2: (src?.size_2 ?? [])[0],
|
|
17
|
+
size3: (src?.size_3 ?? [])[0],
|
|
18
|
+
size4: (src?.size_4 ?? [])[0],
|
|
19
|
+
size5: (src?.size_5 ?? [])[0],
|
|
20
|
+
size6: (src?.size_6 ?? [])[0],
|
|
21
|
+
size7: (src?.size_7 ?? [])[0],
|
|
22
|
+
size8: (src?.size_8 ?? [])[0],
|
|
23
|
+
size9: (src?.size_9 ?? [])[0],
|
|
24
|
+
size10: (src?.size_10 ?? [])[0],
|
|
25
|
+
size11: (src?.size_11 ?? [])[0],
|
|
26
|
+
size12: (src?.size_12 ?? [])[0],
|
|
27
|
+
size13: (src?.size_13 ?? [])[0],
|
|
28
|
+
size14: (src?.size_14 ?? [])[0],
|
|
29
|
+
size15: (src?.size_15 ?? [])[0],
|
|
30
|
+
size16: (src?.size_16 ?? [])[0],
|
|
31
|
+
size17: (src?.size_17 ?? [])[0],
|
|
32
|
+
size18: (src?.size_18 ?? [])[0],
|
|
33
|
+
size19: (src?.size_19 ?? [])[0],
|
|
34
|
+
size20: (src?.size_20 ?? [])[0],
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function mapStockColor(src) {
|
|
38
|
+
return mapStockBaseInterface(src);
|
|
39
|
+
}
|
|
40
|
+
export function mapStockClassification(src) {
|
|
41
|
+
return mapStockBaseInterface(src);
|
|
42
|
+
}
|
|
43
|
+
export function mapStockBarcode(src) {
|
|
44
|
+
return {
|
|
45
|
+
stock: (src?.stock ?? [])[0],
|
|
46
|
+
barcode: (src?.barcode ?? [])[0],
|
|
47
|
+
size: (src?.size ?? [])[0],
|
|
48
|
+
pack: (src?.pack ?? [])[0],
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export function mapStockCategory(src) {
|
|
52
|
+
return {
|
|
53
|
+
code: (src?.code ?? [])[0],
|
|
54
|
+
description1: (src?.description_1 ?? [])[0],
|
|
55
|
+
description2: (src?.description_2 ?? [])[0],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export function mapStock(src) {
|
|
59
|
+
return {
|
|
60
|
+
namekey: (src?.namekey ?? [])[0],
|
|
61
|
+
description1: (src?.description_1 ?? [])[0],
|
|
62
|
+
description2: (src?.description_2 ?? [])[0],
|
|
63
|
+
category: (src?.category ?? [])[0],
|
|
64
|
+
class1: (src?.class_1 ?? [])[0],
|
|
65
|
+
class2: (src?.class_2 ?? [])[0],
|
|
66
|
+
class3: (src?.class_3 ?? [])[0],
|
|
67
|
+
extraClass1: (src?.extra_class_1 ?? [])[0],
|
|
68
|
+
extraClass2: (src?.extra_class_2 ?? [])[0],
|
|
69
|
+
extraClass3: (src?.extra_class_3 ?? [])[0],
|
|
70
|
+
extraClass4: (src?.extra_class_4 ?? [])[0],
|
|
71
|
+
extraClass5: (src?.extra_class_5 ?? [])[0],
|
|
72
|
+
salesCode: (src?.sales_code ?? [])[0],
|
|
73
|
+
per: (src?.per ?? [])[0],
|
|
74
|
+
colorCode: (src?.color_code ?? [])[0],
|
|
75
|
+
colorDescription: (src?.color_description ?? [])[0],
|
|
76
|
+
supplier: (src?.supplier ?? [])[0],
|
|
77
|
+
supplierReference: (src?.supplier_reference ?? [])[0],
|
|
78
|
+
barcode: (src?.barcode ?? [])[0],
|
|
79
|
+
weight: Utils.toNumber((src?.weight ?? [])[0]),
|
|
80
|
+
volume: Utils.toNumber((src?.volume ?? [])[0]),
|
|
81
|
+
taxCategory: Utils.toNumber((src?.tax_category ?? [])[0]),
|
|
82
|
+
qdp: Utils.toNumber((src?.qdp ?? [])[0]),
|
|
83
|
+
pdp: Utils.toNumber((src?.pdp ?? [])[0]),
|
|
84
|
+
packsPerCarton: Utils.toNumber((src?.packs_per_carton ?? [])[0]),
|
|
85
|
+
singlesPerPack: Utils.toNumber((src?.singles_per_pack ?? [])[0]),
|
|
86
|
+
cartonPerItem: Utils.toNumber((src?.carton_per_item ?? [])[0]),
|
|
87
|
+
unitsPerSingle: Utils.toNumber((src?.units_per_single ?? [])[0]),
|
|
88
|
+
unitsPerBox: Utils.toNumber((src?.units_per_box ?? [])[0]),
|
|
89
|
+
salesPrice1: Utils.toNumber((src?.sales_price_1 ?? [])[0]),
|
|
90
|
+
salesPrice2: Utils.toNumber((src?.sales_price_2 ?? [])[0]),
|
|
91
|
+
salesPrice3: Utils.toNumber((src?.sales_price_3 ?? [])[0]),
|
|
92
|
+
salesPrice4: Utils.toNumber((src?.sales_price_4 ?? [])[0]),
|
|
93
|
+
salesPrice5: Utils.toNumber((src?.sales_price_5 ?? [])[0]),
|
|
94
|
+
salesPrice6: Utils.toNumber((src?.sales_price_6 ?? [])[0]),
|
|
95
|
+
salesPrice7: Utils.toNumber((src?.sales_price_7 ?? [])[0]),
|
|
96
|
+
salesPrice8: Utils.toNumber((src?.sales_price_8 ?? [])[0]),
|
|
97
|
+
salesPrice9: Utils.toNumber((src?.sales_price_9 ?? [])[0]),
|
|
98
|
+
salesPrice10: Utils.toNumber((src?.sales_price_10 ?? [])[0]),
|
|
99
|
+
salesPrice11: Utils.toNumber((src?.sales_price_11 ?? [])[0]),
|
|
100
|
+
salesPrice12: Utils.toNumber((src?.sales_price_12 ?? [])[0]),
|
|
101
|
+
sellStartDate: (src?.sell_start_date ?? [])[0],
|
|
102
|
+
sellEndDate: (src?.sell_end_date ?? [])[0],
|
|
103
|
+
deliverFromDate: (src?.deliver_from_date ?? [])[0],
|
|
104
|
+
isoCountryOfOrigin: (src?.iso_country_of_origin ?? [])[0],
|
|
105
|
+
stockActive: (src?.stock_active ?? [])[0],
|
|
106
|
+
alternateNamekey: (src?.alternate_namekey ?? [])[0],
|
|
107
|
+
size: (src?.size ?? [])[0],
|
|
108
|
+
pack: (src?.pack ?? [])[0],
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function mapStockBaseInterface(src) {
|
|
112
|
+
return {
|
|
113
|
+
code: (src?.code ?? [])[0],
|
|
114
|
+
description: (src?.description ?? [])[0],
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Map request params for stock lookup to SOAP request body
|
|
119
|
+
*
|
|
120
|
+
* @export
|
|
121
|
+
* @param {StockLookupRequestParams} src request parameters from the SDK API
|
|
122
|
+
* @returns {StockLookupRequestBody} SOAP request body object for Harmony SOAP API
|
|
123
|
+
*/
|
|
124
|
+
export function mapStockLookupRequestParams(src) {
|
|
125
|
+
checkParamLimits(src, STOCK_LOOKUP_REQUEST_PARAMS_LIMIT);
|
|
126
|
+
return new StockLookupRequestBody({
|
|
127
|
+
SearchType: src?.searchType,
|
|
128
|
+
SearchValue: src?.searchValue,
|
|
129
|
+
StockCategoryFr: src?.stockCategoryFr,
|
|
130
|
+
StockCategoryTo: src?.stockCategoryTo,
|
|
131
|
+
StockClassFr1: src?.stockClassFr1,
|
|
132
|
+
StockClassTo1: src?.stockClassTo1,
|
|
133
|
+
StockClassFr2: src?.stockClassFr2,
|
|
134
|
+
StockClassTo2: src?.stockClassTo2,
|
|
135
|
+
StockClassFr3: src?.stockClassFr3,
|
|
136
|
+
StockClassTo3: src?.stockClassTo3,
|
|
137
|
+
StockExtraClassFr1: src?.stockExtraClassFr1,
|
|
138
|
+
StockExtraClassTo1: src?.stockExtraClassTo1,
|
|
139
|
+
StockExtraClassFr2: src?.stockExtraClassFr2,
|
|
140
|
+
StockExtraClassTo2: src?.stockExtraClassTo2,
|
|
141
|
+
StockExtraClassFr3: src?.stockExtraClassFr3,
|
|
142
|
+
StockExtraClassTo3: src?.stockExtraClassTo3,
|
|
143
|
+
StockExtraClassFr4: src?.stockExtraClassFr4,
|
|
144
|
+
StockExtraClassTo4: src?.stockExtraClassTo4,
|
|
145
|
+
StockExtraClassFr5: src?.stockExtraClassFr5,
|
|
146
|
+
StockExtraClassTo5: src?.stockExtraClassTo5,
|
|
147
|
+
SysModTimeFr: src?.sysModTimeFr,
|
|
148
|
+
SysModTimeTo: src?.sysModTimeTo,
|
|
149
|
+
AlternateNamekeyFr: src?.alternateNamekeyFr,
|
|
150
|
+
AlternateNamekeyTo: src?.alternateNamekeyTo,
|
|
151
|
+
StockActive: (src?.stockActive ?? []).join(""),
|
|
152
|
+
Warehouse: src?.warehouse,
|
|
153
|
+
Debtor: src?.debtor,
|
|
154
|
+
DateTime: src?.datetime,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { StockActive } from "../../shared/types";
|
|
2
|
+
import { StockClassificationType, StockSearchType, } from "../types";
|
|
3
|
+
import { mapStockLookupRequestParams } from "./stock-lookup.mapper";
|
|
4
|
+
describe("stockLookup mappers", () => {
|
|
5
|
+
test("mapStockLookupRequestParams all params", () => {
|
|
6
|
+
const src = {
|
|
7
|
+
searchType: StockClassificationType.EXT1,
|
|
8
|
+
searchValue: "123",
|
|
9
|
+
stockCategoryFr: "1",
|
|
10
|
+
stockCategoryTo: "2",
|
|
11
|
+
stockClassFr1: "3",
|
|
12
|
+
stockClassTo1: "4",
|
|
13
|
+
stockClassFr2: "5",
|
|
14
|
+
stockClassTo2: "6",
|
|
15
|
+
stockClassFr3: "7",
|
|
16
|
+
stockClassTo3: "8",
|
|
17
|
+
stockExtraClassFr1: "9",
|
|
18
|
+
stockExtraClassTo1: "10",
|
|
19
|
+
stockExtraClassFr2: "11",
|
|
20
|
+
stockExtraClassTo2: "12",
|
|
21
|
+
stockExtraClassFr3: "13",
|
|
22
|
+
stockExtraClassTo3: "14",
|
|
23
|
+
stockExtraClassFr4: "15",
|
|
24
|
+
stockExtraClassTo4: "16",
|
|
25
|
+
stockExtraClassFr5: "17",
|
|
26
|
+
stockExtraClassTo5: "18",
|
|
27
|
+
sysModTimeFr: "2022-01-01",
|
|
28
|
+
sysModTimeTo: "2022-01-05",
|
|
29
|
+
alternateNamekeyFr: "2022-01-02",
|
|
30
|
+
alternateNamekeyTo: "2022-01-03",
|
|
31
|
+
stockActive: [StockActive.Y],
|
|
32
|
+
warehouse: "W1",
|
|
33
|
+
debtor: "D1",
|
|
34
|
+
datetime: "2022-01-04",
|
|
35
|
+
};
|
|
36
|
+
const expected = {
|
|
37
|
+
SearchType: StockClassificationType.EXT1,
|
|
38
|
+
SearchValue: "123",
|
|
39
|
+
StockCategoryFr: "1",
|
|
40
|
+
StockCategoryTo: "2",
|
|
41
|
+
StockClassFr1: "3",
|
|
42
|
+
StockClassTo1: "4",
|
|
43
|
+
StockClassFr2: "5",
|
|
44
|
+
StockClassTo2: "6",
|
|
45
|
+
StockClassFr3: "7",
|
|
46
|
+
StockClassTo3: "8",
|
|
47
|
+
StockExtraClassFr1: "9",
|
|
48
|
+
StockExtraClassTo1: "10",
|
|
49
|
+
StockExtraClassFr2: "11",
|
|
50
|
+
StockExtraClassTo2: "12",
|
|
51
|
+
StockExtraClassFr3: "13",
|
|
52
|
+
StockExtraClassTo3: "14",
|
|
53
|
+
StockExtraClassFr4: "15",
|
|
54
|
+
StockExtraClassTo4: "16",
|
|
55
|
+
StockExtraClassFr5: "17",
|
|
56
|
+
StockExtraClassTo5: "18",
|
|
57
|
+
SysModTimeFr: "2022-01-01",
|
|
58
|
+
SysModTimeTo: "2022-01-05",
|
|
59
|
+
AlternateNamekeyFr: "2022-01-02",
|
|
60
|
+
AlternateNamekeyTo: "2022-01-03",
|
|
61
|
+
StockActive: "Y",
|
|
62
|
+
Warehouse: "W1",
|
|
63
|
+
Debtor: "D1",
|
|
64
|
+
DateTime: "2022-01-04",
|
|
65
|
+
};
|
|
66
|
+
const mapped = mapStockLookupRequestParams(src);
|
|
67
|
+
expect(mapped).toEqual(expected);
|
|
68
|
+
});
|
|
69
|
+
test("mapStockLookupRequestParams required params", () => {
|
|
70
|
+
const src = {
|
|
71
|
+
searchType: StockClassificationType.EXT1,
|
|
72
|
+
};
|
|
73
|
+
const expected = {
|
|
74
|
+
SearchType: StockClassificationType.EXT1,
|
|
75
|
+
};
|
|
76
|
+
const mapped = mapStockLookupRequestParams(src);
|
|
77
|
+
expect(mapped.SearchType).toEqual(expected.SearchType);
|
|
78
|
+
});
|
|
79
|
+
test("mapStockLookupRequestParams search type and value", () => {
|
|
80
|
+
const src = {
|
|
81
|
+
searchType: StockSearchType.BARCODE,
|
|
82
|
+
searchValue: "1234567890123",
|
|
83
|
+
};
|
|
84
|
+
const expected = {
|
|
85
|
+
SearchType: StockSearchType.BARCODE,
|
|
86
|
+
SearchValue: "1234567890123",
|
|
87
|
+
};
|
|
88
|
+
const mapped = mapStockLookupRequestParams(src);
|
|
89
|
+
expect(mapped.SearchType).toEqual(expected.SearchType);
|
|
90
|
+
expect(mapped.SearchValue).toEqual(expected.SearchValue);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
import { SizeGrid, Stock, StockBarcode, StockCategory, StockClassification, StockClassificationType, StockColor, StockLookupRequestParams } from "./types/stock-lookup.interface";
|
|
3
|
+
/**
|
|
4
|
+
* Module containing all methods to call endpoints belonging to the StockLookup service in Harmony API
|
|
5
|
+
*
|
|
6
|
+
* @export
|
|
7
|
+
* @class StockLookupModule
|
|
8
|
+
* @typedef {StockLookupModule}
|
|
9
|
+
*/
|
|
10
|
+
export declare class StockLookupModule {
|
|
11
|
+
private axiosInstance;
|
|
12
|
+
private readonly SERVICE_URL;
|
|
13
|
+
constructor(axiosInstance: AxiosInstance);
|
|
14
|
+
/**
|
|
15
|
+
* Function to call the sizeGridLookup endpoint in Harmony API
|
|
16
|
+
*
|
|
17
|
+
* @async
|
|
18
|
+
* @param {string} sessionId session ID for authentication
|
|
19
|
+
* @returns {Promise<SizeGrid[]>} Array of size grid response objects which correspond to Harmony API response
|
|
20
|
+
*/
|
|
21
|
+
sizeGridLookup(sessionId: string): Promise<SizeGrid[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Function to call the stockClassificationLookup endpoint in Harmony API
|
|
24
|
+
*
|
|
25
|
+
* @async
|
|
26
|
+
* @param {string} sessionId session ID for authentication
|
|
27
|
+
* @param {*} [scType=StockClassificationType.STK1] Stock classification type (default is "STK1")
|
|
28
|
+
* @returns {Promise<StockClassification[]>} Array of stock classification response objects which correspond to Harmony API response
|
|
29
|
+
*/
|
|
30
|
+
stockClassificationLookup(sessionId: string, scType?: StockClassificationType): Promise<StockClassification[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Function to call the stockBarcodeLookup endpoint in Harmony API
|
|
33
|
+
*
|
|
34
|
+
* @async
|
|
35
|
+
* @param {string} sessionId session ID for authentication
|
|
36
|
+
* @param {StockLookupRequestParams} params object containing search parameters
|
|
37
|
+
* @returns {Promise<StockBarcode[]>} Array of stock barcode response objects which correspond to Harmony API response
|
|
38
|
+
*/
|
|
39
|
+
stockBarcodeLookup(params: StockLookupRequestParams, sessionId: string): Promise<StockBarcode[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Function to call the StockColorLookup endpoint in Harmony API
|
|
42
|
+
*
|
|
43
|
+
* @async
|
|
44
|
+
* @param {string} sessionId session ID for authentication
|
|
45
|
+
* @returns {Promise<StockColor[]>} Array of stock classification response objects which correspond to Harmony API response
|
|
46
|
+
*/
|
|
47
|
+
stockColorLookup(sessionId: string): Promise<StockColor[]>;
|
|
48
|
+
/**
|
|
49
|
+
* Function to call the StockCateogryLookup endpoint in Harmony API
|
|
50
|
+
*
|
|
51
|
+
* @async
|
|
52
|
+
* @param {string} sessionId session ID for authentication
|
|
53
|
+
* @returns {Promise<StockCategory[]>} Array of stock category response objects which correspond to Harmony API response
|
|
54
|
+
*/
|
|
55
|
+
stockCategoryLookup(sessionId: string): Promise<StockCategory[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Function to call the StockLookup endpoint in Harmony API
|
|
58
|
+
*
|
|
59
|
+
* @async
|
|
60
|
+
* @param {StockLookupRequestParams} params object containing search parameters to be used in the SOAP request sent to Harmony API
|
|
61
|
+
* @param {string} sessionId session ID for authentication
|
|
62
|
+
* @returns {Promise<Stock[]>} Array of stock response objects which correspond to Harmony API response
|
|
63
|
+
*/
|
|
64
|
+
stockLookup(params: StockLookupRequestParams, sessionId: string): Promise<Stock[]>;
|
|
65
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { ApiHelper, Utils } from "../../helpers";
|
|
2
|
+
import { ServiceAlias } from "../shared/types";
|
|
3
|
+
import { mapSizeGrid, mapStock, mapStockBarcode, mapStockCategory, mapStockClassification, mapStockColor, mapStockLookupRequestParams, } from "./mappings/stock-lookup.mapper";
|
|
4
|
+
import { StockClassificationType, StockLookupRequestBody, StockSearchType, } from "./types/stock-lookup.interface";
|
|
5
|
+
/**
|
|
6
|
+
* Module containing all methods to call endpoints belonging to the StockLookup service in Harmony API
|
|
7
|
+
*
|
|
8
|
+
* @export
|
|
9
|
+
* @class StockLookupModule
|
|
10
|
+
* @typedef {StockLookupModule}
|
|
11
|
+
*/
|
|
12
|
+
export class StockLookupModule {
|
|
13
|
+
axiosInstance;
|
|
14
|
+
SERVICE_URL = "/StockLookupService/StockLookupService";
|
|
15
|
+
constructor(axiosInstance) {
|
|
16
|
+
this.axiosInstance = axiosInstance;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Function to call the sizeGridLookup endpoint in Harmony API
|
|
20
|
+
*
|
|
21
|
+
* @async
|
|
22
|
+
* @param {string} sessionId session ID for authentication
|
|
23
|
+
* @returns {Promise<SizeGrid[]>} Array of size grid response objects which correspond to Harmony API response
|
|
24
|
+
*/
|
|
25
|
+
async sizeGridLookup(sessionId) {
|
|
26
|
+
try {
|
|
27
|
+
const response = await ApiHelper.sendServiceRequest(this.SERVICE_URL, `SizeGridLookup`, sessionId, ServiceAlias.STOCK_LOOKUP, this.axiosInstance);
|
|
28
|
+
return response?.SizeGrid?.map(mapSizeGrid);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
throw await ApiHelper.parseError(error);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Function to call the stockClassificationLookup endpoint in Harmony API
|
|
36
|
+
*
|
|
37
|
+
* @async
|
|
38
|
+
* @param {string} sessionId session ID for authentication
|
|
39
|
+
* @param {*} [scType=StockClassificationType.STK1] Stock classification type (default is "STK1")
|
|
40
|
+
* @returns {Promise<StockClassification[]>} Array of stock classification response objects which correspond to Harmony API response
|
|
41
|
+
*/
|
|
42
|
+
async stockClassificationLookup(sessionId, scType = StockClassificationType.STK1) {
|
|
43
|
+
const body = new StockLookupRequestBody({ SearchType: scType });
|
|
44
|
+
try {
|
|
45
|
+
const response = await ApiHelper.sendServiceRequest(this.SERVICE_URL, `StockClassificationLookup`, sessionId, ServiceAlias.STOCK_LOOKUP, this.axiosInstance, body.toString());
|
|
46
|
+
return response?.StockClassification?.map(mapStockClassification);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
throw await ApiHelper.parseError(error);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Function to call the stockBarcodeLookup endpoint in Harmony API
|
|
54
|
+
*
|
|
55
|
+
* @async
|
|
56
|
+
* @param {string} sessionId session ID for authentication
|
|
57
|
+
* @param {StockLookupRequestParams} params object containing search parameters
|
|
58
|
+
* @returns {Promise<StockBarcode[]>} Array of stock barcode response objects which correspond to Harmony API response
|
|
59
|
+
*/
|
|
60
|
+
async stockBarcodeLookup(params, sessionId) {
|
|
61
|
+
const body = mapStockLookupRequestParams(params);
|
|
62
|
+
const { SearchType, SearchValue } = body;
|
|
63
|
+
// Logic for the search value based on stock barcode type
|
|
64
|
+
switch (SearchType) {
|
|
65
|
+
case StockSearchType.BARCODE:
|
|
66
|
+
if (Utils.nonEmptyString(SearchValue) && SearchValue?.length != 13) {
|
|
67
|
+
throw new Error("Barcode search requires a barcode value");
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
70
|
+
case StockSearchType.STOCK:
|
|
71
|
+
if (Utils.nonEmptyString(SearchValue) && SearchValue?.trim() === "*") {
|
|
72
|
+
throw new Error("Stock search value cannot be '*'");
|
|
73
|
+
}
|
|
74
|
+
break;
|
|
75
|
+
case StockSearchType.STOCK_KEYWORD:
|
|
76
|
+
if (Utils.nonEmptyString(SearchValue) && SearchValue?.includes("*")) {
|
|
77
|
+
throw new Error("Stock Keyword search does not allow wildcard character (*)");
|
|
78
|
+
}
|
|
79
|
+
if (Utils.isEmptyString(SearchValue)) {
|
|
80
|
+
throw new Error("Stock Keyword search value cannot be empty");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const response = await ApiHelper.sendServiceRequest(this.SERVICE_URL, [`StockBarcodeLookup`, `Request`], sessionId, ServiceAlias.STOCK_LOOKUP, this.axiosInstance, body.toString());
|
|
85
|
+
return response?.StockBarcode?.map(mapStockBarcode);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
throw await ApiHelper.parseError(error);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Function to call the StockColorLookup endpoint in Harmony API
|
|
93
|
+
*
|
|
94
|
+
* @async
|
|
95
|
+
* @param {string} sessionId session ID for authentication
|
|
96
|
+
* @returns {Promise<StockColor[]>} Array of stock classification response objects which correspond to Harmony API response
|
|
97
|
+
*/
|
|
98
|
+
async stockColorLookup(sessionId) {
|
|
99
|
+
try {
|
|
100
|
+
const response = await ApiHelper.sendServiceRequest(this.SERVICE_URL, `StockColorLookup`, sessionId, ServiceAlias.STOCK_LOOKUP, this.axiosInstance);
|
|
101
|
+
return response?.StockColor?.map(mapStockColor);
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
throw await ApiHelper.parseError(error);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Function to call the StockCateogryLookup endpoint in Harmony API
|
|
109
|
+
*
|
|
110
|
+
* @async
|
|
111
|
+
* @param {string} sessionId session ID for authentication
|
|
112
|
+
* @returns {Promise<StockCategory[]>} Array of stock category response objects which correspond to Harmony API response
|
|
113
|
+
*/
|
|
114
|
+
async stockCategoryLookup(sessionId) {
|
|
115
|
+
try {
|
|
116
|
+
const response = await ApiHelper.sendServiceRequest(this.SERVICE_URL, `StockCategoryLookup`, sessionId, ServiceAlias.STOCK_LOOKUP, this.axiosInstance);
|
|
117
|
+
return response?.StockCategory?.map(mapStockCategory);
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
throw await ApiHelper.parseError(error);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Function to call the StockLookup endpoint in Harmony API
|
|
125
|
+
*
|
|
126
|
+
* @async
|
|
127
|
+
* @param {StockLookupRequestParams} params object containing search parameters to be used in the SOAP request sent to Harmony API
|
|
128
|
+
* @param {string} sessionId session ID for authentication
|
|
129
|
+
* @returns {Promise<Stock[]>} Array of stock response objects which correspond to Harmony API response
|
|
130
|
+
*/
|
|
131
|
+
async stockLookup(params, sessionId) {
|
|
132
|
+
const body = mapStockLookupRequestParams(params);
|
|
133
|
+
try {
|
|
134
|
+
const response = await ApiHelper.sendServiceRequest(this.SERVICE_URL, [`StockLookup`, `Request`], sessionId, ServiceAlias.STOCK_LOOKUP, this.axiosInstance, body.toString());
|
|
135
|
+
return response?.Stock?.map(mapStock);
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
throw await ApiHelper.parseError(error);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|