@shipengine/js-api 0.7.1 → 0.8.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/index.js +66 -27
- package/index.mjs +66 -27
- package/package.json +1 -1
- package/shipments/api.d.ts +3 -1
package/index.js
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
var __getOwnPropSymbols$
|
|
6
|
-
var __hasOwnProp$
|
|
7
|
-
var __propIsEnum$
|
|
5
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
8
8
|
var __objRest$1 = (source, exclude) => {
|
|
9
9
|
var target = {};
|
|
10
10
|
for (var prop in source)
|
|
11
|
-
if (__hasOwnProp$
|
|
11
|
+
if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
12
12
|
target[prop] = source[prop];
|
|
13
|
-
if (source != null && __getOwnPropSymbols$
|
|
14
|
-
for (var prop of __getOwnPropSymbols$
|
|
15
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
13
|
+
if (source != null && __getOwnPropSymbols$3)
|
|
14
|
+
for (var prop of __getOwnPropSymbols$3(source)) {
|
|
15
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
|
|
16
16
|
target[prop] = source[prop];
|
|
17
17
|
}
|
|
18
18
|
return target;
|
|
@@ -2790,21 +2790,21 @@ var ipaddr = {
|
|
|
2790
2790
|
const isCodedErrors = (errs) => Array.isArray(errs) && errs.every((err) => isCodedError(err));
|
|
2791
2791
|
const isCodedError = (err) => !!err.errorCode;
|
|
2792
2792
|
|
|
2793
|
-
var __defProp$
|
|
2793
|
+
var __defProp$2 = Object.defineProperty;
|
|
2794
2794
|
var __defProps$1 = Object.defineProperties;
|
|
2795
2795
|
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
2796
|
-
var __getOwnPropSymbols$
|
|
2797
|
-
var __hasOwnProp$
|
|
2798
|
-
var __propIsEnum$
|
|
2799
|
-
var __defNormalProp$
|
|
2800
|
-
var __spreadValues$
|
|
2796
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
2797
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
2798
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
2799
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2800
|
+
var __spreadValues$2 = (a, b) => {
|
|
2801
2801
|
for (var prop in b || (b = {}))
|
|
2802
|
-
if (__hasOwnProp$
|
|
2803
|
-
__defNormalProp$
|
|
2804
|
-
if (__getOwnPropSymbols$
|
|
2805
|
-
for (var prop of __getOwnPropSymbols$
|
|
2806
|
-
if (__propIsEnum$
|
|
2807
|
-
__defNormalProp$
|
|
2802
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
2803
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
2804
|
+
if (__getOwnPropSymbols$2)
|
|
2805
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
2806
|
+
if (__propIsEnum$2.call(b, prop))
|
|
2807
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
2808
2808
|
}
|
|
2809
2809
|
return a;
|
|
2810
2810
|
};
|
|
@@ -2812,16 +2812,16 @@ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
|
2812
2812
|
var __objRest = (source, exclude) => {
|
|
2813
2813
|
var target = {};
|
|
2814
2814
|
for (var prop in source)
|
|
2815
|
-
if (__hasOwnProp$
|
|
2815
|
+
if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
2816
2816
|
target[prop] = source[prop];
|
|
2817
|
-
if (source != null && __getOwnPropSymbols$
|
|
2818
|
-
for (var prop of __getOwnPropSymbols$
|
|
2819
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
2817
|
+
if (source != null && __getOwnPropSymbols$2)
|
|
2818
|
+
for (var prop of __getOwnPropSymbols$2(source)) {
|
|
2819
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop))
|
|
2820
2820
|
target[prop] = source[prop];
|
|
2821
2821
|
}
|
|
2822
2822
|
return target;
|
|
2823
2823
|
};
|
|
2824
|
-
var __async$
|
|
2824
|
+
var __async$2 = (__this, __arguments, generator) => {
|
|
2825
2825
|
return new Promise((resolve, reject) => {
|
|
2826
2826
|
var fulfilled = (value) => {
|
|
2827
2827
|
try {
|
|
@@ -2841,7 +2841,7 @@ var __async$1 = (__this, __arguments, generator) => {
|
|
|
2841
2841
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
2842
2842
|
});
|
|
2843
2843
|
};
|
|
2844
|
-
const getEndUserIpAddress = () => __async$
|
|
2844
|
+
const getEndUserIpAddress = () => __async$2(void 0, null, function* () {
|
|
2845
2845
|
try {
|
|
2846
2846
|
const response = yield axios.get("https://api.ipify.org/?format=json");
|
|
2847
2847
|
if (response.data.ip && ipaddrExports.isValid(response.data.ip)) {
|
|
@@ -2861,12 +2861,12 @@ class CarriersAPI {
|
|
|
2861
2861
|
this.get = (carrierId) => {
|
|
2862
2862
|
return this.client.get(`/v1/carriers/${carrierId}`);
|
|
2863
2863
|
};
|
|
2864
|
-
this.connect = (_a) => __async$
|
|
2864
|
+
this.connect = (_a) => __async$2(this, null, function* () {
|
|
2865
2865
|
var _b = _a, { carrierCode } = _b, connection = __objRest(_b, ["carrierCode"]);
|
|
2866
2866
|
const endUserIpAddress = yield getEndUserIpAddress();
|
|
2867
2867
|
if (!endUserIpAddress)
|
|
2868
2868
|
return Promise.reject([new CodedError("Unable to get IP address")]);
|
|
2869
|
-
return yield this.client.post(`/v1/registration/${carrierCode}`, __spreadProps$1(__spreadValues$
|
|
2869
|
+
return yield this.client.post(`/v1/registration/${carrierCode}`, __spreadProps$1(__spreadValues$2({}, connection), {
|
|
2870
2870
|
endUserIpAddress
|
|
2871
2871
|
}));
|
|
2872
2872
|
});
|
|
@@ -5180,6 +5180,42 @@ class SalesOrdersAPI {
|
|
|
5180
5180
|
}
|
|
5181
5181
|
}
|
|
5182
5182
|
|
|
5183
|
+
var __defProp$1 = Object.defineProperty;
|
|
5184
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
5185
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
5186
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
5187
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5188
|
+
var __spreadValues$1 = (a, b) => {
|
|
5189
|
+
for (var prop in b || (b = {}))
|
|
5190
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
5191
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
5192
|
+
if (__getOwnPropSymbols$1)
|
|
5193
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
5194
|
+
if (__propIsEnum$1.call(b, prop))
|
|
5195
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
5196
|
+
}
|
|
5197
|
+
return a;
|
|
5198
|
+
};
|
|
5199
|
+
var __async$1 = (__this, __arguments, generator) => {
|
|
5200
|
+
return new Promise((resolve, reject) => {
|
|
5201
|
+
var fulfilled = (value) => {
|
|
5202
|
+
try {
|
|
5203
|
+
step(generator.next(value));
|
|
5204
|
+
} catch (e) {
|
|
5205
|
+
reject(e);
|
|
5206
|
+
}
|
|
5207
|
+
};
|
|
5208
|
+
var rejected = (value) => {
|
|
5209
|
+
try {
|
|
5210
|
+
step(generator.throw(value));
|
|
5211
|
+
} catch (e) {
|
|
5212
|
+
reject(e);
|
|
5213
|
+
}
|
|
5214
|
+
};
|
|
5215
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
5216
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
5217
|
+
});
|
|
5218
|
+
};
|
|
5183
5219
|
class ShipmentsAPI {
|
|
5184
5220
|
constructor(client) {
|
|
5185
5221
|
this.client = client;
|
|
@@ -5189,6 +5225,9 @@ class ShipmentsAPI {
|
|
|
5189
5225
|
createdAtStart !== void 0 ? { params: { createdAtStart } } : void 0
|
|
5190
5226
|
);
|
|
5191
5227
|
};
|
|
5228
|
+
this.create = (shipment) => __async$1(this, null, function* () {
|
|
5229
|
+
return this.client.post("/v1/shipments", __spreadValues$1({}, shipment));
|
|
5230
|
+
});
|
|
5192
5231
|
this.client = client;
|
|
5193
5232
|
}
|
|
5194
5233
|
}
|
package/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
var __getOwnPropSymbols$
|
|
2
|
-
var __hasOwnProp$
|
|
3
|
-
var __propIsEnum$
|
|
1
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
2
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
3
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
4
4
|
var __objRest$1 = (source, exclude) => {
|
|
5
5
|
var target = {};
|
|
6
6
|
for (var prop in source)
|
|
7
|
-
if (__hasOwnProp$
|
|
7
|
+
if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
8
8
|
target[prop] = source[prop];
|
|
9
|
-
if (source != null && __getOwnPropSymbols$
|
|
10
|
-
for (var prop of __getOwnPropSymbols$
|
|
11
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
9
|
+
if (source != null && __getOwnPropSymbols$3)
|
|
10
|
+
for (var prop of __getOwnPropSymbols$3(source)) {
|
|
11
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
|
|
12
12
|
target[prop] = source[prop];
|
|
13
13
|
}
|
|
14
14
|
return target;
|
|
@@ -2786,21 +2786,21 @@ var ipaddr = {
|
|
|
2786
2786
|
const isCodedErrors = (errs) => Array.isArray(errs) && errs.every((err) => isCodedError(err));
|
|
2787
2787
|
const isCodedError = (err) => !!err.errorCode;
|
|
2788
2788
|
|
|
2789
|
-
var __defProp$
|
|
2789
|
+
var __defProp$2 = Object.defineProperty;
|
|
2790
2790
|
var __defProps$1 = Object.defineProperties;
|
|
2791
2791
|
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
2792
|
-
var __getOwnPropSymbols$
|
|
2793
|
-
var __hasOwnProp$
|
|
2794
|
-
var __propIsEnum$
|
|
2795
|
-
var __defNormalProp$
|
|
2796
|
-
var __spreadValues$
|
|
2792
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
2793
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
2794
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
2795
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2796
|
+
var __spreadValues$2 = (a, b) => {
|
|
2797
2797
|
for (var prop in b || (b = {}))
|
|
2798
|
-
if (__hasOwnProp$
|
|
2799
|
-
__defNormalProp$
|
|
2800
|
-
if (__getOwnPropSymbols$
|
|
2801
|
-
for (var prop of __getOwnPropSymbols$
|
|
2802
|
-
if (__propIsEnum$
|
|
2803
|
-
__defNormalProp$
|
|
2798
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
2799
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
2800
|
+
if (__getOwnPropSymbols$2)
|
|
2801
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
2802
|
+
if (__propIsEnum$2.call(b, prop))
|
|
2803
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
2804
2804
|
}
|
|
2805
2805
|
return a;
|
|
2806
2806
|
};
|
|
@@ -2808,16 +2808,16 @@ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
|
2808
2808
|
var __objRest = (source, exclude) => {
|
|
2809
2809
|
var target = {};
|
|
2810
2810
|
for (var prop in source)
|
|
2811
|
-
if (__hasOwnProp$
|
|
2811
|
+
if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
2812
2812
|
target[prop] = source[prop];
|
|
2813
|
-
if (source != null && __getOwnPropSymbols$
|
|
2814
|
-
for (var prop of __getOwnPropSymbols$
|
|
2815
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
2813
|
+
if (source != null && __getOwnPropSymbols$2)
|
|
2814
|
+
for (var prop of __getOwnPropSymbols$2(source)) {
|
|
2815
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop))
|
|
2816
2816
|
target[prop] = source[prop];
|
|
2817
2817
|
}
|
|
2818
2818
|
return target;
|
|
2819
2819
|
};
|
|
2820
|
-
var __async$
|
|
2820
|
+
var __async$2 = (__this, __arguments, generator) => {
|
|
2821
2821
|
return new Promise((resolve, reject) => {
|
|
2822
2822
|
var fulfilled = (value) => {
|
|
2823
2823
|
try {
|
|
@@ -2837,7 +2837,7 @@ var __async$1 = (__this, __arguments, generator) => {
|
|
|
2837
2837
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
2838
2838
|
});
|
|
2839
2839
|
};
|
|
2840
|
-
const getEndUserIpAddress = () => __async$
|
|
2840
|
+
const getEndUserIpAddress = () => __async$2(void 0, null, function* () {
|
|
2841
2841
|
try {
|
|
2842
2842
|
const response = yield axios.get("https://api.ipify.org/?format=json");
|
|
2843
2843
|
if (response.data.ip && ipaddrExports.isValid(response.data.ip)) {
|
|
@@ -2857,12 +2857,12 @@ class CarriersAPI {
|
|
|
2857
2857
|
this.get = (carrierId) => {
|
|
2858
2858
|
return this.client.get(`/v1/carriers/${carrierId}`);
|
|
2859
2859
|
};
|
|
2860
|
-
this.connect = (_a) => __async$
|
|
2860
|
+
this.connect = (_a) => __async$2(this, null, function* () {
|
|
2861
2861
|
var _b = _a, { carrierCode } = _b, connection = __objRest(_b, ["carrierCode"]);
|
|
2862
2862
|
const endUserIpAddress = yield getEndUserIpAddress();
|
|
2863
2863
|
if (!endUserIpAddress)
|
|
2864
2864
|
return Promise.reject([new CodedError("Unable to get IP address")]);
|
|
2865
|
-
return yield this.client.post(`/v1/registration/${carrierCode}`, __spreadProps$1(__spreadValues$
|
|
2865
|
+
return yield this.client.post(`/v1/registration/${carrierCode}`, __spreadProps$1(__spreadValues$2({}, connection), {
|
|
2866
2866
|
endUserIpAddress
|
|
2867
2867
|
}));
|
|
2868
2868
|
});
|
|
@@ -5176,6 +5176,42 @@ class SalesOrdersAPI {
|
|
|
5176
5176
|
}
|
|
5177
5177
|
}
|
|
5178
5178
|
|
|
5179
|
+
var __defProp$1 = Object.defineProperty;
|
|
5180
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
5181
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
5182
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
5183
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5184
|
+
var __spreadValues$1 = (a, b) => {
|
|
5185
|
+
for (var prop in b || (b = {}))
|
|
5186
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
5187
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
5188
|
+
if (__getOwnPropSymbols$1)
|
|
5189
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
5190
|
+
if (__propIsEnum$1.call(b, prop))
|
|
5191
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
5192
|
+
}
|
|
5193
|
+
return a;
|
|
5194
|
+
};
|
|
5195
|
+
var __async$1 = (__this, __arguments, generator) => {
|
|
5196
|
+
return new Promise((resolve, reject) => {
|
|
5197
|
+
var fulfilled = (value) => {
|
|
5198
|
+
try {
|
|
5199
|
+
step(generator.next(value));
|
|
5200
|
+
} catch (e) {
|
|
5201
|
+
reject(e);
|
|
5202
|
+
}
|
|
5203
|
+
};
|
|
5204
|
+
var rejected = (value) => {
|
|
5205
|
+
try {
|
|
5206
|
+
step(generator.throw(value));
|
|
5207
|
+
} catch (e) {
|
|
5208
|
+
reject(e);
|
|
5209
|
+
}
|
|
5210
|
+
};
|
|
5211
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
5212
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
5213
|
+
});
|
|
5214
|
+
};
|
|
5179
5215
|
class ShipmentsAPI {
|
|
5180
5216
|
constructor(client) {
|
|
5181
5217
|
this.client = client;
|
|
@@ -5185,6 +5221,9 @@ class ShipmentsAPI {
|
|
|
5185
5221
|
createdAtStart !== void 0 ? { params: { createdAtStart } } : void 0
|
|
5186
5222
|
);
|
|
5187
5223
|
};
|
|
5224
|
+
this.create = (shipment) => __async$1(this, null, function* () {
|
|
5225
|
+
return this.client.post("/v1/shipments", __spreadValues$1({}, shipment));
|
|
5226
|
+
});
|
|
5188
5227
|
this.client = client;
|
|
5189
5228
|
}
|
|
5190
5229
|
}
|
package/package.json
CHANGED
package/shipments/api.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
|
-
import {
|
|
2
|
+
import { SalesOrderShipment } from "../sales-order-shipments";
|
|
3
|
+
import { Shipment, ShipmentRateResponse } from "./types";
|
|
3
4
|
export type GetShipmentRatesOptions = {
|
|
4
5
|
/**
|
|
5
6
|
* Date to filter rates by (they must be more recent than this date if passed)
|
|
@@ -12,4 +13,5 @@ export declare class ShipmentsAPI {
|
|
|
12
13
|
private client;
|
|
13
14
|
constructor(client: AxiosInstance);
|
|
14
15
|
getShipmentRates: ({ shipmentId, createdAtStart }: GetShipmentRatesOptions) => Promise<import("axios").AxiosResponse<ShipmentRateResponse, any>>;
|
|
16
|
+
create: (shipment: Partial<Omit<Shipment, "items">>) => Promise<import("axios").AxiosResponse<SalesOrderShipment, any>>;
|
|
15
17
|
}
|