@dotdev/harmony-sdk 1.5.0 → 1.6.0
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/dist/HarmonyAPI.d.ts +2 -1
- package/dist/HarmonyAPI.js +13 -1
- package/package.json +2 -1
package/dist/HarmonyAPI.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IAxiosRetryConfig } from "axios-retry";
|
|
1
2
|
import { AuthenticationToken, Carrier, CarrierShipment, CreateDiaryQueryParams, Diary, GetCarrierShipmentByTimeQueryParams, GetDiaryQueryParams, ProcessSaleOrderQueryParams, SizeGrid, Stock, StockBarcode, StockCategory, StockClassification, StockClassificationType, StockColor, StockLevel, StockLevelLookupQueryParams, StockLookupRequestParams, Warehouse } from "./modules";
|
|
2
3
|
import { GiftVoucher, GiftVoucherLookupQueryParams, GiftVoucherReservationQueryParams, GiftVoucherUsedQueryParams, GiftVoucherVerificationKeyQueryParams } from "./modules/gift-voucher/types";
|
|
3
4
|
export declare class HarmonyAPI {
|
|
@@ -10,7 +11,7 @@ export declare class HarmonyAPI {
|
|
|
10
11
|
private carrierModule;
|
|
11
12
|
private diaryModule;
|
|
12
13
|
private giftVoucherModule;
|
|
13
|
-
constructor(url: string);
|
|
14
|
+
constructor(url: string, axiosRetryConfig?: IAxiosRetryConfig);
|
|
14
15
|
authenticate(authToken: AuthenticationToken): Promise<string>;
|
|
15
16
|
stockLookup(params: StockLookupRequestParams, sessionId: string): Promise<Stock[]>;
|
|
16
17
|
stockCategoryLookup(sessionId: string): Promise<StockCategory[]>;
|
package/dist/HarmonyAPI.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
|
+
import axiosRetry from "axios-retry";
|
|
2
3
|
import * as https from "https";
|
|
3
4
|
import { promisify } from "util";
|
|
4
5
|
import { parseString } from "xml2js";
|
|
@@ -15,7 +16,7 @@ export class HarmonyAPI {
|
|
|
15
16
|
carrierModule;
|
|
16
17
|
diaryModule;
|
|
17
18
|
giftVoucherModule;
|
|
18
|
-
constructor(url) {
|
|
19
|
+
constructor(url, axiosRetryConfig) {
|
|
19
20
|
this.baseUrl = url;
|
|
20
21
|
this.axiosInstance = axios.create({
|
|
21
22
|
baseURL: this.baseUrl,
|
|
@@ -26,6 +27,17 @@ export class HarmonyAPI {
|
|
|
26
27
|
rejectUnauthorized: false,
|
|
27
28
|
}),
|
|
28
29
|
});
|
|
30
|
+
if (axiosRetryConfig) {
|
|
31
|
+
if (!axiosRetryConfig.retryDelay) {
|
|
32
|
+
axiosRetryConfig.retryDelay = (...arg) => axiosRetry.exponentialDelay(...arg, 1000);
|
|
33
|
+
}
|
|
34
|
+
if (!axiosRetryConfig.onRetry) {
|
|
35
|
+
axiosRetryConfig.onRetry = (retryCount, error, requestConfig) => {
|
|
36
|
+
console.log(`Retrying request (attempt ${retryCount}): ${error}`);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
axiosRetry(this.axiosInstance, axiosRetryConfig);
|
|
40
|
+
}
|
|
29
41
|
// Initialise modules that correspond to Harmony API services
|
|
30
42
|
this.authModule = new AuthModule(this.axiosInstance);
|
|
31
43
|
this.stockLookupModule = new StockLookupModule(this.axiosInstance);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotdev/harmony-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Harmony API SDK",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"license": "ISC",
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"axios": "^1.7.2",
|
|
21
|
+
"axios-retry": "^4.5.0",
|
|
21
22
|
"xml2js": "0.6.2"
|
|
22
23
|
},
|
|
23
24
|
"devDependencies": {
|