@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.
- package/README.md +132 -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,39 @@
|
|
|
1
|
+
import { ApiHelper } from "../../helpers";
|
|
2
|
+
import { ServiceAlias } from "../shared";
|
|
3
|
+
import { mapCarrier, mapCarrierShipment, mapGetCarrierShipmentByOrderNumber, mapGetCarrierShipmentByTimeQueryParams, } from "./mappings";
|
|
4
|
+
export class CarrierModule {
|
|
5
|
+
axiosInstance;
|
|
6
|
+
SERVICE_URL = `CarrierShipmentService/CarrierShipmentService`;
|
|
7
|
+
constructor(axiosInstance) {
|
|
8
|
+
this.axiosInstance = axiosInstance;
|
|
9
|
+
}
|
|
10
|
+
async getCarrier(sessionId) {
|
|
11
|
+
try {
|
|
12
|
+
const response = await ApiHelper.sendServiceRequest(this.SERVICE_URL, `GetCarrier`, sessionId, ServiceAlias.CARRIER, this.axiosInstance);
|
|
13
|
+
return response?.Carrier?.map(mapCarrier);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
throw await ApiHelper.parseError(error);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
async getCarrierShipmentByOrderNumber(orderNo, sessionId) {
|
|
20
|
+
try {
|
|
21
|
+
const bodyStr = mapGetCarrierShipmentByOrderNumber(orderNo);
|
|
22
|
+
const response = await ApiHelper.sendServiceRequest(this.SERVICE_URL, ["GetCarrierShipmentByOrderNumber", "Request"], sessionId, ServiceAlias.CARRIER, this.axiosInstance, bodyStr);
|
|
23
|
+
return response?.CarrierShipment?.map(mapCarrierShipment);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
throw await ApiHelper.parseError(error);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async getCarrierShipmentBySysTime(params, sessionId) {
|
|
30
|
+
try {
|
|
31
|
+
const bodyStr = mapGetCarrierShipmentByTimeQueryParams(params);
|
|
32
|
+
const response = await ApiHelper.sendServiceRequest(this.SERVICE_URL, ["GetCarrierShipmentBySysModTime", "Request"], sessionId, ServiceAlias.CARRIER, this.axiosInstance, bodyStr);
|
|
33
|
+
return response?.CarrierShipment?.map(mapCarrierShipment);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
throw await ApiHelper.parseError(error);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { ApiHelper, Utils } from "../../helpers";
|
|
3
|
+
import { CarrierModule } from "./carrier.module";
|
|
4
|
+
jest.mock("axios");
|
|
5
|
+
const mAxios = axios;
|
|
6
|
+
describe("CarrierModule.getCarrier()", () => {
|
|
7
|
+
const token = "test-sid"; // process.env.SESSION_ID as string;
|
|
8
|
+
let carrierModule;
|
|
9
|
+
let mockApiHelperSendRequest;
|
|
10
|
+
beforeAll(() => {
|
|
11
|
+
carrierModule = new CarrierModule(mAxios);
|
|
12
|
+
mockApiHelperSendRequest = jest.spyOn(ApiHelper, "sendSoapRequest");
|
|
13
|
+
});
|
|
14
|
+
it("should send correct request for stockLevelLookup and return a list of stock level objets", async () => {
|
|
15
|
+
const expectedPayload = `
|
|
16
|
+
|
|
17
|
+
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:discs="http://discs.ws.fbsaust.com.au">
|
|
18
|
+
<S:Header>
|
|
19
|
+
<discs:SessionId>${token}</discs:SessionId>
|
|
20
|
+
</S:Header>
|
|
21
|
+
<S:Body>
|
|
22
|
+
<discs:GetCarrier></discs:GetCarrier>
|
|
23
|
+
</S:Body>
|
|
24
|
+
</S:Envelope>
|
|
25
|
+
`;
|
|
26
|
+
const mockedResp = {
|
|
27
|
+
data: `
|
|
28
|
+
<?xml version='1.0' encoding='UTF-8'?>
|
|
29
|
+
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
|
30
|
+
<S:Body>
|
|
31
|
+
<ns2:GetCarrierResponse xmlns:ns2="http://discs.ws.fbsaust.com.au">
|
|
32
|
+
<Carrier>
|
|
33
|
+
<namekey>TEST</namekey>
|
|
34
|
+
<name>TEST International</name>
|
|
35
|
+
</Carrier>
|
|
36
|
+
</ns2:GetCarrierResponse>
|
|
37
|
+
</S:Body>
|
|
38
|
+
</S:Envelope>
|
|
39
|
+
`,
|
|
40
|
+
};
|
|
41
|
+
const expectedResult = {
|
|
42
|
+
namekey: "TEST",
|
|
43
|
+
name: "TEST International",
|
|
44
|
+
};
|
|
45
|
+
mAxios.post.mockResolvedValueOnce(mockedResp);
|
|
46
|
+
const response = await carrierModule.getCarrier(token);
|
|
47
|
+
// Test that expected response is correct
|
|
48
|
+
expect(Array.isArray(response)).toBe(true);
|
|
49
|
+
expect(response.length).toBe(1);
|
|
50
|
+
expect(response[0]).toEqual(expectedResult);
|
|
51
|
+
const actualPayload = mAxios.post.mock.calls[0][1];
|
|
52
|
+
// Test that actual payload sent in the API matches expected payload
|
|
53
|
+
expect(Utils.removeEmptySpaces(actualPayload)).toEqual(Utils.removeEmptySpaces(expectedPayload));
|
|
54
|
+
mAxios.post.mockReset();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
describe("CarrierModule.getCarrierByOrderNumber()", () => {
|
|
58
|
+
const token = "test-sid"; // process.env.SESSION_ID as string;
|
|
59
|
+
let carrierModule;
|
|
60
|
+
let mockApiHelperSendRequest;
|
|
61
|
+
beforeAll(() => {
|
|
62
|
+
carrierModule = new CarrierModule(mAxios);
|
|
63
|
+
mockApiHelperSendRequest = jest.spyOn(ApiHelper, "sendSoapRequest");
|
|
64
|
+
});
|
|
65
|
+
it("should send correct request for stockLevelLookup and return a list of stock level objets", async () => {
|
|
66
|
+
const orderNo = "TEST";
|
|
67
|
+
const expectedPayload = `
|
|
68
|
+
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:discs="http://discs.ws.fbsaust.com.au">
|
|
69
|
+
<S:Header>
|
|
70
|
+
<discs:SessionId>${token}</discs:SessionId>
|
|
71
|
+
</S:Header>
|
|
72
|
+
<S:Body>
|
|
73
|
+
|
|
74
|
+
<discs:GetCarrierShipmentByOrderNumberRequest>
|
|
75
|
+
<parameter>
|
|
76
|
+
<OrderNo>${orderNo}</OrderNo>
|
|
77
|
+
</parameter>
|
|
78
|
+
</discs:GetCarrierShipmentByOrderNumberRequest>
|
|
79
|
+
|
|
80
|
+
</S:Body>
|
|
81
|
+
</S:Envelope>
|
|
82
|
+
`;
|
|
83
|
+
const mockedResp = {
|
|
84
|
+
data: `
|
|
85
|
+
<?xml version='1.0' encoding='UTF-8'?>
|
|
86
|
+
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
|
87
|
+
<S:Body><ns2:GetCarrierShipmentByOrderNumberResponse xmlns:ns2="http://discs.ws.fbsaust.com.au">
|
|
88
|
+
<CarrierShipment>
|
|
89
|
+
<order_no>${orderNo}</order_no>
|
|
90
|
+
<carrier>TNT</carrier>
|
|
91
|
+
<consignment_no>0332222</consignment_no>
|
|
92
|
+
<carrier_tracking_no>0332222</carrier_tracking_no>
|
|
93
|
+
<dispatch_date_time>03-03-2016 09:08:00</dispatch_date_time>
|
|
94
|
+
</CarrierShipment>
|
|
95
|
+
</ns2:GetCarrierShipmentByOrderNumberResponse>
|
|
96
|
+
</S:Body>
|
|
97
|
+
</S:Envelope>
|
|
98
|
+
`,
|
|
99
|
+
};
|
|
100
|
+
const expectedResult = {
|
|
101
|
+
orderNo: orderNo,
|
|
102
|
+
carrier: "TNT",
|
|
103
|
+
consignmentNo: "0332222",
|
|
104
|
+
carrierTrackingNo: "0332222",
|
|
105
|
+
dispatchDateTime: "03-03-2016 09:08:00",
|
|
106
|
+
};
|
|
107
|
+
mAxios.post.mockResolvedValueOnce(mockedResp);
|
|
108
|
+
const response = await carrierModule.getCarrierShipmentByOrderNumber(orderNo, token);
|
|
109
|
+
// Test that expected response is correct
|
|
110
|
+
expect(Array.isArray(response)).toBe(true);
|
|
111
|
+
expect(response.length).toBe(1);
|
|
112
|
+
expect(response[0]).toEqual(expectedResult);
|
|
113
|
+
const actualPayload = mAxios.post.mock.calls[0][1];
|
|
114
|
+
// Test that actual payload sent in the API matches expected payload
|
|
115
|
+
expect(Utils.removeEmptySpaces(actualPayload)).toEqual(Utils.removeEmptySpaces(expectedPayload));
|
|
116
|
+
mAxios.post.mockReset();
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
describe("CarrierModule.getCarrierShipmentBySysTime()", () => {
|
|
120
|
+
const token = "test-sid"; // process.env.SESSION_ID as string;
|
|
121
|
+
let carrierModule;
|
|
122
|
+
let mockApiHelperSendRequest;
|
|
123
|
+
beforeAll(() => {
|
|
124
|
+
carrierModule = new CarrierModule(mAxios);
|
|
125
|
+
mockApiHelperSendRequest = jest.spyOn(ApiHelper, "sendSoapRequest");
|
|
126
|
+
});
|
|
127
|
+
it("should send correct request for stockLevelLookup and return a list of stock level objets", async () => {
|
|
128
|
+
const params = {
|
|
129
|
+
sysModTimeFr: "01-01-2020 00:00:00",
|
|
130
|
+
sysModTimeTo: "01-01-2021 00:00:00",
|
|
131
|
+
};
|
|
132
|
+
const orderNo = "TEST";
|
|
133
|
+
const expectedPayload = `
|
|
134
|
+
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:discs="http://discs.ws.fbsaust.com.au">
|
|
135
|
+
<S:Header>
|
|
136
|
+
<discs:SessionId>${token}</discs:SessionId>
|
|
137
|
+
</S:Header>
|
|
138
|
+
<S:Body>
|
|
139
|
+
|
|
140
|
+
<discs:GetCarrierShipmentBySysModTimeRequest>
|
|
141
|
+
<parameter>
|
|
142
|
+
<SysModTimeFr>${params.sysModTimeFr}</SysModTimeFr>
|
|
143
|
+
<SysModTimeTo>${params.sysModTimeTo}</SysModTimeTo>
|
|
144
|
+
</parameter>
|
|
145
|
+
</discs:GetCarrierShipmentBySysModTimeRequest>
|
|
146
|
+
|
|
147
|
+
</S:Body>
|
|
148
|
+
</S:Envelope>
|
|
149
|
+
`;
|
|
150
|
+
const mockedResp = {
|
|
151
|
+
data: `
|
|
152
|
+
<?xml version='1.0' encoding='UTF-8'?>
|
|
153
|
+
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
|
154
|
+
<S:Body>
|
|
155
|
+
<ns2:GetCarrierShipmentBySysModTimeResponse xmlns:ns2="http://discs.ws.fbsaust.com.au">
|
|
156
|
+
<SystemTime>03-03-2016 14:13:21</SystemTime>
|
|
157
|
+
<CarrierShipment>
|
|
158
|
+
<order_no>${orderNo}</order_no>
|
|
159
|
+
<carrier>TNT</carrier>
|
|
160
|
+
<consignment_no>0332222</consignment_no>
|
|
161
|
+
<carrier_tracking_no>0332222</carrier_tracking_no>
|
|
162
|
+
<dispatch_date_time>03-03-2016 09:08:00</dispatch_date_time>
|
|
163
|
+
</CarrierShipment>
|
|
164
|
+
</ns2:GetCarrierShipmentBySysModTimeResponse>
|
|
165
|
+
</S:Body>
|
|
166
|
+
</S:Envelope>
|
|
167
|
+
`,
|
|
168
|
+
};
|
|
169
|
+
const expectedResult = {
|
|
170
|
+
orderNo: orderNo,
|
|
171
|
+
carrier: "TNT",
|
|
172
|
+
consignmentNo: "0332222",
|
|
173
|
+
carrierTrackingNo: "0332222",
|
|
174
|
+
dispatchDateTime: "03-03-2016 09:08:00",
|
|
175
|
+
};
|
|
176
|
+
mAxios.post.mockResolvedValueOnce(mockedResp);
|
|
177
|
+
const response = await carrierModule.getCarrierShipmentBySysTime(params, token);
|
|
178
|
+
// Test that expected response is correct
|
|
179
|
+
expect(Array.isArray(response)).toBe(true);
|
|
180
|
+
expect(response.length).toBe(1);
|
|
181
|
+
expect(response[0]).toEqual(expectedResult);
|
|
182
|
+
const actualPayload = mAxios.post.mock.calls[0][1];
|
|
183
|
+
// Test that actual payload sent in the API matches expected payload
|
|
184
|
+
expect(Utils.removeEmptySpaces(actualPayload)).toEqual(Utils.removeEmptySpaces(expectedPayload));
|
|
185
|
+
mAxios.post.mockReset();
|
|
186
|
+
});
|
|
187
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Carrier, CarrierRaw, CarrierShipment, CarrierShipmentRaw, GetCarrierShipmentByTimeQueryParams } from "../types";
|
|
2
|
+
export declare function mapCarrier(src: CarrierRaw): Carrier;
|
|
3
|
+
export declare function mapCarrierShipment(src: CarrierShipmentRaw): CarrierShipment;
|
|
4
|
+
export declare function mapGetCarrierShipmentByOrderNumber(orderNo: string): string;
|
|
5
|
+
export declare function mapGetCarrierShipmentByTimeQueryParams(src: GetCarrierShipmentByTimeQueryParams): string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Utils } from "../../../helpers";
|
|
2
|
+
export function mapCarrier(src) {
|
|
3
|
+
return {
|
|
4
|
+
namekey: (src?.namekey ?? [])[0],
|
|
5
|
+
name: (src?.name ?? [])[0],
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export function mapCarrierShipment(src) {
|
|
9
|
+
return {
|
|
10
|
+
carrier: (src?.carrier ?? [])[0],
|
|
11
|
+
orderNo: (src?.order_no ?? [])[0],
|
|
12
|
+
consignmentNo: (src?.consignment_no ?? [])[0],
|
|
13
|
+
carrierTrackingNo: (src?.carrier_tracking_no ?? [])[0],
|
|
14
|
+
dispatchDateTime: (src?.dispatch_date_time ?? [])[0],
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function mapGetCarrierShipmentByOrderNumber(orderNo) {
|
|
18
|
+
const params = {
|
|
19
|
+
OrderNo: orderNo,
|
|
20
|
+
};
|
|
21
|
+
return mapCarrierShipmentRequestBody(Utils.toXml(params));
|
|
22
|
+
}
|
|
23
|
+
export function mapGetCarrierShipmentByTimeQueryParams(src) {
|
|
24
|
+
const params = {
|
|
25
|
+
SysModTimeFr: src?.sysModTimeFr,
|
|
26
|
+
SysModTimeTo: src?.sysModTimeTo,
|
|
27
|
+
};
|
|
28
|
+
return mapCarrierShipmentRequestBody(Utils.toXml(params));
|
|
29
|
+
}
|
|
30
|
+
function mapCarrierShipmentRequestBody(body) {
|
|
31
|
+
return `
|
|
32
|
+
<parameter>
|
|
33
|
+
${body}
|
|
34
|
+
</parameter>
|
|
35
|
+
`;
|
|
36
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface CarrierRaw {
|
|
2
|
+
namekey: string[];
|
|
3
|
+
name: string[];
|
|
4
|
+
}
|
|
5
|
+
export interface Carrier {
|
|
6
|
+
namekey: string;
|
|
7
|
+
name: string;
|
|
8
|
+
}
|
|
9
|
+
export interface CarrierResponse {
|
|
10
|
+
Carrier: CarrierRaw[];
|
|
11
|
+
}
|
|
12
|
+
export interface CarrierShipmentRaw {
|
|
13
|
+
order_no: string[];
|
|
14
|
+
carrier: string[];
|
|
15
|
+
consignment_no: string[];
|
|
16
|
+
carrier_tracking_no: string[];
|
|
17
|
+
dispatch_date_time: string[];
|
|
18
|
+
}
|
|
19
|
+
export interface CarrierShipment {
|
|
20
|
+
orderNo: string;
|
|
21
|
+
carrier: string;
|
|
22
|
+
consignmentNo: string;
|
|
23
|
+
carrierTrackingNo: string;
|
|
24
|
+
dispatchDateTime: string;
|
|
25
|
+
}
|
|
26
|
+
export interface CarrierShipmentResponse {
|
|
27
|
+
CarrierShipment: CarrierShipmentRaw[];
|
|
28
|
+
}
|
|
29
|
+
export interface GetCarrierShipmentByTimeQueryParams {
|
|
30
|
+
/**
|
|
31
|
+
* From System Modify Time. Value must be in format dd-MM-yyyy hh:mm:SS
|
|
32
|
+
*
|
|
33
|
+
* @type {string}
|
|
34
|
+
*/
|
|
35
|
+
sysModTimeFr?: string;
|
|
36
|
+
/**
|
|
37
|
+
* To System Modify Time. Value must be in format dd-MM-yyyy hh:mm:SS
|
|
38
|
+
*
|
|
39
|
+
* @type {string}
|
|
40
|
+
*/
|
|
41
|
+
sysModTimeTo?: string;
|
|
42
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
import { CreateDiaryQueryParams, Diary, GetDiaryQueryParams } from "./types";
|
|
3
|
+
export declare class DiaryModule {
|
|
4
|
+
private axiosInstance;
|
|
5
|
+
private readonly SERVICE_URL;
|
|
6
|
+
constructor(axiosInstance: AxiosInstance);
|
|
7
|
+
getDiaryBy(params: GetDiaryQueryParams, sessionId: string): Promise<Diary[]>;
|
|
8
|
+
createDiary(params: CreateDiaryQueryParams, sessionId: string): Promise<boolean>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ApiHelper } from "../../helpers";
|
|
2
|
+
import { ServiceAlias } from "../shared";
|
|
3
|
+
import { mapCreateDiaryQueryParams, mapDiary, mapGetDiaryQueryParams, } from "./mappings";
|
|
4
|
+
export class DiaryModule {
|
|
5
|
+
axiosInstance;
|
|
6
|
+
SERVICE_URL = `/DiaryService/DiaryService`;
|
|
7
|
+
constructor(axiosInstance) {
|
|
8
|
+
this.axiosInstance = axiosInstance;
|
|
9
|
+
}
|
|
10
|
+
async getDiaryBy(params, sessionId) {
|
|
11
|
+
try {
|
|
12
|
+
const response = await ApiHelper.sendServiceRequest(this.SERVICE_URL, `GetDiaryBy`, sessionId, ServiceAlias.DIARY, this.axiosInstance, mapGetDiaryQueryParams(params));
|
|
13
|
+
return response?.Diary?.map(mapDiary);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
throw await ApiHelper.parseError(error);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
async createDiary(params, sessionId) {
|
|
20
|
+
try {
|
|
21
|
+
const response = await ApiHelper.sendServiceRequest(this.SERVICE_URL, `CreateDiary`, sessionId, ServiceAlias.DIARY, this.axiosInstance, mapCreateDiaryQueryParams(params));
|
|
22
|
+
return response?.result[0];
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
throw await ApiHelper.parseError(error);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CreateDiaryQueryParams, Diary, DiaryRaw, GetDiaryQueryParams } from "../types";
|
|
2
|
+
export declare function mapGetDiaryQueryParams(src: GetDiaryQueryParams): string;
|
|
3
|
+
export declare function mapDiary(src: DiaryRaw): Diary;
|
|
4
|
+
export declare function mapCreateDiaryQueryParams(src: CreateDiaryQueryParams): string;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Utils } from "../../../helpers";
|
|
2
|
+
export function mapGetDiaryQueryParams(src) {
|
|
3
|
+
const params = {
|
|
4
|
+
SearchType: src?.searchType,
|
|
5
|
+
SearchValue: src?.searchValue,
|
|
6
|
+
};
|
|
7
|
+
return `<parameter>${Utils.toXml(params)}</parameter>`;
|
|
8
|
+
}
|
|
9
|
+
export function mapDiary(src) {
|
|
10
|
+
return {
|
|
11
|
+
namekey: Utils.getFirst(src?.namekey),
|
|
12
|
+
title: Utils.getFirst(src?.title),
|
|
13
|
+
surname: Utils.getFirst(src?.surname),
|
|
14
|
+
firstName: Utils.getFirst(src?.first_name),
|
|
15
|
+
isActive: Utils.getFirst(src?.is_active),
|
|
16
|
+
address1: Utils.getFirst(src?.address_1),
|
|
17
|
+
address2: Utils.getFirst(src?.address_2),
|
|
18
|
+
address3: Utils.getFirst(src?.address_3),
|
|
19
|
+
address4: Utils.getFirst(src?.address_4),
|
|
20
|
+
postcode: Utils.getFirst(src?.postcode),
|
|
21
|
+
postalAddressId: Utils.toNumber(Utils.getFirst(src?.postal_address_id)),
|
|
22
|
+
deliveryAddress1: Utils.getFirst(src?.delivery_address_1),
|
|
23
|
+
deliveryAddress2: Utils.getFirst(src?.delivery_address_2),
|
|
24
|
+
deliveryAddress3: Utils.getFirst(src?.delivery_address_3),
|
|
25
|
+
deliveryAddress4: Utils.getFirst(src?.delivery_address_4),
|
|
26
|
+
deliveryPostcode: Utils.getFirst(src?.delivery_postcode),
|
|
27
|
+
deliveryAddressId: Utils.toNumber(Utils.getFirst(src?.delivery_address_id)),
|
|
28
|
+
dateOfBirth: Utils.getFirst(src?.date_of_birth),
|
|
29
|
+
email: Utils.getFirst(src?.email),
|
|
30
|
+
telephone1: Utils.getFirst(src?.telephone_1),
|
|
31
|
+
telephone2: Utils.getFirst(src?.telephone_2),
|
|
32
|
+
telephone3: Utils.getFirst(src?.telephone_3),
|
|
33
|
+
fax: Utils.getFirst(src?.fax),
|
|
34
|
+
membershipNo: Utils.getFirst(src?.membership_no),
|
|
35
|
+
membershipAssignDate: Utils.getFirst(src?.membership_assign_date),
|
|
36
|
+
agent: Utils.toNumber(Utils.getFirst(src?.agent)),
|
|
37
|
+
agentName: Utils.getFirst(src?.agent_name),
|
|
38
|
+
class1: Utils.getFirst(src?.class_1),
|
|
39
|
+
class2: Utils.getFirst(src?.class_2),
|
|
40
|
+
class3: Utils.getFirst(src?.class_3),
|
|
41
|
+
dpid: Utils.getFirst(src?.dpid),
|
|
42
|
+
dpidBarcode: Utils.getFirst(src?.dpid_barcode),
|
|
43
|
+
text1: Utils.getFirst(src?.text_1),
|
|
44
|
+
text2: Utils.getFirst(src?.text_2),
|
|
45
|
+
outstandingRewardPoints: Utils.toNumber(Utils.getFirst(src?.outstanding_reward_points)),
|
|
46
|
+
totalAccumulatedRewardPoints: Utils.toNumber(Utils.getFirst(src?.total_accumulated_reward_points)),
|
|
47
|
+
firstContactDate: Utils.getFirst(src?.first_contact_date),
|
|
48
|
+
lastContactDate: Utils.getFirst(src?.last_contact_date),
|
|
49
|
+
nextContactDate: Utils.getFirst(src?.next_contact_date),
|
|
50
|
+
salesAmount: Utils.toNumber(Utils.getFirst(src?.sales_amount)),
|
|
51
|
+
accumulatedSalesAmount: Utils.toNumber(Utils.getFirst(src?.accumulated_sales_amount)),
|
|
52
|
+
lastSaleDate: Utils.getFirst(src?.last_sale_date),
|
|
53
|
+
category: Utils.getFirst(src?.category),
|
|
54
|
+
dsoDebtorNamekey: Utils.getFirst(src?.dso_debtor_namekey),
|
|
55
|
+
defaultDiscountReason: Utils.getFirst(src?.default_discount_reason),
|
|
56
|
+
discountPercentage: Utils.toNumber(Utils.getFirst(src?.discount_percentage)),
|
|
57
|
+
customisedInfo: Utils.getFirst(src?.customised_info),
|
|
58
|
+
externalId: Utils.getFirst(src?.external_id),
|
|
59
|
+
outstandingDiscountAmount: Utils.toNumber(Utils.getFirst(src?.outstanding_discount_amount)),
|
|
60
|
+
customisedField: Utils.getFirst(src?.customised_field),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// Mapper for create diary endpoint
|
|
64
|
+
export function mapCreateDiaryQueryParams(src) {
|
|
65
|
+
const params = {
|
|
66
|
+
namekey: src?.namekey,
|
|
67
|
+
title: src?.title,
|
|
68
|
+
surname: src?.surname,
|
|
69
|
+
first_name: src?.firstName,
|
|
70
|
+
is_active: src?.isActive,
|
|
71
|
+
address_1: src?.address1,
|
|
72
|
+
address_2: src?.address2,
|
|
73
|
+
address_3: src?.address3,
|
|
74
|
+
address_4: src?.address4,
|
|
75
|
+
postcode: src?.postcode,
|
|
76
|
+
postal_address_id: src?.postalAddressId,
|
|
77
|
+
delivery_address_1: src?.deliveryAddress1,
|
|
78
|
+
deliveryaddress2: src?.deliveryAddress2,
|
|
79
|
+
deliveryaddress3: src?.deliveryAddress3,
|
|
80
|
+
deliveryaddress4: src?.deliveryAddress4,
|
|
81
|
+
deliverypostcode: src?.deliveryPostcode,
|
|
82
|
+
deliveryaddressid: src?.deliveryAddressId,
|
|
83
|
+
dateofbirth: src?.dateOfBirth,
|
|
84
|
+
membershipno: src?.membershipNo,
|
|
85
|
+
email: src?.email,
|
|
86
|
+
telephone1: src?.telephone1,
|
|
87
|
+
telephone2: src?.telephone2,
|
|
88
|
+
telephone3: src?.telephone3,
|
|
89
|
+
fax: src?.fax,
|
|
90
|
+
agent: src?.agent,
|
|
91
|
+
class1: src?.class1,
|
|
92
|
+
class2: src?.class2,
|
|
93
|
+
class3: src?.class3,
|
|
94
|
+
text1: src?.text1,
|
|
95
|
+
text2: src?.text2,
|
|
96
|
+
first_contact_date: src?.firstContactDate,
|
|
97
|
+
last_contact_date: src?.lastContactDate,
|
|
98
|
+
next_contact_date: src?.nextContactDate,
|
|
99
|
+
};
|
|
100
|
+
return `<Diary>${Utils.toXml(params)}</Diary>`;
|
|
101
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Utils } from "../../../helpers";
|
|
2
|
+
import { GetDiarySearchType } from "../types";
|
|
3
|
+
import { mapGetDiaryQueryParams } from "./diary.mapper";
|
|
4
|
+
describe("mapGetDiaryQueryParams", () => {
|
|
5
|
+
it("should map query params for GetDiaryBy endpoint correctly", () => {
|
|
6
|
+
const params = {
|
|
7
|
+
searchType: GetDiarySearchType.EMAIL,
|
|
8
|
+
searchValue: "test@example.com",
|
|
9
|
+
};
|
|
10
|
+
const expectedXml = `
|
|
11
|
+
<parameter>
|
|
12
|
+
<SearchType>Email</SearchType>
|
|
13
|
+
<SearchValue>test@example.com</SearchValue>
|
|
14
|
+
</parameter>
|
|
15
|
+
`;
|
|
16
|
+
expect(Utils.removeEmptySpaces(mapGetDiaryQueryParams(params))).toEqual(Utils.removeEmptySpaces(expectedXml));
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./diary.mapper";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./diary.mapper";
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { BooleanResponse } from "../../shared";
|
|
2
|
+
export interface GetDiaryQueryParams {
|
|
3
|
+
searchType: GetDiarySearchType;
|
|
4
|
+
searchValue: string;
|
|
5
|
+
}
|
|
6
|
+
export declare enum GetDiarySearchType {
|
|
7
|
+
MEMBERSHIP_NO = "MembershipNo",
|
|
8
|
+
EMAIL = "Email",
|
|
9
|
+
TELEPHONE_1 = "Telephone1",
|
|
10
|
+
TELEPHONE_2 = "Telephone2",
|
|
11
|
+
TELEPHONE_3 = "Telephone3"
|
|
12
|
+
}
|
|
13
|
+
export interface DiaryRaw {
|
|
14
|
+
namekey: string[];
|
|
15
|
+
title: string[];
|
|
16
|
+
surname: string[];
|
|
17
|
+
first_name: string[];
|
|
18
|
+
is_active: string[];
|
|
19
|
+
address_1: string[];
|
|
20
|
+
address_2: string[];
|
|
21
|
+
address_3: string[];
|
|
22
|
+
address_4: string[];
|
|
23
|
+
postcode: string[];
|
|
24
|
+
postal_address_id: string[];
|
|
25
|
+
delivery_address_1: string[];
|
|
26
|
+
delivery_address_2: string[];
|
|
27
|
+
delivery_address_3: string[];
|
|
28
|
+
delivery_address_4: string[];
|
|
29
|
+
delivery_postcode: string[];
|
|
30
|
+
delivery_address_id: string[];
|
|
31
|
+
date_of_birth: string[];
|
|
32
|
+
email: string[];
|
|
33
|
+
telephone_1: string[];
|
|
34
|
+
telephone_2: string[];
|
|
35
|
+
telephone_3: string[];
|
|
36
|
+
fax: string[];
|
|
37
|
+
membership_no: string[];
|
|
38
|
+
membership_assign_date: string[];
|
|
39
|
+
agent: string[];
|
|
40
|
+
agent_name: string[];
|
|
41
|
+
class_1: string[];
|
|
42
|
+
class_2: string[];
|
|
43
|
+
class_3: string[];
|
|
44
|
+
dpid: string[];
|
|
45
|
+
dpid_barcode: string[];
|
|
46
|
+
text_1: string[];
|
|
47
|
+
text_2: string[];
|
|
48
|
+
outstanding_reward_points: string[];
|
|
49
|
+
total_accumulated_reward_points: string[];
|
|
50
|
+
first_contact_date: string[];
|
|
51
|
+
last_contact_date: string[];
|
|
52
|
+
next_contact_date: string[];
|
|
53
|
+
sales_amount: string[];
|
|
54
|
+
accumulated_sales_amount: string[];
|
|
55
|
+
last_sale_date: string[];
|
|
56
|
+
category: string[];
|
|
57
|
+
dso_debtor_namekey: string[];
|
|
58
|
+
default_discount_reason: string[];
|
|
59
|
+
discount_percentage: string[];
|
|
60
|
+
customised_info: string[];
|
|
61
|
+
external_id: string[];
|
|
62
|
+
outstanding_discount_amount: string[];
|
|
63
|
+
customised_field: string[];
|
|
64
|
+
}
|
|
65
|
+
export interface DiaryResponse {
|
|
66
|
+
Diary: DiaryRaw[];
|
|
67
|
+
}
|
|
68
|
+
export interface Diary extends DiaryBase {
|
|
69
|
+
title: DiaryTitle;
|
|
70
|
+
membershipAssignDate: string;
|
|
71
|
+
agentName: string;
|
|
72
|
+
dpid: string;
|
|
73
|
+
dpidBarcode: string;
|
|
74
|
+
outstandingRewardPoints: number;
|
|
75
|
+
totalAccumulatedRewardPoints: number;
|
|
76
|
+
salesAmount: number;
|
|
77
|
+
accumulatedSalesAmount: number;
|
|
78
|
+
lastSaleDate: string;
|
|
79
|
+
category: string;
|
|
80
|
+
dsoDebtorNamekey: string;
|
|
81
|
+
defaultDiscountReason: string;
|
|
82
|
+
discountPercentage: number;
|
|
83
|
+
customisedInfo: string;
|
|
84
|
+
externalId: string;
|
|
85
|
+
outstandingDiscountAmount: number;
|
|
86
|
+
customisedField: string;
|
|
87
|
+
}
|
|
88
|
+
export type CreateDiaryQueryParams = DiaryBase;
|
|
89
|
+
export type CreateDiaryResponse = BooleanResponse;
|
|
90
|
+
export interface DiaryBase {
|
|
91
|
+
namekey: string;
|
|
92
|
+
title: DiaryTitle;
|
|
93
|
+
surname: string;
|
|
94
|
+
firstName: string;
|
|
95
|
+
isActive: string;
|
|
96
|
+
address1: string;
|
|
97
|
+
address2: string;
|
|
98
|
+
address3: string;
|
|
99
|
+
address4: string;
|
|
100
|
+
postcode: string;
|
|
101
|
+
postalAddressId: number;
|
|
102
|
+
deliveryAddress1: string;
|
|
103
|
+
deliveryAddress2: string;
|
|
104
|
+
deliveryAddress3: string;
|
|
105
|
+
deliveryAddress4: string;
|
|
106
|
+
deliveryPostcode: string;
|
|
107
|
+
deliveryAddressId: number;
|
|
108
|
+
dateOfBirth: string;
|
|
109
|
+
email: string;
|
|
110
|
+
telephone1: string;
|
|
111
|
+
telephone2: string;
|
|
112
|
+
telephone3: string;
|
|
113
|
+
fax: string;
|
|
114
|
+
membershipNo: string;
|
|
115
|
+
agent: number;
|
|
116
|
+
class1: string;
|
|
117
|
+
class2: string;
|
|
118
|
+
class3: string;
|
|
119
|
+
text1: string;
|
|
120
|
+
text2: string;
|
|
121
|
+
firstContactDate: string;
|
|
122
|
+
lastContactDate: string;
|
|
123
|
+
nextContactDate: string;
|
|
124
|
+
}
|
|
125
|
+
export declare enum DiaryTitle {
|
|
126
|
+
LADY = "LADY",
|
|
127
|
+
MR = "MR",
|
|
128
|
+
MRS = "MRS",
|
|
129
|
+
MISS = "MISS",
|
|
130
|
+
DR = "DR",
|
|
131
|
+
M_S = "M/S",
|
|
132
|
+
SR = "SR",
|
|
133
|
+
FR = "FR",
|
|
134
|
+
BR = "BR",
|
|
135
|
+
SIR = "SIR",
|
|
136
|
+
REV = "REV",
|
|
137
|
+
MS = "MS"
|
|
138
|
+
}
|