@dotdev/harmony-sdk 1.0.1

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.
Files changed (124) hide show
  1. package/README.md +132 -0
  2. package/dist/HarmonyAPI.d.ts +37 -0
  3. package/dist/HarmonyAPI.js +113 -0
  4. package/dist/errors/index.d.ts +15 -0
  5. package/dist/errors/index.js +18 -0
  6. package/dist/helpers/index.d.ts +50 -0
  7. package/dist/helpers/index.js +167 -0
  8. package/dist/helpers/index.spec.d.ts +1 -0
  9. package/dist/helpers/index.spec.js +147 -0
  10. package/dist/helpers/mapper.d.ts +2 -0
  11. package/dist/helpers/mapper.js +28 -0
  12. package/dist/helpers/utils.d.ts +71 -0
  13. package/dist/helpers/utils.js +133 -0
  14. package/dist/helpers/utils.spec.d.ts +1 -0
  15. package/dist/helpers/utils.spec.js +96 -0
  16. package/dist/index.d.ts +5 -0
  17. package/dist/index.js +5 -0
  18. package/dist/modules/auth/auth.module.d.ts +7 -0
  19. package/dist/modules/auth/auth.module.js +42 -0
  20. package/dist/modules/auth/auth.module.spec.d.ts +1 -0
  21. package/dist/modules/auth/auth.module.spec.js +55 -0
  22. package/dist/modules/auth/index.d.ts +2 -0
  23. package/dist/modules/auth/index.js +2 -0
  24. package/dist/modules/auth/types/index.d.ts +7 -0
  25. package/dist/modules/auth/types/index.js +1 -0
  26. package/dist/modules/carrier/carrier.module.d.ts +10 -0
  27. package/dist/modules/carrier/carrier.module.js +39 -0
  28. package/dist/modules/carrier/carrier.module.spec.d.ts +1 -0
  29. package/dist/modules/carrier/carrier.module.spec.js +187 -0
  30. package/dist/modules/carrier/index.d.ts +3 -0
  31. package/dist/modules/carrier/index.js +3 -0
  32. package/dist/modules/carrier/mappings/index.d.ts +5 -0
  33. package/dist/modules/carrier/mappings/index.js +36 -0
  34. package/dist/modules/carrier/types/index.d.ts +42 -0
  35. package/dist/modules/carrier/types/index.js +2 -0
  36. package/dist/modules/diary/diary.module.d.ts +9 -0
  37. package/dist/modules/diary/diary.module.js +28 -0
  38. package/dist/modules/diary/index.d.ts +3 -0
  39. package/dist/modules/diary/index.js +3 -0
  40. package/dist/modules/diary/mappings/diary.mapper.d.ts +4 -0
  41. package/dist/modules/diary/mappings/diary.mapper.js +101 -0
  42. package/dist/modules/diary/mappings/diary.mapper.spec.d.ts +1 -0
  43. package/dist/modules/diary/mappings/diary.mapper.spec.js +18 -0
  44. package/dist/modules/diary/mappings/index.d.ts +1 -0
  45. package/dist/modules/diary/mappings/index.js +1 -0
  46. package/dist/modules/diary/types/diary.interface.d.ts +138 -0
  47. package/dist/modules/diary/types/diary.interface.js +24 -0
  48. package/dist/modules/diary/types/index.d.ts +1 -0
  49. package/dist/modules/diary/types/index.js +1 -0
  50. package/dist/modules/gift-voucher/gift-voucher.module.d.ts +12 -0
  51. package/dist/modules/gift-voucher/gift-voucher.module.js +55 -0
  52. package/dist/modules/gift-voucher/gift-voucher.module.spec.d.ts +1 -0
  53. package/dist/modules/gift-voucher/gift-voucher.module.spec.js +296 -0
  54. package/dist/modules/gift-voucher/index.d.ts +1 -0
  55. package/dist/modules/gift-voucher/index.js +1 -0
  56. package/dist/modules/gift-voucher/mappings/index.d.ts +6 -0
  57. package/dist/modules/gift-voucher/mappings/index.js +70 -0
  58. package/dist/modules/gift-voucher/mappings/index.spec.d.ts +1 -0
  59. package/dist/modules/gift-voucher/mappings/index.spec.js +21 -0
  60. package/dist/modules/gift-voucher/types/index.d.ts +92 -0
  61. package/dist/modules/gift-voucher/types/index.js +1 -0
  62. package/dist/modules/index.d.ts +8 -0
  63. package/dist/modules/index.js +8 -0
  64. package/dist/modules/point-of-sale/index.d.ts +3 -0
  65. package/dist/modules/point-of-sale/index.js +3 -0
  66. package/dist/modules/point-of-sale/mappings/index.d.ts +1 -0
  67. package/dist/modules/point-of-sale/mappings/index.js +1 -0
  68. package/dist/modules/point-of-sale/mappings/process-sale-order.mapper.d.ts +6 -0
  69. package/dist/modules/point-of-sale/mappings/process-sale-order.mapper.js +142 -0
  70. package/dist/modules/point-of-sale/point-of-sale.module.d.ts +43 -0
  71. package/dist/modules/point-of-sale/point-of-sale.module.js +64 -0
  72. package/dist/modules/point-of-sale/point-of-sale.module.spec.d.ts +1 -0
  73. package/dist/modules/point-of-sale/point-of-sale.module.spec.js +205 -0
  74. package/dist/modules/point-of-sale/types/cancel-existing-sales-order.interface.d.ts +13 -0
  75. package/dist/modules/point-of-sale/types/cancel-existing-sales-order.interface.js +1 -0
  76. package/dist/modules/point-of-sale/types/index.d.ts +124 -0
  77. package/dist/modules/point-of-sale/types/index.js +31 -0
  78. package/dist/modules/point-of-sale/types/modify-existing-sales-order.interface.d.ts +12 -0
  79. package/dist/modules/point-of-sale/types/modify-existing-sales-order.interface.js +1 -0
  80. package/dist/modules/point-of-sale/types/process-returns.interface.d.ts +17 -0
  81. package/dist/modules/point-of-sale/types/process-returns.interface.js +1 -0
  82. package/dist/modules/point-of-sale/types/process-sale-order.interface.d.ts +67 -0
  83. package/dist/modules/point-of-sale/types/process-sale-order.interface.js +1 -0
  84. package/dist/modules/shared/index.d.ts +1 -0
  85. package/dist/modules/shared/index.js +1 -0
  86. package/dist/modules/shared/types/index.d.ts +93 -0
  87. package/dist/modules/shared/types/index.js +53 -0
  88. package/dist/modules/stock-level-lookup/index.d.ts +3 -0
  89. package/dist/modules/stock-level-lookup/index.js +3 -0
  90. package/dist/modules/stock-level-lookup/mappings/index.d.ts +1 -0
  91. package/dist/modules/stock-level-lookup/mappings/index.js +1 -0
  92. package/dist/modules/stock-level-lookup/mappings/stock-level-lookup.mapper.d.ts +4 -0
  93. package/dist/modules/stock-level-lookup/mappings/stock-level-lookup.mapper.js +78 -0
  94. package/dist/modules/stock-level-lookup/mappings/stock-level-lookup.mapper.spec.d.ts +1 -0
  95. package/dist/modules/stock-level-lookup/mappings/stock-level-lookup.mapper.spec.js +57 -0
  96. package/dist/modules/stock-level-lookup/stock-level-lookup.module.d.ts +10 -0
  97. package/dist/modules/stock-level-lookup/stock-level-lookup.module.js +39 -0
  98. package/dist/modules/stock-level-lookup/stock-level-lookup.module.spec.d.ts +1 -0
  99. package/dist/modules/stock-level-lookup/stock-level-lookup.module.spec.js +317 -0
  100. package/dist/modules/stock-level-lookup/types/index.d.ts +1 -0
  101. package/dist/modules/stock-level-lookup/types/index.js +1 -0
  102. package/dist/modules/stock-level-lookup/types/stock-level-lookup.interface.d.ts +162 -0
  103. package/dist/modules/stock-level-lookup/types/stock-level-lookup.interface.js +61 -0
  104. package/dist/modules/stock-lookup/index.d.ts +3 -0
  105. package/dist/modules/stock-lookup/index.js +3 -0
  106. package/dist/modules/stock-lookup/mappings/index.d.ts +1 -0
  107. package/dist/modules/stock-lookup/mappings/index.js +1 -0
  108. package/dist/modules/stock-lookup/mappings/stock-lookup.mapper.d.ts +22 -0
  109. package/dist/modules/stock-lookup/mappings/stock-lookup.mapper.js +156 -0
  110. package/dist/modules/stock-lookup/mappings/stock-lookup.mapper.spec.d.ts +1 -0
  111. package/dist/modules/stock-lookup/mappings/stock-lookup.mapper.spec.js +92 -0
  112. package/dist/modules/stock-lookup/stock-lookup.module.d.ts +65 -0
  113. package/dist/modules/stock-lookup/stock-lookup.module.js +141 -0
  114. package/dist/modules/stock-lookup/stock-lookup.module.spec.d.ts +1 -0
  115. package/dist/modules/stock-lookup/stock-lookup.module.spec.js +419 -0
  116. package/dist/modules/stock-lookup/types/index.d.ts +1 -0
  117. package/dist/modules/stock-lookup/types/index.js +1 -0
  118. package/dist/modules/stock-lookup/types/stock-lookup.interface.d.ts +242 -0
  119. package/dist/modules/stock-lookup/types/stock-lookup.interface.js +82 -0
  120. package/dist/modules/stock-lookup/types/stock-lookup.interface.spec.d.ts +1 -0
  121. package/dist/modules/stock-lookup/types/stock-lookup.interface.spec.js +76 -0
  122. package/dist/types/index.d.ts +5 -0
  123. package/dist/types/index.js +6 -0
  124. package/package.json +39 -0
