@shipengine/js-api 4.16.2 → 4.17.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/account-addons/api.d.ts +5 -1
- package/client.d.ts +6 -1
- package/index.js +28 -18
- package/index.mjs +28 -18
- package/package.json +1 -1
package/account-addons/api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
-
import { Addon } from "./types";
|
|
2
|
+
import { Addon, AddonTypes } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* # Account Addons API module - /v1/account/addons
|
|
5
5
|
* @docs https://auctane.atlassian.net/wiki/spaces/SEEU/pages/6364332064/Add-ons+New+endpoints+definition
|
|
@@ -14,4 +14,8 @@ export declare class AccountAddonsAPI {
|
|
|
14
14
|
list: () => Promise<import("axios").AxiosResponse<{
|
|
15
15
|
addons: Addon[];
|
|
16
16
|
}, any>>;
|
|
17
|
+
/**
|
|
18
|
+
* The `enable` method allows to enable an AddOn for the current user
|
|
19
|
+
*/
|
|
20
|
+
enable: (addonCode: AddonTypes) => Promise<import("axios").AxiosResponse<void, any>>;
|
|
17
21
|
}
|
package/client.d.ts
CHANGED
|
@@ -52,6 +52,11 @@ export interface ShipEngineAPIConfig {
|
|
|
52
52
|
* `baseURL` is an optional string that represents the base URL to be used for all requests.
|
|
53
53
|
*/
|
|
54
54
|
baseURL?: string;
|
|
55
|
+
/**
|
|
56
|
+
* The `debug` flag is an optional boolean that allow to disable the debug logs while working in localhost
|
|
57
|
+
* by default is always enabled
|
|
58
|
+
*/
|
|
59
|
+
debug?: boolean;
|
|
55
60
|
/**
|
|
56
61
|
* `getSandboxToken` is an optional callback function that returns a token to be used to authenticate sandbox requests.
|
|
57
62
|
*/
|
|
@@ -79,7 +84,7 @@ export declare class ShipEngineAPI {
|
|
|
79
84
|
private client;
|
|
80
85
|
private getSandboxToken?;
|
|
81
86
|
sandboxToken?: string;
|
|
82
|
-
constructor(token: string, { baseURL, headers, getToken, getSandboxToken, onApiError }: ShipEngineAPIConfig);
|
|
87
|
+
constructor(token: string, { baseURL, debug, headers, getToken, getSandboxToken, onApiError }: ShipEngineAPIConfig);
|
|
83
88
|
/**
|
|
84
89
|
* The `token` method takes in a string and sets it as the Authorization header for all requests.
|
|
85
90
|
*/
|
package/index.js
CHANGED
|
@@ -226,6 +226,12 @@ class AccountAddonsAPI {
|
|
|
226
226
|
this.list = () => {
|
|
227
227
|
return this.client.get("/v1/account/addons");
|
|
228
228
|
};
|
|
229
|
+
/**
|
|
230
|
+
* The `enable` method allows to enable an AddOn for the current user
|
|
231
|
+
*/
|
|
232
|
+
this.enable = (addonCode) => {
|
|
233
|
+
return this.client.post(`/v1/account/addons/${addonCode}/enable`);
|
|
234
|
+
};
|
|
229
235
|
this.client = client;
|
|
230
236
|
}
|
|
231
237
|
}
|
|
@@ -21764,7 +21770,7 @@ const logger = E({
|
|
|
21764
21770
|
]
|
|
21765
21771
|
});
|
|
21766
21772
|
class ShipEngineAPI {
|
|
21767
|
-
constructor(token, { baseURL, headers, getToken, getSandboxToken, onApiError }) {
|
|
21773
|
+
constructor(token, { baseURL, debug = true, headers, getToken, getSandboxToken, onApiError }) {
|
|
21768
21774
|
this.getSandboxToken = getSandboxToken;
|
|
21769
21775
|
const client = axios.create({
|
|
21770
21776
|
baseURL,
|
|
@@ -21825,27 +21831,31 @@ class ShipEngineAPI {
|
|
|
21825
21831
|
client.interceptors.response.use(
|
|
21826
21832
|
(res) => {
|
|
21827
21833
|
var _a;
|
|
21828
|
-
|
|
21829
|
-
|
|
21830
|
-
|
|
21831
|
-
|
|
21832
|
-
|
|
21833
|
-
|
|
21834
|
-
|
|
21835
|
-
|
|
21834
|
+
if (debug) {
|
|
21835
|
+
logger.info(
|
|
21836
|
+
{ req: res.config, res },
|
|
21837
|
+
"%s %s: %s %s",
|
|
21838
|
+
(_a = res.config.method) == null ? void 0 : _a.toUpperCase(),
|
|
21839
|
+
res.config.url,
|
|
21840
|
+
res.status,
|
|
21841
|
+
res.statusText
|
|
21842
|
+
);
|
|
21843
|
+
}
|
|
21836
21844
|
return res;
|
|
21837
21845
|
},
|
|
21838
21846
|
(err) => __async(this, null, function* () {
|
|
21839
21847
|
var _a, _b, _c, _d, _e;
|
|
21840
|
-
|
|
21841
|
-
|
|
21842
|
-
|
|
21843
|
-
|
|
21844
|
-
|
|
21845
|
-
|
|
21846
|
-
|
|
21847
|
-
|
|
21848
|
-
|
|
21848
|
+
if (debug) {
|
|
21849
|
+
logger.error(
|
|
21850
|
+
{ err, req: err.config, res: err.response },
|
|
21851
|
+
"%s %s: %s %s - %s",
|
|
21852
|
+
(_b = (_a = err.config) == null ? void 0 : _a.method) == null ? void 0 : _b.toUpperCase(),
|
|
21853
|
+
(_c = err.config) == null ? void 0 : _c.url,
|
|
21854
|
+
(_d = err.response) == null ? void 0 : _d.status,
|
|
21855
|
+
(_e = err.response) == null ? void 0 : _e.statusText,
|
|
21856
|
+
err.message
|
|
21857
|
+
);
|
|
21858
|
+
}
|
|
21849
21859
|
if (isInvalidTokenError(err)) {
|
|
21850
21860
|
const token2 = yield err.config.isSandbox ? getSandboxToken == null ? void 0 : getSandboxToken() : getToken();
|
|
21851
21861
|
const config = err.config;
|
package/index.mjs
CHANGED
|
@@ -222,6 +222,12 @@ class AccountAddonsAPI {
|
|
|
222
222
|
this.list = () => {
|
|
223
223
|
return this.client.get("/v1/account/addons");
|
|
224
224
|
};
|
|
225
|
+
/**
|
|
226
|
+
* The `enable` method allows to enable an AddOn for the current user
|
|
227
|
+
*/
|
|
228
|
+
this.enable = (addonCode) => {
|
|
229
|
+
return this.client.post(`/v1/account/addons/${addonCode}/enable`);
|
|
230
|
+
};
|
|
225
231
|
this.client = client;
|
|
226
232
|
}
|
|
227
233
|
}
|
|
@@ -21760,7 +21766,7 @@ const logger = E({
|
|
|
21760
21766
|
]
|
|
21761
21767
|
});
|
|
21762
21768
|
class ShipEngineAPI {
|
|
21763
|
-
constructor(token, { baseURL, headers, getToken, getSandboxToken, onApiError }) {
|
|
21769
|
+
constructor(token, { baseURL, debug = true, headers, getToken, getSandboxToken, onApiError }) {
|
|
21764
21770
|
this.getSandboxToken = getSandboxToken;
|
|
21765
21771
|
const client = axios.create({
|
|
21766
21772
|
baseURL,
|
|
@@ -21821,27 +21827,31 @@ class ShipEngineAPI {
|
|
|
21821
21827
|
client.interceptors.response.use(
|
|
21822
21828
|
(res) => {
|
|
21823
21829
|
var _a;
|
|
21824
|
-
|
|
21825
|
-
|
|
21826
|
-
|
|
21827
|
-
|
|
21828
|
-
|
|
21829
|
-
|
|
21830
|
-
|
|
21831
|
-
|
|
21830
|
+
if (debug) {
|
|
21831
|
+
logger.info(
|
|
21832
|
+
{ req: res.config, res },
|
|
21833
|
+
"%s %s: %s %s",
|
|
21834
|
+
(_a = res.config.method) == null ? void 0 : _a.toUpperCase(),
|
|
21835
|
+
res.config.url,
|
|
21836
|
+
res.status,
|
|
21837
|
+
res.statusText
|
|
21838
|
+
);
|
|
21839
|
+
}
|
|
21832
21840
|
return res;
|
|
21833
21841
|
},
|
|
21834
21842
|
(err) => __async(this, null, function* () {
|
|
21835
21843
|
var _a, _b, _c, _d, _e;
|
|
21836
|
-
|
|
21837
|
-
|
|
21838
|
-
|
|
21839
|
-
|
|
21840
|
-
|
|
21841
|
-
|
|
21842
|
-
|
|
21843
|
-
|
|
21844
|
-
|
|
21844
|
+
if (debug) {
|
|
21845
|
+
logger.error(
|
|
21846
|
+
{ err, req: err.config, res: err.response },
|
|
21847
|
+
"%s %s: %s %s - %s",
|
|
21848
|
+
(_b = (_a = err.config) == null ? void 0 : _a.method) == null ? void 0 : _b.toUpperCase(),
|
|
21849
|
+
(_c = err.config) == null ? void 0 : _c.url,
|
|
21850
|
+
(_d = err.response) == null ? void 0 : _d.status,
|
|
21851
|
+
(_e = err.response) == null ? void 0 : _e.statusText,
|
|
21852
|
+
err.message
|
|
21853
|
+
);
|
|
21854
|
+
}
|
|
21845
21855
|
if (isInvalidTokenError(err)) {
|
|
21846
21856
|
const token2 = yield err.config.isSandbox ? getSandboxToken == null ? void 0 : getSandboxToken() : getToken();
|
|
21847
21857
|
const config = err.config;
|