@shipengine/js-api 0.19.1 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -52,15 +52,15 @@ export interface CarrierPackage {
52
52
  * @category Entities
53
53
  */
54
54
  export interface CarrierRatePackageFormat {
55
- apiCode: string;
56
- carrierPackageTypeCode: string;
57
- description?: string;
58
- dimensions?: DimensionsWithUnit;
59
- id: string;
55
+ apiCode?: string;
56
+ carrierPackageTypeCode?: string;
57
+ description: string;
58
+ dimensions: DimensionsWithUnit;
59
+ maxWeight: WeightWithUnit;
60
60
  name: string;
61
+ packageId: string;
61
62
  packageTypeId?: string;
62
63
  status: string;
63
- weight: WeightWithUnit;
64
64
  }
65
65
  /**
66
66
  * @category Entities
package/index.d.ts CHANGED
@@ -21,3 +21,4 @@ export * from "./shipments";
21
21
  export * from "./utilities";
22
22
  export * from "./warehouses";
23
23
  export * from "./weight";
24
+ export * from "./zones";
package/index.js CHANGED
@@ -3291,6 +3291,14 @@ class RateCardsAPI {
3291
3291
  this.create = (rateCardInput) => {
3292
3292
  return this.client.post("/v1/rate_cards", rateCardInput);
3293
3293
  };
3294
+ this.update = (rateCard) => {
3295
+ return this.client.put(`/v1/rate_cards/${rateCard.id}`, rateCard);
3296
+ };
3297
+ this.download = (rateCardId) => {
3298
+ return this.client.get(`/v1/rate_cards/${rateCardId}/rates/download`, {
3299
+ responseType: "blob"
3300
+ });
3301
+ };
3294
3302
  this.client = client;
3295
3303
  }
3296
3304
  }
@@ -3482,12 +3490,17 @@ class ShipEngineAPI {
3482
3490
  transformRequest: [(data) => humpsExports.decamelizeKeys(data), (data) => JSON.stringify(data)],
3483
3491
  transformResponse: [
3484
3492
  (data) => {
3485
- if (data)
3493
+ if (data && !(data instanceof Blob))
3486
3494
  return JSON.parse(data);
3487
3495
  else
3488
- return;
3496
+ return data;
3489
3497
  },
3490
- (data) => humpsExports.camelizeKeys(data)
3498
+ (data) => {
3499
+ if (data && !(data instanceof Blob))
3500
+ return humpsExports.camelizeKeys(data);
3501
+ else
3502
+ return data;
3503
+ }
3491
3504
  ]
3492
3505
  });
3493
3506
  client.interceptors.response.use(
package/index.mjs CHANGED
@@ -3287,6 +3287,14 @@ class RateCardsAPI {
3287
3287
  this.create = (rateCardInput) => {
3288
3288
  return this.client.post("/v1/rate_cards", rateCardInput);
3289
3289
  };
3290
+ this.update = (rateCard) => {
3291
+ return this.client.put(`/v1/rate_cards/${rateCard.id}`, rateCard);
3292
+ };
3293
+ this.download = (rateCardId) => {
3294
+ return this.client.get(`/v1/rate_cards/${rateCardId}/rates/download`, {
3295
+ responseType: "blob"
3296
+ });
3297
+ };
3290
3298
  this.client = client;
3291
3299
  }
3292
3300
  }
@@ -3478,12 +3486,17 @@ class ShipEngineAPI {
3478
3486
  transformRequest: [(data) => humpsExports.decamelizeKeys(data), (data) => JSON.stringify(data)],
3479
3487
  transformResponse: [
3480
3488
  (data) => {
3481
- if (data)
3489
+ if (data && !(data instanceof Blob))
3482
3490
  return JSON.parse(data);
3483
3491
  else
3484
- return;
3492
+ return data;
3485
3493
  },
3486
- (data) => humpsExports.camelizeKeys(data)
3494
+ (data) => {
3495
+ if (data && !(data instanceof Blob))
3496
+ return humpsExports.camelizeKeys(data);
3497
+ else
3498
+ return data;
3499
+ }
3487
3500
  ]
3488
3501
  });
3489
3502
  client.interceptors.response.use(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipengine/js-api",
3
- "version": "0.19.1",
3
+ "version": "0.21.0",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {
@@ -7,4 +7,6 @@ export declare class RateCardsAPI {
7
7
  rateCards: RateCard[];
8
8
  }, any>>;
9
9
  create: (rateCardInput: RateCardInput) => Promise<import("axios").AxiosResponse<RateCard, any>>;
10
+ update: (rateCard: RateCard) => Promise<import("axios").AxiosResponse<RateCard, any>>;
11
+ download: (rateCardId: string) => Promise<import("axios").AxiosResponse<Blob, any>>;
10
12
  }
@@ -1,6 +1,8 @@
1
1
  import { CarrierRatePackageFormat, CarrierService } from "../carriers";
2
2
  import { Currency } from "../payments";
3
+ import { ISOString } from "../resources";
3
4
  import { WeightBandIncremental, WeightBandMinMax } from "../weight-band";
5
+ import { Zone } from "../zones";
4
6
  /**
5
7
  * @category Entities
6
8
  */
@@ -8,19 +10,58 @@ export interface ShipFromLocation {
8
10
  countryCode: string;
9
11
  postalCode?: string;
10
12
  }
13
+ /**
14
+ * @category Entities
15
+ */
16
+ export interface RateSurcharge {
17
+ fixedAmount: {
18
+ currency: Currency;
19
+ value: number;
20
+ };
21
+ name: string;
22
+ surchargeCode: string;
23
+ surchargeId: string;
24
+ }
11
25
  /**
12
26
  * @category Entities
13
27
  */
14
28
  export type RateService = Pick<CarrierService, "serviceCode" | "name"> & {
15
- packageTypes: RatePackageType[];
29
+ packageTypes?: RatePackageType[];
30
+ surcharges?: RateSurcharge[];
31
+ };
32
+ /**
33
+ * @category Entities
34
+ */
35
+ export type RateCardRate = {
36
+ currency: Currency;
37
+ value: number;
38
+ };
39
+ /**
40
+ * @category Entities
41
+ */
42
+ export type ZoneWithRate = Zone & {
43
+ rate?: RateCardRate;
44
+ surcharges?: RateSurcharge[];
45
+ };
46
+ /**
47
+ * @category Entities
48
+ */
49
+ export type RateWeightBandMinMax = WeightBandMinMax & {
50
+ zones?: ZoneWithRate[];
51
+ };
52
+ /**
53
+ * @category Entities
54
+ */
55
+ export type RateWeightBandIncremental = WeightBandIncremental & {
56
+ zones?: ZoneWithRate[];
16
57
  };
17
58
  /**
18
59
  * @category Entities
19
60
  */
20
- export type RatePackageType = CarrierRatePackageFormat & {
21
- weightBands: {
22
- incrementalBands: WeightBandIncremental[];
23
- minMaxBands: WeightBandMinMax[];
61
+ export type RatePackageType = Pick<CarrierRatePackageFormat, "packageId" | "name" | "description" | "dimensions" | "maxWeight"> & {
62
+ weightBands?: {
63
+ incrementalBands?: RateWeightBandIncremental[];
64
+ minMaxBands?: RateWeightBandMinMax[];
24
65
  };
25
66
  };
26
67
  /**
@@ -28,14 +69,17 @@ export type RatePackageType = CarrierRatePackageFormat & {
28
69
  */
29
70
  export interface RateCard {
30
71
  carrierId: string;
72
+ createdAt?: ISOString;
31
73
  currency?: Currency;
32
- endDate?: string;
74
+ endDate?: ISOString;
33
75
  id: string;
34
76
  name: string;
77
+ publishedAt?: ISOString;
35
78
  services?: RateService[];
36
79
  shipFrom?: ShipFromLocation;
37
- startDate?: string;
80
+ startDate?: ISOString;
38
81
  status?: string;
82
+ surcharges?: RateSurcharge[];
39
83
  }
40
84
  /**
41
85
  * @category Entities
package/types.d.ts CHANGED
@@ -19,3 +19,4 @@ export * from "./shipments/types";
19
19
  export * from "./warehouses/types";
20
20
  export * from "./weight/types";
21
21
  export * from "./weight-band/types";
22
+ export * from "./zones/types";
@@ -0,0 +1 @@
1
+ export * from "./types";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @category Entities
3
+ */
4
+ export type Zone = {
5
+ name: string;
6
+ zoneCode: string;
7
+ zoneId: string;
8
+ };