@@ -0,0 +1,67 @@
1
+ import { PosBaseQueryParams, PosQueryDebtor, PosQueryExtra, PosQueryHeader, PosQueryInvoice, PosQueryStock } from ".";
2
+ import { BooleanResponse } from "../../shared";
3
+ export interface ProcessSaleOrderQueryParams extends PosBaseQueryParams {
4
+ header: ProcessSaleOrderQueryHeader;
5
+ extra: ProcessSaleOrderQueryExtra;
6
+ stock: ProcessSaleOrderQueryStock[];
7
+ debtor: ProcessSaleOrderQueryDebtor[];
8
+ }
9
+ export interface ProcessSaleOrderQueryHeader extends PosQueryHeader {
10
+ invoiceNo?: string;
11
+ orderNo: string;
12
+ fulfillmentWarehouse?: string;
13
+ cancelLaybyNo?: string;
14
+ orderLines: number;
15
+ orderDepositTotal?: number;
16
+ orderVersion: number;
17
+ orderDeliveryDate?: string;
18
+ orderCancelAfterDate?: string;
19
+ webOrderType?: string;
20
+ }
21
+ export interface ProcessSaleOrderQueryExtra extends PosQueryExtra {
22
+ /**
23
+ * Delivery street number and name
24
+ *
25
+ * @type {?string}
26
+ */
27
+ deliveryAddress1?: string;
28
+ /**
29
+ * Additional address identifier like building name
30
+ *
31
+ * @type {?string}
32
+ */
33
+ deliveryAddress2?: string;
34
+ /**
35
+ * Delivery Suburb and State Code ie 2or3 char identifier ie NSW,WA.
36
+ * For Australia: Suburb + State, separated by space (should be valid and compatible with APOST if dispatch is from Harmony)
37
+ *
38
+ * @type {?string}
39
+ */
40
+ deliveryAddress3?: string;
41
+ /**
42
+ * Delivery country
43
+ *
44
+ * @type {?string}
45
+ */
46
+ deliveryAddress4?: string;
47
+ /**
48
+ * Delivery postcode. For Australia - valid APOST postcode
49
+ *
50
+ * @type {?string}
51
+ */
52
+ deliveryPostcode?: string;
53
+ deliveryInstruction1?: string;
54
+ deliveryInstruction2?: string;
55
+ carrier?: string;
56
+ }
57
+ export interface ProcessSaleOrderQueryStock extends PosQueryStock {
58
+ dispatchDate?: string;
59
+ invoiceQty: number;
60
+ orderQty: number;
61
+ depositAmount?: number;
62
+ exportLineNo?: number;
63
+ markdownReason?: string;
64
+ skuBarcode?: string;
65
+ }
66
+ export type ProcessSaleOrderQueryDebtor = PosQueryInvoice & PosQueryDebtor;
67
+ export type ProcessSalesOrderResponse = BooleanResponse;
@@ -0,0 +1 @@
1
+ export * from "./types";
@@ -0,0 +1 @@
1
+ export * from "./types";
@@ -0,0 +1,93 @@
1
+ import { StockSearchType } from "../../stock-lookup";
2
+ /**
3
+ * Generic type containing limit for each property within the type. Use in conjunction with `checkParamLimits` function to check whether
4
+ * all properties/params provided meet their individual limits.
5
+ *
6
+ * @export
7
+ * @typedef {ParamLimits}
8
+ * @template T
9
+ */
10
+ export type ParamLimits<T> = {
11
+ [K in keyof T]: number | ((val: any) => boolean);
12
+ };
13
+ /**
14
+ * Enum values corresponding to the alias of services used in the Harmonic API URL
15
+ * i.e. StockLookupService with alias "stk" has service URL as "http://stk.ws.fbsaust.com.au"
16
+ *
17
+ * @export
18
+ * @enum {number}
19
+ */
20
+ export declare enum ServiceAlias {
21
+ STOCK_LOOKUP = "stk",
22
+ STOCK_LEVEL_LOOKUP = "stklvl",
23
+ POINT_OF_SALE = "pos",
24
+ GIFT_VOUCHER = "gv",
25
+ DIARY = "dry",
26
+ CARRIER = "discs"
27
+ }
28
+ export interface OptionalStockQueryParams {
29
+ stockCategoryFr?: string;
30
+ stockCategoryTo?: string;
31
+ stockClassFr1?: string;
32
+ stockClassTo1?: string;
33
+ stockClassFr2?: string;
34
+ stockClassTo2?: string;
35
+ stockClassFr3?: string;
36
+ stockClassTo3?: string;
37
+ stockExtraClassFr1?: string;
38
+ stockExtraClassTo1?: string;
39
+ stockExtraClassFr2?: string;
40
+ stockExtraClassTo2?: string;
41
+ stockExtraClassFr3?: string;
42
+ stockExtraClassTo3?: string;
43
+ stockExtraClassFr4?: string;
44
+ stockExtraClassTo4?: string;
45
+ stockExtraClassFr5?: string;
46
+ stockExtraClassTo5?: string;
47
+ sysModTimeFr?: string;
48
+ sysModTimeTo?: string;
49
+ alternateNamekeyFr?: string;
50
+ alternateNamekeyTo?: string;
51
+ stockActive?: StockActive[];
52
+ }
53
+ export declare enum StockActive {
54
+ Y = "Y",
55
+ I = "I",
56
+ N = "N",
57
+ S = "S",
58
+ O = "O",
59
+ P = "P"
60
+ }
61
+ export interface CombinedSearchTypeValue {
62
+ type: StockSearchType;
63
+ value: string;
64
+ }
65
+ export declare class OptionalStockRequestBody {
66
+ StockCategoryFr?: string;
67
+ StockCategoryTo?: string;
68
+ StockClassFr1?: string;
69
+ StockClassTo1?: string;
70
+ StockClassFr2?: string;
71
+ StockClassTo2?: string;
72
+ StockClassFr3?: string;
73
+ StockClassTo3?: string;
74
+ StockExtraClassFr1?: string;
75
+ StockExtraClassTo1?: string;
76
+ StockExtraClassFr2?: string;
77
+ StockExtraClassTo2?: string;
78
+ StockExtraClassFr3?: string;
79
+ StockExtraClassTo3?: string;
80
+ StockExtraClassFr4?: string;
81
+ StockExtraClassTo4?: string;
82
+ StockExtraClassFr5?: string;
83
+ StockExtraClassTo5?: string;
84
+ SysModTimeFr?: string;
85
+ SysModTimeTo?: string;
86
+ AlternateNamekeyFr?: string;
87
+ AlternateNamekeyTo?: string;
88
+ StockActive?: string;
89
+ constructor(obj: Partial<OptionalStockRequestBody>);
90
+ }
91
+ export interface BooleanResponse {
92
+ result: boolean[];
93
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Enum values corresponding to the alias of services used in the Harmonic API URL
3
+ * i.e. StockLookupService with alias "stk" has service URL as "http://stk.ws.fbsaust.com.au"
4
+ *
5
+ * @export
6
+ * @enum {number}
7
+ */
8
+ export var ServiceAlias;
9
+ (function (ServiceAlias) {
10
+ ServiceAlias["STOCK_LOOKUP"] = "stk";
11
+ ServiceAlias["STOCK_LEVEL_LOOKUP"] = "stklvl";
12
+ ServiceAlias["POINT_OF_SALE"] = "pos";
13
+ ServiceAlias["GIFT_VOUCHER"] = "gv";
14
+ ServiceAlias["DIARY"] = "dry";
15
+ ServiceAlias["CARRIER"] = "discs";
16
+ })(ServiceAlias || (ServiceAlias = {}));
17
+ export var StockActive;
18
+ (function (StockActive) {
19
+ StockActive["Y"] = "Y";
20
+ StockActive["I"] = "I";
21
+ StockActive["N"] = "N";
22
+ StockActive["S"] = "S";
23
+ StockActive["O"] = "O";
24
+ StockActive["P"] = "P";
25
+ })(StockActive || (StockActive = {}));
26
+ export class OptionalStockRequestBody {
27
+ StockCategoryFr;
28
+ StockCategoryTo;
29
+ StockClassFr1;
30
+ StockClassTo1;
31
+ StockClassFr2;
32
+ StockClassTo2;
33
+ StockClassFr3;
34
+ StockClassTo3;
35
+ StockExtraClassFr1;
36
+ StockExtraClassTo1;
37
+ StockExtraClassFr2;
38
+ StockExtraClassTo2;
39
+ StockExtraClassFr3;
40
+ StockExtraClassTo3;
41
+ StockExtraClassFr4;
42
+ StockExtraClassTo4;
43
+ StockExtraClassFr5;
44
+ StockExtraClassTo5;
45
+ SysModTimeFr;
46
+ SysModTimeTo;
47
+ AlternateNamekeyFr;
48
+ AlternateNamekeyTo;
49
+ StockActive;
50
+ constructor(obj) {
51
+ Object.assign(this, obj);
52
+ }
53
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./mappings";
2
+ export * from "./stock-level-lookup.module";
3
+ export * from "./types";
@@ -0,0 +1,3 @@
1
+ export * from "./mappings";
2
+ export * from "./stock-level-lookup.module";
3
+ export * from "./types";
@@ -0,0 +1 @@
1
+ export * from "./stock-level-lookup.mapper";
@@ -0,0 +1 @@
1
+ export * from "./stock-level-lookup.mapper";
@@ -0,0 +1,4 @@
1
+ import { StockLevel, StockLevelLookupQueryParams, StockLevelLookupRequestBody, StockLevelRaw, Warehouse, WarehouseRaw } from "../types";
2
+ export declare function mapWarehouse(src: WarehouseRaw): Warehouse;
3
+ export declare function mapStockLevel(src: StockLevelRaw): StockLevel;
4
+ export declare function mapStockLevelLookupQueryParams(src: StockLevelLookupQueryParams): StockLevelLookupRequestBody;
@@ -0,0 +1,78 @@
1
+ import { Utils } from "../../../helpers";
2
+ import { mapOptionalStockQueryParams } from "../../../helpers/mapper";
3
+ import { OnlyNonZero, QtyType, StockLevelLookupRequestBody, } from "../types";
4
+ export function mapWarehouse(src) {
5
+ return {
6
+ namekey: (src?.namekey ?? [])[0],
7
+ description1: (src?.description_1 ?? [])[0],
8
+ description2: (src?.description_2 ?? [])[0],
9
+ class1: (src?.class_1 ?? [])[0],
10
+ class2: (src?.class_2 ?? [])[0],
11
+ class3: (src?.class_3 ?? [])[0],
12
+ class4: (src?.class_4 ?? [])[0],
13
+ class5: (src?.class_5 ?? [])[0],
14
+ };
15
+ }
16
+ export function mapStockLevel(src) {
17
+ return {
18
+ stock: (src?.stock ?? [])[0],
19
+ stockType: (src?.stock_type ?? [])[0],
20
+ pack: (src?.pack ?? [])[0],
21
+ warehouse: (src?.warehouse ?? [])[0],
22
+ salesCode: (src?.sales_code ?? [])[0],
23
+ qtyType: (src?.qty_type ?? [])[0],
24
+ qdp: Utils.toNumber((src?.qdp ?? [])[0] ?? 0),
25
+ packQty: Utils.toNumber((src?.pack_qty ?? [])[0] ?? 0),
26
+ qty: Utils.toNumber((src?.qty ?? [])[0] ?? 0),
27
+ sizeQty1: Utils.toNumber((src?.size_qty_01 ?? [])[0] ?? 0),
28
+ sizeQty2: Utils.toNumber((src?.size_qty_02 ?? [])[0] ?? 0),
29
+ sizeQty3: Utils.toNumber((src?.size_qty_03 ?? [])[0] ?? 0),
30
+ sizeQty4: Utils.toNumber((src?.size_qty_04 ?? [])[0] ?? 0),
31
+ sizeQty5: Utils.toNumber((src?.size_qty_05 ?? [])[0] ?? 0),
32
+ sizeQty6: Utils.toNumber((src?.size_qty_06 ?? [])[0] ?? 0),
33
+ sizeQty7: Utils.toNumber((src?.size_qty_07 ?? [])[0] ?? 0),
34
+ sizeQty8: Utils.toNumber((src?.size_qty_08 ?? [])[0] ?? 0),
35
+ sizeQty9: Utils.toNumber((src?.size_qty_09 ?? [])[0] ?? 0),
36
+ sizeQty10: Utils.toNumber((src?.size_qty_10 ?? [])[0] ?? 0),
37
+ sizeQty11: Utils.toNumber((src?.size_qty_11 ?? [])[0] ?? 0),
38
+ sizeQty12: Utils.toNumber((src?.size_qty_12 ?? [])[0] ?? 0),
39
+ sizeQty13: Utils.toNumber((src?.size_qty_13 ?? [])[0] ?? 0),
40
+ sizeQty14: Utils.toNumber((src?.size_qty_14 ?? [])[0] ?? 0),
41
+ sizeQty15: Utils.toNumber((src?.size_qty_15 ?? [])[0] ?? 0),
42
+ sizeQty16: Utils.toNumber((src?.size_qty_16 ?? [])[0] ?? 0),
43
+ sizeQty17: Utils.toNumber((src?.size_qty_17 ?? [])[0] ?? 0),
44
+ sizeQty18: Utils.toNumber((src?.size_qty_18 ?? [])[0] ?? 0),
45
+ sizeQty19: Utils.toNumber((src?.size_qty_19 ?? [])[0] ?? 0),
46
+ sizeQty20: Utils.toNumber((src?.size_qty_20 ?? [])[0] ?? 0),
47
+ };
48
+ }
49
+ export function mapStockLevelLookupQueryParams(src) {
50
+ const optional = mapOptionalStockQueryParams(src);
51
+ return new StockLevelLookupRequestBody({
52
+ SearchType: `<Type>${src?.searchType?.type ?? ""}</Type><Value>${src?.searchType?.value ?? ""}</Value>`,
53
+ QtyType: `<Type>${src?.qtyType ?? QtyType.STK}</Type>`,
54
+ Summarised: src?.summarised,
55
+ OnlyNonZero: src?.onlyNonZero ?? OnlyNonZero.YES,
56
+ Warehouse: src?.warehouse ?? "",
57
+ Warehouse1: src?.warehouse1 ?? "",
58
+ Warehouse2: src?.warehouse2 ?? "",
59
+ Warehouse3: src?.warehouse3 ?? "",
60
+ Warehouse4: src?.warehouse4 ?? "",
61
+ Warehouse5: src?.warehouse5 ?? "",
62
+ Warehouse6: src?.warehouse6 ?? "",
63
+ Warehouse7: src?.warehouse7 ?? "",
64
+ Warehouse8: src?.warehouse8 ?? "",
65
+ Warehouse9: src?.warehouse9 ?? "",
66
+ Warehouse10: src?.warehouse10 ?? "",
67
+ WarehouseClassFr1: src?.warehouseClassFr1 ?? "",
68
+ WarehouseClassTo1: src?.warehouseClassTo1 ?? "",
69
+ WarehouseClassFr2: src?.warehouseClassFr2 ?? "",
70
+ WarehouseClassTo2: src?.warehouseClassTo2 ?? "",
71
+ WarehouseClassFr3: src?.warehouseClassFr3 ?? "",
72
+ WarehouseClassTo3: src?.warehouseClassTo3 ?? "",
73
+ WarehouseClassFr4: src?.warehouseClassFr4 ?? "",
74
+ WarehouseClassTo4: src?.warehouseClassTo4 ?? "",
75
+ WarehouseClassFr5: src?.warehouseClassFr5 ?? "",
76
+ ...optional,
77
+ });
78
+ }
@@ -0,0 +1,57 @@
1
+ import { mapWarehouse } from "./stock-level-lookup.mapper";
2
+ describe("StockLevelLookupMapper.mapWarehouse", () => {
3
+ it("should map warehouse response correctly", () => {
4
+ const warehouseResponse = {
5
+ Warehouse: [
6
+ {
7
+ namekey: ["testNamekey"],
8
+ description_1: ["testDescription1"],
9
+ description_2: ["testDescription2"],
10
+ class_1: ["testClass1"],
11
+ class_2: ["testClass2"],
12
+ class_3: ["testClass3"],
13
+ class_4: ["testClass4"],
14
+ class_5: ["testClass5"],
15
+ },
16
+ ],
17
+ };
18
+ const expected = {
19
+ namekey: "testNamekey",
20
+ description1: "testDescription1",
21
+ description2: "testDescription2",
22
+ class1: "testClass1",
23
+ class2: "testClass2",
24
+ class3: "testClass3",
25
+ class4: "testClass4",
26
+ class5: "testClass5",
27
+ };
28
+ expect(mapWarehouse(warehouseResponse.Warehouse[0])).toEqual(expected);
29
+ });
30
+ it("should map warehouse response and return arrrays of same size regardless whether the properties are available or not", () => {
31
+ const warehouseResponse = {
32
+ Warehouse: [
33
+ {
34
+ namekey: ["testNamekey"],
35
+ description_1: ["testDescription1"],
36
+ description_2: undefined,
37
+ class_1: ["testClass1"],
38
+ class_2: undefined,
39
+ class_3: undefined,
40
+ class_4: ["testClass4"],
41
+ class_5: ["testClass5"],
42
+ },
43
+ ],
44
+ };
45
+ const expected = {
46
+ namekey: "testNamekey",
47
+ description1: "testDescription1",
48
+ description2: undefined,
49
+ class1: "testClass1",
50
+ class2: undefined,
51
+ class3: undefined,
52
+ class4: "testClass4",
53
+ class5: "testClass5",
54
+ };
55
+ expect(mapWarehouse(warehouseResponse.Warehouse[0])).toEqual(expected);
56
+ });
57
+ });
@@ -0,0 +1,10 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { StockLevel, StockLevelLookupQueryParams, Warehouse } from "./types";
3
+ export declare class StockLevelLookupModule {
4
+ private axiosInstance;
5
+ private readonly SERVICE_URL;
6
+ constructor(axiosInstance: AxiosInstance);
7
+ warehouseLookup(sessionId: string): Promise<Warehouse[]>;
8
+ stockLevelLookup(params: StockLevelLookupQueryParams, sessionId: string): Promise<StockLevel[]>;
9
+ stockLevelLookupByWarehouseQuickView(params: StockLevelLookupQueryParams, sessionId: string): Promise<StockLevel[]>;
10
+ }
@@ -0,0 +1,39 @@
1
+ import { ApiHelper } from "../../helpers";
2
+ import { ServiceAlias } from "../shared/types";
3
+ import { mapStockLevel, mapStockLevelLookupQueryParams, mapWarehouse, } from "./mappings";
4
+ export class StockLevelLookupModule {
5
+ axiosInstance;
6
+ SERVICE_URL = "/StockLevelLookupService/StockLevelLookupService";
7
+ constructor(axiosInstance) {
8
+ this.axiosInstance = axiosInstance;
9
+ }
10
+ async warehouseLookup(sessionId) {
11
+ try {
12
+ const response = await ApiHelper.sendServiceRequest(this.SERVICE_URL, `WarehouseLookup`, sessionId, ServiceAlias.STOCK_LEVEL_LOOKUP, this.axiosInstance);
13
+ return response?.Warehouse?.map(mapWarehouse) ?? [];
14
+ }
15
+ catch (error) {
16
+ throw await ApiHelper.parseError(error);
17
+ }
18
+ }
19
+ async stockLevelLookup(params, sessionId) {
20
+ const body = mapStockLevelLookupQueryParams(params);
21
+ try {
22
+ const response = await ApiHelper.sendServiceRequest(this.SERVICE_URL, [`StockLevelLookup`, `Request`], sessionId, ServiceAlias.STOCK_LEVEL_LOOKUP, this.axiosInstance, body.toString());
23
+ return response?.StockLevel?.map(mapStockLevel) ?? [];
24
+ }
25
+ catch (error) {
26
+ throw await ApiHelper.parseError(error);
27
+ }
28
+ }
29
+ async stockLevelLookupByWarehouseQuickView(params, sessionId) {
30
+ const body = mapStockLevelLookupQueryParams(params);
31
+ try {
32
+ const response = await ApiHelper.sendServiceRequest(this.SERVICE_URL, [`StockLevelLookupByWarehouseQuickView`, `Request`], sessionId, ServiceAlias.STOCK_LEVEL_LOOKUP, this.axiosInstance, body.toString());
33
+ return response?.StockLevel?.map(mapStockLevel) ?? [];
34
+ }
35
+ catch (error) {
36
+ throw await ApiHelper.parseError(error);
37
+ }
38
+ }
39
+ }