@shipengine/alchemy 2.2.2 → 2.2.4
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 +931 -609
- package/index.mjs +932 -611
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -2575,9 +2575,17 @@ const types = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
|
2575
2575
|
class AccountSettingsAPI {
|
|
2576
2576
|
constructor(client) {
|
|
2577
2577
|
this.client = client;
|
|
2578
|
+
/**
|
|
2579
|
+
* The `get` method retrieves the account settings for a given user.
|
|
2580
|
+
*/
|
|
2578
2581
|
this.get = () => {
|
|
2579
2582
|
return this.client.get("/v1/account/settings");
|
|
2580
2583
|
};
|
|
2584
|
+
/**
|
|
2585
|
+
* The `update` method updates specific account settings for a given user.
|
|
2586
|
+
*
|
|
2587
|
+
* @params Partial<AccountSettings> The account settings to update.
|
|
2588
|
+
*/
|
|
2581
2589
|
this.update = (settings) => {
|
|
2582
2590
|
return this.client.put("/v1/account/settings", settings);
|
|
2583
2591
|
};
|
|
@@ -2588,9 +2596,17 @@ class AccountSettingsAPI {
|
|
|
2588
2596
|
class AddressesAPI {
|
|
2589
2597
|
constructor(client) {
|
|
2590
2598
|
this.client = client;
|
|
2599
|
+
/**
|
|
2600
|
+
* The `validate` method validates a list of addresses.
|
|
2601
|
+
*
|
|
2602
|
+
* @params Address[] The addresses to be validated.
|
|
2603
|
+
*/
|
|
2591
2604
|
this.validate = (addresses) => {
|
|
2592
2605
|
return this.client.post("/v1/addresses/validate", addresses);
|
|
2593
2606
|
};
|
|
2607
|
+
/**
|
|
2608
|
+
* The `parse` method parses a string of text to extract addresses.
|
|
2609
|
+
*/
|
|
2594
2610
|
this.parse = (text, address) => {
|
|
2595
2611
|
return this.client.put("/v1/addresses/recognize", {
|
|
2596
2612
|
address,
|
|
@@ -5238,7 +5254,7 @@ var ipaddr = {
|
|
|
5238
5254
|
}).call(commonjsGlobal);
|
|
5239
5255
|
} (ipaddr));
|
|
5240
5256
|
|
|
5241
|
-
var __async$
|
|
5257
|
+
var __async$x = (__this, __arguments, generator) => {
|
|
5242
5258
|
return new Promise((resolve, reject) => {
|
|
5243
5259
|
var fulfilled = (value) => {
|
|
5244
5260
|
try {
|
|
@@ -5258,7 +5274,7 @@ var __async$w = (__this, __arguments, generator) => {
|
|
|
5258
5274
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
5259
5275
|
});
|
|
5260
5276
|
};
|
|
5261
|
-
const getEndUserIpAddress = () => __async$
|
|
5277
|
+
const getEndUserIpAddress = () => __async$x(void 0, null, function* () {
|
|
5262
5278
|
try {
|
|
5263
5279
|
const response = yield axios.get("https://api.ipify.org/?format=json");
|
|
5264
5280
|
if (response.data.ip && ipaddrExports.isValid(response.data.ip)) {
|
|
@@ -5301,7 +5317,7 @@ var __objRest$7 = (source, exclude) => {
|
|
|
5301
5317
|
}
|
|
5302
5318
|
return target;
|
|
5303
5319
|
};
|
|
5304
|
-
var __async$
|
|
5320
|
+
var __async$w = (__this, __arguments, generator) => {
|
|
5305
5321
|
return new Promise((resolve, reject) => {
|
|
5306
5322
|
var fulfilled = (value) => {
|
|
5307
5323
|
try {
|
|
@@ -5324,13 +5340,22 @@ var __async$v = (__this, __arguments, generator) => {
|
|
|
5324
5340
|
class CarriersAPI {
|
|
5325
5341
|
constructor(client) {
|
|
5326
5342
|
this.client = client;
|
|
5343
|
+
/**
|
|
5344
|
+
* The `list` method retrieves a list of connected carriers for a given user.
|
|
5345
|
+
*/
|
|
5327
5346
|
this.list = () => {
|
|
5328
5347
|
return this.client.get("/v1/carriers");
|
|
5329
5348
|
};
|
|
5349
|
+
/**
|
|
5350
|
+
* The `get` method retrieves a specific carrier by `carrierId`.
|
|
5351
|
+
*/
|
|
5330
5352
|
this.get = (carrierId) => {
|
|
5331
5353
|
return this.client.get(`/v1/carriers/${carrierId}`);
|
|
5332
5354
|
};
|
|
5333
|
-
|
|
5355
|
+
/**
|
|
5356
|
+
* The `connect` method connects a carrier account to a user's ShipEngine account.
|
|
5357
|
+
*/
|
|
5358
|
+
this.connect = (_a) => __async$w(this, null, function* () {
|
|
5334
5359
|
var _b = _a, { carrierCode } = _b, connection = __objRest$7(_b, ["carrierCode"]);
|
|
5335
5360
|
const endUserIpAddress = yield getEndUserIpAddress();
|
|
5336
5361
|
if (!endUserIpAddress)
|
|
@@ -5339,20 +5364,44 @@ class CarriersAPI {
|
|
|
5339
5364
|
endUserIpAddress
|
|
5340
5365
|
}));
|
|
5341
5366
|
});
|
|
5367
|
+
/**
|
|
5368
|
+
* The `addFunds` method allows a user to add funds to their carrier account balance.
|
|
5369
|
+
* Not all carrier providers allow you to maintain a balance.
|
|
5370
|
+
*
|
|
5371
|
+
* - For example, FedEx does
|
|
5372
|
+
* not require you to maintain a balance that will be used when purchasing labels.
|
|
5373
|
+
*/
|
|
5342
5374
|
this.addFunds = (carrierId, funds) => {
|
|
5343
5375
|
return this.client.put(`/v1/carriers/${carrierId}/add_funds`, funds);
|
|
5344
5376
|
};
|
|
5377
|
+
/**
|
|
5378
|
+
* The `updateAutoFunding` method allows a user to update the auto-funding settings
|
|
5379
|
+
* on their ShipEngine account.
|
|
5380
|
+
*
|
|
5381
|
+
* e.g. Enable auto-funding, set a balance threshold, and a maximum number of time
|
|
5382
|
+
* per day you wish to auto-fund your account.
|
|
5383
|
+
*/
|
|
5345
5384
|
this.updateAutoFunding = (carrierId, options) => {
|
|
5346
5385
|
return this.client.post(
|
|
5347
5386
|
`/v1/carriers/${carrierId}/auto_funding`,
|
|
5348
5387
|
options
|
|
5349
5388
|
);
|
|
5350
5389
|
};
|
|
5390
|
+
/**
|
|
5391
|
+
* The `getAutoFunding` method retrieves the current auto-funding settings.
|
|
5392
|
+
*
|
|
5393
|
+
* If no auto-funding rules have been set, the response will contain the default
|
|
5394
|
+
* values for auto-funding. Auto-funding is disabled by default.
|
|
5395
|
+
*/
|
|
5351
5396
|
this.getAutoFunding = (carrierId) => {
|
|
5352
5397
|
return this.client.get(
|
|
5353
5398
|
`/v1/carriers/${carrierId}/auto_funding`
|
|
5354
5399
|
);
|
|
5355
5400
|
};
|
|
5401
|
+
/**
|
|
5402
|
+
* The `getWalletHistory` method retrieves the wallet transaction history for
|
|
5403
|
+
* a ShipEngine wallet account.
|
|
5404
|
+
*/
|
|
5356
5405
|
this.getWalletHistory = (startDate, endDate, page) => {
|
|
5357
5406
|
return this.client.get(`/v1/carriers/wallet_history`, {
|
|
5358
5407
|
params: {
|
|
@@ -5362,17 +5411,33 @@ class CarriersAPI {
|
|
|
5362
5411
|
}
|
|
5363
5412
|
});
|
|
5364
5413
|
};
|
|
5414
|
+
/**
|
|
5415
|
+
* The `getServices` method retrieves a list of shipping services that a given carrier offers.
|
|
5416
|
+
*/
|
|
5365
5417
|
this.getServices = (carrierId) => {
|
|
5366
5418
|
return this.client.get(`/v1/carriers/${carrierId}/services`);
|
|
5367
5419
|
};
|
|
5420
|
+
/**
|
|
5421
|
+
* The `getPackageRatingGroup` method retrieves a list of package rating groups.
|
|
5422
|
+
* This is primarily used for carriers that support negotiated rates, and a user
|
|
5423
|
+
* has a rate card with multiple package rating groups.
|
|
5424
|
+
*/
|
|
5368
5425
|
this.getPackageRatingGroup = (carrierId) => {
|
|
5369
5426
|
return this.client.get(
|
|
5370
5427
|
`/v1/carriers/${carrierId}/package_rating_group`
|
|
5371
5428
|
);
|
|
5372
5429
|
};
|
|
5430
|
+
/**
|
|
5431
|
+
* The `getCountries` method retrieves a list of countries that a given carrier
|
|
5432
|
+
* supports shipping to.
|
|
5433
|
+
*/
|
|
5373
5434
|
this.getCountries = (carrierId) => {
|
|
5374
5435
|
return this.client.get(`/v1/carriers/${carrierId}/countries`);
|
|
5375
5436
|
};
|
|
5437
|
+
/**
|
|
5438
|
+
* The `getCurrencies` method retrieves a list of currencies that a given carrier
|
|
5439
|
+
* supports the usage of.
|
|
5440
|
+
*/
|
|
5376
5441
|
this.getCurrencies = (carrierId) => {
|
|
5377
5442
|
return this.client.get(`/v1/carriers/${carrierId}/currencies`);
|
|
5378
5443
|
};
|
|
@@ -7560,6 +7625,9 @@ var lib = {
|
|
|
7560
7625
|
class CustomPackagesAPI {
|
|
7561
7626
|
constructor(client) {
|
|
7562
7627
|
this.client = client;
|
|
7628
|
+
/**
|
|
7629
|
+
* The `list` method retrieves a list of custom packages a given user has created.
|
|
7630
|
+
*/
|
|
7563
7631
|
this.list = () => {
|
|
7564
7632
|
return this.client.get("/v1/packages");
|
|
7565
7633
|
};
|
|
@@ -7583,7 +7651,7 @@ var __spreadValues$6 = (a, b) => {
|
|
|
7583
7651
|
}
|
|
7584
7652
|
return a;
|
|
7585
7653
|
};
|
|
7586
|
-
var __async$
|
|
7654
|
+
var __async$v = (__this, __arguments, generator) => {
|
|
7587
7655
|
return new Promise((resolve, reject) => {
|
|
7588
7656
|
var fulfilled = (value) => {
|
|
7589
7657
|
try {
|
|
@@ -7606,13 +7674,23 @@ var __async$u = (__this, __arguments, generator) => {
|
|
|
7606
7674
|
class FundingSourcesAPI {
|
|
7607
7675
|
constructor(client) {
|
|
7608
7676
|
this.client = client;
|
|
7677
|
+
/**
|
|
7678
|
+
* The `list` method retrieves a list of funding sources for a given user.
|
|
7679
|
+
*/
|
|
7609
7680
|
this.list = () => {
|
|
7610
7681
|
return this.client.get("/v1/funding_sources");
|
|
7611
7682
|
};
|
|
7683
|
+
/**
|
|
7684
|
+
* The `get` method retrieves a specific funding source by `fundingSourceId`.
|
|
7685
|
+
*/
|
|
7612
7686
|
this.get = (fundingSourceId) => {
|
|
7613
7687
|
return this.client.get(`/v1/funding_sources/${fundingSourceId}`);
|
|
7614
7688
|
};
|
|
7615
|
-
|
|
7689
|
+
/**
|
|
7690
|
+
* The `create` method creates a new funding source for a given user. This requires
|
|
7691
|
+
* payment information to be collected from the user.
|
|
7692
|
+
*/
|
|
7693
|
+
this.create = (createFundingSource) => __async$v(this, null, function* () {
|
|
7616
7694
|
const endUserIpAddress = yield getEndUserIpAddress();
|
|
7617
7695
|
if (!endUserIpAddress)
|
|
7618
7696
|
return Promise.reject([new CodedError("Unable to get IP address")]);
|
|
@@ -7620,7 +7698,12 @@ class FundingSourcesAPI {
|
|
|
7620
7698
|
endUserIpAddress
|
|
7621
7699
|
}, createFundingSource));
|
|
7622
7700
|
});
|
|
7623
|
-
|
|
7701
|
+
/**
|
|
7702
|
+
* The `update` method updates a funding source for a given user. This allows the
|
|
7703
|
+
* user to update the billing address or payment information associated with the
|
|
7704
|
+
* funding source.
|
|
7705
|
+
*/
|
|
7706
|
+
this.update = (billingInfo, creditCardInfo, fundingSourceId) => __async$v(this, null, function* () {
|
|
7624
7707
|
const endUserIpAddress = yield getEndUserIpAddress();
|
|
7625
7708
|
if (!endUserIpAddress)
|
|
7626
7709
|
return Promise.reject([new CodedError("Unable to get IP address")]);
|
|
@@ -7633,7 +7716,11 @@ class FundingSourcesAPI {
|
|
|
7633
7716
|
}
|
|
7634
7717
|
);
|
|
7635
7718
|
});
|
|
7636
|
-
|
|
7719
|
+
/**
|
|
7720
|
+
* The `registerCarrier` method registers a carrier account and associates
|
|
7721
|
+
* it with a given funding source.
|
|
7722
|
+
*/
|
|
7723
|
+
this.registerCarrier = (carrier) => __async$v(this, null, function* () {
|
|
7637
7724
|
const endUserIpAddress = yield getEndUserIpAddress();
|
|
7638
7725
|
if (!endUserIpAddress)
|
|
7639
7726
|
return Promise.reject([new CodedError("Unable to get IP address")]);
|
|
@@ -7641,7 +7728,10 @@ class FundingSourcesAPI {
|
|
|
7641
7728
|
endUserIpAddress
|
|
7642
7729
|
}, carrier));
|
|
7643
7730
|
});
|
|
7644
|
-
|
|
7731
|
+
/**
|
|
7732
|
+
* The `addFunds` method allows you to add funds to a funding source.
|
|
7733
|
+
*/
|
|
7734
|
+
this.addFunds = (amount, fundingSourceId) => __async$v(this, null, function* () {
|
|
7645
7735
|
return yield this.client.put(
|
|
7646
7736
|
`/v1/funding_sources/${fundingSourceId}/add_funds`,
|
|
7647
7737
|
amount
|
|
@@ -7654,6 +7744,10 @@ class FundingSourcesAPI {
|
|
|
7654
7744
|
class InsuranceAPI {
|
|
7655
7745
|
constructor(client) {
|
|
7656
7746
|
this.client = client;
|
|
7747
|
+
/**
|
|
7748
|
+
* The `get` method retrieves the insurance balance for a given `insuranceProvider`
|
|
7749
|
+
* by ID.
|
|
7750
|
+
*/
|
|
7657
7751
|
this.get = (insuranceProvider) => {
|
|
7658
7752
|
return this.client.get(`/v1/insurance/${insuranceProvider}/balance`);
|
|
7659
7753
|
};
|
|
@@ -7664,15 +7758,31 @@ class InsuranceAPI {
|
|
|
7664
7758
|
class LabelsAPI {
|
|
7665
7759
|
constructor(client) {
|
|
7666
7760
|
this.client = client;
|
|
7761
|
+
/**
|
|
7762
|
+
* The `get` method retrieves a specific label by `labelId`.
|
|
7763
|
+
*/
|
|
7667
7764
|
this.get = (labelId) => {
|
|
7668
7765
|
return this.client.get(`/v1/labels/${labelId}`);
|
|
7669
7766
|
};
|
|
7767
|
+
/**
|
|
7768
|
+
* The `list` method retrieves a list of labels created by a given user.
|
|
7769
|
+
*/
|
|
7670
7770
|
this.list = (params = {}) => {
|
|
7671
7771
|
return this.client.get("/v1/labels", { params });
|
|
7672
7772
|
};
|
|
7773
|
+
/**
|
|
7774
|
+
* The `createByRateId` allows you to create a shipping label by using a `rateId`
|
|
7775
|
+
* which is a unique identifier tied to a specific rate.
|
|
7776
|
+
*
|
|
7777
|
+
* This helps ensure that when a user is rate shopping, they can purchase a
|
|
7778
|
+
* label for the price they were initially rated.
|
|
7779
|
+
*/
|
|
7673
7780
|
this.createByRateId = (rateId, options) => {
|
|
7674
7781
|
return this.client.post(`/v1/labels/rates/${rateId}`, options);
|
|
7675
7782
|
};
|
|
7783
|
+
/**
|
|
7784
|
+
* The `void` method allows a user to void a label by `labelId`.
|
|
7785
|
+
*/
|
|
7676
7786
|
this.void = (labelId) => {
|
|
7677
7787
|
return this.client.put(`/v1/labels/${labelId}/void`);
|
|
7678
7788
|
};
|
|
@@ -7683,12 +7793,22 @@ class LabelsAPI {
|
|
|
7683
7793
|
class OrderSourcesAPI {
|
|
7684
7794
|
constructor(client) {
|
|
7685
7795
|
this.client = client;
|
|
7796
|
+
/**
|
|
7797
|
+
* The `list` method retrieves a list of connected order sources for a given user.
|
|
7798
|
+
*/
|
|
7686
7799
|
this.list = () => {
|
|
7687
7800
|
return this.client.get("/v-beta/order_sources");
|
|
7688
7801
|
};
|
|
7802
|
+
/**
|
|
7803
|
+
* The `get` method retrieves a specific order source by `orderSourceId`.
|
|
7804
|
+
*/
|
|
7689
7805
|
this.get = (orderSourceId) => {
|
|
7690
7806
|
return this.client.get(`/v-beta/order_sources/${orderSourceId}`);
|
|
7691
7807
|
};
|
|
7808
|
+
/**
|
|
7809
|
+
* The `refresh` method refreshes a specific order source by `orderSourceId`.
|
|
7810
|
+
* This will pull in any `new orders` since the last order import.
|
|
7811
|
+
*/
|
|
7692
7812
|
this.refresh = (orderSourceId) => {
|
|
7693
7813
|
return this.client.put(`/v-beta/order_sources/${orderSourceId}/refresh`);
|
|
7694
7814
|
};
|
|
@@ -7699,20 +7819,36 @@ class OrderSourcesAPI {
|
|
|
7699
7819
|
class RateCardsAPI {
|
|
7700
7820
|
constructor(client) {
|
|
7701
7821
|
this.client = client;
|
|
7822
|
+
/**
|
|
7823
|
+
* The `list` method retrieves a list of rate cards for a given list of carrier ID's.
|
|
7824
|
+
*/
|
|
7702
7825
|
this.list = (carrierIds) => {
|
|
7703
7826
|
return this.client.get(
|
|
7704
7827
|
`/v1/rate_cards?carrier_ids=${carrierIds.toString()}`
|
|
7705
7828
|
);
|
|
7706
7829
|
};
|
|
7830
|
+
/**
|
|
7831
|
+
* The `get` method retrieves a specific rate card by `rateCardId`.
|
|
7832
|
+
*/
|
|
7707
7833
|
this.get = (rateCardId) => {
|
|
7708
7834
|
return this.client.get(`/v1/rate_cards/${rateCardId}`);
|
|
7709
7835
|
};
|
|
7836
|
+
/**
|
|
7837
|
+
* The `create` method creates a new rate card for a given user.
|
|
7838
|
+
*/
|
|
7710
7839
|
this.create = (rateCardInput) => {
|
|
7711
7840
|
return this.client.post("/v1/rate_cards", rateCardInput);
|
|
7712
7841
|
};
|
|
7842
|
+
/**
|
|
7843
|
+
* The `update` method updates a specific rate card by `rateCardId` with a new
|
|
7844
|
+
* `RateCard`.
|
|
7845
|
+
*/
|
|
7713
7846
|
this.update = (rateCard) => {
|
|
7714
7847
|
return this.client.put(`/v1/rate_cards/${rateCard.id}`, rateCard);
|
|
7715
7848
|
};
|
|
7849
|
+
/**
|
|
7850
|
+
* The `download` method allows for downloading a given rate card by `rateCardId`.
|
|
7851
|
+
*/
|
|
7716
7852
|
this.download = (rateCardId) => {
|
|
7717
7853
|
return this.client.get(`/v1/rate_cards/${rateCardId}/rates/download`, {
|
|
7718
7854
|
headers: {
|
|
@@ -7721,6 +7857,9 @@ class RateCardsAPI {
|
|
|
7721
7857
|
responseType: "blob"
|
|
7722
7858
|
});
|
|
7723
7859
|
};
|
|
7860
|
+
/**
|
|
7861
|
+
* The `upload` method allows for uploading a given rate card as a spreadsheet file.
|
|
7862
|
+
*/
|
|
7724
7863
|
this.upload = (rateCardId, file) => {
|
|
7725
7864
|
const formData = new FormData();
|
|
7726
7865
|
formData.append("file", file);
|
|
@@ -7730,9 +7869,18 @@ class RateCardsAPI {
|
|
|
7730
7869
|
}
|
|
7731
7870
|
});
|
|
7732
7871
|
};
|
|
7872
|
+
/**
|
|
7873
|
+
* The `publish` method allows for publishing a given rate card by `rateCardId`.
|
|
7874
|
+
*/
|
|
7733
7875
|
this.publish = (rateCardId) => {
|
|
7734
7876
|
return this.client.post(`/v1/rate_cards/${rateCardId}/publish`);
|
|
7735
7877
|
};
|
|
7878
|
+
/**
|
|
7879
|
+
* @description https://auctane.atlassian.net/wiki/spaces/TE/pages/3837431603/Inc+1+3.+Rate+Card+Details#Delete-Rate-Card
|
|
7880
|
+
*/
|
|
7881
|
+
this.delete = (rateCardId) => {
|
|
7882
|
+
return this.client.delete(`/v1/rate_cards/${rateCardId}`);
|
|
7883
|
+
};
|
|
7736
7884
|
this.client = client;
|
|
7737
7885
|
}
|
|
7738
7886
|
}
|
|
@@ -7740,6 +7888,10 @@ class RateCardsAPI {
|
|
|
7740
7888
|
class RatesAPI {
|
|
7741
7889
|
constructor(client) {
|
|
7742
7890
|
this.client = client;
|
|
7891
|
+
/**
|
|
7892
|
+
* The `calculate` method calculates rates for a shipment by shipment ID based
|
|
7893
|
+
* on the shipment's options.
|
|
7894
|
+
*/
|
|
7743
7895
|
this.calculateByShipmentId = (shipmentId, options) => {
|
|
7744
7896
|
return this.client.post("/v1/rates", {
|
|
7745
7897
|
rateOptions: options,
|
|
@@ -7753,20 +7905,32 @@ class RatesAPI {
|
|
|
7753
7905
|
class SalesOrderShipmentsAPI {
|
|
7754
7906
|
constructor(client) {
|
|
7755
7907
|
this.client = client;
|
|
7908
|
+
/**
|
|
7909
|
+
* The `list` method retrieves a list of sales order shipments for a given user.
|
|
7910
|
+
*/
|
|
7756
7911
|
this.list = (body = {}, params) => {
|
|
7757
7912
|
return this.client.post("/v-beta/shipments/list", body, {
|
|
7758
7913
|
params
|
|
7759
7914
|
});
|
|
7760
7915
|
};
|
|
7916
|
+
/**
|
|
7917
|
+
* The `get` method retrieves a specific sales order shipment by `shipmentId`.
|
|
7918
|
+
*/
|
|
7761
7919
|
this.get = (shipmentId) => {
|
|
7762
7920
|
return this.client.get(`/v-beta/shipments/${shipmentId}`);
|
|
7763
7921
|
};
|
|
7922
|
+
/**
|
|
7923
|
+
* The `create` method creates a new shipment for a sales order.
|
|
7924
|
+
*/
|
|
7764
7925
|
this.create = (salesOrderId, shipment) => {
|
|
7765
7926
|
return this.client.post(
|
|
7766
7927
|
`/v-beta/shipments/sales_order/${salesOrderId}`,
|
|
7767
7928
|
shipment
|
|
7768
7929
|
);
|
|
7769
7930
|
};
|
|
7931
|
+
/**
|
|
7932
|
+
* The `update` method updates a specific sales order shipment by `shipmentId`.
|
|
7933
|
+
*/
|
|
7770
7934
|
this.update = (shipmentId, shipment) => {
|
|
7771
7935
|
return this.client.put(`/v-beta/shipments/${shipmentId}`, shipment);
|
|
7772
7936
|
};
|
|
@@ -7777,12 +7941,23 @@ class SalesOrderShipmentsAPI {
|
|
|
7777
7941
|
class SalesOrdersAPI {
|
|
7778
7942
|
constructor(client) {
|
|
7779
7943
|
this.client = client;
|
|
7944
|
+
/**
|
|
7945
|
+
* The `list` method retrieves a list of sales orders.
|
|
7946
|
+
*/
|
|
7780
7947
|
this.list = (params = {}) => {
|
|
7781
7948
|
return this.client.get("/v-beta/sales_orders", { params });
|
|
7782
7949
|
};
|
|
7950
|
+
/**
|
|
7951
|
+
* The `get` method retrieves a specific sales order by `salesOrderId`.
|
|
7952
|
+
*/
|
|
7783
7953
|
this.get = (salesOrderId) => {
|
|
7784
7954
|
return this.client.get(`/v-beta/sales_orders/${salesOrderId}`);
|
|
7785
7955
|
};
|
|
7956
|
+
/**
|
|
7957
|
+
* The `notifyShipped` method notifies order source that the order has been
|
|
7958
|
+
* shipped. Typically, the order source will then notify the user based on
|
|
7959
|
+
* this update from ShipEngine API.
|
|
7960
|
+
*/
|
|
7786
7961
|
this.notifyShipped = (salesOrderId, tracking) => {
|
|
7787
7962
|
return this.client.post(`/v-beta/sales_orders/${salesOrderId}/notify`, tracking);
|
|
7788
7963
|
};
|
|
@@ -7790,7 +7965,7 @@ class SalesOrdersAPI {
|
|
|
7790
7965
|
}
|
|
7791
7966
|
}
|
|
7792
7967
|
|
|
7793
|
-
var __async$
|
|
7968
|
+
var __async$u = (__this, __arguments, generator) => {
|
|
7794
7969
|
return new Promise((resolve, reject) => {
|
|
7795
7970
|
var fulfilled = (value) => {
|
|
7796
7971
|
try {
|
|
@@ -7813,16 +7988,27 @@ var __async$t = (__this, __arguments, generator) => {
|
|
|
7813
7988
|
class ShipmentsAPI {
|
|
7814
7989
|
constructor(client) {
|
|
7815
7990
|
this.client = client;
|
|
7991
|
+
/**
|
|
7992
|
+
* The `getShipmentRates` method retrieves rates for a given shipment by
|
|
7993
|
+
* shipment ID.
|
|
7994
|
+
*/
|
|
7816
7995
|
this.getShipmentRates = ({ shipmentId, createdAtStart }) => {
|
|
7817
7996
|
return this.client.get(
|
|
7818
7997
|
`/v1/shipments/${shipmentId}/rates`,
|
|
7819
7998
|
createdAtStart !== void 0 ? { params: { createdAtStart } } : void 0
|
|
7820
7999
|
);
|
|
7821
8000
|
};
|
|
8001
|
+
/**
|
|
8002
|
+
* The `list` method retrieves a list of shipments for a given user.
|
|
8003
|
+
*/
|
|
7822
8004
|
this.list = (options) => {
|
|
7823
8005
|
return this.client.get("/v1/shipments", { params: options });
|
|
7824
8006
|
};
|
|
7825
|
-
|
|
8007
|
+
/**
|
|
8008
|
+
* The `create` method allows for creating shipments based on a list of shipment
|
|
8009
|
+
* items passed into this method.
|
|
8010
|
+
*/
|
|
8011
|
+
this.create = (...shipments) => __async$u(this, null, function* () {
|
|
7826
8012
|
return this.client.post("/v1/shipments", {
|
|
7827
8013
|
shipments
|
|
7828
8014
|
});
|
|
@@ -7834,15 +8020,31 @@ class ShipmentsAPI {
|
|
|
7834
8020
|
class WarehousesAPI {
|
|
7835
8021
|
constructor(client) {
|
|
7836
8022
|
this.client = client;
|
|
8023
|
+
/**
|
|
8024
|
+
* The `list` method retrieves a list of `warehouses` (Ship From Locations)
|
|
8025
|
+
* for a given user.
|
|
8026
|
+
*/
|
|
7837
8027
|
this.list = () => {
|
|
7838
8028
|
return this.client.get("/v1/warehouses");
|
|
7839
8029
|
};
|
|
8030
|
+
/**
|
|
8031
|
+
* The `create` method allows for creation of warehouses (Ship From Locations)
|
|
8032
|
+
* on a users ShipEngine account.
|
|
8033
|
+
*/
|
|
7840
8034
|
this.create = (warehouse) => {
|
|
7841
8035
|
return this.client.post("/v1/warehouses", warehouse);
|
|
7842
8036
|
};
|
|
8037
|
+
/**
|
|
8038
|
+
* The `update` method updates a specific warehouse (Ship From Location) for a
|
|
8039
|
+
* given user by `warehouseId`.
|
|
8040
|
+
*/
|
|
7843
8041
|
this.update = (warehouseId, warehouse) => {
|
|
7844
8042
|
return this.client.put(`/v1/warehouses/${warehouseId}`, warehouse);
|
|
7845
8043
|
};
|
|
8044
|
+
/**
|
|
8045
|
+
* The `delete` method deletes a specific warehouse (Ship From Location) by
|
|
8046
|
+
* `warehouseId` from a users ShipEngine account.
|
|
8047
|
+
*/
|
|
7846
8048
|
this.delete = (warehouseId) => {
|
|
7847
8049
|
return this.client.delete(`/v1/warehouses/${warehouseId}`);
|
|
7848
8050
|
};
|
|
@@ -7869,7 +8071,7 @@ var __spreadValues$5 = (a, b) => {
|
|
|
7869
8071
|
return a;
|
|
7870
8072
|
};
|
|
7871
8073
|
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
|
7872
|
-
var __async$
|
|
8074
|
+
var __async$t = (__this, __arguments, generator) => {
|
|
7873
8075
|
return new Promise((resolve, reject) => {
|
|
7874
8076
|
var fulfilled = (value) => {
|
|
7875
8077
|
try {
|
|
@@ -7963,7 +8165,7 @@ class ShipEngineAPI {
|
|
|
7963
8165
|
);
|
|
7964
8166
|
return res;
|
|
7965
8167
|
},
|
|
7966
|
-
(err) => __async$
|
|
8168
|
+
(err) => __async$t(this, null, function* () {
|
|
7967
8169
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
7968
8170
|
logger$1.error(
|
|
7969
8171
|
{ err, req: err.config, res: err.response },
|
|
@@ -8003,48 +8205,135 @@ class ShipEngineAPI {
|
|
|
8003
8205
|
);
|
|
8004
8206
|
this.client = client;
|
|
8005
8207
|
}
|
|
8208
|
+
/**
|
|
8209
|
+
* The `token` method takes in a string and sets it as the Authorization header for all requests.
|
|
8210
|
+
*/
|
|
8006
8211
|
set token(token) {
|
|
8007
8212
|
this.client.defaults.headers.common["Authorization"] = `Bearer ${token}`;
|
|
8008
8213
|
}
|
|
8214
|
+
/**
|
|
8215
|
+
* The `accountSettings` method provides access to the Account Settings endpoints
|
|
8216
|
+
* in ShipEngine API.
|
|
8217
|
+
*
|
|
8218
|
+
* @see {@link AccountSettingsAPI | The Account Settings API module}
|
|
8219
|
+
*/
|
|
8009
8220
|
get accountSettings() {
|
|
8010
8221
|
return new AccountSettingsAPI(this.client);
|
|
8011
8222
|
}
|
|
8223
|
+
/**
|
|
8224
|
+
* The `addresses` method provides access to the Address Validation endpoints
|
|
8225
|
+
* in ShipEngine API. e.g. Validate Addresses, Parse Addresses, etc.
|
|
8226
|
+
*
|
|
8227
|
+
* @see {@link AddressesAPI | The Addresses API module}
|
|
8228
|
+
*/
|
|
8012
8229
|
get addresses() {
|
|
8013
8230
|
return new AddressesAPI(this.client);
|
|
8014
8231
|
}
|
|
8232
|
+
/**
|
|
8233
|
+
* The `carriers` method provides access to the Carrier endpoints in ShipEngine
|
|
8234
|
+
* API. e.g. List Carriers, Get Carrier, Connect Carrier, etc.
|
|
8235
|
+
*
|
|
8236
|
+
* @see {@link CarriersAPI | The Carriers API module}
|
|
8237
|
+
*/
|
|
8015
8238
|
get carriers() {
|
|
8016
8239
|
return new CarriersAPI(this.client);
|
|
8017
8240
|
}
|
|
8241
|
+
/**
|
|
8242
|
+
* The `customPackages` method provides access to the Packages endpoint in ShipEngine
|
|
8243
|
+
* API. e.g. List Packages
|
|
8244
|
+
*
|
|
8245
|
+
* @see {@link CustomPackagesAPI | The Custom Packages API module}
|
|
8246
|
+
*/
|
|
8018
8247
|
get customPackages() {
|
|
8019
8248
|
return new CustomPackagesAPI(this.client);
|
|
8020
8249
|
}
|
|
8250
|
+
/**
|
|
8251
|
+
* The `fundingSources` method provides access to the Funding Sources endpoints
|
|
8252
|
+
* in ShipEngine API.
|
|
8253
|
+
*
|
|
8254
|
+
* @see {@link FundingSourcesAPI | The Funding Sources API module}
|
|
8255
|
+
*/
|
|
8021
8256
|
get fundingSources() {
|
|
8022
8257
|
return new FundingSourcesAPI(this.client);
|
|
8023
8258
|
}
|
|
8259
|
+
/**
|
|
8260
|
+
* The `insurance` method provides access to the Insurance endpoint in ShipEngine
|
|
8261
|
+
* API. e.g. Get Insurance Balance
|
|
8262
|
+
*
|
|
8263
|
+
* @see {@link InsuranceAPI | The Insurance API module}
|
|
8264
|
+
*/
|
|
8024
8265
|
get insurance() {
|
|
8025
8266
|
return new InsuranceAPI(this.client);
|
|
8026
8267
|
}
|
|
8268
|
+
/**
|
|
8269
|
+
* The `labels` method provides access to the Label endpoints in ShipEngine API.
|
|
8270
|
+
* e.g. Create Label, Get Label, Void Label, etc.
|
|
8271
|
+
*
|
|
8272
|
+
* @see {@link LabelsAPI | The Labels API module}
|
|
8273
|
+
*/
|
|
8027
8274
|
get labels() {
|
|
8028
8275
|
return new LabelsAPI(this.client);
|
|
8029
8276
|
}
|
|
8277
|
+
/**
|
|
8278
|
+
* The `orderSources` method provides access to the Order Sources endpoints in
|
|
8279
|
+
* ShipEngine API. e.g. List Order Sources, Get Order Source, Refresh Order Source, etc.
|
|
8280
|
+
*
|
|
8281
|
+
* @see {@link OrderSourcesAPI | The Order Sources API module}
|
|
8282
|
+
*/
|
|
8030
8283
|
get orderSources() {
|
|
8031
8284
|
return new OrderSourcesAPI(this.client);
|
|
8032
8285
|
}
|
|
8286
|
+
/**
|
|
8287
|
+
* The `rateCards` method provides access to the Rate Cards endpoints in ShipEngine
|
|
8288
|
+
* API.
|
|
8289
|
+
*
|
|
8290
|
+
* @see {@link RateCardsAPI | The Rate Cards API module}
|
|
8291
|
+
*/
|
|
8033
8292
|
get rateCards() {
|
|
8034
8293
|
return new RateCardsAPI(this.client);
|
|
8035
8294
|
}
|
|
8295
|
+
/**
|
|
8296
|
+
* The `rates` method provides access to the Rate endpoints in ShipEngine API.
|
|
8297
|
+
* e.g. Get Rates
|
|
8298
|
+
*
|
|
8299
|
+
* @see {@link RatesAPI | The Rates API module}
|
|
8300
|
+
*/
|
|
8036
8301
|
get rates() {
|
|
8037
8302
|
return new RatesAPI(this.client);
|
|
8038
8303
|
}
|
|
8304
|
+
/**
|
|
8305
|
+
* The `salesOrderShipments` method provides access to the `v-beta` Sales
|
|
8306
|
+
* Order Shipments endpoints in ShipEngine API.
|
|
8307
|
+
*
|
|
8308
|
+
* @see {@link SalesOrderShipmentsAPI | The Sales Order Shipments API module}
|
|
8309
|
+
*/
|
|
8039
8310
|
get salesOrderShipments() {
|
|
8040
8311
|
return new SalesOrderShipmentsAPI(this.client);
|
|
8041
8312
|
}
|
|
8313
|
+
/**
|
|
8314
|
+
* The `salesOrders` method provides access to the `v-beta` Sales Order endpoints
|
|
8315
|
+
* in ShipEngine API.
|
|
8316
|
+
*
|
|
8317
|
+
* @see {@link SalesOrdersAPI | The Sales Orders API module}
|
|
8318
|
+
*/
|
|
8042
8319
|
get salesOrders() {
|
|
8043
8320
|
return new SalesOrdersAPI(this.client);
|
|
8044
8321
|
}
|
|
8322
|
+
/**
|
|
8323
|
+
* The `shipments` method provides access to the Shipment endpoints in ShipEngine
|
|
8324
|
+
* API. e.g. Create Shipment, Get Shipment, etc.
|
|
8325
|
+
*
|
|
8326
|
+
* @see {@link ShipmentsAPI | The Shipments API module}
|
|
8327
|
+
*/
|
|
8045
8328
|
get shipments() {
|
|
8046
8329
|
return new ShipmentsAPI(this.client);
|
|
8047
8330
|
}
|
|
8331
|
+
/**
|
|
8332
|
+
* The `warehouses` method provides access to the Warehouses endpoints in ShipEngine
|
|
8333
|
+
* API. e.g. List Warehouses, Get Warehouse, etc.
|
|
8334
|
+
*
|
|
8335
|
+
* @see {@link WarehousesAPI | The Warehouses API module}
|
|
8336
|
+
*/
|
|
8048
8337
|
get warehouses() {
|
|
8049
8338
|
return new WarehousesAPI(this.client);
|
|
8050
8339
|
}
|
|
@@ -8155,7 +8444,17 @@ const retryUntil = (callbackFn, retries = 10, timeoutBetweenAttempts = 1e3) => P
|
|
|
8155
8444
|
throw error;
|
|
8156
8445
|
});
|
|
8157
8446
|
|
|
8158
|
-
|
|
8447
|
+
const useGetAccountSettings = () => {
|
|
8448
|
+
const { client } = useShipEngine();
|
|
8449
|
+
return reactQuery.useQuery({
|
|
8450
|
+
onError,
|
|
8451
|
+
queryFn: () => client.accountSettings.get(),
|
|
8452
|
+
queryKey: ["getAccountSettings"],
|
|
8453
|
+
select: (result) => result.data
|
|
8454
|
+
});
|
|
8455
|
+
};
|
|
8456
|
+
|
|
8457
|
+
var __async$s = (__this, __arguments, generator) => {
|
|
8159
8458
|
return new Promise((resolve, reject) => {
|
|
8160
8459
|
var fulfilled = (value) => {
|
|
8161
8460
|
try {
|
|
@@ -8175,19 +8474,19 @@ var __async$r = (__this, __arguments, generator) => {
|
|
|
8175
8474
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
8176
8475
|
});
|
|
8177
8476
|
};
|
|
8178
|
-
const
|
|
8477
|
+
const useUpdateAccountSettings = () => {
|
|
8179
8478
|
const { client } = useShipEngine();
|
|
8180
8479
|
return reactQuery.useMutation({
|
|
8181
|
-
mutationFn: (
|
|
8182
|
-
const result = yield client.
|
|
8480
|
+
mutationFn: (settings) => __async$s(void 0, null, function* () {
|
|
8481
|
+
const result = yield client.accountSettings.update(settings);
|
|
8183
8482
|
return result.data;
|
|
8184
8483
|
}),
|
|
8185
|
-
mutationKey: ["
|
|
8484
|
+
mutationKey: ["useUpdateAccountSettings"],
|
|
8186
8485
|
onError
|
|
8187
8486
|
});
|
|
8188
8487
|
};
|
|
8189
8488
|
|
|
8190
|
-
var __async$
|
|
8489
|
+
var __async$r = (__this, __arguments, generator) => {
|
|
8191
8490
|
return new Promise((resolve, reject) => {
|
|
8192
8491
|
var fulfilled = (value) => {
|
|
8193
8492
|
try {
|
|
@@ -8207,19 +8506,19 @@ var __async$q = (__this, __arguments, generator) => {
|
|
|
8207
8506
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
8208
8507
|
});
|
|
8209
8508
|
};
|
|
8210
|
-
const
|
|
8509
|
+
const useParseAddress = () => {
|
|
8211
8510
|
const { client } = useShipEngine();
|
|
8212
8511
|
return reactQuery.useMutation({
|
|
8213
|
-
mutationFn: (_0) => __async$
|
|
8214
|
-
const result = yield client.
|
|
8512
|
+
mutationFn: (_0) => __async$r(void 0, [_0], function* ({ address, text }) {
|
|
8513
|
+
const result = yield client.addresses.parse(text, address);
|
|
8215
8514
|
return result.data;
|
|
8216
8515
|
}),
|
|
8217
|
-
mutationKey: ["
|
|
8516
|
+
mutationKey: ["useParseAddress"],
|
|
8218
8517
|
onError
|
|
8219
8518
|
});
|
|
8220
8519
|
};
|
|
8221
8520
|
|
|
8222
|
-
var __async$
|
|
8521
|
+
var __async$q = (__this, __arguments, generator) => {
|
|
8223
8522
|
return new Promise((resolve, reject) => {
|
|
8224
8523
|
var fulfilled = (value) => {
|
|
8225
8524
|
try {
|
|
@@ -8239,19 +8538,19 @@ var __async$p = (__this, __arguments, generator) => {
|
|
|
8239
8538
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
8240
8539
|
});
|
|
8241
8540
|
};
|
|
8242
|
-
const
|
|
8541
|
+
const useValidateAddresses = () => {
|
|
8243
8542
|
const { client } = useShipEngine();
|
|
8244
8543
|
return reactQuery.useMutation({
|
|
8245
|
-
mutationFn: (
|
|
8246
|
-
const result = yield client.
|
|
8544
|
+
mutationFn: (addresses) => __async$q(void 0, null, function* () {
|
|
8545
|
+
const result = yield client.addresses.validate(addresses);
|
|
8247
8546
|
return result.data;
|
|
8248
8547
|
}),
|
|
8249
|
-
mutationKey: ["
|
|
8548
|
+
mutationKey: ["useValidateAddresses"],
|
|
8250
8549
|
onError
|
|
8251
8550
|
});
|
|
8252
8551
|
};
|
|
8253
8552
|
|
|
8254
|
-
var __async$
|
|
8553
|
+
var __async$p = (__this, __arguments, generator) => {
|
|
8255
8554
|
return new Promise((resolve, reject) => {
|
|
8256
8555
|
var fulfilled = (value) => {
|
|
8257
8556
|
try {
|
|
@@ -8271,34 +8570,19 @@ var __async$o = (__this, __arguments, generator) => {
|
|
|
8271
8570
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
8272
8571
|
});
|
|
8273
8572
|
};
|
|
8274
|
-
const
|
|
8573
|
+
const useAddFunds = (carrierId) => {
|
|
8275
8574
|
const { client } = useShipEngine();
|
|
8276
8575
|
return reactQuery.useMutation({
|
|
8277
|
-
mutationFn: (
|
|
8278
|
-
const result = yield client.
|
|
8576
|
+
mutationFn: (funds) => __async$p(void 0, null, function* () {
|
|
8577
|
+
const result = yield client.carriers.addFunds(carrierId, funds);
|
|
8279
8578
|
return result.data;
|
|
8280
8579
|
}),
|
|
8281
|
-
mutationKey: ["
|
|
8580
|
+
mutationKey: ["useAddFunds"],
|
|
8282
8581
|
onError
|
|
8283
8582
|
});
|
|
8284
8583
|
};
|
|
8285
8584
|
|
|
8286
|
-
var
|
|
8287
|
-
var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
|
|
8288
|
-
var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
|
|
8289
|
-
var __objRest$6 = (source, exclude) => {
|
|
8290
|
-
var target = {};
|
|
8291
|
-
for (var prop in source)
|
|
8292
|
-
if (__hasOwnProp$9.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
8293
|
-
target[prop] = source[prop];
|
|
8294
|
-
if (source != null && __getOwnPropSymbols$9)
|
|
8295
|
-
for (var prop of __getOwnPropSymbols$9(source)) {
|
|
8296
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$9.call(source, prop))
|
|
8297
|
-
target[prop] = source[prop];
|
|
8298
|
-
}
|
|
8299
|
-
return target;
|
|
8300
|
-
};
|
|
8301
|
-
var __async$n = (__this, __arguments, generator) => {
|
|
8585
|
+
var __async$o = (__this, __arguments, generator) => {
|
|
8302
8586
|
return new Promise((resolve, reject) => {
|
|
8303
8587
|
var fulfilled = (value) => {
|
|
8304
8588
|
try {
|
|
@@ -8318,20 +8602,147 @@ var __async$n = (__this, __arguments, generator) => {
|
|
|
8318
8602
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
8319
8603
|
});
|
|
8320
8604
|
};
|
|
8321
|
-
const
|
|
8605
|
+
const useConnectCarrier = () => {
|
|
8322
8606
|
const { client } = useShipEngine();
|
|
8323
8607
|
return reactQuery.useMutation({
|
|
8324
|
-
mutationFn: (
|
|
8325
|
-
|
|
8326
|
-
const result = yield client.labels.createByRateId(rateId, options);
|
|
8608
|
+
mutationFn: (params) => __async$o(void 0, null, function* () {
|
|
8609
|
+
const result = yield client.carriers.connect(params);
|
|
8327
8610
|
return result.data;
|
|
8328
8611
|
}),
|
|
8329
|
-
mutationKey: ["
|
|
8612
|
+
mutationKey: ["useConnectCarrier"],
|
|
8330
8613
|
onError
|
|
8331
8614
|
});
|
|
8332
8615
|
};
|
|
8333
8616
|
|
|
8334
|
-
|
|
8617
|
+
const useGetAutoFundingConfiguration = (carrierId) => {
|
|
8618
|
+
const { client } = useShipEngine();
|
|
8619
|
+
return reactQuery.useQuery({
|
|
8620
|
+
enabled: carrierId !== void 0,
|
|
8621
|
+
onError,
|
|
8622
|
+
queryFn: () => {
|
|
8623
|
+
if (carrierId)
|
|
8624
|
+
return client.carriers.getAutoFunding(carrierId);
|
|
8625
|
+
return Promise.reject(new Error("carrierId is required."));
|
|
8626
|
+
},
|
|
8627
|
+
queryKey: ["useGetAutoFundingConfiguration", carrierId],
|
|
8628
|
+
select: (result) => result.data
|
|
8629
|
+
});
|
|
8630
|
+
};
|
|
8631
|
+
|
|
8632
|
+
const useGetCarrierById = (carrierId) => {
|
|
8633
|
+
const { client } = useShipEngine();
|
|
8634
|
+
return reactQuery.useQuery({
|
|
8635
|
+
enabled: !!carrierId,
|
|
8636
|
+
onError,
|
|
8637
|
+
queryFn: () => {
|
|
8638
|
+
if (carrierId)
|
|
8639
|
+
return client.carriers.get(carrierId);
|
|
8640
|
+
return Promise.reject(new Error("carrierId is require"));
|
|
8641
|
+
},
|
|
8642
|
+
queryKey: ["useGetCarrierById", carrierId],
|
|
8643
|
+
select: (result) => result.data,
|
|
8644
|
+
// Fresh for 5 minutes
|
|
8645
|
+
staleTime: 5 * 60 * 1e3
|
|
8646
|
+
});
|
|
8647
|
+
};
|
|
8648
|
+
|
|
8649
|
+
const useGetCountriesByCarrier = (carrierId) => {
|
|
8650
|
+
const { client } = useShipEngine();
|
|
8651
|
+
return reactQuery.useQuery({
|
|
8652
|
+
enabled: !!carrierId,
|
|
8653
|
+
onError,
|
|
8654
|
+
queryFn: () => {
|
|
8655
|
+
if (carrierId)
|
|
8656
|
+
return client.carriers.getCountries(carrierId);
|
|
8657
|
+
return Promise.reject(new Error("carrierId is require"));
|
|
8658
|
+
},
|
|
8659
|
+
queryKey: ["useGetCountriesByCarrier", carrierId],
|
|
8660
|
+
select: (result) => result.data.countries,
|
|
8661
|
+
// Fresh for 5 minutes
|
|
8662
|
+
staleTime: 5 * 60 * 1e3
|
|
8663
|
+
});
|
|
8664
|
+
};
|
|
8665
|
+
|
|
8666
|
+
const useGetCurrenciesByCarrier = (carrierId) => {
|
|
8667
|
+
const { client } = useShipEngine();
|
|
8668
|
+
return reactQuery.useQuery({
|
|
8669
|
+
enabled: !!carrierId,
|
|
8670
|
+
onError,
|
|
8671
|
+
queryFn: () => {
|
|
8672
|
+
if (carrierId)
|
|
8673
|
+
return client.carriers.getCurrencies(carrierId);
|
|
8674
|
+
return Promise.reject(new Error("carrierId is require"));
|
|
8675
|
+
},
|
|
8676
|
+
queryKey: ["useGetCurrenciesByCarrier", carrierId],
|
|
8677
|
+
select: (result) => result.data.currencies,
|
|
8678
|
+
// Fresh for 5 minutes
|
|
8679
|
+
staleTime: 5 * 60 * 1e3
|
|
8680
|
+
});
|
|
8681
|
+
};
|
|
8682
|
+
|
|
8683
|
+
const useGetPackageRatingGroupByCarrier = (carrierId) => {
|
|
8684
|
+
const { client } = useShipEngine();
|
|
8685
|
+
return reactQuery.useQuery({
|
|
8686
|
+
enabled: !!carrierId,
|
|
8687
|
+
onError,
|
|
8688
|
+
queryFn: () => {
|
|
8689
|
+
if (carrierId)
|
|
8690
|
+
return client.carriers.getPackageRatingGroup(carrierId);
|
|
8691
|
+
return Promise.reject(new Error("carrierId is required"));
|
|
8692
|
+
},
|
|
8693
|
+
queryKey: ["useGetRatePackageFormatsByCarrier", carrierId],
|
|
8694
|
+
select: (result) => result.data.packageRatingGroup,
|
|
8695
|
+
// Fresh for 5 minutes
|
|
8696
|
+
staleTime: 5 * 60 * 1e3
|
|
8697
|
+
});
|
|
8698
|
+
};
|
|
8699
|
+
|
|
8700
|
+
const useGetServicesByCarrier = (carrierId) => {
|
|
8701
|
+
const { client } = useShipEngine();
|
|
8702
|
+
return reactQuery.useQuery({
|
|
8703
|
+
enabled: !!carrierId,
|
|
8704
|
+
onError,
|
|
8705
|
+
queryFn: () => {
|
|
8706
|
+
if (carrierId)
|
|
8707
|
+
return client.carriers.getServices(carrierId);
|
|
8708
|
+
return Promise.reject(new Error("carrierId is required"));
|
|
8709
|
+
},
|
|
8710
|
+
queryKey: ["useGetServicesByCarrier", carrierId],
|
|
8711
|
+
select: (result) => result.data.services,
|
|
8712
|
+
// Fresh for 5 minutes
|
|
8713
|
+
staleTime: 5 * 60 * 1e3
|
|
8714
|
+
});
|
|
8715
|
+
};
|
|
8716
|
+
|
|
8717
|
+
const useGetWalletHistory = ({
|
|
8718
|
+
enabled,
|
|
8719
|
+
page,
|
|
8720
|
+
range
|
|
8721
|
+
}) => {
|
|
8722
|
+
const { client } = useShipEngine();
|
|
8723
|
+
const [startDate, endDate] = range;
|
|
8724
|
+
return reactQuery.useQuery({
|
|
8725
|
+
enabled,
|
|
8726
|
+
keepPreviousData: true,
|
|
8727
|
+
// See https://react-query-v3.tanstack.com/guides/paginated-queries#better-paginated-queries-with-keeppreviousdata
|
|
8728
|
+
onError,
|
|
8729
|
+
queryFn: () => client.carriers.getWalletHistory(startDate, endDate, page),
|
|
8730
|
+
queryKey: ["useGetWalletHistory", startDate, endDate, page],
|
|
8731
|
+
select: (result) => result.data
|
|
8732
|
+
});
|
|
8733
|
+
};
|
|
8734
|
+
|
|
8735
|
+
const useListCarriers = () => {
|
|
8736
|
+
const { client } = useShipEngine();
|
|
8737
|
+
return reactQuery.useQuery({
|
|
8738
|
+
onError,
|
|
8739
|
+
queryFn: () => client.carriers.list(),
|
|
8740
|
+
queryKey: ["useListCarriers"],
|
|
8741
|
+
select: (result) => result.data.carriers
|
|
8742
|
+
});
|
|
8743
|
+
};
|
|
8744
|
+
|
|
8745
|
+
var __async$n = (__this, __arguments, generator) => {
|
|
8335
8746
|
return new Promise((resolve, reject) => {
|
|
8336
8747
|
var fulfilled = (value) => {
|
|
8337
8748
|
try {
|
|
@@ -8351,34 +8762,33 @@ var __async$m = (__this, __arguments, generator) => {
|
|
|
8351
8762
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
8352
8763
|
});
|
|
8353
8764
|
};
|
|
8354
|
-
const
|
|
8765
|
+
const useUpdateAutoFunding = (carrierId) => {
|
|
8355
8766
|
const { client } = useShipEngine();
|
|
8767
|
+
const queryClient = reactQuery.useQueryClient();
|
|
8356
8768
|
return reactQuery.useMutation({
|
|
8357
|
-
mutationFn: (
|
|
8358
|
-
const result = yield client.
|
|
8769
|
+
mutationFn: (options) => __async$n(void 0, null, function* () {
|
|
8770
|
+
const result = yield client.carriers.updateAutoFunding(carrierId, options);
|
|
8359
8771
|
return result.data;
|
|
8360
8772
|
}),
|
|
8361
|
-
mutationKey: ["
|
|
8362
|
-
onError
|
|
8773
|
+
mutationKey: ["useUpdateAutoFunding"],
|
|
8774
|
+
onError,
|
|
8775
|
+
onSuccess: (_) => {
|
|
8776
|
+
queryClient.invalidateQueries(["useGetAutoFunding", carrierId], { exact: true });
|
|
8777
|
+
}
|
|
8363
8778
|
});
|
|
8364
8779
|
};
|
|
8365
8780
|
|
|
8366
|
-
|
|
8367
|
-
|
|
8368
|
-
|
|
8369
|
-
|
|
8370
|
-
|
|
8371
|
-
|
|
8372
|
-
|
|
8373
|
-
|
|
8374
|
-
if (source != null && __getOwnPropSymbols$8)
|
|
8375
|
-
for (var prop of __getOwnPropSymbols$8(source)) {
|
|
8376
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$8.call(source, prop))
|
|
8377
|
-
target[prop] = source[prop];
|
|
8378
|
-
}
|
|
8379
|
-
return target;
|
|
8781
|
+
const useListCustomPackageTypes = () => {
|
|
8782
|
+
const { client } = useShipEngine();
|
|
8783
|
+
return reactQuery.useQuery({
|
|
8784
|
+
onError,
|
|
8785
|
+
queryFn: () => client.customPackages.list(),
|
|
8786
|
+
queryKey: ["useListCustomPackageTypes"],
|
|
8787
|
+
select: (result) => result.data.packages
|
|
8788
|
+
});
|
|
8380
8789
|
};
|
|
8381
|
-
|
|
8790
|
+
|
|
8791
|
+
var __async$m = (__this, __arguments, generator) => {
|
|
8382
8792
|
return new Promise((resolve, reject) => {
|
|
8383
8793
|
var fulfilled = (value) => {
|
|
8384
8794
|
try {
|
|
@@ -8398,39 +8808,19 @@ var __async$l = (__this, __arguments, generator) => {
|
|
|
8398
8808
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
8399
8809
|
});
|
|
8400
8810
|
};
|
|
8401
|
-
const
|
|
8811
|
+
const useCreateFundingSource = () => {
|
|
8402
8812
|
const { client } = useShipEngine();
|
|
8403
8813
|
return reactQuery.useMutation({
|
|
8404
|
-
mutationFn: (
|
|
8405
|
-
|
|
8406
|
-
const result = yield client.salesOrderShipments.create(salesOrderId, shipment);
|
|
8814
|
+
mutationFn: (fundingSource) => __async$m(void 0, null, function* () {
|
|
8815
|
+
const result = yield client.fundingSources.create(fundingSource);
|
|
8407
8816
|
return result.data;
|
|
8408
8817
|
}),
|
|
8409
|
-
mutationKey: ["
|
|
8818
|
+
mutationKey: ["useCreateFundingSource"],
|
|
8410
8819
|
onError
|
|
8411
8820
|
});
|
|
8412
8821
|
};
|
|
8413
8822
|
|
|
8414
|
-
var
|
|
8415
|
-
var __defProps$2 = Object.defineProperties;
|
|
8416
|
-
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
8417
|
-
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
|
8418
|
-
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
|
8419
|
-
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
|
8420
|
-
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8421
|
-
var __spreadValues$3 = (a, b) => {
|
|
8422
|
-
for (var prop in b || (b = {}))
|
|
8423
|
-
if (__hasOwnProp$7.call(b, prop))
|
|
8424
|
-
__defNormalProp$3(a, prop, b[prop]);
|
|
8425
|
-
if (__getOwnPropSymbols$7)
|
|
8426
|
-
for (var prop of __getOwnPropSymbols$7(b)) {
|
|
8427
|
-
if (__propIsEnum$7.call(b, prop))
|
|
8428
|
-
__defNormalProp$3(a, prop, b[prop]);
|
|
8429
|
-
}
|
|
8430
|
-
return a;
|
|
8431
|
-
};
|
|
8432
|
-
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
8433
|
-
var __async$k = (__this, __arguments, generator) => {
|
|
8823
|
+
var __async$l = (__this, __arguments, generator) => {
|
|
8434
8824
|
return new Promise((resolve, reject) => {
|
|
8435
8825
|
var fulfilled = (value) => {
|
|
8436
8826
|
try {
|
|
@@ -8450,69 +8840,39 @@ var __async$k = (__this, __arguments, generator) => {
|
|
|
8450
8840
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
8451
8841
|
});
|
|
8452
8842
|
};
|
|
8453
|
-
const
|
|
8843
|
+
const useFundingSourcesAddFunds = (fundingSourceId) => {
|
|
8454
8844
|
const { client } = useShipEngine();
|
|
8455
8845
|
return reactQuery.useMutation({
|
|
8456
|
-
mutationFn: (
|
|
8457
|
-
|
|
8458
|
-
|
|
8459
|
-
throw new CodedError("errorMessages.noWarehouses", {
|
|
8460
|
-
errorCode: "unknown",
|
|
8461
|
-
errorSource: "client",
|
|
8462
|
-
errorType: "business_rules"
|
|
8463
|
-
});
|
|
8464
|
-
}
|
|
8465
|
-
const shipTo = (_a = shipment.shipTo) != null ? _a : {
|
|
8466
|
-
addressLine1: "",
|
|
8467
|
-
cityLocality: "",
|
|
8468
|
-
countryCode: "",
|
|
8469
|
-
name: "",
|
|
8470
|
-
phone: "",
|
|
8471
|
-
postalCode: "",
|
|
8472
|
-
stateProvince: ""
|
|
8473
|
-
};
|
|
8474
|
-
return (yield client.shipments.create(__spreadProps$2(__spreadValues$3({}, shipment), {
|
|
8475
|
-
shipTo
|
|
8476
|
-
}))).data;
|
|
8846
|
+
mutationFn: (funds) => __async$l(void 0, null, function* () {
|
|
8847
|
+
const result = yield client.fundingSources.addFunds(funds, fundingSourceId);
|
|
8848
|
+
return result.data;
|
|
8477
8849
|
}),
|
|
8478
|
-
mutationKey: ["
|
|
8850
|
+
mutationKey: ["useFundingSourcesAddFunds"],
|
|
8479
8851
|
onError
|
|
8480
8852
|
});
|
|
8481
8853
|
};
|
|
8482
8854
|
|
|
8483
|
-
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
}
|
|
8491
|
-
};
|
|
8492
|
-
var rejected = (value) => {
|
|
8493
|
-
try {
|
|
8494
|
-
step(generator.throw(value));
|
|
8495
|
-
} catch (e) {
|
|
8496
|
-
reject(e);
|
|
8497
|
-
}
|
|
8498
|
-
};
|
|
8499
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
8500
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
8855
|
+
const useGetFundingSourceById = (fundingSourceId) => {
|
|
8856
|
+
const { client } = useShipEngine();
|
|
8857
|
+
return reactQuery.useQuery({
|
|
8858
|
+
onError,
|
|
8859
|
+
queryFn: () => client.fundingSources.get(fundingSourceId),
|
|
8860
|
+
queryKey: ["getFundingSourceById"],
|
|
8861
|
+
select: (result) => result.data
|
|
8501
8862
|
});
|
|
8502
8863
|
};
|
|
8503
|
-
|
|
8864
|
+
|
|
8865
|
+
const useListFundingSources = () => {
|
|
8504
8866
|
const { client } = useShipEngine();
|
|
8505
|
-
return reactQuery.
|
|
8506
|
-
|
|
8507
|
-
|
|
8508
|
-
|
|
8509
|
-
|
|
8510
|
-
mutationKey: ["useCreateWarehouse"],
|
|
8511
|
-
onError
|
|
8867
|
+
return reactQuery.useQuery({
|
|
8868
|
+
onError,
|
|
8869
|
+
queryFn: () => client.fundingSources.list(),
|
|
8870
|
+
queryKey: ["useListFundingSources"],
|
|
8871
|
+
select: (result) => result.data.fundingSources
|
|
8512
8872
|
});
|
|
8513
8873
|
};
|
|
8514
8874
|
|
|
8515
|
-
var __async$
|
|
8875
|
+
var __async$k = (__this, __arguments, generator) => {
|
|
8516
8876
|
return new Promise((resolve, reject) => {
|
|
8517
8877
|
var fulfilled = (value) => {
|
|
8518
8878
|
try {
|
|
@@ -8532,31 +8892,19 @@ var __async$i = (__this, __arguments, generator) => {
|
|
|
8532
8892
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
8533
8893
|
});
|
|
8534
8894
|
};
|
|
8535
|
-
const
|
|
8895
|
+
const useRegisterCarrier = () => {
|
|
8536
8896
|
const { client } = useShipEngine();
|
|
8537
8897
|
return reactQuery.useMutation({
|
|
8538
|
-
mutationFn: (
|
|
8539
|
-
const result = yield client.
|
|
8898
|
+
mutationFn: (carrier) => __async$k(void 0, null, function* () {
|
|
8899
|
+
const result = yield client.fundingSources.registerCarrier(carrier);
|
|
8540
8900
|
return result.data;
|
|
8541
8901
|
}),
|
|
8542
|
-
mutationKey: ["
|
|
8902
|
+
mutationKey: ["useRegisterCarrier"],
|
|
8543
8903
|
onError
|
|
8544
8904
|
});
|
|
8545
8905
|
};
|
|
8546
8906
|
|
|
8547
|
-
|
|
8548
|
-
const { client } = useShipEngine();
|
|
8549
|
-
return reactQuery.useQuery({
|
|
8550
|
-
enabled: !!rateCardId.length,
|
|
8551
|
-
onError,
|
|
8552
|
-
queryFn: () => {
|
|
8553
|
-
return client.rateCards.download(rateCardId);
|
|
8554
|
-
},
|
|
8555
|
-
queryKey: ["useDownloadRateCard", rateCardId]
|
|
8556
|
-
});
|
|
8557
|
-
};
|
|
8558
|
-
|
|
8559
|
-
var __async$h = (__this, __arguments, generator) => {
|
|
8907
|
+
var __async$j = (__this, __arguments, generator) => {
|
|
8560
8908
|
return new Promise((resolve, reject) => {
|
|
8561
8909
|
var fulfilled = (value) => {
|
|
8562
8910
|
try {
|
|
@@ -8576,104 +8924,26 @@ var __async$h = (__this, __arguments, generator) => {
|
|
|
8576
8924
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
8577
8925
|
});
|
|
8578
8926
|
};
|
|
8579
|
-
const
|
|
8927
|
+
const useUpdateFundingSource = () => {
|
|
8580
8928
|
const { client } = useShipEngine();
|
|
8581
8929
|
return reactQuery.useMutation({
|
|
8582
|
-
mutationFn: (
|
|
8583
|
-
|
|
8930
|
+
mutationFn: (_0) => __async$j(void 0, [_0], function* ({
|
|
8931
|
+
billingInfo,
|
|
8932
|
+
creditCardInfo,
|
|
8933
|
+
fundingSourceId
|
|
8934
|
+
}) {
|
|
8935
|
+
const result = yield client.fundingSources.update(
|
|
8936
|
+
billingInfo,
|
|
8937
|
+
creditCardInfo,
|
|
8938
|
+
fundingSourceId
|
|
8939
|
+
);
|
|
8584
8940
|
return result.data;
|
|
8585
8941
|
}),
|
|
8586
|
-
mutationKey: ["
|
|
8942
|
+
mutationKey: ["useUpdateFundingSource"],
|
|
8587
8943
|
onError
|
|
8588
8944
|
});
|
|
8589
8945
|
};
|
|
8590
8946
|
|
|
8591
|
-
const useGetAccountSettings = () => {
|
|
8592
|
-
const { client } = useShipEngine();
|
|
8593
|
-
return reactQuery.useQuery({
|
|
8594
|
-
onError,
|
|
8595
|
-
queryFn: () => client.accountSettings.get(),
|
|
8596
|
-
queryKey: ["getAccountSettings"],
|
|
8597
|
-
select: (result) => result.data
|
|
8598
|
-
});
|
|
8599
|
-
};
|
|
8600
|
-
|
|
8601
|
-
const useGetAutoFundingConfiguration = (carrierId) => {
|
|
8602
|
-
const { client } = useShipEngine();
|
|
8603
|
-
return reactQuery.useQuery({
|
|
8604
|
-
enabled: carrierId !== void 0,
|
|
8605
|
-
onError,
|
|
8606
|
-
queryFn: () => {
|
|
8607
|
-
if (carrierId)
|
|
8608
|
-
return client.carriers.getAutoFunding(carrierId);
|
|
8609
|
-
return Promise.reject(new Error("carrierId is required."));
|
|
8610
|
-
},
|
|
8611
|
-
queryKey: ["useGetAutoFundingConfiguration", carrierId],
|
|
8612
|
-
select: (result) => result.data
|
|
8613
|
-
});
|
|
8614
|
-
};
|
|
8615
|
-
|
|
8616
|
-
const useGetCarrierById = (carrierId) => {
|
|
8617
|
-
const { client } = useShipEngine();
|
|
8618
|
-
return reactQuery.useQuery({
|
|
8619
|
-
enabled: !!carrierId,
|
|
8620
|
-
onError,
|
|
8621
|
-
queryFn: () => {
|
|
8622
|
-
if (carrierId)
|
|
8623
|
-
return client.carriers.get(carrierId);
|
|
8624
|
-
return Promise.reject(new Error("carrierId is require"));
|
|
8625
|
-
},
|
|
8626
|
-
queryKey: ["useGetCarrierById", carrierId],
|
|
8627
|
-
select: (result) => result.data,
|
|
8628
|
-
// Fresh for 5 minutes
|
|
8629
|
-
staleTime: 5 * 60 * 1e3
|
|
8630
|
-
});
|
|
8631
|
-
};
|
|
8632
|
-
|
|
8633
|
-
const useGetCountriesByCarrier = (carrierId) => {
|
|
8634
|
-
const { client } = useShipEngine();
|
|
8635
|
-
return reactQuery.useQuery({
|
|
8636
|
-
enabled: !!carrierId,
|
|
8637
|
-
onError,
|
|
8638
|
-
queryFn: () => {
|
|
8639
|
-
if (carrierId)
|
|
8640
|
-
return client.carriers.getCountries(carrierId);
|
|
8641
|
-
return Promise.reject(new Error("carrierId is require"));
|
|
8642
|
-
},
|
|
8643
|
-
queryKey: ["useGetCountriesByCarrier", carrierId],
|
|
8644
|
-
select: (result) => result.data.countries,
|
|
8645
|
-
// Fresh for 5 minutes
|
|
8646
|
-
staleTime: 5 * 60 * 1e3
|
|
8647
|
-
});
|
|
8648
|
-
};
|
|
8649
|
-
|
|
8650
|
-
const useGetCurrenciesByCarrier = (carrierId) => {
|
|
8651
|
-
const { client } = useShipEngine();
|
|
8652
|
-
return reactQuery.useQuery({
|
|
8653
|
-
enabled: !!carrierId,
|
|
8654
|
-
onError,
|
|
8655
|
-
queryFn: () => {
|
|
8656
|
-
if (carrierId)
|
|
8657
|
-
return client.carriers.getCurrencies(carrierId);
|
|
8658
|
-
return Promise.reject(new Error("carrierId is require"));
|
|
8659
|
-
},
|
|
8660
|
-
queryKey: ["useGetCurrenciesByCarrier", carrierId],
|
|
8661
|
-
select: (result) => result.data.currencies,
|
|
8662
|
-
// Fresh for 5 minutes
|
|
8663
|
-
staleTime: 5 * 60 * 1e3
|
|
8664
|
-
});
|
|
8665
|
-
};
|
|
8666
|
-
|
|
8667
|
-
const useGetFundingSourceById = (fundingSourceId) => {
|
|
8668
|
-
const { client } = useShipEngine();
|
|
8669
|
-
return reactQuery.useQuery({
|
|
8670
|
-
onError,
|
|
8671
|
-
queryFn: () => client.fundingSources.get(fundingSourceId),
|
|
8672
|
-
queryKey: ["getFundingSourceById"],
|
|
8673
|
-
select: (result) => result.data
|
|
8674
|
-
});
|
|
8675
|
-
};
|
|
8676
|
-
|
|
8677
8947
|
const useGetInsuranceAccount = (insuranceProvider) => {
|
|
8678
8948
|
const { client } = useShipEngine();
|
|
8679
8949
|
return reactQuery.useQuery({
|
|
@@ -8689,288 +8959,122 @@ const useGetInsuranceAccount = (insuranceProvider) => {
|
|
|
8689
8959
|
});
|
|
8690
8960
|
};
|
|
8691
8961
|
|
|
8692
|
-
|
|
8693
|
-
|
|
8694
|
-
|
|
8695
|
-
|
|
8696
|
-
|
|
8697
|
-
|
|
8698
|
-
|
|
8699
|
-
|
|
8700
|
-
|
|
8701
|
-
|
|
8702
|
-
|
|
8703
|
-
|
|
8704
|
-
|
|
8705
|
-
|
|
8706
|
-
|
|
8707
|
-
|
|
8708
|
-
|
|
8709
|
-
|
|
8710
|
-
|
|
8711
|
-
|
|
8712
|
-
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
|
|
8718
|
-
|
|
8719
|
-
|
|
8720
|
-
|
|
8721
|
-
|
|
8722
|
-
|
|
8723
|
-
|
|
8724
|
-
|
|
8725
|
-
queryFn: () => {
|
|
8726
|
-
if (carrierId)
|
|
8727
|
-
return client.carriers.getPackageRatingGroup(carrierId);
|
|
8728
|
-
return Promise.reject(new Error("carrierId is required"));
|
|
8729
|
-
},
|
|
8730
|
-
queryKey: ["useGetRatePackageFormatsByCarrier", carrierId],
|
|
8731
|
-
select: (result) => result.data.packageRatingGroup,
|
|
8732
|
-
// Fresh for 5 minutes
|
|
8733
|
-
staleTime: 5 * 60 * 1e3
|
|
8734
|
-
});
|
|
8735
|
-
};
|
|
8736
|
-
|
|
8737
|
-
const useGetSalesOrderShipment = (shipmentId) => {
|
|
8738
|
-
const { client } = useShipEngine();
|
|
8739
|
-
return reactQuery.useQuery({
|
|
8740
|
-
enabled: shipmentId !== void 0,
|
|
8741
|
-
onError,
|
|
8742
|
-
queryFn: () => {
|
|
8743
|
-
if (shipmentId)
|
|
8744
|
-
return client.salesOrderShipments.get(shipmentId);
|
|
8745
|
-
return Promise.reject(new Error("shipmentId is required"));
|
|
8746
|
-
},
|
|
8747
|
-
queryKey: ["useGetSalesOrderShipment", shipmentId],
|
|
8748
|
-
select: (result) => result.data
|
|
8749
|
-
});
|
|
8750
|
-
};
|
|
8751
|
-
|
|
8752
|
-
const useGetSalesOrder = (salesOrderId) => {
|
|
8753
|
-
const { client } = useShipEngine();
|
|
8754
|
-
return reactQuery.useQuery({
|
|
8755
|
-
enabled: salesOrderId !== void 0,
|
|
8756
|
-
onError,
|
|
8757
|
-
queryFn: () => {
|
|
8758
|
-
if (salesOrderId)
|
|
8759
|
-
return client.salesOrders.get(salesOrderId);
|
|
8760
|
-
return Promise.reject(new Error("salesOrderId is required"));
|
|
8761
|
-
},
|
|
8762
|
-
queryKey: ["useGetSalesOrder", salesOrderId],
|
|
8763
|
-
select: (result) => result.data
|
|
8764
|
-
});
|
|
8765
|
-
};
|
|
8766
|
-
|
|
8767
|
-
const useGetServicesByCarrier = (carrierId) => {
|
|
8768
|
-
const { client } = useShipEngine();
|
|
8769
|
-
return reactQuery.useQuery({
|
|
8770
|
-
enabled: !!carrierId,
|
|
8771
|
-
onError,
|
|
8772
|
-
queryFn: () => {
|
|
8773
|
-
if (carrierId)
|
|
8774
|
-
return client.carriers.getServices(carrierId);
|
|
8775
|
-
return Promise.reject(new Error("carrierId is required"));
|
|
8776
|
-
},
|
|
8777
|
-
queryKey: ["useGetServicesByCarrier", carrierId],
|
|
8778
|
-
select: (result) => result.data.services,
|
|
8779
|
-
// Fresh for 5 minutes
|
|
8780
|
-
staleTime: 5 * 60 * 1e3
|
|
8781
|
-
});
|
|
8782
|
-
};
|
|
8783
|
-
|
|
8784
|
-
const useGetShipmentRates = (shipmentId, createdAtStart) => {
|
|
8785
|
-
const { client } = useShipEngine();
|
|
8786
|
-
return reactQuery.useQuery({
|
|
8787
|
-
enabled: shipmentId !== void 0,
|
|
8788
|
-
onError,
|
|
8789
|
-
queryFn: () => {
|
|
8790
|
-
if (shipmentId) {
|
|
8791
|
-
return client.shipments.getShipmentRates({ createdAtStart, shipmentId });
|
|
8792
|
-
}
|
|
8793
|
-
return Promise.reject(new Error("shipmentId is required"));
|
|
8794
|
-
},
|
|
8795
|
-
queryKey: ["useGetShipmentRates", shipmentId, createdAtStart],
|
|
8796
|
-
select: (result) => result.data
|
|
8797
|
-
});
|
|
8798
|
-
};
|
|
8799
|
-
|
|
8800
|
-
const useGetShipment = (shipmentId) => {
|
|
8801
|
-
const { client } = useShipEngine();
|
|
8802
|
-
return reactQuery.useQuery({
|
|
8803
|
-
enabled: shipmentId !== void 0,
|
|
8804
|
-
onError,
|
|
8805
|
-
queryFn: () => {
|
|
8806
|
-
if (!shipmentId) {
|
|
8807
|
-
return Promise.reject(new Error("shipmentId is required"));
|
|
8808
|
-
}
|
|
8809
|
-
return client.salesOrderShipments.get(shipmentId);
|
|
8810
|
-
},
|
|
8811
|
-
queryKey: ["useGetShipment", shipmentId],
|
|
8812
|
-
select: (result) => result.data
|
|
8813
|
-
});
|
|
8814
|
-
};
|
|
8815
|
-
|
|
8816
|
-
const useGetWalletHistory = ({
|
|
8817
|
-
enabled,
|
|
8818
|
-
page,
|
|
8819
|
-
range
|
|
8820
|
-
}) => {
|
|
8821
|
-
const { client } = useShipEngine();
|
|
8822
|
-
const [startDate, endDate] = range;
|
|
8823
|
-
return reactQuery.useQuery({
|
|
8824
|
-
enabled,
|
|
8825
|
-
keepPreviousData: true,
|
|
8826
|
-
// See https://react-query-v3.tanstack.com/guides/paginated-queries#better-paginated-queries-with-keeppreviousdata
|
|
8827
|
-
onError,
|
|
8828
|
-
queryFn: () => client.carriers.getWalletHistory(startDate, endDate, page),
|
|
8829
|
-
queryKey: ["useGetWalletHistory", startDate, endDate, page],
|
|
8830
|
-
select: (result) => result.data
|
|
8831
|
-
});
|
|
8832
|
-
};
|
|
8833
|
-
|
|
8834
|
-
const useListCarriers = () => {
|
|
8835
|
-
const { client } = useShipEngine();
|
|
8836
|
-
return reactQuery.useQuery({
|
|
8837
|
-
onError,
|
|
8838
|
-
queryFn: () => client.carriers.list(),
|
|
8839
|
-
queryKey: ["useListCarriers"],
|
|
8840
|
-
select: (result) => result.data.carriers
|
|
8841
|
-
});
|
|
8842
|
-
};
|
|
8843
|
-
|
|
8844
|
-
const useListCustomPackageTypes = () => {
|
|
8845
|
-
const { client } = useShipEngine();
|
|
8846
|
-
return reactQuery.useQuery({
|
|
8847
|
-
onError,
|
|
8848
|
-
queryFn: () => client.customPackages.list(),
|
|
8849
|
-
queryKey: ["useListCustomPackageTypes"],
|
|
8850
|
-
select: (result) => result.data.packages
|
|
8851
|
-
});
|
|
8852
|
-
};
|
|
8853
|
-
|
|
8854
|
-
const useListFundingSources = () => {
|
|
8855
|
-
const { client } = useShipEngine();
|
|
8856
|
-
return reactQuery.useQuery({
|
|
8857
|
-
onError,
|
|
8858
|
-
queryFn: () => client.fundingSources.list(),
|
|
8859
|
-
queryKey: ["useListFundingSources"],
|
|
8860
|
-
select: (result) => result.data.fundingSources
|
|
8861
|
-
});
|
|
8862
|
-
};
|
|
8863
|
-
|
|
8864
|
-
const useListLabels = (params) => {
|
|
8865
|
-
const { client } = useShipEngine();
|
|
8866
|
-
return reactQuery.useQuery({
|
|
8867
|
-
enabled: params && Object.values(params).some((v) => v !== void 0),
|
|
8868
|
-
onError,
|
|
8869
|
-
queryFn: () => client.labels.list(params),
|
|
8870
|
-
queryKey: ["useListLabels", params],
|
|
8871
|
-
select: (result) => result.data.labels
|
|
8962
|
+
var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
|
|
8963
|
+
var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
|
|
8964
|
+
var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
|
|
8965
|
+
var __objRest$6 = (source, exclude) => {
|
|
8966
|
+
var target = {};
|
|
8967
|
+
for (var prop in source)
|
|
8968
|
+
if (__hasOwnProp$9.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
8969
|
+
target[prop] = source[prop];
|
|
8970
|
+
if (source != null && __getOwnPropSymbols$9)
|
|
8971
|
+
for (var prop of __getOwnPropSymbols$9(source)) {
|
|
8972
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$9.call(source, prop))
|
|
8973
|
+
target[prop] = source[prop];
|
|
8974
|
+
}
|
|
8975
|
+
return target;
|
|
8976
|
+
};
|
|
8977
|
+
var __async$i = (__this, __arguments, generator) => {
|
|
8978
|
+
return new Promise((resolve, reject) => {
|
|
8979
|
+
var fulfilled = (value) => {
|
|
8980
|
+
try {
|
|
8981
|
+
step(generator.next(value));
|
|
8982
|
+
} catch (e) {
|
|
8983
|
+
reject(e);
|
|
8984
|
+
}
|
|
8985
|
+
};
|
|
8986
|
+
var rejected = (value) => {
|
|
8987
|
+
try {
|
|
8988
|
+
step(generator.throw(value));
|
|
8989
|
+
} catch (e) {
|
|
8990
|
+
reject(e);
|
|
8991
|
+
}
|
|
8992
|
+
};
|
|
8993
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
8994
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
8872
8995
|
});
|
|
8873
8996
|
};
|
|
8874
|
-
|
|
8875
|
-
const useListOrderSources = () => {
|
|
8997
|
+
const useCreateLabel = () => {
|
|
8876
8998
|
const { client } = useShipEngine();
|
|
8877
|
-
return reactQuery.
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
8999
|
+
return reactQuery.useMutation({
|
|
9000
|
+
mutationFn: (_a) => __async$i(void 0, null, function* () {
|
|
9001
|
+
var _b = _a, { rateId } = _b, options = __objRest$6(_b, ["rateId"]);
|
|
9002
|
+
const result = yield client.labels.createByRateId(rateId, options);
|
|
9003
|
+
return result.data;
|
|
9004
|
+
}),
|
|
9005
|
+
mutationKey: ["useCreateLabel"],
|
|
9006
|
+
onError
|
|
8882
9007
|
});
|
|
8883
9008
|
};
|
|
8884
9009
|
|
|
8885
|
-
const
|
|
9010
|
+
const useGetLabel = (labelId) => {
|
|
8886
9011
|
const { client } = useShipEngine();
|
|
8887
9012
|
return reactQuery.useQuery({
|
|
8888
|
-
enabled:
|
|
9013
|
+
enabled: labelId !== void 0,
|
|
8889
9014
|
onError,
|
|
8890
9015
|
queryFn: () => {
|
|
8891
|
-
|
|
9016
|
+
if (labelId)
|
|
9017
|
+
return client.labels.get(labelId);
|
|
9018
|
+
return Promise.reject(new Error("labelId is require"));
|
|
8892
9019
|
},
|
|
8893
|
-
queryKey: ["
|
|
8894
|
-
select: (result) => result.data
|
|
9020
|
+
queryKey: ["useGetLabel", labelId],
|
|
9021
|
+
select: (result) => result.data
|
|
8895
9022
|
});
|
|
8896
9023
|
};
|
|
8897
9024
|
|
|
8898
|
-
const
|
|
9025
|
+
const useListLabels = (params) => {
|
|
8899
9026
|
const { client } = useShipEngine();
|
|
8900
9027
|
return reactQuery.useQuery({
|
|
8901
9028
|
enabled: params && Object.values(params).some((v) => v !== void 0),
|
|
8902
9029
|
onError,
|
|
8903
|
-
queryFn: () => client.
|
|
8904
|
-
queryKey: ["
|
|
8905
|
-
select: (result) => result.data.
|
|
9030
|
+
queryFn: () => client.labels.list(params),
|
|
9031
|
+
queryKey: ["useListLabels", params],
|
|
9032
|
+
select: (result) => result.data.labels
|
|
8906
9033
|
});
|
|
8907
9034
|
};
|
|
8908
9035
|
|
|
8909
|
-
|
|
8910
|
-
|
|
8911
|
-
|
|
8912
|
-
|
|
8913
|
-
|
|
8914
|
-
|
|
8915
|
-
|
|
8916
|
-
|
|
9036
|
+
var __async$h = (__this, __arguments, generator) => {
|
|
9037
|
+
return new Promise((resolve, reject) => {
|
|
9038
|
+
var fulfilled = (value) => {
|
|
9039
|
+
try {
|
|
9040
|
+
step(generator.next(value));
|
|
9041
|
+
} catch (e) {
|
|
9042
|
+
reject(e);
|
|
9043
|
+
}
|
|
9044
|
+
};
|
|
9045
|
+
var rejected = (value) => {
|
|
9046
|
+
try {
|
|
9047
|
+
step(generator.throw(value));
|
|
9048
|
+
} catch (e) {
|
|
9049
|
+
reject(e);
|
|
9050
|
+
}
|
|
9051
|
+
};
|
|
9052
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
9053
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
8917
9054
|
});
|
|
8918
9055
|
};
|
|
8919
|
-
|
|
8920
|
-
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
8921
|
-
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
8922
|
-
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
8923
|
-
var __objRest$4 = (source, exclude) => {
|
|
8924
|
-
var target = {};
|
|
8925
|
-
for (var prop in source)
|
|
8926
|
-
if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
8927
|
-
target[prop] = source[prop];
|
|
8928
|
-
if (source != null && __getOwnPropSymbols$6)
|
|
8929
|
-
for (var prop of __getOwnPropSymbols$6(source)) {
|
|
8930
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
|
|
8931
|
-
target[prop] = source[prop];
|
|
8932
|
-
}
|
|
8933
|
-
return target;
|
|
8934
|
-
};
|
|
8935
|
-
const useListShipments = (_params) => {
|
|
8936
|
-
const _a = _params || {}, { enabled = true } = _a, params = __objRest$4(_a, ["enabled"]);
|
|
9056
|
+
const useVoidLabel = () => {
|
|
8937
9057
|
const { client } = useShipEngine();
|
|
8938
|
-
return reactQuery.
|
|
8939
|
-
|
|
8940
|
-
|
|
8941
|
-
|
|
8942
|
-
|
|
8943
|
-
|
|
9058
|
+
return reactQuery.useMutation({
|
|
9059
|
+
mutationFn: (labelId) => __async$h(void 0, null, function* () {
|
|
9060
|
+
const result = yield client.labels.void(labelId);
|
|
9061
|
+
return result.data;
|
|
9062
|
+
}),
|
|
9063
|
+
mutationKey: ["useVoidLabel"],
|
|
9064
|
+
onError
|
|
8944
9065
|
});
|
|
8945
9066
|
};
|
|
8946
9067
|
|
|
8947
|
-
const
|
|
8948
|
-
var _a;
|
|
9068
|
+
const useListOrderSources = () => {
|
|
8949
9069
|
const { client } = useShipEngine();
|
|
8950
9070
|
return reactQuery.useQuery({
|
|
8951
|
-
enabled: (_a = options == null ? void 0 : options.enabled) != null ? _a : true,
|
|
8952
9071
|
onError,
|
|
8953
|
-
queryFn: () => client.
|
|
8954
|
-
queryKey: ["
|
|
8955
|
-
select: (result) => result.data.
|
|
9072
|
+
queryFn: () => client.orderSources.list(),
|
|
9073
|
+
queryKey: ["useListOrderSources"],
|
|
9074
|
+
select: (result) => result.data.orderSources
|
|
8956
9075
|
});
|
|
8957
9076
|
};
|
|
8958
9077
|
|
|
8959
|
-
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
8960
|
-
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
8961
|
-
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
8962
|
-
var __objRest$3 = (source, exclude) => {
|
|
8963
|
-
var target = {};
|
|
8964
|
-
for (var prop in source)
|
|
8965
|
-
if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
8966
|
-
target[prop] = source[prop];
|
|
8967
|
-
if (source != null && __getOwnPropSymbols$5)
|
|
8968
|
-
for (var prop of __getOwnPropSymbols$5(source)) {
|
|
8969
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
|
|
8970
|
-
target[prop] = source[prop];
|
|
8971
|
-
}
|
|
8972
|
-
return target;
|
|
8973
|
-
};
|
|
8974
9078
|
var __async$g = (__this, __arguments, generator) => {
|
|
8975
9079
|
return new Promise((resolve, reject) => {
|
|
8976
9080
|
var fulfilled = (value) => {
|
|
@@ -8991,15 +9095,32 @@ var __async$g = (__this, __arguments, generator) => {
|
|
|
8991
9095
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
8992
9096
|
});
|
|
8993
9097
|
};
|
|
8994
|
-
const
|
|
9098
|
+
const useRefreshOrderSourceAsync = () => {
|
|
8995
9099
|
const { client } = useShipEngine();
|
|
8996
9100
|
return reactQuery.useMutation({
|
|
8997
|
-
mutationFn: (
|
|
8998
|
-
|
|
8999
|
-
const result = yield client.salesOrders.notifyShipped(salesOrderId, tracking);
|
|
9101
|
+
mutationFn: (orderSourceId) => __async$g(void 0, null, function* () {
|
|
9102
|
+
const result = yield client.orderSources.refresh(orderSourceId);
|
|
9000
9103
|
return result.data;
|
|
9001
9104
|
}),
|
|
9002
|
-
mutationKey: ["
|
|
9105
|
+
mutationKey: ["useRefreshOrderSourceAsync"]
|
|
9106
|
+
});
|
|
9107
|
+
};
|
|
9108
|
+
const useRefreshOrderSource = () => {
|
|
9109
|
+
const { client } = useShipEngine();
|
|
9110
|
+
const { mutateAsync: refreshOrderSourceAsync } = useRefreshOrderSourceAsync();
|
|
9111
|
+
return reactQuery.useMutation({
|
|
9112
|
+
mutationFn: (orderSourceId) => __async$g(void 0, null, function* () {
|
|
9113
|
+
yield refreshOrderSourceAsync(orderSourceId);
|
|
9114
|
+
const waitResult = yield retryUntil(() => __async$g(void 0, null, function* () {
|
|
9115
|
+
const { data: checkResult } = yield client.orderSources.get(orderSourceId);
|
|
9116
|
+
if (["preparing_update", "updating"].includes(checkResult.refreshInfo.status)) {
|
|
9117
|
+
throw new CodedError("Order source is still refreshing");
|
|
9118
|
+
}
|
|
9119
|
+
return checkResult;
|
|
9120
|
+
}), 20);
|
|
9121
|
+
return waitResult;
|
|
9122
|
+
}),
|
|
9123
|
+
mutationKey: ["useRefreshOrderSource"],
|
|
9003
9124
|
onError
|
|
9004
9125
|
});
|
|
9005
9126
|
};
|
|
@@ -9024,18 +9145,56 @@ var __async$f = (__this, __arguments, generator) => {
|
|
|
9024
9145
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
9025
9146
|
});
|
|
9026
9147
|
};
|
|
9027
|
-
const
|
|
9148
|
+
const useCreateRateCard = () => {
|
|
9028
9149
|
const { client } = useShipEngine();
|
|
9029
9150
|
return reactQuery.useMutation({
|
|
9030
|
-
mutationFn: (
|
|
9031
|
-
const result = yield client.
|
|
9151
|
+
mutationFn: (rateCard) => __async$f(void 0, null, function* () {
|
|
9152
|
+
const result = yield client.rateCards.create(rateCard);
|
|
9032
9153
|
return result.data;
|
|
9033
9154
|
}),
|
|
9034
|
-
mutationKey: ["
|
|
9155
|
+
mutationKey: ["useCreateRateCard"],
|
|
9035
9156
|
onError
|
|
9036
9157
|
});
|
|
9037
9158
|
};
|
|
9038
9159
|
|
|
9160
|
+
const useDownloadRateCard = (rateCardId) => {
|
|
9161
|
+
const { client } = useShipEngine();
|
|
9162
|
+
return reactQuery.useQuery({
|
|
9163
|
+
enabled: !!rateCardId.length,
|
|
9164
|
+
onError,
|
|
9165
|
+
queryFn: () => {
|
|
9166
|
+
return client.rateCards.download(rateCardId);
|
|
9167
|
+
},
|
|
9168
|
+
queryKey: ["useDownloadRateCard", rateCardId]
|
|
9169
|
+
});
|
|
9170
|
+
};
|
|
9171
|
+
|
|
9172
|
+
const useGetRateCardById = (rateCardId) => {
|
|
9173
|
+
const { client } = useShipEngine();
|
|
9174
|
+
return reactQuery.useQuery({
|
|
9175
|
+
enabled: !!rateCardId,
|
|
9176
|
+
onError,
|
|
9177
|
+
queryFn: () => {
|
|
9178
|
+
return client.rateCards.get(rateCardId);
|
|
9179
|
+
},
|
|
9180
|
+
queryKey: ["useGetRateCardById", rateCardId],
|
|
9181
|
+
select: (result) => result.data
|
|
9182
|
+
});
|
|
9183
|
+
};
|
|
9184
|
+
|
|
9185
|
+
const useListRateCards = (carrierIds) => {
|
|
9186
|
+
const { client } = useShipEngine();
|
|
9187
|
+
return reactQuery.useQuery({
|
|
9188
|
+
enabled: !!carrierIds.length,
|
|
9189
|
+
onError,
|
|
9190
|
+
queryFn: () => {
|
|
9191
|
+
return client.rateCards.list(carrierIds);
|
|
9192
|
+
},
|
|
9193
|
+
queryKey: ["useListRateCards", carrierIds],
|
|
9194
|
+
select: (result) => result.data.rateCards
|
|
9195
|
+
});
|
|
9196
|
+
};
|
|
9197
|
+
|
|
9039
9198
|
var __async$e = (__this, __arguments, generator) => {
|
|
9040
9199
|
return new Promise((resolve, reject) => {
|
|
9041
9200
|
var fulfilled = (value) => {
|
|
@@ -9087,32 +9246,14 @@ var __async$d = (__this, __arguments, generator) => {
|
|
|
9087
9246
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
9088
9247
|
});
|
|
9089
9248
|
};
|
|
9090
|
-
const
|
|
9249
|
+
const useUpdateRateCard = () => {
|
|
9091
9250
|
const { client } = useShipEngine();
|
|
9092
9251
|
return reactQuery.useMutation({
|
|
9093
|
-
mutationFn: (
|
|
9094
|
-
const result = yield client.
|
|
9252
|
+
mutationFn: (rateCard) => __async$d(void 0, null, function* () {
|
|
9253
|
+
const result = yield client.rateCards.update(rateCard);
|
|
9095
9254
|
return result.data;
|
|
9096
9255
|
}),
|
|
9097
|
-
mutationKey: ["
|
|
9098
|
-
});
|
|
9099
|
-
};
|
|
9100
|
-
const useRefreshOrderSource = () => {
|
|
9101
|
-
const { client } = useShipEngine();
|
|
9102
|
-
const { mutateAsync: refreshOrderSourceAsync } = useRefreshOrderSourceAsync();
|
|
9103
|
-
return reactQuery.useMutation({
|
|
9104
|
-
mutationFn: (orderSourceId) => __async$d(void 0, null, function* () {
|
|
9105
|
-
yield refreshOrderSourceAsync(orderSourceId);
|
|
9106
|
-
const waitResult = yield retryUntil(() => __async$d(void 0, null, function* () {
|
|
9107
|
-
const { data: checkResult } = yield client.orderSources.get(orderSourceId);
|
|
9108
|
-
if (["preparing_update", "updating"].includes(checkResult.refreshInfo.status)) {
|
|
9109
|
-
throw new CodedError("Order source is still refreshing");
|
|
9110
|
-
}
|
|
9111
|
-
return checkResult;
|
|
9112
|
-
}), 20);
|
|
9113
|
-
return waitResult;
|
|
9114
|
-
}),
|
|
9115
|
-
mutationKey: ["useRefreshOrderSource"],
|
|
9256
|
+
mutationKey: ["useUpdateRateCard"],
|
|
9116
9257
|
onError
|
|
9117
9258
|
});
|
|
9118
9259
|
};
|
|
@@ -9137,14 +9278,14 @@ var __async$c = (__this, __arguments, generator) => {
|
|
|
9137
9278
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
9138
9279
|
});
|
|
9139
9280
|
};
|
|
9140
|
-
const
|
|
9281
|
+
const useUploadRateCard = () => {
|
|
9141
9282
|
const { client } = useShipEngine();
|
|
9142
9283
|
return reactQuery.useMutation({
|
|
9143
|
-
mutationFn: (
|
|
9144
|
-
const result = yield client.
|
|
9284
|
+
mutationFn: (_0) => __async$c(void 0, [_0], function* ({ rateCardId, file }) {
|
|
9285
|
+
const result = yield client.rateCards.upload(rateCardId, file);
|
|
9145
9286
|
return result.data;
|
|
9146
9287
|
}),
|
|
9147
|
-
mutationKey: ["
|
|
9288
|
+
mutationKey: ["useUploadRateCard"],
|
|
9148
9289
|
onError
|
|
9149
9290
|
});
|
|
9150
9291
|
};
|
|
@@ -9169,14 +9310,14 @@ var __async$b = (__this, __arguments, generator) => {
|
|
|
9169
9310
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
9170
9311
|
});
|
|
9171
9312
|
};
|
|
9172
|
-
const
|
|
9313
|
+
const useDeleteRateCard = () => {
|
|
9173
9314
|
const { client } = useShipEngine();
|
|
9174
9315
|
return reactQuery.useMutation({
|
|
9175
|
-
mutationFn: (
|
|
9176
|
-
const result = yield client.
|
|
9316
|
+
mutationFn: (rateCardId) => __async$b(void 0, null, function* () {
|
|
9317
|
+
const result = yield client.rateCards.delete(rateCardId);
|
|
9177
9318
|
return result.data;
|
|
9178
9319
|
}),
|
|
9179
|
-
mutationKey: ["
|
|
9320
|
+
mutationKey: ["useDeleteRateCard"],
|
|
9180
9321
|
onError
|
|
9181
9322
|
});
|
|
9182
9323
|
};
|
|
@@ -9201,22 +9342,59 @@ var __async$a = (__this, __arguments, generator) => {
|
|
|
9201
9342
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
9202
9343
|
});
|
|
9203
9344
|
};
|
|
9204
|
-
const
|
|
9345
|
+
const useCalculateRates = () => {
|
|
9205
9346
|
const { client } = useShipEngine();
|
|
9206
|
-
const queryClient = reactQuery.useQueryClient();
|
|
9207
9347
|
return reactQuery.useMutation({
|
|
9208
|
-
mutationFn: (
|
|
9209
|
-
const result = yield client.
|
|
9348
|
+
mutationFn: (_0) => __async$a(void 0, [_0], function* ({ rateOptions, shipmentId }) {
|
|
9349
|
+
const result = yield client.rates.calculateByShipmentId(shipmentId, rateOptions);
|
|
9210
9350
|
return result.data;
|
|
9211
9351
|
}),
|
|
9212
|
-
mutationKey: ["
|
|
9352
|
+
mutationKey: ["useCalculateRates"],
|
|
9353
|
+
onError
|
|
9354
|
+
});
|
|
9355
|
+
};
|
|
9356
|
+
|
|
9357
|
+
const useGetSalesOrder = (salesOrderId) => {
|
|
9358
|
+
const { client } = useShipEngine();
|
|
9359
|
+
return reactQuery.useQuery({
|
|
9360
|
+
enabled: salesOrderId !== void 0,
|
|
9361
|
+
onError,
|
|
9362
|
+
queryFn: () => {
|
|
9363
|
+
if (salesOrderId)
|
|
9364
|
+
return client.salesOrders.get(salesOrderId);
|
|
9365
|
+
return Promise.reject(new Error("salesOrderId is required"));
|
|
9366
|
+
},
|
|
9367
|
+
queryKey: ["useGetSalesOrder", salesOrderId],
|
|
9368
|
+
select: (result) => result.data
|
|
9369
|
+
});
|
|
9370
|
+
};
|
|
9371
|
+
|
|
9372
|
+
const useListSalesOrders = (params = {}) => {
|
|
9373
|
+
const { client } = useShipEngine();
|
|
9374
|
+
return reactQuery.useQuery({
|
|
9375
|
+
enabled: params && Object.values(params).some((v) => v !== void 0),
|
|
9213
9376
|
onError,
|
|
9214
|
-
|
|
9215
|
-
|
|
9216
|
-
|
|
9377
|
+
queryFn: () => client.salesOrders.list(params),
|
|
9378
|
+
queryKey: ["useListSalesOrders", params],
|
|
9379
|
+
select: (result) => result.data.salesOrders
|
|
9217
9380
|
});
|
|
9218
9381
|
};
|
|
9219
9382
|
|
|
9383
|
+
var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
|
|
9384
|
+
var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
|
|
9385
|
+
var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
|
|
9386
|
+
var __objRest$5 = (source, exclude) => {
|
|
9387
|
+
var target = {};
|
|
9388
|
+
for (var prop in source)
|
|
9389
|
+
if (__hasOwnProp$8.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
9390
|
+
target[prop] = source[prop];
|
|
9391
|
+
if (source != null && __getOwnPropSymbols$8)
|
|
9392
|
+
for (var prop of __getOwnPropSymbols$8(source)) {
|
|
9393
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$8.call(source, prop))
|
|
9394
|
+
target[prop] = source[prop];
|
|
9395
|
+
}
|
|
9396
|
+
return target;
|
|
9397
|
+
};
|
|
9220
9398
|
var __async$9 = (__this, __arguments, generator) => {
|
|
9221
9399
|
return new Promise((resolve, reject) => {
|
|
9222
9400
|
var fulfilled = (value) => {
|
|
@@ -9237,26 +9415,34 @@ var __async$9 = (__this, __arguments, generator) => {
|
|
|
9237
9415
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
9238
9416
|
});
|
|
9239
9417
|
};
|
|
9240
|
-
const
|
|
9418
|
+
const useNotifySalesOrderShipped = () => {
|
|
9241
9419
|
const { client } = useShipEngine();
|
|
9242
9420
|
return reactQuery.useMutation({
|
|
9243
|
-
mutationFn: (
|
|
9244
|
-
|
|
9245
|
-
|
|
9246
|
-
fundingSourceId
|
|
9247
|
-
}) {
|
|
9248
|
-
const result = yield client.fundingSources.update(
|
|
9249
|
-
billingInfo,
|
|
9250
|
-
creditCardInfo,
|
|
9251
|
-
fundingSourceId
|
|
9252
|
-
);
|
|
9421
|
+
mutationFn: (_a) => __async$9(void 0, null, function* () {
|
|
9422
|
+
var _b = _a, { salesOrderId } = _b, tracking = __objRest$5(_b, ["salesOrderId"]);
|
|
9423
|
+
const result = yield client.salesOrders.notifyShipped(salesOrderId, tracking);
|
|
9253
9424
|
return result.data;
|
|
9254
9425
|
}),
|
|
9255
|
-
mutationKey: ["
|
|
9426
|
+
mutationKey: ["useNotifySalesOrder"],
|
|
9256
9427
|
onError
|
|
9257
9428
|
});
|
|
9258
9429
|
};
|
|
9259
9430
|
|
|
9431
|
+
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
|
9432
|
+
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
|
9433
|
+
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
|
9434
|
+
var __objRest$4 = (source, exclude) => {
|
|
9435
|
+
var target = {};
|
|
9436
|
+
for (var prop in source)
|
|
9437
|
+
if (__hasOwnProp$7.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
9438
|
+
target[prop] = source[prop];
|
|
9439
|
+
if (source != null && __getOwnPropSymbols$7)
|
|
9440
|
+
for (var prop of __getOwnPropSymbols$7(source)) {
|
|
9441
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$7.call(source, prop))
|
|
9442
|
+
target[prop] = source[prop];
|
|
9443
|
+
}
|
|
9444
|
+
return target;
|
|
9445
|
+
};
|
|
9260
9446
|
var __async$8 = (__this, __arguments, generator) => {
|
|
9261
9447
|
return new Promise((resolve, reject) => {
|
|
9262
9448
|
var fulfilled = (value) => {
|
|
@@ -9277,29 +9463,56 @@ var __async$8 = (__this, __arguments, generator) => {
|
|
|
9277
9463
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
9278
9464
|
});
|
|
9279
9465
|
};
|
|
9280
|
-
const
|
|
9466
|
+
const useCreateSalesOrderShipment = () => {
|
|
9281
9467
|
const { client } = useShipEngine();
|
|
9282
9468
|
return reactQuery.useMutation({
|
|
9283
|
-
mutationFn: (
|
|
9284
|
-
|
|
9469
|
+
mutationFn: (_a) => __async$8(void 0, null, function* () {
|
|
9470
|
+
var _b = _a, { salesOrderId } = _b, shipment = __objRest$4(_b, ["salesOrderId"]);
|
|
9471
|
+
const result = yield client.salesOrderShipments.create(salesOrderId, shipment);
|
|
9285
9472
|
return result.data;
|
|
9286
9473
|
}),
|
|
9287
|
-
mutationKey: ["
|
|
9474
|
+
mutationKey: ["useCreateSalesOrderShipment"],
|
|
9288
9475
|
onError
|
|
9289
9476
|
});
|
|
9290
9477
|
};
|
|
9291
9478
|
|
|
9292
|
-
|
|
9293
|
-
|
|
9294
|
-
|
|
9295
|
-
|
|
9479
|
+
const useGetSalesOrderShipment = (shipmentId) => {
|
|
9480
|
+
const { client } = useShipEngine();
|
|
9481
|
+
return reactQuery.useQuery({
|
|
9482
|
+
enabled: shipmentId !== void 0,
|
|
9483
|
+
onError,
|
|
9484
|
+
queryFn: () => {
|
|
9485
|
+
if (shipmentId)
|
|
9486
|
+
return client.salesOrderShipments.get(shipmentId);
|
|
9487
|
+
return Promise.reject(new Error("shipmentId is required"));
|
|
9488
|
+
},
|
|
9489
|
+
queryKey: ["useGetSalesOrderShipment", shipmentId],
|
|
9490
|
+
select: (result) => result.data
|
|
9491
|
+
});
|
|
9492
|
+
};
|
|
9493
|
+
|
|
9494
|
+
const useListSalesOrderShipments = (params) => {
|
|
9495
|
+
const { client } = useShipEngine();
|
|
9496
|
+
return reactQuery.useQuery({
|
|
9497
|
+
enabled: params && Object.values(params).some((v) => v !== void 0),
|
|
9498
|
+
onError,
|
|
9499
|
+
queryFn: () => client.salesOrderShipments.list(params),
|
|
9500
|
+
queryKey: ["useListSalesOrderShipments", params],
|
|
9501
|
+
select: (result) => result.data.shipments
|
|
9502
|
+
});
|
|
9503
|
+
};
|
|
9504
|
+
|
|
9505
|
+
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
9506
|
+
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
9507
|
+
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
9508
|
+
var __objRest$3 = (source, exclude) => {
|
|
9296
9509
|
var target = {};
|
|
9297
9510
|
for (var prop in source)
|
|
9298
|
-
if (__hasOwnProp$
|
|
9511
|
+
if (__hasOwnProp$6.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
9299
9512
|
target[prop] = source[prop];
|
|
9300
|
-
if (source != null && __getOwnPropSymbols$
|
|
9301
|
-
for (var prop of __getOwnPropSymbols$
|
|
9302
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
9513
|
+
if (source != null && __getOwnPropSymbols$6)
|
|
9514
|
+
for (var prop of __getOwnPropSymbols$6(source)) {
|
|
9515
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$6.call(source, prop))
|
|
9303
9516
|
target[prop] = source[prop];
|
|
9304
9517
|
}
|
|
9305
9518
|
return target;
|
|
@@ -9328,7 +9541,7 @@ const useUpdateSalesOrderShipment = () => {
|
|
|
9328
9541
|
const { client } = useShipEngine();
|
|
9329
9542
|
return reactQuery.useMutation({
|
|
9330
9543
|
mutationFn: (_a) => __async$7(void 0, null, function* () {
|
|
9331
|
-
var _b = _a, { shipmentId } = _b, shipment = __objRest$
|
|
9544
|
+
var _b = _a, { shipmentId } = _b, shipment = __objRest$3(_b, ["shipmentId"]);
|
|
9332
9545
|
const result = yield client.salesOrderShipments.update(shipmentId, shipment);
|
|
9333
9546
|
return result.data;
|
|
9334
9547
|
}),
|
|
@@ -9337,21 +9550,25 @@ const useUpdateSalesOrderShipment = () => {
|
|
|
9337
9550
|
});
|
|
9338
9551
|
};
|
|
9339
9552
|
|
|
9340
|
-
var
|
|
9341
|
-
var
|
|
9342
|
-
var
|
|
9343
|
-
var
|
|
9344
|
-
|
|
9345
|
-
|
|
9346
|
-
|
|
9347
|
-
|
|
9348
|
-
|
|
9349
|
-
|
|
9350
|
-
|
|
9351
|
-
|
|
9553
|
+
var __defProp$3 = Object.defineProperty;
|
|
9554
|
+
var __defProps$2 = Object.defineProperties;
|
|
9555
|
+
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
9556
|
+
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
9557
|
+
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
9558
|
+
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
9559
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9560
|
+
var __spreadValues$3 = (a, b) => {
|
|
9561
|
+
for (var prop in b || (b = {}))
|
|
9562
|
+
if (__hasOwnProp$5.call(b, prop))
|
|
9563
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
9564
|
+
if (__getOwnPropSymbols$5)
|
|
9565
|
+
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
9566
|
+
if (__propIsEnum$5.call(b, prop))
|
|
9567
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
9352
9568
|
}
|
|
9353
|
-
return
|
|
9569
|
+
return a;
|
|
9354
9570
|
};
|
|
9571
|
+
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
9355
9572
|
var __async$6 = (__this, __arguments, generator) => {
|
|
9356
9573
|
return new Promise((resolve, reject) => {
|
|
9357
9574
|
var fulfilled = (value) => {
|
|
@@ -9372,19 +9589,95 @@ var __async$6 = (__this, __arguments, generator) => {
|
|
|
9372
9589
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
9373
9590
|
});
|
|
9374
9591
|
};
|
|
9375
|
-
const
|
|
9592
|
+
const useCreateShipment = () => {
|
|
9376
9593
|
const { client } = useShipEngine();
|
|
9377
9594
|
return reactQuery.useMutation({
|
|
9378
|
-
mutationFn: (
|
|
9379
|
-
var
|
|
9380
|
-
|
|
9381
|
-
|
|
9595
|
+
mutationFn: (shipment) => __async$6(void 0, null, function* () {
|
|
9596
|
+
var _a;
|
|
9597
|
+
if (shipment.warehouseId === void 0) {
|
|
9598
|
+
throw new CodedError("errorMessages.noWarehouses", {
|
|
9599
|
+
errorCode: "unknown",
|
|
9600
|
+
errorSource: "client",
|
|
9601
|
+
errorType: "business_rules"
|
|
9602
|
+
});
|
|
9603
|
+
}
|
|
9604
|
+
const shipTo = (_a = shipment.shipTo) != null ? _a : {
|
|
9605
|
+
addressLine1: "",
|
|
9606
|
+
cityLocality: "",
|
|
9607
|
+
countryCode: "",
|
|
9608
|
+
name: "",
|
|
9609
|
+
phone: "",
|
|
9610
|
+
postalCode: "",
|
|
9611
|
+
stateProvince: ""
|
|
9612
|
+
};
|
|
9613
|
+
return (yield client.shipments.create(__spreadProps$2(__spreadValues$3({}, shipment), {
|
|
9614
|
+
shipTo
|
|
9615
|
+
}))).data;
|
|
9382
9616
|
}),
|
|
9383
|
-
mutationKey: ["
|
|
9617
|
+
mutationKey: ["useCreateShipment"],
|
|
9384
9618
|
onError
|
|
9385
9619
|
});
|
|
9386
9620
|
};
|
|
9387
9621
|
|
|
9622
|
+
const useGetShipmentRates = (shipmentId, createdAtStart) => {
|
|
9623
|
+
const { client } = useShipEngine();
|
|
9624
|
+
return reactQuery.useQuery({
|
|
9625
|
+
enabled: shipmentId !== void 0,
|
|
9626
|
+
onError,
|
|
9627
|
+
queryFn: () => {
|
|
9628
|
+
if (shipmentId) {
|
|
9629
|
+
return client.shipments.getShipmentRates({ createdAtStart, shipmentId });
|
|
9630
|
+
}
|
|
9631
|
+
return Promise.reject(new Error("shipmentId is required"));
|
|
9632
|
+
},
|
|
9633
|
+
queryKey: ["useGetShipmentRates", shipmentId, createdAtStart],
|
|
9634
|
+
select: (result) => result.data
|
|
9635
|
+
});
|
|
9636
|
+
};
|
|
9637
|
+
|
|
9638
|
+
const useGetShipment = (shipmentId) => {
|
|
9639
|
+
const { client } = useShipEngine();
|
|
9640
|
+
return reactQuery.useQuery({
|
|
9641
|
+
enabled: shipmentId !== void 0,
|
|
9642
|
+
onError,
|
|
9643
|
+
queryFn: () => {
|
|
9644
|
+
if (!shipmentId) {
|
|
9645
|
+
return Promise.reject(new Error("shipmentId is required"));
|
|
9646
|
+
}
|
|
9647
|
+
return client.salesOrderShipments.get(shipmentId);
|
|
9648
|
+
},
|
|
9649
|
+
queryKey: ["useGetShipment", shipmentId],
|
|
9650
|
+
select: (result) => result.data
|
|
9651
|
+
});
|
|
9652
|
+
};
|
|
9653
|
+
|
|
9654
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
9655
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
9656
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
9657
|
+
var __objRest$2 = (source, exclude) => {
|
|
9658
|
+
var target = {};
|
|
9659
|
+
for (var prop in source)
|
|
9660
|
+
if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
9661
|
+
target[prop] = source[prop];
|
|
9662
|
+
if (source != null && __getOwnPropSymbols$4)
|
|
9663
|
+
for (var prop of __getOwnPropSymbols$4(source)) {
|
|
9664
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
|
|
9665
|
+
target[prop] = source[prop];
|
|
9666
|
+
}
|
|
9667
|
+
return target;
|
|
9668
|
+
};
|
|
9669
|
+
const useListShipments = (_params) => {
|
|
9670
|
+
const _a = _params || {}, { enabled = true } = _a, params = __objRest$2(_a, ["enabled"]);
|
|
9671
|
+
const { client } = useShipEngine();
|
|
9672
|
+
return reactQuery.useQuery({
|
|
9673
|
+
enabled,
|
|
9674
|
+
onError,
|
|
9675
|
+
queryFn: () => client.shipments.list(params),
|
|
9676
|
+
queryKey: ["useListShipments", params],
|
|
9677
|
+
select: (result) => result.data
|
|
9678
|
+
});
|
|
9679
|
+
};
|
|
9680
|
+
|
|
9388
9681
|
var __async$5 = (__this, __arguments, generator) => {
|
|
9389
9682
|
return new Promise((resolve, reject) => {
|
|
9390
9683
|
var fulfilled = (value) => {
|
|
@@ -9405,14 +9698,14 @@ var __async$5 = (__this, __arguments, generator) => {
|
|
|
9405
9698
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
9406
9699
|
});
|
|
9407
9700
|
};
|
|
9408
|
-
const
|
|
9701
|
+
const useCreateWarehouse = () => {
|
|
9409
9702
|
const { client } = useShipEngine();
|
|
9410
9703
|
return reactQuery.useMutation({
|
|
9411
|
-
mutationFn: (
|
|
9412
|
-
const result = yield client.
|
|
9704
|
+
mutationFn: (data) => __async$5(void 0, null, function* () {
|
|
9705
|
+
const result = yield client.warehouses.create(data);
|
|
9413
9706
|
return result.data;
|
|
9414
9707
|
}),
|
|
9415
|
-
mutationKey: ["
|
|
9708
|
+
mutationKey: ["useCreateWarehouse"],
|
|
9416
9709
|
onError
|
|
9417
9710
|
});
|
|
9418
9711
|
};
|
|
@@ -9437,18 +9730,45 @@ var __async$4 = (__this, __arguments, generator) => {
|
|
|
9437
9730
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
9438
9731
|
});
|
|
9439
9732
|
};
|
|
9440
|
-
const
|
|
9733
|
+
const useDeleteWarehouse = () => {
|
|
9441
9734
|
const { client } = useShipEngine();
|
|
9442
9735
|
return reactQuery.useMutation({
|
|
9443
|
-
mutationFn: (
|
|
9444
|
-
const result = yield client.
|
|
9736
|
+
mutationFn: (_0) => __async$4(void 0, [_0], function* ({ warehouseId }) {
|
|
9737
|
+
const result = yield client.warehouses.delete(warehouseId);
|
|
9445
9738
|
return result.data;
|
|
9446
9739
|
}),
|
|
9447
|
-
mutationKey: ["
|
|
9740
|
+
mutationKey: ["useDeleteWarehouse"],
|
|
9448
9741
|
onError
|
|
9449
9742
|
});
|
|
9450
9743
|
};
|
|
9451
9744
|
|
|
9745
|
+
const useListWarehouses = (options) => {
|
|
9746
|
+
var _a;
|
|
9747
|
+
const { client } = useShipEngine();
|
|
9748
|
+
return reactQuery.useQuery({
|
|
9749
|
+
enabled: (_a = options == null ? void 0 : options.enabled) != null ? _a : true,
|
|
9750
|
+
onError,
|
|
9751
|
+
queryFn: () => client.warehouses.list(),
|
|
9752
|
+
queryKey: ["useListWarehouses"],
|
|
9753
|
+
select: (result) => result.data.warehouses
|
|
9754
|
+
});
|
|
9755
|
+
};
|
|
9756
|
+
|
|
9757
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
9758
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
9759
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
9760
|
+
var __objRest$1 = (source, exclude) => {
|
|
9761
|
+
var target = {};
|
|
9762
|
+
for (var prop in source)
|
|
9763
|
+
if (__hasOwnProp$3.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
9764
|
+
target[prop] = source[prop];
|
|
9765
|
+
if (source != null && __getOwnPropSymbols$3)
|
|
9766
|
+
for (var prop of __getOwnPropSymbols$3(source)) {
|
|
9767
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$3.call(source, prop))
|
|
9768
|
+
target[prop] = source[prop];
|
|
9769
|
+
}
|
|
9770
|
+
return target;
|
|
9771
|
+
};
|
|
9452
9772
|
var __async$3 = (__this, __arguments, generator) => {
|
|
9453
9773
|
return new Promise((resolve, reject) => {
|
|
9454
9774
|
var fulfilled = (value) => {
|
|
@@ -9469,14 +9789,15 @@ var __async$3 = (__this, __arguments, generator) => {
|
|
|
9469
9789
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
9470
9790
|
});
|
|
9471
9791
|
};
|
|
9472
|
-
const
|
|
9792
|
+
const useUpdateWarehouse = () => {
|
|
9473
9793
|
const { client } = useShipEngine();
|
|
9474
9794
|
return reactQuery.useMutation({
|
|
9475
|
-
mutationFn: (
|
|
9476
|
-
|
|
9795
|
+
mutationFn: (_a) => __async$3(void 0, null, function* () {
|
|
9796
|
+
var _b = _a, { warehouseId } = _b, warehouse = __objRest$1(_b, ["warehouseId"]);
|
|
9797
|
+
const result = yield client.warehouses.update(warehouseId, warehouse);
|
|
9477
9798
|
return result.data;
|
|
9478
9799
|
}),
|
|
9479
|
-
mutationKey: ["
|
|
9800
|
+
mutationKey: ["useUpdateWarehouse"],
|
|
9480
9801
|
onError
|
|
9481
9802
|
});
|
|
9482
9803
|
};
|
|
@@ -10384,6 +10705,7 @@ exports.useCreateRateCard = useCreateRateCard;
|
|
|
10384
10705
|
exports.useCreateSalesOrderShipment = useCreateSalesOrderShipment;
|
|
10385
10706
|
exports.useCreateShipment = useCreateShipment;
|
|
10386
10707
|
exports.useCreateWarehouse = useCreateWarehouse;
|
|
10708
|
+
exports.useDeleteRateCard = useDeleteRateCard;
|
|
10387
10709
|
exports.useDeleteWarehouse = useDeleteWarehouse;
|
|
10388
10710
|
exports.useDownloadRateCard = useDownloadRateCard;
|
|
10389
10711
|
exports.useElementContainer = useElementContainer;
|