@shipengine/js-api 1.2.0 → 1.4.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/client.d.ts +2 -0
- package/connections/api.d.ts +6 -2
- package/connections/types.d.ts +24 -20
- package/index.d.ts +1 -0
- package/index.js +118 -49
- package/index.mjs +118 -50
- package/labels/api.d.ts +8 -0
- package/package.json +1 -1
- package/service-points/api.d.ts +19 -0
- package/service-points/index.d.ts +2 -0
- package/service-points/types.d.ts +74 -0
- package/shipping-rules/api.d.ts +3 -3
- package/shipping-rules/types.d.ts +55 -7
- package/types.d.ts +1 -0
package/client.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { RateCardsAPI } from "./rate-cards";
|
|
|
14
14
|
import { RatesAPI } from "./rates";
|
|
15
15
|
import { SalesOrderShipmentsAPI } from "./sales-order-shipments";
|
|
16
16
|
import { SalesOrdersAPI } from "./sales-orders";
|
|
17
|
+
import { ServicePointsAPI } from "./service-points";
|
|
17
18
|
import { ShipmentsAPI } from "./shipments";
|
|
18
19
|
import { ShippingRulesAPI } from "./shipping-rules";
|
|
19
20
|
import { ThemesAPI } from "./themes";
|
|
@@ -158,6 +159,7 @@ export declare class ShipEngineAPI {
|
|
|
158
159
|
* @see {@link SalesOrdersAPI | The Sales Orders API module}
|
|
159
160
|
*/
|
|
160
161
|
get salesOrders(): SalesOrdersAPI;
|
|
162
|
+
get servicePoints(): ServicePointsAPI;
|
|
161
163
|
/**
|
|
162
164
|
* The `shipments` method provides access to the Shipment endpoints in ShipEngine
|
|
163
165
|
* API. e.g. Create Shipment, Get Shipment, etc.
|
package/connections/api.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
-
import { GetCarrierConnectionFormParams, GetCarrierConnectionFormResponse, ListCarrierConnectionsParams, ListCarrierConnectionsResponse } from "./types";
|
|
2
|
+
import { ConnectCarrierAccount, ConnectCarrierAccountResponse, GetCarrierConnectionFormParams, GetCarrierConnectionFormResponse, ListCarrierConnectionsParams, ListCarrierConnectionsResponse } from "./types";
|
|
3
3
|
/**
|
|
4
|
-
* #
|
|
4
|
+
* # Connections API module - /v1/connections
|
|
5
5
|
*/
|
|
6
6
|
export declare class ConnectionsAPI {
|
|
7
7
|
private client;
|
|
@@ -15,4 +15,8 @@ export declare class ConnectionsAPI {
|
|
|
15
15
|
* information required to connect to the carrier.
|
|
16
16
|
*/
|
|
17
17
|
getCarrierConnectionForm: (carrierName: string, params: GetCarrierConnectionFormParams) => Promise<import("axios").AxiosResponse<GetCarrierConnectionFormResponse, any>>;
|
|
18
|
+
/**
|
|
19
|
+
* The `connectCarrier` method connects a carrier to account.
|
|
20
|
+
*/
|
|
21
|
+
connectCarrier: (carrierName: string, formData: ConnectCarrierAccount) => Promise<import("axios").AxiosResponse<ConnectCarrierAccountResponse, any>>;
|
|
18
22
|
}
|
package/connections/types.d.ts
CHANGED
|
@@ -1,36 +1,40 @@
|
|
|
1
1
|
import { GenericObject, LocaleBasedQuery } from "../resources";
|
|
2
2
|
/**
|
|
3
|
-
* @category
|
|
3
|
+
* @category Entities
|
|
4
4
|
*/
|
|
5
|
+
export type CarrierMetadata = {
|
|
6
|
+
beta: boolean;
|
|
7
|
+
carrierFeatures?: {
|
|
8
|
+
country: string;
|
|
9
|
+
featureList: string[];
|
|
10
|
+
}[] | null;
|
|
11
|
+
carrierName: string;
|
|
12
|
+
description: string;
|
|
13
|
+
iconUrl: string;
|
|
14
|
+
logoUrl: string;
|
|
15
|
+
name: string;
|
|
16
|
+
searchTerms?: string[] | null;
|
|
17
|
+
};
|
|
5
18
|
export type ListCarrierConnectionsParams = LocaleBasedQuery;
|
|
6
19
|
export type GetCarrierConnectionFormParams = LocaleBasedQuery;
|
|
20
|
+
export type ConnectCarrierAccount = {
|
|
21
|
+
nickname: string;
|
|
22
|
+
} & GenericObject;
|
|
7
23
|
/**
|
|
8
24
|
* @category Responses
|
|
9
25
|
*/
|
|
10
26
|
export type GetCarrierConnectionFormResponse = {
|
|
11
27
|
formMetadata: {
|
|
12
|
-
connectionNames?: string[];
|
|
13
|
-
defaultConnectionName?: string;
|
|
28
|
+
connectionNames?: string[] | null;
|
|
29
|
+
defaultConnectionName?: string | null;
|
|
14
30
|
formSchema: {
|
|
15
31
|
jsonSchema: GenericObject;
|
|
16
32
|
uiSchema: GenericObject;
|
|
17
33
|
};
|
|
18
34
|
};
|
|
19
35
|
};
|
|
20
|
-
export type ListCarrierConnectionsResponse = [
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
country: string;
|
|
26
|
-
featureList: string[];
|
|
27
|
-
}
|
|
28
|
-
];
|
|
29
|
-
carrierName: string;
|
|
30
|
-
description: string;
|
|
31
|
-
iconUrl: string;
|
|
32
|
-
logoUrl: string;
|
|
33
|
-
name: string;
|
|
34
|
-
searchTerms?: string[];
|
|
35
|
-
}
|
|
36
|
-
];
|
|
36
|
+
export type ListCarrierConnectionsResponse = CarrierMetadata[];
|
|
37
|
+
export type ConnectCarrierAccountResponse = {
|
|
38
|
+
carrierId?: string;
|
|
39
|
+
redirectUrl?: string;
|
|
40
|
+
};
|
package/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export * from "./relay-points";
|
|
|
18
18
|
export * from "./resources";
|
|
19
19
|
export * from "./sales-order-shipments";
|
|
20
20
|
export * from "./sales-orders";
|
|
21
|
+
export * from "./service-points";
|
|
21
22
|
export * from "./shipments";
|
|
22
23
|
export * from "./shipping-rules";
|
|
23
24
|
export * from "./utilities";
|
package/index.js
CHANGED
|
@@ -10,17 +10,17 @@ var AccountBillingPlanChangeType = /* @__PURE__ */ ((AccountBillingPlanChangeTyp
|
|
|
10
10
|
return AccountBillingPlanChangeType2;
|
|
11
11
|
})(AccountBillingPlanChangeType || {});
|
|
12
12
|
|
|
13
|
-
var __getOwnPropSymbols$
|
|
14
|
-
var __hasOwnProp$
|
|
15
|
-
var __propIsEnum$
|
|
13
|
+
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
14
|
+
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
15
|
+
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
16
16
|
var __objRest$2 = (source, exclude) => {
|
|
17
17
|
var target = {};
|
|
18
18
|
for (var prop in source)
|
|
19
|
-
if (__hasOwnProp$
|
|
19
|
+
if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
20
20
|
target[prop] = source[prop];
|
|
21
|
-
if (source != null && __getOwnPropSymbols$
|
|
22
|
-
for (var prop of __getOwnPropSymbols$
|
|
23
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
21
|
+
if (source != null && __getOwnPropSymbols$5)
|
|
22
|
+
for (var prop of __getOwnPropSymbols$5(source)) {
|
|
23
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
|
|
24
24
|
target[prop] = source[prop];
|
|
25
25
|
}
|
|
26
26
|
return target;
|
|
@@ -142,17 +142,17 @@ const types = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
142
142
|
RateCardStatus
|
|
143
143
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
144
144
|
|
|
145
|
-
var __getOwnPropSymbols$
|
|
146
|
-
var __hasOwnProp$
|
|
147
|
-
var __propIsEnum$
|
|
145
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
146
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
147
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
148
148
|
var __objRest$1 = (source, exclude) => {
|
|
149
149
|
var target = {};
|
|
150
150
|
for (var prop in source)
|
|
151
|
-
if (__hasOwnProp$
|
|
151
|
+
if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
152
152
|
target[prop] = source[prop];
|
|
153
|
-
if (source != null && __getOwnPropSymbols$
|
|
154
|
-
for (var prop of __getOwnPropSymbols$
|
|
155
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
153
|
+
if (source != null && __getOwnPropSymbols$4)
|
|
154
|
+
for (var prop of __getOwnPropSymbols$4(source)) {
|
|
155
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
|
|
156
156
|
target[prop] = source[prop];
|
|
157
157
|
}
|
|
158
158
|
return target;
|
|
@@ -964,7 +964,7 @@ var ipaddr = {
|
|
|
964
964
|
}).call(commonjsGlobal);
|
|
965
965
|
} (ipaddr));
|
|
966
966
|
|
|
967
|
-
var __async$
|
|
967
|
+
var __async$5 = (__this, __arguments, generator) => {
|
|
968
968
|
return new Promise((resolve, reject) => {
|
|
969
969
|
var fulfilled = (value) => {
|
|
970
970
|
try {
|
|
@@ -984,7 +984,7 @@ var __async$4 = (__this, __arguments, generator) => {
|
|
|
984
984
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
985
985
|
});
|
|
986
986
|
};
|
|
987
|
-
const getEndUserIpAddress = () => __async$
|
|
987
|
+
const getEndUserIpAddress = () => __async$5(void 0, null, function* () {
|
|
988
988
|
try {
|
|
989
989
|
const response = yield axios.get("https://api.ipify.org/?format=json");
|
|
990
990
|
if (response.data.ip && ipaddrExports.isValid(response.data.ip)) {
|
|
@@ -996,21 +996,21 @@ const getEndUserIpAddress = () => __async$4(void 0, null, function* () {
|
|
|
996
996
|
}
|
|
997
997
|
});
|
|
998
998
|
|
|
999
|
-
var __defProp$
|
|
999
|
+
var __defProp$3 = Object.defineProperty;
|
|
1000
1000
|
var __defProps$1 = Object.defineProperties;
|
|
1001
1001
|
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
1002
|
-
var __getOwnPropSymbols$
|
|
1003
|
-
var __hasOwnProp$
|
|
1004
|
-
var __propIsEnum$
|
|
1005
|
-
var __defNormalProp$
|
|
1006
|
-
var __spreadValues$
|
|
1002
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
1003
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
1004
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
1005
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1006
|
+
var __spreadValues$3 = (a, b) => {
|
|
1007
1007
|
for (var prop in b || (b = {}))
|
|
1008
|
-
if (__hasOwnProp$
|
|
1009
|
-
__defNormalProp$
|
|
1010
|
-
if (__getOwnPropSymbols$
|
|
1011
|
-
for (var prop of __getOwnPropSymbols$
|
|
1012
|
-
if (__propIsEnum$
|
|
1013
|
-
__defNormalProp$
|
|
1008
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
1009
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
1010
|
+
if (__getOwnPropSymbols$3)
|
|
1011
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
1012
|
+
if (__propIsEnum$3.call(b, prop))
|
|
1013
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
1014
1014
|
}
|
|
1015
1015
|
return a;
|
|
1016
1016
|
};
|
|
@@ -1018,16 +1018,16 @@ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
|
1018
1018
|
var __objRest = (source, exclude) => {
|
|
1019
1019
|
var target = {};
|
|
1020
1020
|
for (var prop in source)
|
|
1021
|
-
if (__hasOwnProp$
|
|
1021
|
+
if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
1022
1022
|
target[prop] = source[prop];
|
|
1023
|
-
if (source != null && __getOwnPropSymbols$
|
|
1024
|
-
for (var prop of __getOwnPropSymbols$
|
|
1025
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
1023
|
+
if (source != null && __getOwnPropSymbols$3)
|
|
1024
|
+
for (var prop of __getOwnPropSymbols$3(source)) {
|
|
1025
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
|
|
1026
1026
|
target[prop] = source[prop];
|
|
1027
1027
|
}
|
|
1028
1028
|
return target;
|
|
1029
1029
|
};
|
|
1030
|
-
var __async$
|
|
1030
|
+
var __async$4 = (__this, __arguments, generator) => {
|
|
1031
1031
|
return new Promise((resolve, reject) => {
|
|
1032
1032
|
var fulfilled = (value) => {
|
|
1033
1033
|
try {
|
|
@@ -1065,12 +1065,12 @@ class CarriersAPI {
|
|
|
1065
1065
|
/**
|
|
1066
1066
|
* The `connect` method connects a carrier account to a user's ShipEngine account.
|
|
1067
1067
|
*/
|
|
1068
|
-
this.connect = (_a) => __async$
|
|
1068
|
+
this.connect = (_a) => __async$4(this, null, function* () {
|
|
1069
1069
|
var _b = _a, { carrierCode } = _b, connection = __objRest(_b, ["carrierCode"]);
|
|
1070
1070
|
const endUserIpAddress = yield getEndUserIpAddress();
|
|
1071
1071
|
if (!endUserIpAddress)
|
|
1072
1072
|
return Promise.reject([new CodedError("Unable to get IP address")]);
|
|
1073
|
-
return yield this.client.post(`/v1/registration/${carrierCode}`, __spreadProps$1(__spreadValues$
|
|
1073
|
+
return yield this.client.post(`/v1/registration/${carrierCode}`, __spreadProps$1(__spreadValues$3({}, connection), {
|
|
1074
1074
|
endUserIpAddress
|
|
1075
1075
|
}));
|
|
1076
1076
|
});
|
|
@@ -1149,6 +1149,26 @@ class CarriersAPI {
|
|
|
1149
1149
|
}
|
|
1150
1150
|
}
|
|
1151
1151
|
|
|
1152
|
+
var __async$3 = (__this, __arguments, generator) => {
|
|
1153
|
+
return new Promise((resolve, reject) => {
|
|
1154
|
+
var fulfilled = (value) => {
|
|
1155
|
+
try {
|
|
1156
|
+
step(generator.next(value));
|
|
1157
|
+
} catch (e) {
|
|
1158
|
+
reject(e);
|
|
1159
|
+
}
|
|
1160
|
+
};
|
|
1161
|
+
var rejected = (value) => {
|
|
1162
|
+
try {
|
|
1163
|
+
step(generator.throw(value));
|
|
1164
|
+
} catch (e) {
|
|
1165
|
+
reject(e);
|
|
1166
|
+
}
|
|
1167
|
+
};
|
|
1168
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
1169
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
1170
|
+
});
|
|
1171
|
+
};
|
|
1152
1172
|
class ConnectionsAPI {
|
|
1153
1173
|
constructor(client) {
|
|
1154
1174
|
this.client = client;
|
|
@@ -1168,6 +1188,15 @@ class ConnectionsAPI {
|
|
|
1168
1188
|
{ params }
|
|
1169
1189
|
);
|
|
1170
1190
|
};
|
|
1191
|
+
/**
|
|
1192
|
+
* The `connectCarrier` method connects a carrier to account.
|
|
1193
|
+
*/
|
|
1194
|
+
this.connectCarrier = (carrierName, formData) => __async$3(this, null, function* () {
|
|
1195
|
+
return yield this.client.post(
|
|
1196
|
+
`/v1/connections/carriers/${carrierName}`,
|
|
1197
|
+
formData
|
|
1198
|
+
);
|
|
1199
|
+
});
|
|
1171
1200
|
this.client = client;
|
|
1172
1201
|
}
|
|
1173
1202
|
}
|
|
@@ -3381,19 +3410,19 @@ class CustomPackagesAPI {
|
|
|
3381
3410
|
}
|
|
3382
3411
|
}
|
|
3383
3412
|
|
|
3384
|
-
var __defProp$
|
|
3385
|
-
var __getOwnPropSymbols$
|
|
3386
|
-
var __hasOwnProp$
|
|
3387
|
-
var __propIsEnum$
|
|
3388
|
-
var __defNormalProp$
|
|
3389
|
-
var __spreadValues$
|
|
3413
|
+
var __defProp$2 = Object.defineProperty;
|
|
3414
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
3415
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
3416
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
3417
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3418
|
+
var __spreadValues$2 = (a, b) => {
|
|
3390
3419
|
for (var prop in b || (b = {}))
|
|
3391
|
-
if (__hasOwnProp$
|
|
3392
|
-
__defNormalProp$
|
|
3393
|
-
if (__getOwnPropSymbols$
|
|
3394
|
-
for (var prop of __getOwnPropSymbols$
|
|
3395
|
-
if (__propIsEnum$
|
|
3396
|
-
__defNormalProp$
|
|
3420
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
3421
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
3422
|
+
if (__getOwnPropSymbols$2)
|
|
3423
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
3424
|
+
if (__propIsEnum$2.call(b, prop))
|
|
3425
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
3397
3426
|
}
|
|
3398
3427
|
return a;
|
|
3399
3428
|
};
|
|
@@ -3440,7 +3469,7 @@ class FundingSourcesAPI {
|
|
|
3440
3469
|
const endUserIpAddress = yield getEndUserIpAddress();
|
|
3441
3470
|
if (!endUserIpAddress)
|
|
3442
3471
|
return Promise.reject([new CodedError("Unable to get IP address")]);
|
|
3443
|
-
return yield this.client.post("/v1/funding_sources", __spreadValues$
|
|
3472
|
+
return yield this.client.post("/v1/funding_sources", __spreadValues$2({
|
|
3444
3473
|
endUserIpAddress
|
|
3445
3474
|
}, createFundingSource));
|
|
3446
3475
|
});
|
|
@@ -3470,7 +3499,7 @@ class FundingSourcesAPI {
|
|
|
3470
3499
|
const endUserIpAddress = yield getEndUserIpAddress();
|
|
3471
3500
|
if (!endUserIpAddress)
|
|
3472
3501
|
return Promise.reject([new CodedError("Unable to get IP address")]);
|
|
3473
|
-
return yield this.client.post("/v1/registration/funding_source", __spreadValues$
|
|
3502
|
+
return yield this.client.post("/v1/registration/funding_source", __spreadValues$2({
|
|
3474
3503
|
endUserIpAddress
|
|
3475
3504
|
}, carrier));
|
|
3476
3505
|
});
|
|
@@ -3745,6 +3774,42 @@ class SalesOrdersAPI {
|
|
|
3745
3774
|
}
|
|
3746
3775
|
}
|
|
3747
3776
|
|
|
3777
|
+
var __defProp$1 = Object.defineProperty;
|
|
3778
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
3779
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
3780
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
3781
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3782
|
+
var __spreadValues$1 = (a, b) => {
|
|
3783
|
+
for (var prop in b || (b = {}))
|
|
3784
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
3785
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
3786
|
+
if (__getOwnPropSymbols$1)
|
|
3787
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
3788
|
+
if (__propIsEnum$1.call(b, prop))
|
|
3789
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
3790
|
+
}
|
|
3791
|
+
return a;
|
|
3792
|
+
};
|
|
3793
|
+
class ServicePointsAPI {
|
|
3794
|
+
constructor(client) {
|
|
3795
|
+
/**
|
|
3796
|
+
* The `list` method returns a list of service points based on several factors
|
|
3797
|
+
* A providers list that must contain at least one provider but no more than five
|
|
3798
|
+
* Either an address, coordinates, or an address query
|
|
3799
|
+
*/
|
|
3800
|
+
this.list = (options) => {
|
|
3801
|
+
return this.client.post("/v1/service_points/list", __spreadValues$1({}, options));
|
|
3802
|
+
};
|
|
3803
|
+
/**
|
|
3804
|
+
* Get a specific service point by its carrier code, country code, and id
|
|
3805
|
+
*/
|
|
3806
|
+
this.get = ({ carrierCode, countryCode, id }) => {
|
|
3807
|
+
return this.client.get(`/v1/service_points/${carrierCode}/${countryCode}/${id}`);
|
|
3808
|
+
};
|
|
3809
|
+
this.client = client;
|
|
3810
|
+
}
|
|
3811
|
+
}
|
|
3812
|
+
|
|
3748
3813
|
var __async$1 = (__this, __arguments, generator) => {
|
|
3749
3814
|
return new Promise((resolve, reject) => {
|
|
3750
3815
|
var fulfilled = (value) => {
|
|
@@ -4162,6 +4227,9 @@ class ShipEngineAPI {
|
|
|
4162
4227
|
get salesOrders() {
|
|
4163
4228
|
return new SalesOrdersAPI(this.client);
|
|
4164
4229
|
}
|
|
4230
|
+
get servicePoints() {
|
|
4231
|
+
return new ServicePointsAPI(this.client);
|
|
4232
|
+
}
|
|
4165
4233
|
/**
|
|
4166
4234
|
* The `shipments` method provides access to the Shipment endpoints in ShipEngine
|
|
4167
4235
|
* API. e.g. Create Shipment, Get Shipment, etc.
|
|
@@ -4224,6 +4292,7 @@ exports.RatesAPI = RatesAPI;
|
|
|
4224
4292
|
exports.SE = types;
|
|
4225
4293
|
exports.SalesOrderShipmentsAPI = SalesOrderShipmentsAPI;
|
|
4226
4294
|
exports.SalesOrdersAPI = SalesOrdersAPI;
|
|
4295
|
+
exports.ServicePointsAPI = ServicePointsAPI;
|
|
4227
4296
|
exports.ShipEngineAPI = ShipEngineAPI;
|
|
4228
4297
|
exports.ShipmentsAPI = ShipmentsAPI;
|
|
4229
4298
|
exports.ShippingRulesAPI = ShippingRulesAPI;
|
package/index.mjs
CHANGED
|
@@ -6,17 +6,17 @@ var AccountBillingPlanChangeType = /* @__PURE__ */ ((AccountBillingPlanChangeTyp
|
|
|
6
6
|
return AccountBillingPlanChangeType2;
|
|
7
7
|
})(AccountBillingPlanChangeType || {});
|
|
8
8
|
|
|
9
|
-
var __getOwnPropSymbols$
|
|
10
|
-
var __hasOwnProp$
|
|
11
|
-
var __propIsEnum$
|
|
9
|
+
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
10
|
+
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
12
12
|
var __objRest$2 = (source, exclude) => {
|
|
13
13
|
var target = {};
|
|
14
14
|
for (var prop in source)
|
|
15
|
-
if (__hasOwnProp$
|
|
15
|
+
if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
16
16
|
target[prop] = source[prop];
|
|
17
|
-
if (source != null && __getOwnPropSymbols$
|
|
18
|
-
for (var prop of __getOwnPropSymbols$
|
|
19
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
17
|
+
if (source != null && __getOwnPropSymbols$5)
|
|
18
|
+
for (var prop of __getOwnPropSymbols$5(source)) {
|
|
19
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
|
|
20
20
|
target[prop] = source[prop];
|
|
21
21
|
}
|
|
22
22
|
return target;
|
|
@@ -138,17 +138,17 @@ const types = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
138
138
|
RateCardStatus
|
|
139
139
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
140
140
|
|
|
141
|
-
var __getOwnPropSymbols$
|
|
142
|
-
var __hasOwnProp$
|
|
143
|
-
var __propIsEnum$
|
|
141
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
142
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
143
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
144
144
|
var __objRest$1 = (source, exclude) => {
|
|
145
145
|
var target = {};
|
|
146
146
|
for (var prop in source)
|
|
147
|
-
if (__hasOwnProp$
|
|
147
|
+
if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
148
148
|
target[prop] = source[prop];
|
|
149
|
-
if (source != null && __getOwnPropSymbols$
|
|
150
|
-
for (var prop of __getOwnPropSymbols$
|
|
151
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
149
|
+
if (source != null && __getOwnPropSymbols$4)
|
|
150
|
+
for (var prop of __getOwnPropSymbols$4(source)) {
|
|
151
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
|
|
152
152
|
target[prop] = source[prop];
|
|
153
153
|
}
|
|
154
154
|
return target;
|
|
@@ -960,7 +960,7 @@ var ipaddr = {
|
|
|
960
960
|
}).call(commonjsGlobal);
|
|
961
961
|
} (ipaddr));
|
|
962
962
|
|
|
963
|
-
var __async$
|
|
963
|
+
var __async$5 = (__this, __arguments, generator) => {
|
|
964
964
|
return new Promise((resolve, reject) => {
|
|
965
965
|
var fulfilled = (value) => {
|
|
966
966
|
try {
|
|
@@ -980,7 +980,7 @@ var __async$4 = (__this, __arguments, generator) => {
|
|
|
980
980
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
981
981
|
});
|
|
982
982
|
};
|
|
983
|
-
const getEndUserIpAddress = () => __async$
|
|
983
|
+
const getEndUserIpAddress = () => __async$5(void 0, null, function* () {
|
|
984
984
|
try {
|
|
985
985
|
const response = yield axios.get("https://api.ipify.org/?format=json");
|
|
986
986
|
if (response.data.ip && ipaddrExports.isValid(response.data.ip)) {
|
|
@@ -992,21 +992,21 @@ const getEndUserIpAddress = () => __async$4(void 0, null, function* () {
|
|
|
992
992
|
}
|
|
993
993
|
});
|
|
994
994
|
|
|
995
|
-
var __defProp$
|
|
995
|
+
var __defProp$3 = Object.defineProperty;
|
|
996
996
|
var __defProps$1 = Object.defineProperties;
|
|
997
997
|
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
998
|
-
var __getOwnPropSymbols$
|
|
999
|
-
var __hasOwnProp$
|
|
1000
|
-
var __propIsEnum$
|
|
1001
|
-
var __defNormalProp$
|
|
1002
|
-
var __spreadValues$
|
|
998
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
999
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
1000
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
1001
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1002
|
+
var __spreadValues$3 = (a, b) => {
|
|
1003
1003
|
for (var prop in b || (b = {}))
|
|
1004
|
-
if (__hasOwnProp$
|
|
1005
|
-
__defNormalProp$
|
|
1006
|
-
if (__getOwnPropSymbols$
|
|
1007
|
-
for (var prop of __getOwnPropSymbols$
|
|
1008
|
-
if (__propIsEnum$
|
|
1009
|
-
__defNormalProp$
|
|
1004
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
1005
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
1006
|
+
if (__getOwnPropSymbols$3)
|
|
1007
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
1008
|
+
if (__propIsEnum$3.call(b, prop))
|
|
1009
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
1010
1010
|
}
|
|
1011
1011
|
return a;
|
|
1012
1012
|
};
|
|
@@ -1014,16 +1014,16 @@ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
|
1014
1014
|
var __objRest = (source, exclude) => {
|
|
1015
1015
|
var target = {};
|
|
1016
1016
|
for (var prop in source)
|
|
1017
|
-
if (__hasOwnProp$
|
|
1017
|
+
if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
1018
1018
|
target[prop] = source[prop];
|
|
1019
|
-
if (source != null && __getOwnPropSymbols$
|
|
1020
|
-
for (var prop of __getOwnPropSymbols$
|
|
1021
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
1019
|
+
if (source != null && __getOwnPropSymbols$3)
|
|
1020
|
+
for (var prop of __getOwnPropSymbols$3(source)) {
|
|
1021
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
|
|
1022
1022
|
target[prop] = source[prop];
|
|
1023
1023
|
}
|
|
1024
1024
|
return target;
|
|
1025
1025
|
};
|
|
1026
|
-
var __async$
|
|
1026
|
+
var __async$4 = (__this, __arguments, generator) => {
|
|
1027
1027
|
return new Promise((resolve, reject) => {
|
|
1028
1028
|
var fulfilled = (value) => {
|
|
1029
1029
|
try {
|
|
@@ -1061,12 +1061,12 @@ class CarriersAPI {
|
|
|
1061
1061
|
/**
|
|
1062
1062
|
* The `connect` method connects a carrier account to a user's ShipEngine account.
|
|
1063
1063
|
*/
|
|
1064
|
-
this.connect = (_a) => __async$
|
|
1064
|
+
this.connect = (_a) => __async$4(this, null, function* () {
|
|
1065
1065
|
var _b = _a, { carrierCode } = _b, connection = __objRest(_b, ["carrierCode"]);
|
|
1066
1066
|
const endUserIpAddress = yield getEndUserIpAddress();
|
|
1067
1067
|
if (!endUserIpAddress)
|
|
1068
1068
|
return Promise.reject([new CodedError("Unable to get IP address")]);
|
|
1069
|
-
return yield this.client.post(`/v1/registration/${carrierCode}`, __spreadProps$1(__spreadValues$
|
|
1069
|
+
return yield this.client.post(`/v1/registration/${carrierCode}`, __spreadProps$1(__spreadValues$3({}, connection), {
|
|
1070
1070
|
endUserIpAddress
|
|
1071
1071
|
}));
|
|
1072
1072
|
});
|
|
@@ -1145,6 +1145,26 @@ class CarriersAPI {
|
|
|
1145
1145
|
}
|
|
1146
1146
|
}
|
|
1147
1147
|
|
|
1148
|
+
var __async$3 = (__this, __arguments, generator) => {
|
|
1149
|
+
return new Promise((resolve, reject) => {
|
|
1150
|
+
var fulfilled = (value) => {
|
|
1151
|
+
try {
|
|
1152
|
+
step(generator.next(value));
|
|
1153
|
+
} catch (e) {
|
|
1154
|
+
reject(e);
|
|
1155
|
+
}
|
|
1156
|
+
};
|
|
1157
|
+
var rejected = (value) => {
|
|
1158
|
+
try {
|
|
1159
|
+
step(generator.throw(value));
|
|
1160
|
+
} catch (e) {
|
|
1161
|
+
reject(e);
|
|
1162
|
+
}
|
|
1163
|
+
};
|
|
1164
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
1165
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
1166
|
+
});
|
|
1167
|
+
};
|
|
1148
1168
|
class ConnectionsAPI {
|
|
1149
1169
|
constructor(client) {
|
|
1150
1170
|
this.client = client;
|
|
@@ -1164,6 +1184,15 @@ class ConnectionsAPI {
|
|
|
1164
1184
|
{ params }
|
|
1165
1185
|
);
|
|
1166
1186
|
};
|
|
1187
|
+
/**
|
|
1188
|
+
* The `connectCarrier` method connects a carrier to account.
|
|
1189
|
+
*/
|
|
1190
|
+
this.connectCarrier = (carrierName, formData) => __async$3(this, null, function* () {
|
|
1191
|
+
return yield this.client.post(
|
|
1192
|
+
`/v1/connections/carriers/${carrierName}`,
|
|
1193
|
+
formData
|
|
1194
|
+
);
|
|
1195
|
+
});
|
|
1167
1196
|
this.client = client;
|
|
1168
1197
|
}
|
|
1169
1198
|
}
|
|
@@ -3377,19 +3406,19 @@ class CustomPackagesAPI {
|
|
|
3377
3406
|
}
|
|
3378
3407
|
}
|
|
3379
3408
|
|
|
3380
|
-
var __defProp$
|
|
3381
|
-
var __getOwnPropSymbols$
|
|
3382
|
-
var __hasOwnProp$
|
|
3383
|
-
var __propIsEnum$
|
|
3384
|
-
var __defNormalProp$
|
|
3385
|
-
var __spreadValues$
|
|
3409
|
+
var __defProp$2 = Object.defineProperty;
|
|
3410
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
3411
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
3412
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
3413
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3414
|
+
var __spreadValues$2 = (a, b) => {
|
|
3386
3415
|
for (var prop in b || (b = {}))
|
|
3387
|
-
if (__hasOwnProp$
|
|
3388
|
-
__defNormalProp$
|
|
3389
|
-
if (__getOwnPropSymbols$
|
|
3390
|
-
for (var prop of __getOwnPropSymbols$
|
|
3391
|
-
if (__propIsEnum$
|
|
3392
|
-
__defNormalProp$
|
|
3416
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
3417
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
3418
|
+
if (__getOwnPropSymbols$2)
|
|
3419
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
3420
|
+
if (__propIsEnum$2.call(b, prop))
|
|
3421
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
3393
3422
|
}
|
|
3394
3423
|
return a;
|
|
3395
3424
|
};
|
|
@@ -3436,7 +3465,7 @@ class FundingSourcesAPI {
|
|
|
3436
3465
|
const endUserIpAddress = yield getEndUserIpAddress();
|
|
3437
3466
|
if (!endUserIpAddress)
|
|
3438
3467
|
return Promise.reject([new CodedError("Unable to get IP address")]);
|
|
3439
|
-
return yield this.client.post("/v1/funding_sources", __spreadValues$
|
|
3468
|
+
return yield this.client.post("/v1/funding_sources", __spreadValues$2({
|
|
3440
3469
|
endUserIpAddress
|
|
3441
3470
|
}, createFundingSource));
|
|
3442
3471
|
});
|
|
@@ -3466,7 +3495,7 @@ class FundingSourcesAPI {
|
|
|
3466
3495
|
const endUserIpAddress = yield getEndUserIpAddress();
|
|
3467
3496
|
if (!endUserIpAddress)
|
|
3468
3497
|
return Promise.reject([new CodedError("Unable to get IP address")]);
|
|
3469
|
-
return yield this.client.post("/v1/registration/funding_source", __spreadValues$
|
|
3498
|
+
return yield this.client.post("/v1/registration/funding_source", __spreadValues$2({
|
|
3470
3499
|
endUserIpAddress
|
|
3471
3500
|
}, carrier));
|
|
3472
3501
|
});
|
|
@@ -3741,6 +3770,42 @@ class SalesOrdersAPI {
|
|
|
3741
3770
|
}
|
|
3742
3771
|
}
|
|
3743
3772
|
|
|
3773
|
+
var __defProp$1 = Object.defineProperty;
|
|
3774
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
3775
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
3776
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
3777
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3778
|
+
var __spreadValues$1 = (a, b) => {
|
|
3779
|
+
for (var prop in b || (b = {}))
|
|
3780
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
3781
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
3782
|
+
if (__getOwnPropSymbols$1)
|
|
3783
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
3784
|
+
if (__propIsEnum$1.call(b, prop))
|
|
3785
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
3786
|
+
}
|
|
3787
|
+
return a;
|
|
3788
|
+
};
|
|
3789
|
+
class ServicePointsAPI {
|
|
3790
|
+
constructor(client) {
|
|
3791
|
+
/**
|
|
3792
|
+
* The `list` method returns a list of service points based on several factors
|
|
3793
|
+
* A providers list that must contain at least one provider but no more than five
|
|
3794
|
+
* Either an address, coordinates, or an address query
|
|
3795
|
+
*/
|
|
3796
|
+
this.list = (options) => {
|
|
3797
|
+
return this.client.post("/v1/service_points/list", __spreadValues$1({}, options));
|
|
3798
|
+
};
|
|
3799
|
+
/**
|
|
3800
|
+
* Get a specific service point by its carrier code, country code, and id
|
|
3801
|
+
*/
|
|
3802
|
+
this.get = ({ carrierCode, countryCode, id }) => {
|
|
3803
|
+
return this.client.get(`/v1/service_points/${carrierCode}/${countryCode}/${id}`);
|
|
3804
|
+
};
|
|
3805
|
+
this.client = client;
|
|
3806
|
+
}
|
|
3807
|
+
}
|
|
3808
|
+
|
|
3744
3809
|
var __async$1 = (__this, __arguments, generator) => {
|
|
3745
3810
|
return new Promise((resolve, reject) => {
|
|
3746
3811
|
var fulfilled = (value) => {
|
|
@@ -4158,6 +4223,9 @@ class ShipEngineAPI {
|
|
|
4158
4223
|
get salesOrders() {
|
|
4159
4224
|
return new SalesOrdersAPI(this.client);
|
|
4160
4225
|
}
|
|
4226
|
+
get servicePoints() {
|
|
4227
|
+
return new ServicePointsAPI(this.client);
|
|
4228
|
+
}
|
|
4161
4229
|
/**
|
|
4162
4230
|
* The `shipments` method provides access to the Shipment endpoints in ShipEngine
|
|
4163
4231
|
* API. e.g. Create Shipment, Get Shipment, etc.
|
|
@@ -4195,4 +4263,4 @@ class ShipEngineAPI {
|
|
|
4195
4263
|
}
|
|
4196
4264
|
}
|
|
4197
4265
|
|
|
4198
|
-
export { AccountSettingsAPI, AddressesAPI, CarriersAPI, CodedError, ConfirmationType, ConnectionsAPI, CreditCardVendor, Currency, CustomPackagesAPI, CustomsContentsType, CustomsNonDeliveryType, FundingSourcesAPI, InsuranceAPI, InsuranceProviderType, LabelsAPI, MetadataCapability, MetadataRequirement, MetadataSatisfyingFormTypes, OrderSourcesAPI, RateCardStatus, RateCardsAPI, RatesAPI, types as SE, SalesOrderShipmentsAPI, SalesOrdersAPI, ShipEngineAPI, ShipmentsAPI, ShippingRulesAPI, ThemesAPI, WarehousesAPI, getEndUserIpAddress, isCodedError, isCodedErrors, isDataCodedErrors, isInvalidTokenError, parseError };
|
|
4266
|
+
export { AccountSettingsAPI, AddressesAPI, CarriersAPI, CodedError, ConfirmationType, ConnectionsAPI, CreditCardVendor, Currency, CustomPackagesAPI, CustomsContentsType, CustomsNonDeliveryType, FundingSourcesAPI, InsuranceAPI, InsuranceProviderType, LabelsAPI, MetadataCapability, MetadataRequirement, MetadataSatisfyingFormTypes, OrderSourcesAPI, RateCardStatus, RateCardsAPI, RatesAPI, types as SE, SalesOrderShipmentsAPI, SalesOrdersAPI, ServicePointsAPI, ShipEngineAPI, ShipmentsAPI, ShippingRulesAPI, ThemesAPI, WarehousesAPI, getEndUserIpAddress, isCodedError, isCodedErrors, isDataCodedErrors, isInvalidTokenError, parseError };
|
package/labels/api.d.ts
CHANGED
|
@@ -27,6 +27,14 @@ export interface CreateLabelOptions {
|
|
|
27
27
|
* e.g. `4x6` or `8.5x11`
|
|
28
28
|
*/
|
|
29
29
|
labelLayout?: LabelLayout;
|
|
30
|
+
/**
|
|
31
|
+
* A unique identifier for a carrier drop-off point where a merchant plans to deliver packages. This will take precedence over a shipment's Ship From address.
|
|
32
|
+
*/
|
|
33
|
+
shipFromServicePointId?: string;
|
|
34
|
+
/**
|
|
35
|
+
* A unique identifier for a carrier service point where the shipment will be delivered by the carrier. This will take precedence over a shipment's Ship To address.
|
|
36
|
+
*/
|
|
37
|
+
shipToServicePointId?: string;
|
|
30
38
|
/**
|
|
31
39
|
* `validateAddress` is an optional string to control address validation during
|
|
32
40
|
* label purchase.
|
package/package.json
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
import type { GetServicePointParams, ListServicePointsOptions, ServicePointsListResponse } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Service points api
|
|
5
|
+
*/
|
|
6
|
+
export declare class ServicePointsAPI {
|
|
7
|
+
private client;
|
|
8
|
+
constructor(client: AxiosInstance);
|
|
9
|
+
/**
|
|
10
|
+
* The `list` method returns a list of service points based on several factors
|
|
11
|
+
* A providers list that must contain at least one provider but no more than five
|
|
12
|
+
* Either an address, coordinates, or an address query
|
|
13
|
+
*/
|
|
14
|
+
list: (options: ListServicePointsOptions) => Promise<import("axios").AxiosResponse<ServicePointsListResponse, any>>;
|
|
15
|
+
/**
|
|
16
|
+
* Get a specific service point by its carrier code, country code, and id
|
|
17
|
+
*/
|
|
18
|
+
get: ({ carrierCode, countryCode, id }: GetServicePointParams) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Address } from "../addresses";
|
|
2
|
+
import type { CodedError } from "../errors";
|
|
3
|
+
/**
|
|
4
|
+
* Specific error type currently only seen during Service Point requests
|
|
5
|
+
*/
|
|
6
|
+
export type ServicePointCustomError = {
|
|
7
|
+
message: string;
|
|
8
|
+
providerId: string;
|
|
9
|
+
sellerProviderId: number;
|
|
10
|
+
};
|
|
11
|
+
export type ServicePointsListResponse = {
|
|
12
|
+
errors: CodedError[] | ServicePointCustomError[];
|
|
13
|
+
lat: number;
|
|
14
|
+
long: number;
|
|
15
|
+
servicePoints: {
|
|
16
|
+
[P in keyof ServicePoint]: ServicePoint[P] | null;
|
|
17
|
+
}[];
|
|
18
|
+
};
|
|
19
|
+
export type OperatingHours = {
|
|
20
|
+
close: string;
|
|
21
|
+
open: string;
|
|
22
|
+
};
|
|
23
|
+
export type DayOfOperation = "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday" | "sunday";
|
|
24
|
+
export type ServicePointFeature = "drop_off_point" | "pickup_point";
|
|
25
|
+
export type ServicePoint = {
|
|
26
|
+
addressLine1: string;
|
|
27
|
+
carrierCode: string;
|
|
28
|
+
cityLocality: string;
|
|
29
|
+
companyName: string;
|
|
30
|
+
countryCode: string;
|
|
31
|
+
distanceInMeters: number;
|
|
32
|
+
features: ServicePointFeature[];
|
|
33
|
+
hoursOfOperation: {
|
|
34
|
+
[key in DayOfOperation]: OperatingHours;
|
|
35
|
+
};
|
|
36
|
+
lat: number;
|
|
37
|
+
long: number;
|
|
38
|
+
phoneNumber: string;
|
|
39
|
+
postalCode: string;
|
|
40
|
+
serviceCodes: string[];
|
|
41
|
+
servicePointId: string;
|
|
42
|
+
stateProvince: string;
|
|
43
|
+
type: "pudo";
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Types the 3 separate ways to make a request to the list service points endpoint
|
|
47
|
+
*/
|
|
48
|
+
export type ListServicePointsOptions = {
|
|
49
|
+
maxResults?: number;
|
|
50
|
+
providers: ServicePointProvider[];
|
|
51
|
+
radius?: number;
|
|
52
|
+
} & (ListServicePointsOptionAddress | ListServicePointsOptionAddressQuery | ListServicePointsOptionCoordinates);
|
|
53
|
+
export type ListServicePointsOptionCoordinates = {
|
|
54
|
+
lat: number;
|
|
55
|
+
long: number;
|
|
56
|
+
};
|
|
57
|
+
export type ListServicePointsOptionAddressQuery = {
|
|
58
|
+
addressQuery: string;
|
|
59
|
+
};
|
|
60
|
+
export type ListServicePointsOptionAddress = {
|
|
61
|
+
address: ServicePointAddress;
|
|
62
|
+
};
|
|
63
|
+
export type ServicePointAddress = Omit<Address, "adressResidentialIndicator" | "email" | "name" | "phone" | "companyName" | "stateProvince"> & {
|
|
64
|
+
stateProvince?: string;
|
|
65
|
+
};
|
|
66
|
+
export type ServicePointProvider = {
|
|
67
|
+
carrierId: string;
|
|
68
|
+
serviceCode?: string[];
|
|
69
|
+
};
|
|
70
|
+
export type GetServicePointParams = {
|
|
71
|
+
carrierCode: string;
|
|
72
|
+
countryCode: string;
|
|
73
|
+
id: string;
|
|
74
|
+
};
|
package/shipping-rules/api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
-
import { RuleConditionsOptions, ShippingRule,
|
|
2
|
+
import { RuleConditionsOptions, ShippingRule, ShippingRuleCreateInput, ShippingRuleEditInput } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* # Shipping Rules API module - /v1/shipping_rules
|
|
5
5
|
*/
|
|
@@ -19,7 +19,7 @@ export declare class ShippingRulesAPI {
|
|
|
19
19
|
/**
|
|
20
20
|
* The `create` method creates a new shipping rule for a given user.
|
|
21
21
|
*/
|
|
22
|
-
create: (shippingRule:
|
|
22
|
+
create: (shippingRule: ShippingRuleCreateInput) => Promise<import("axios").AxiosResponse<ShippingRule, any>>;
|
|
23
23
|
/**
|
|
24
24
|
* The `delete` method deletes a shipping rule by `shippingRuleId`.
|
|
25
25
|
*/
|
|
@@ -28,7 +28,7 @@ export declare class ShippingRulesAPI {
|
|
|
28
28
|
* The `edit` method edits a specific shipping rule by `shippingRuleId` with a new
|
|
29
29
|
* `ShippingRule`.
|
|
30
30
|
*/
|
|
31
|
-
edit: (shippingRule:
|
|
31
|
+
edit: (shippingRule: ShippingRuleEditInput) => Promise<import("axios").AxiosResponse<ShippingRule, any>>;
|
|
32
32
|
/**
|
|
33
33
|
* The `getConditionOptions` method retrieves the list of condition options availables for creating shipping rules.
|
|
34
34
|
*/
|
|
@@ -38,6 +38,13 @@ export interface Rule {
|
|
|
38
38
|
priority: number;
|
|
39
39
|
service: ShippingRuleSelectedService;
|
|
40
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* @category Entities
|
|
43
|
+
*/
|
|
44
|
+
export interface ExclusionRule {
|
|
45
|
+
conditions: ShippingRulesConditions[];
|
|
46
|
+
services: ShippingRuleSelectedService[];
|
|
47
|
+
}
|
|
41
48
|
/**
|
|
42
49
|
* @category Entities
|
|
43
50
|
*/
|
|
@@ -48,20 +55,61 @@ export interface ShippingRuleSelectedService {
|
|
|
48
55
|
/**
|
|
49
56
|
* @category Entities
|
|
50
57
|
*/
|
|
51
|
-
export
|
|
52
|
-
|
|
53
|
-
|
|
58
|
+
export type ShippingRuleSelectedServiceWithPriority = {
|
|
59
|
+
priority: number;
|
|
60
|
+
} & ShippingRuleSelectedService;
|
|
61
|
+
export interface CommonShippingRule {
|
|
62
|
+
code: string;
|
|
54
63
|
createdAt?: ISOString;
|
|
55
|
-
|
|
64
|
+
modifiedAt?: ISOString;
|
|
56
65
|
name: string;
|
|
57
|
-
rules?: Rule[];
|
|
58
66
|
shippingRuleId: string;
|
|
59
|
-
updatedAt?: ISOString;
|
|
60
67
|
}
|
|
61
68
|
/**
|
|
62
69
|
* @category Entities
|
|
63
70
|
*/
|
|
64
|
-
export
|
|
71
|
+
export interface ConditionalShippingRule extends CommonShippingRule {
|
|
72
|
+
default?: ShippingRuleSelectedService;
|
|
73
|
+
rules?: Rule[];
|
|
74
|
+
type: "CONDITIONAL";
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* @category Entities
|
|
78
|
+
*/
|
|
79
|
+
export interface ServiceGroupShippingRule extends CommonShippingRule {
|
|
80
|
+
exclusionRules?: ExclusionRule[];
|
|
81
|
+
services: ShippingRuleSelectedServiceWithPriority[];
|
|
82
|
+
type: "SERVICE_GROUP";
|
|
83
|
+
}
|
|
84
|
+
export type ShippingRule = ConditionalShippingRule | ServiceGroupShippingRule;
|
|
85
|
+
/**
|
|
86
|
+
* @category Entities
|
|
87
|
+
*/
|
|
88
|
+
export type ShippingRuleType = ShippingRule["type"];
|
|
89
|
+
/**
|
|
90
|
+
* @category Entities
|
|
91
|
+
*/
|
|
92
|
+
export type ConditionalShippingRuleCreateInput = Omit<ConditionalShippingRule, "shippingRuleId" | "code">;
|
|
93
|
+
/**
|
|
94
|
+
* @category Entities
|
|
95
|
+
*/
|
|
96
|
+
export type ServiceGroupShippingRuleCreateInput = Omit<ServiceGroupShippingRule, "shippingRuleId" | "code">;
|
|
97
|
+
/**
|
|
98
|
+
* @category Entities
|
|
99
|
+
*/
|
|
100
|
+
export type ConditionalShippingRuleEditInput = Omit<ConditionalShippingRule, "code">;
|
|
101
|
+
/**
|
|
102
|
+
* @category Entities
|
|
103
|
+
*/
|
|
104
|
+
export type ServiceGroupShippingRuleEditInput = Omit<ServiceGroupShippingRule, "code">;
|
|
105
|
+
/**
|
|
106
|
+
* @category Entities
|
|
107
|
+
*/
|
|
108
|
+
export type ShippingRuleCreateInput = ConditionalShippingRuleCreateInput | ServiceGroupShippingRuleCreateInput;
|
|
109
|
+
/**
|
|
110
|
+
* @category Entities
|
|
111
|
+
*/
|
|
112
|
+
export type ShippingRuleEditInput = ConditionalShippingRuleEditInput | ServiceGroupShippingRuleEditInput;
|
|
65
113
|
/**
|
|
66
114
|
* @category Entities
|
|
67
115
|
*/
|
package/types.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export * from "./relay-points/types";
|
|
|
18
18
|
export * from "./resources/types";
|
|
19
19
|
export * from "./sales-order-shipments/types";
|
|
20
20
|
export * from "./sales-orders/types";
|
|
21
|
+
export * from "./service-points/types";
|
|
21
22
|
export * from "./shipments/types";
|
|
22
23
|
export * from "./shipping-rules/types";
|
|
23
24
|
export * from "./themes/types";
|