@shipengine/js-api 1.30.2 → 2.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/carriers/api.d.ts +2 -1
- package/client.d.ts +15 -2
- package/connections/api.d.ts +4 -4
- package/index.js +62 -26
- package/index.mjs +62 -26
- package/package.json +1 -1
- package/resources/types.d.ts +6 -0
- package/shipping-rules/api.d.ts +15 -6
- package/warehouses/api.d.ts +2 -1
package/carriers/api.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
2
|
import { Currency, Money } from "../payments";
|
|
3
|
+
import { SandboxableQuery } from "../resources";
|
|
3
4
|
import { Carrier, CarrierAutoFundingSettings, CarrierAutoFundingSettingsResponse, CarrierConnection, CarrierService, CarrierZone, PackageRatingType } from "./types";
|
|
4
5
|
/**
|
|
5
6
|
* # Carriers API module - /v1/carriers
|
|
@@ -10,7 +11,7 @@ export declare class CarriersAPI {
|
|
|
10
11
|
/**
|
|
11
12
|
* The `list` method retrieves a list of connected carriers for a given user.
|
|
12
13
|
*/
|
|
13
|
-
list: () => Promise<import("axios").AxiosResponse<{
|
|
14
|
+
list: (props?: SandboxableQuery) => Promise<import("axios").AxiosResponse<{
|
|
14
15
|
carriers: Carrier[];
|
|
15
16
|
}, any>>;
|
|
16
17
|
/**
|
package/client.d.ts
CHANGED
|
@@ -21,6 +21,14 @@ import { ShippingRulesAPI } from "./shipping-rules";
|
|
|
21
21
|
import { ThemesAPI } from "./themes";
|
|
22
22
|
import { WarehousesAPI } from "./warehouses";
|
|
23
23
|
import { WebhooksAPI } from "./webhooks";
|
|
24
|
+
/**
|
|
25
|
+
* Extends client with custom properties
|
|
26
|
+
*/
|
|
27
|
+
declare module "axios" {
|
|
28
|
+
interface AxiosRequestConfig {
|
|
29
|
+
isSandbox?: boolean;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
24
32
|
/**
|
|
25
33
|
* # ShipEngine API Client Headers
|
|
26
34
|
*/
|
|
@@ -40,7 +48,11 @@ export interface ShipEngineAPIConfig {
|
|
|
40
48
|
*/
|
|
41
49
|
baseURL?: string;
|
|
42
50
|
/**
|
|
43
|
-
* `
|
|
51
|
+
* `getSandboxToken` is an optional callback function that returns a token to be used to authenticate sandbox requests.
|
|
52
|
+
*/
|
|
53
|
+
getSandboxToken?: () => Promise<string> | string;
|
|
54
|
+
/**
|
|
55
|
+
* `getToken` is a callback function that returns a token to used to authenticate all requests.
|
|
44
56
|
*/
|
|
45
57
|
getToken: () => Promise<string> | string;
|
|
46
58
|
/**
|
|
@@ -60,7 +72,8 @@ export interface ShipEngineAPIConfig {
|
|
|
60
72
|
*/
|
|
61
73
|
export declare class ShipEngineAPI {
|
|
62
74
|
private client;
|
|
63
|
-
|
|
75
|
+
private sandboxToken?;
|
|
76
|
+
constructor(token: string, { baseURL, headers, getToken, getSandboxToken, onApiError }: ShipEngineAPIConfig);
|
|
64
77
|
/**
|
|
65
78
|
* The `token` method takes in a string and sets it as the Authorization header for all requests.
|
|
66
79
|
*/
|
package/connections/api.d.ts
CHANGED
|
@@ -26,12 +26,12 @@ export declare class ConnectionsAPI {
|
|
|
26
26
|
getCarrierConnectionsServicesList: (carrierCode: string) => Promise<import("axios").AxiosResponse<CarrierServicesListResponse, any>>;
|
|
27
27
|
/**
|
|
28
28
|
* The `getCarrierSettings` method retrieves the settings for a given carrier,
|
|
29
|
-
* identified by the `carrierName` and `
|
|
29
|
+
* identified by the `carrierName` and `carrierId`.
|
|
30
30
|
*/
|
|
31
|
-
getCarrierSettings: <T extends ConnectionsCarrierName>(carrierName: T,
|
|
31
|
+
getCarrierSettings: <T extends ConnectionsCarrierName>(carrierName: T, carrierId: string) => Promise<import("axios").AxiosResponse<ConnectionsCarrierSettingsResponse<T>, any>>;
|
|
32
32
|
/**
|
|
33
33
|
* The `updateCarrierSettings` method updates the settings for a given carrier,
|
|
34
|
-
* identified by the `carrierName` and `
|
|
34
|
+
* identified by the `carrierName` and `carrierId`.
|
|
35
35
|
*/
|
|
36
|
-
updateCarrierSettings: <T extends ConnectionsCarrierName>(carrierName: T,
|
|
36
|
+
updateCarrierSettings: <T extends ConnectionsCarrierName>(carrierName: T, carrierId: string, formData: ConnectionsCarrierSettingsData<T>) => Promise<import("axios").AxiosResponse<void, any>>;
|
|
37
37
|
}
|
package/index.js
CHANGED
|
@@ -1053,8 +1053,10 @@ class CarriersAPI {
|
|
|
1053
1053
|
/**
|
|
1054
1054
|
* The `list` method retrieves a list of connected carriers for a given user.
|
|
1055
1055
|
*/
|
|
1056
|
-
this.list = () => {
|
|
1057
|
-
return this.client.get("/v1/carriers"
|
|
1056
|
+
this.list = (props) => {
|
|
1057
|
+
return this.client.get("/v1/carriers", {
|
|
1058
|
+
isSandbox: props == null ? void 0 : props.isSandbox
|
|
1059
|
+
});
|
|
1058
1060
|
};
|
|
1059
1061
|
/**
|
|
1060
1062
|
* The `get` method retrieves a specific carrier by `carrierId`.
|
|
@@ -1223,20 +1225,20 @@ class ConnectionsAPI {
|
|
|
1223
1225
|
};
|
|
1224
1226
|
/**
|
|
1225
1227
|
* The `getCarrierSettings` method retrieves the settings for a given carrier,
|
|
1226
|
-
* identified by the `carrierName` and `
|
|
1228
|
+
* identified by the `carrierName` and `carrierId`.
|
|
1227
1229
|
*/
|
|
1228
|
-
this.getCarrierSettings = (carrierName,
|
|
1230
|
+
this.getCarrierSettings = (carrierName, carrierId) => {
|
|
1229
1231
|
return this.client.get(
|
|
1230
|
-
`/v1/connections/carriers/${carrierName}/${
|
|
1232
|
+
`/v1/connections/carriers/${carrierName}/${carrierId}/settings`
|
|
1231
1233
|
);
|
|
1232
1234
|
};
|
|
1233
1235
|
/**
|
|
1234
1236
|
* The `updateCarrierSettings` method updates the settings for a given carrier,
|
|
1235
|
-
* identified by the `carrierName` and `
|
|
1237
|
+
* identified by the `carrierName` and `carrierId`.
|
|
1236
1238
|
*/
|
|
1237
|
-
this.updateCarrierSettings = (carrierName,
|
|
1239
|
+
this.updateCarrierSettings = (carrierName, carrierId, formData) => {
|
|
1238
1240
|
return this.client.put(
|
|
1239
|
-
`/v1/connections/carriers/${carrierName}/${
|
|
1241
|
+
`/v1/connections/carriers/${carrierName}/${carrierId}/settings`,
|
|
1240
1242
|
formData
|
|
1241
1243
|
);
|
|
1242
1244
|
};
|
|
@@ -3988,42 +3990,55 @@ class ShippingRulesAPI {
|
|
|
3988
3990
|
/**
|
|
3989
3991
|
* The `list` method retrieves the list of shipping rules by seller.
|
|
3990
3992
|
*/
|
|
3991
|
-
this.list = () => {
|
|
3992
|
-
return this.client.get(`/v1/shipping_rules
|
|
3993
|
+
this.list = (props) => {
|
|
3994
|
+
return this.client.get(`/v1/shipping_rules`, {
|
|
3995
|
+
isSandbox: props == null ? void 0 : props.isSandbox
|
|
3996
|
+
});
|
|
3993
3997
|
};
|
|
3994
3998
|
/**
|
|
3995
3999
|
* The `get` method retrieves a specific shipping rule by `shippingRuleId`.
|
|
3996
4000
|
*/
|
|
3997
|
-
this.get = (
|
|
3998
|
-
return this.client.get(`/v1/shipping_rules/${shippingRuleId}
|
|
4001
|
+
this.get = (props) => {
|
|
4002
|
+
return this.client.get(`/v1/shipping_rules/${props == null ? void 0 : props.shippingRuleId}`, {
|
|
4003
|
+
isSandbox: props == null ? void 0 : props.isSandbox
|
|
4004
|
+
});
|
|
3999
4005
|
};
|
|
4000
4006
|
/**
|
|
4001
4007
|
* The `create` method creates a new shipping rule for a given user.
|
|
4002
4008
|
*/
|
|
4003
|
-
this.create = (
|
|
4004
|
-
return this.client.post("/v1/shipping_rules", shippingRule
|
|
4009
|
+
this.create = (props) => {
|
|
4010
|
+
return this.client.post("/v1/shipping_rules", props.shippingRule, {
|
|
4011
|
+
isSandbox: props.isSandbox
|
|
4012
|
+
});
|
|
4005
4013
|
};
|
|
4006
4014
|
/**
|
|
4007
4015
|
* The `delete` method deletes a shipping rule by `shippingRuleId`.
|
|
4008
4016
|
*/
|
|
4009
|
-
this.delete = (
|
|
4010
|
-
return this.client.delete(`/v1/shipping_rules/${shippingRuleId}
|
|
4017
|
+
this.delete = (props) => {
|
|
4018
|
+
return this.client.delete(`/v1/shipping_rules/${props.shippingRuleId}`, {
|
|
4019
|
+
isSandbox: props.isSandbox
|
|
4020
|
+
});
|
|
4011
4021
|
};
|
|
4012
4022
|
/**
|
|
4013
4023
|
* The `edit` method edits a specific shipping rule by `shippingRuleId` with a new
|
|
4014
4024
|
* `ShippingRule`.
|
|
4015
4025
|
*/
|
|
4016
|
-
this.edit = (
|
|
4026
|
+
this.edit = (props) => {
|
|
4017
4027
|
return this.client.put(
|
|
4018
|
-
`/v1/shipping_rules/${shippingRule.shippingRuleId}`,
|
|
4019
|
-
shippingRule
|
|
4028
|
+
`/v1/shipping_rules/${props.shippingRule.shippingRuleId}`,
|
|
4029
|
+
props.shippingRule,
|
|
4030
|
+
{
|
|
4031
|
+
isSandbox: props.isSandbox
|
|
4032
|
+
}
|
|
4020
4033
|
);
|
|
4021
4034
|
};
|
|
4022
4035
|
/**
|
|
4023
4036
|
* The `getConditionOptions` method retrieves the list of condition options availables for creating shipping rules.
|
|
4024
4037
|
*/
|
|
4025
|
-
this.getConditionOptions = () => {
|
|
4026
|
-
return this.client.get(`/v1/shipping_rules/rule_conditions_options
|
|
4038
|
+
this.getConditionOptions = (props) => {
|
|
4039
|
+
return this.client.get(`/v1/shipping_rules/rule_conditions_options`, {
|
|
4040
|
+
isSandbox: props == null ? void 0 : props.isSandbox
|
|
4041
|
+
});
|
|
4027
4042
|
};
|
|
4028
4043
|
this.client = client;
|
|
4029
4044
|
}
|
|
@@ -4049,8 +4064,10 @@ class WarehousesAPI {
|
|
|
4049
4064
|
* The `list` method retrieves a list of `warehouses` (Ship From Locations)
|
|
4050
4065
|
* for a given user.
|
|
4051
4066
|
*/
|
|
4052
|
-
this.list = () => {
|
|
4053
|
-
return this.client.get("/v1/warehouses"
|
|
4067
|
+
this.list = (props) => {
|
|
4068
|
+
return this.client.get("/v1/warehouses", {
|
|
4069
|
+
isSandbox: props == null ? void 0 : props.isSandbox
|
|
4070
|
+
});
|
|
4054
4071
|
};
|
|
4055
4072
|
/**
|
|
4056
4073
|
* The `create` method allows for creation of warehouses (Ship From Locations)
|
|
@@ -21402,7 +21419,7 @@ const logger = E({
|
|
|
21402
21419
|
]
|
|
21403
21420
|
});
|
|
21404
21421
|
class ShipEngineAPI {
|
|
21405
|
-
constructor(token, { baseURL, headers, getToken, onApiError }) {
|
|
21422
|
+
constructor(token, { baseURL, headers, getToken, getSandboxToken, onApiError }) {
|
|
21406
21423
|
const client = axios.create({
|
|
21407
21424
|
baseURL,
|
|
21408
21425
|
headers: __spreadProps(__spreadValues({}, headers), {
|
|
@@ -21439,6 +21456,21 @@ class ShipEngineAPI {
|
|
|
21439
21456
|
]
|
|
21440
21457
|
});
|
|
21441
21458
|
client.defaults.headers.common["Authorization"] = `Bearer ${token}`;
|
|
21459
|
+
client.interceptors.request.use(
|
|
21460
|
+
(config) => __async(this, null, function* () {
|
|
21461
|
+
if (config.isSandbox) {
|
|
21462
|
+
if (!this.sandboxToken) {
|
|
21463
|
+
this.sandboxToken = yield getSandboxToken == null ? void 0 : getSandboxToken();
|
|
21464
|
+
}
|
|
21465
|
+
config.headers || (config.headers = {});
|
|
21466
|
+
config.headers["Authorization"] = `Bearer ${this.sandboxToken}`;
|
|
21467
|
+
}
|
|
21468
|
+
return config;
|
|
21469
|
+
}),
|
|
21470
|
+
function(error) {
|
|
21471
|
+
return Promise.reject(error);
|
|
21472
|
+
}
|
|
21473
|
+
);
|
|
21442
21474
|
client.interceptors.response.use(
|
|
21443
21475
|
(res) => {
|
|
21444
21476
|
var _a;
|
|
@@ -21464,9 +21496,13 @@ class ShipEngineAPI {
|
|
|
21464
21496
|
err.message
|
|
21465
21497
|
);
|
|
21466
21498
|
if (isInvalidTokenError(err)) {
|
|
21467
|
-
const token2 = yield getToken();
|
|
21499
|
+
const token2 = yield err.config.isSandbox ? getSandboxToken == null ? void 0 : getSandboxToken() : getToken();
|
|
21468
21500
|
const config = err.config;
|
|
21469
|
-
|
|
21501
|
+
if (err.config.isSandbox) {
|
|
21502
|
+
this.sandboxToken = token2;
|
|
21503
|
+
} else {
|
|
21504
|
+
this.token = token2;
|
|
21505
|
+
}
|
|
21470
21506
|
if (config) {
|
|
21471
21507
|
config.headers || (config.headers = {});
|
|
21472
21508
|
config.headers["Authorization"] = `Bearer ${token2}`;
|
package/index.mjs
CHANGED
|
@@ -1049,8 +1049,10 @@ class CarriersAPI {
|
|
|
1049
1049
|
/**
|
|
1050
1050
|
* The `list` method retrieves a list of connected carriers for a given user.
|
|
1051
1051
|
*/
|
|
1052
|
-
this.list = () => {
|
|
1053
|
-
return this.client.get("/v1/carriers"
|
|
1052
|
+
this.list = (props) => {
|
|
1053
|
+
return this.client.get("/v1/carriers", {
|
|
1054
|
+
isSandbox: props == null ? void 0 : props.isSandbox
|
|
1055
|
+
});
|
|
1054
1056
|
};
|
|
1055
1057
|
/**
|
|
1056
1058
|
* The `get` method retrieves a specific carrier by `carrierId`.
|
|
@@ -1219,20 +1221,20 @@ class ConnectionsAPI {
|
|
|
1219
1221
|
};
|
|
1220
1222
|
/**
|
|
1221
1223
|
* The `getCarrierSettings` method retrieves the settings for a given carrier,
|
|
1222
|
-
* identified by the `carrierName` and `
|
|
1224
|
+
* identified by the `carrierName` and `carrierId`.
|
|
1223
1225
|
*/
|
|
1224
|
-
this.getCarrierSettings = (carrierName,
|
|
1226
|
+
this.getCarrierSettings = (carrierName, carrierId) => {
|
|
1225
1227
|
return this.client.get(
|
|
1226
|
-
`/v1/connections/carriers/${carrierName}/${
|
|
1228
|
+
`/v1/connections/carriers/${carrierName}/${carrierId}/settings`
|
|
1227
1229
|
);
|
|
1228
1230
|
};
|
|
1229
1231
|
/**
|
|
1230
1232
|
* The `updateCarrierSettings` method updates the settings for a given carrier,
|
|
1231
|
-
* identified by the `carrierName` and `
|
|
1233
|
+
* identified by the `carrierName` and `carrierId`.
|
|
1232
1234
|
*/
|
|
1233
|
-
this.updateCarrierSettings = (carrierName,
|
|
1235
|
+
this.updateCarrierSettings = (carrierName, carrierId, formData) => {
|
|
1234
1236
|
return this.client.put(
|
|
1235
|
-
`/v1/connections/carriers/${carrierName}/${
|
|
1237
|
+
`/v1/connections/carriers/${carrierName}/${carrierId}/settings`,
|
|
1236
1238
|
formData
|
|
1237
1239
|
);
|
|
1238
1240
|
};
|
|
@@ -3984,42 +3986,55 @@ class ShippingRulesAPI {
|
|
|
3984
3986
|
/**
|
|
3985
3987
|
* The `list` method retrieves the list of shipping rules by seller.
|
|
3986
3988
|
*/
|
|
3987
|
-
this.list = () => {
|
|
3988
|
-
return this.client.get(`/v1/shipping_rules
|
|
3989
|
+
this.list = (props) => {
|
|
3990
|
+
return this.client.get(`/v1/shipping_rules`, {
|
|
3991
|
+
isSandbox: props == null ? void 0 : props.isSandbox
|
|
3992
|
+
});
|
|
3989
3993
|
};
|
|
3990
3994
|
/**
|
|
3991
3995
|
* The `get` method retrieves a specific shipping rule by `shippingRuleId`.
|
|
3992
3996
|
*/
|
|
3993
|
-
this.get = (
|
|
3994
|
-
return this.client.get(`/v1/shipping_rules/${shippingRuleId}
|
|
3997
|
+
this.get = (props) => {
|
|
3998
|
+
return this.client.get(`/v1/shipping_rules/${props == null ? void 0 : props.shippingRuleId}`, {
|
|
3999
|
+
isSandbox: props == null ? void 0 : props.isSandbox
|
|
4000
|
+
});
|
|
3995
4001
|
};
|
|
3996
4002
|
/**
|
|
3997
4003
|
* The `create` method creates a new shipping rule for a given user.
|
|
3998
4004
|
*/
|
|
3999
|
-
this.create = (
|
|
4000
|
-
return this.client.post("/v1/shipping_rules", shippingRule
|
|
4005
|
+
this.create = (props) => {
|
|
4006
|
+
return this.client.post("/v1/shipping_rules", props.shippingRule, {
|
|
4007
|
+
isSandbox: props.isSandbox
|
|
4008
|
+
});
|
|
4001
4009
|
};
|
|
4002
4010
|
/**
|
|
4003
4011
|
* The `delete` method deletes a shipping rule by `shippingRuleId`.
|
|
4004
4012
|
*/
|
|
4005
|
-
this.delete = (
|
|
4006
|
-
return this.client.delete(`/v1/shipping_rules/${shippingRuleId}
|
|
4013
|
+
this.delete = (props) => {
|
|
4014
|
+
return this.client.delete(`/v1/shipping_rules/${props.shippingRuleId}`, {
|
|
4015
|
+
isSandbox: props.isSandbox
|
|
4016
|
+
});
|
|
4007
4017
|
};
|
|
4008
4018
|
/**
|
|
4009
4019
|
* The `edit` method edits a specific shipping rule by `shippingRuleId` with a new
|
|
4010
4020
|
* `ShippingRule`.
|
|
4011
4021
|
*/
|
|
4012
|
-
this.edit = (
|
|
4022
|
+
this.edit = (props) => {
|
|
4013
4023
|
return this.client.put(
|
|
4014
|
-
`/v1/shipping_rules/${shippingRule.shippingRuleId}`,
|
|
4015
|
-
shippingRule
|
|
4024
|
+
`/v1/shipping_rules/${props.shippingRule.shippingRuleId}`,
|
|
4025
|
+
props.shippingRule,
|
|
4026
|
+
{
|
|
4027
|
+
isSandbox: props.isSandbox
|
|
4028
|
+
}
|
|
4016
4029
|
);
|
|
4017
4030
|
};
|
|
4018
4031
|
/**
|
|
4019
4032
|
* The `getConditionOptions` method retrieves the list of condition options availables for creating shipping rules.
|
|
4020
4033
|
*/
|
|
4021
|
-
this.getConditionOptions = () => {
|
|
4022
|
-
return this.client.get(`/v1/shipping_rules/rule_conditions_options
|
|
4034
|
+
this.getConditionOptions = (props) => {
|
|
4035
|
+
return this.client.get(`/v1/shipping_rules/rule_conditions_options`, {
|
|
4036
|
+
isSandbox: props == null ? void 0 : props.isSandbox
|
|
4037
|
+
});
|
|
4023
4038
|
};
|
|
4024
4039
|
this.client = client;
|
|
4025
4040
|
}
|
|
@@ -4045,8 +4060,10 @@ class WarehousesAPI {
|
|
|
4045
4060
|
* The `list` method retrieves a list of `warehouses` (Ship From Locations)
|
|
4046
4061
|
* for a given user.
|
|
4047
4062
|
*/
|
|
4048
|
-
this.list = () => {
|
|
4049
|
-
return this.client.get("/v1/warehouses"
|
|
4063
|
+
this.list = (props) => {
|
|
4064
|
+
return this.client.get("/v1/warehouses", {
|
|
4065
|
+
isSandbox: props == null ? void 0 : props.isSandbox
|
|
4066
|
+
});
|
|
4050
4067
|
};
|
|
4051
4068
|
/**
|
|
4052
4069
|
* The `create` method allows for creation of warehouses (Ship From Locations)
|
|
@@ -21398,7 +21415,7 @@ const logger = E({
|
|
|
21398
21415
|
]
|
|
21399
21416
|
});
|
|
21400
21417
|
class ShipEngineAPI {
|
|
21401
|
-
constructor(token, { baseURL, headers, getToken, onApiError }) {
|
|
21418
|
+
constructor(token, { baseURL, headers, getToken, getSandboxToken, onApiError }) {
|
|
21402
21419
|
const client = axios.create({
|
|
21403
21420
|
baseURL,
|
|
21404
21421
|
headers: __spreadProps(__spreadValues({}, headers), {
|
|
@@ -21435,6 +21452,21 @@ class ShipEngineAPI {
|
|
|
21435
21452
|
]
|
|
21436
21453
|
});
|
|
21437
21454
|
client.defaults.headers.common["Authorization"] = `Bearer ${token}`;
|
|
21455
|
+
client.interceptors.request.use(
|
|
21456
|
+
(config) => __async(this, null, function* () {
|
|
21457
|
+
if (config.isSandbox) {
|
|
21458
|
+
if (!this.sandboxToken) {
|
|
21459
|
+
this.sandboxToken = yield getSandboxToken == null ? void 0 : getSandboxToken();
|
|
21460
|
+
}
|
|
21461
|
+
config.headers || (config.headers = {});
|
|
21462
|
+
config.headers["Authorization"] = `Bearer ${this.sandboxToken}`;
|
|
21463
|
+
}
|
|
21464
|
+
return config;
|
|
21465
|
+
}),
|
|
21466
|
+
function(error) {
|
|
21467
|
+
return Promise.reject(error);
|
|
21468
|
+
}
|
|
21469
|
+
);
|
|
21438
21470
|
client.interceptors.response.use(
|
|
21439
21471
|
(res) => {
|
|
21440
21472
|
var _a;
|
|
@@ -21460,9 +21492,13 @@ class ShipEngineAPI {
|
|
|
21460
21492
|
err.message
|
|
21461
21493
|
);
|
|
21462
21494
|
if (isInvalidTokenError(err)) {
|
|
21463
|
-
const token2 = yield getToken();
|
|
21495
|
+
const token2 = yield err.config.isSandbox ? getSandboxToken == null ? void 0 : getSandboxToken() : getToken();
|
|
21464
21496
|
const config = err.config;
|
|
21465
|
-
|
|
21497
|
+
if (err.config.isSandbox) {
|
|
21498
|
+
this.sandboxToken = token2;
|
|
21499
|
+
} else {
|
|
21500
|
+
this.token = token2;
|
|
21501
|
+
}
|
|
21466
21502
|
if (config) {
|
|
21467
21503
|
config.headers || (config.headers = {});
|
|
21468
21504
|
config.headers["Authorization"] = `Bearer ${token2}`;
|
package/package.json
CHANGED
package/resources/types.d.ts
CHANGED
|
@@ -54,3 +54,9 @@ export type SortableQuery<TSortKeys = "created_at" | "modified_at"> = {
|
|
|
54
54
|
export type LocaleBasedQuery = {
|
|
55
55
|
locale?: string;
|
|
56
56
|
};
|
|
57
|
+
export type SandboxableQuery<T = unknown> = T & {
|
|
58
|
+
isSandbox?: boolean;
|
|
59
|
+
};
|
|
60
|
+
export type SandboxableMutation<T = unknown> = T & {
|
|
61
|
+
isSandbox?: boolean;
|
|
62
|
+
};
|
package/shipping-rules/api.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
+
import { SandboxableMutation, SandboxableQuery } from "../resources";
|
|
2
3
|
import { RuleConditionsOptions, ShippingRule, ShippingRuleCreateInput, ShippingRuleEditInput } from "./types";
|
|
3
4
|
/**
|
|
4
5
|
* # Shipping Rules API module - /v1/shipping_rules
|
|
@@ -9,28 +10,36 @@ export declare class ShippingRulesAPI {
|
|
|
9
10
|
/**
|
|
10
11
|
* The `list` method retrieves the list of shipping rules by seller.
|
|
11
12
|
*/
|
|
12
|
-
list: () => Promise<import("axios").AxiosResponse<{
|
|
13
|
+
list: (props?: SandboxableQuery) => Promise<import("axios").AxiosResponse<{
|
|
13
14
|
shippingRules: ShippingRule[];
|
|
14
15
|
}, any>>;
|
|
15
16
|
/**
|
|
16
17
|
* The `get` method retrieves a specific shipping rule by `shippingRuleId`.
|
|
17
18
|
*/
|
|
18
|
-
get: (
|
|
19
|
+
get: (props?: SandboxableQuery<{
|
|
20
|
+
shippingRuleId: string;
|
|
21
|
+
}>) => Promise<import("axios").AxiosResponse<ShippingRule, any>>;
|
|
19
22
|
/**
|
|
20
23
|
* The `create` method creates a new shipping rule for a given user.
|
|
21
24
|
*/
|
|
22
|
-
create: (
|
|
25
|
+
create: (props: SandboxableMutation<{
|
|
26
|
+
shippingRule: ShippingRuleCreateInput;
|
|
27
|
+
}>) => Promise<import("axios").AxiosResponse<ShippingRule, any>>;
|
|
23
28
|
/**
|
|
24
29
|
* The `delete` method deletes a shipping rule by `shippingRuleId`.
|
|
25
30
|
*/
|
|
26
|
-
delete: (
|
|
31
|
+
delete: (props: SandboxableMutation<{
|
|
32
|
+
shippingRuleId: string;
|
|
33
|
+
}>) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
27
34
|
/**
|
|
28
35
|
* The `edit` method edits a specific shipping rule by `shippingRuleId` with a new
|
|
29
36
|
* `ShippingRule`.
|
|
30
37
|
*/
|
|
31
|
-
edit: (
|
|
38
|
+
edit: (props: SandboxableMutation<{
|
|
39
|
+
shippingRule: ShippingRuleEditInput;
|
|
40
|
+
}>) => Promise<import("axios").AxiosResponse<ShippingRule, any>>;
|
|
32
41
|
/**
|
|
33
42
|
* The `getConditionOptions` method retrieves the list of condition options availables for creating shipping rules.
|
|
34
43
|
*/
|
|
35
|
-
getConditionOptions: () => Promise<import("axios").AxiosResponse<RuleConditionsOptions[], any>>;
|
|
44
|
+
getConditionOptions: (props?: SandboxableQuery) => Promise<import("axios").AxiosResponse<RuleConditionsOptions[], any>>;
|
|
36
45
|
}
|
package/warehouses/api.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
+
import { SandboxableQuery } from "../resources";
|
|
2
3
|
import { Warehouse } from "./types";
|
|
3
4
|
/**
|
|
4
5
|
* # Warehouses API module - /v1/warehouses
|
|
@@ -10,7 +11,7 @@ export declare class WarehousesAPI {
|
|
|
10
11
|
* The `list` method retrieves a list of `warehouses` (Ship From Locations)
|
|
11
12
|
* for a given user.
|
|
12
13
|
*/
|
|
13
|
-
list: () => Promise<import("axios").AxiosResponse<{
|
|
14
|
+
list: (props?: SandboxableQuery) => Promise<import("axios").AxiosResponse<{
|
|
14
15
|
warehouses: Warehouse[];
|
|
15
16
|
}, any>>;
|
|
16
17
|
/**
|