@shipengine/js-api 1.0.0-next.5 → 1.0.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.
Files changed (51) hide show
  1. package/README.md +30 -0
  2. package/account-billing-plan/api.d.ts +17 -0
  3. package/account-billing-plan/index.d.ts +2 -0
  4. package/account-billing-plan/types.d.ts +37 -0
  5. package/account-settings/api.d.ts +29 -2
  6. package/account-settings/types.d.ts +19 -3
  7. package/addresses/api.d.ts +11 -0
  8. package/carriers/api.d.ts +69 -2
  9. package/carriers/types.d.ts +21 -3
  10. package/client.d.ts +156 -2
  11. package/connections/api.d.ts +18 -0
  12. package/connections/index.d.ts +2 -0
  13. package/connections/types.d.ts +36 -0
  14. package/custom-packages/api.d.ts +6 -0
  15. package/dimensions/types.d.ts +5 -0
  16. package/errors/types.d.ts +2 -2
  17. package/errors/utils.d.ts +4 -0
  18. package/funding-sources/api.d.ts +56 -0
  19. package/funding-sources/index.d.ts +2 -0
  20. package/funding-sources/types.d.ts +159 -0
  21. package/index.d.ts +7 -0
  22. package/index.js +4212 -16
  23. package/index.mjs +4025 -2784
  24. package/insurance/api.d.ts +7 -0
  25. package/labels/api.d.ts +89 -5
  26. package/order-sources/api.d.ts +17 -0
  27. package/package.json +6 -2
  28. package/rate-cards/api.d.ts +44 -0
  29. package/rate-cards/index.d.ts +2 -0
  30. package/rate-cards/types.d.ts +88 -0
  31. package/rates/api.d.ts +26 -0
  32. package/resources/types.d.ts +40 -0
  33. package/sales-order-shipments/api.d.ts +94 -5
  34. package/sales-orders/api.d.ts +25 -0
  35. package/shipments/api.d.ts +72 -0
  36. package/shipments/index.d.ts +1 -0
  37. package/shipments/types.d.ts +85 -4
  38. package/shipping-rules/api.d.ts +36 -0
  39. package/shipping-rules/index.d.ts +2 -0
  40. package/shipping-rules/types.d.ts +77 -0
  41. package/themes/api.d.ts +13 -0
  42. package/themes/index.d.ts +2 -0
  43. package/themes/types.d.ts +21 -0
  44. package/types.d.ts +9 -0
  45. package/utilities/index.d.ts +1 -0
  46. package/utilities/ip-address.d.ts +1 -0
  47. package/warehouses/api.d.ts +19 -0
  48. package/weight-band/index.d.ts +1 -0
  49. package/weight-band/types.d.ts +17 -0
  50. package/zones/index.d.ts +1 -0
  51. package/zones/types.d.ts +7 -0
package/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # ShipEngine JS Api
2
+
3
+ The `shipengine/js-api` library instantiates a batteries-included, vanilla JavaScript client for interacting with the [ShipEngine API](https://shipengine.github.io/shipengine-openapi/). The client provides a set of fully-typed methods that map directly to ShipEngine API operations[^1], bound to a user specified via platform token.
4
+
5
+ ## Features:
6
+
7
+ - Converts all outbound JSON keys to `snake_case` for consumption by the ShipEngine API.
8
+ - Converts all inbound JSON keys to `camelCase` for use in JS.
9
+ - Attempts to refresh expired tokens on `401 Unauthorized` responses, followed by retrying the original request.
10
+ - Logs all requests and responses to the console.
11
+
12
+ In addition to the client, the `shipengine/js-api` lib provides TypeScript types for all ShipEngine API entities.
13
+
14
+ ## Basic Usage
15
+
16
+ ```tsx
17
+ import { ShipEngineAPI } from "@shipengine/js-api";
18
+
19
+ const client = new ShipEngineAPI("your-platform-token", {
20
+ // Used when attempting to refresh the token on 401 responses
21
+ getToken: async () => {
22
+ return "your-platform-token";
23
+ },
24
+ });
25
+
26
+ client.shipments.list().then((response) => {
27
+ console.log(response.data);
28
+ // > an object matching the response schema of https://shipengine.github.io/shipengine-openapi/#operation/list_shipments
29
+ });
30
+ ```
@@ -0,0 +1,17 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { AccountBillingPlanResponse, UpdateAccountBillingPlanRequestBody, UpdateAccountBillingPlanResponse } from "./types";
3
+ /**
4
+ * # Account Billing Plan API module - /v1/account/billing_plan
5
+ */
6
+ export declare class AccountBillingPlanAPI {
7
+ private client;
8
+ constructor(client: AxiosInstance);
9
+ /**
10
+ * The `get` method retrieves the account billing plan for the current user.
11
+ */
12
+ get: () => Promise<import("axios").AxiosResponse<AccountBillingPlanResponse, any>>;
13
+ /**
14
+ * The `update` method updates the code of the account billing plan
15
+ */
16
+ update: (reqBody: UpdateAccountBillingPlanRequestBody) => Promise<import("axios").AxiosResponse<UpdateAccountBillingPlanResponse, any>>;
17
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./api";
2
+ export * from "./types";
@@ -0,0 +1,37 @@
1
+ export declare enum AccountBillingPlanChangeType {
2
+ Downgrade = "Downgrade",
3
+ Cancellation = "Cancellation"
4
+ }
5
+ export type AccountBillingPlan = {
6
+ code: string;
7
+ name: string;
8
+ };
9
+ /**
10
+ * Responses
11
+ */
12
+ /**
13
+ * "cancelledAt", "pendingChange" and "trialEndAt" are only available when applies
14
+ * won't be on the response otherwise
15
+ */
16
+ export type AccountBillingPlanResponse = {
17
+ billingPlan: AccountBillingPlan;
18
+ cancelledAt?: string;
19
+ currentBillingCycle: {
20
+ endsAt: string;
21
+ startedAt: string;
22
+ };
23
+ pendingChange?: {
24
+ changeTo: AccountBillingPlan;
25
+ effectiveAt: string;
26
+ requestedAt: string;
27
+ type: AccountBillingPlanChangeType;
28
+ };
29
+ trialEndAt?: string;
30
+ };
31
+ export type UpdateAccountBillingPlanResponse = {
32
+ code: string;
33
+ name: string;
34
+ };
35
+ export type UpdateAccountBillingPlanRequestBody = {
36
+ code: string;
37
+ };
@@ -1,8 +1,35 @@
1
1
  import { AxiosInstance } from "axios";
2
- import { AccountSettings } from "./types";
2
+ import { AccountImage, AccountImageResponse, AccountImagesResponse, AccountSettings, UpdateAccountImage } from "./types";
3
+ /**
4
+ * # Account Settings API module - /v1/account/settings
5
+ */
3
6
  export declare class AccountSettingsAPI {
4
7
  private client;
5
8
  constructor(client: AxiosInstance);
9
+ /**
10
+ * The `get` method retrieves the account settings for a given user.
11
+ */
6
12
  get: () => Promise<import("axios").AxiosResponse<AccountSettings, any>>;
7
- update: (settings: AccountSettings) => Promise<import("axios").AxiosResponse<AccountSettings, any>>;
13
+ /**
14
+ * The `update` method updates specific account settings for a given user.
15
+ *
16
+ * @params Partial<AccountSettings> The account settings to update.
17
+ */
18
+ update: (settings: Partial<AccountSettings>) => Promise<import("axios").AxiosResponse<AccountSettings, any>>;
19
+ /**
20
+ * The `createImage` method creates an image that can be used in your printed labels.
21
+ */
22
+ createImage: (data: AccountImage) => Promise<import("axios").AxiosResponse<AccountImageResponse, any>>;
23
+ /**
24
+ * The `updateImage` method updates specific image data for a given image id.
25
+ */
26
+ updateImage: ({ labelImageId, ...data }: UpdateAccountImage) => Promise<import("axios").AxiosResponse<void, any>>;
27
+ /**
28
+ * The `getImages` method retrieves a list of images for a given user.
29
+ */
30
+ getImages: () => Promise<import("axios").AxiosResponse<AccountImagesResponse, any>>;
31
+ /**
32
+ * The `deleteAccountImage` method deletes an image by id.
33
+ */
34
+ deleteImage: (labelImageId: string) => Promise<import("axios").AxiosResponse<void, any>>;
8
35
  }
@@ -1,8 +1,24 @@
1
1
  import { DimensionUnit } from "../dimensions";
2
2
  import { LabelLayout } from "../labels";
3
+ import { PageableResult } from "../resources";
3
4
  import { WeightUnit } from "../weight";
4
5
  export interface AccountSettings {
5
- defaultLabelLayout?: LabelLayout;
6
- dimension?: DimensionUnit;
7
- weight?: WeightUnit;
6
+ defaultLabelLayout: LabelLayout;
7
+ dimensionsUnit: DimensionUnit;
8
+ weightUnit: WeightUnit;
8
9
  }
10
+ export type AccountImage = {
11
+ imageContentType: string;
12
+ imageData: string;
13
+ isDefault: boolean;
14
+ name: string;
15
+ };
16
+ export type AccountImageResponse = AccountImage & {
17
+ createdAt: string;
18
+ labelImageId: string;
19
+ modifiedAt: string;
20
+ };
21
+ export type AccountImagesResponse = {
22
+ images: AccountImageResponse[];
23
+ } & PageableResult;
24
+ export type UpdateAccountImage = Partial<Omit<AccountImageResponse, "isDefault" | "createdAt" | "modifiedAt">> & Pick<AccountImageResponse, "isDefault">;
@@ -1,8 +1,19 @@
1
1
  import { AxiosInstance } from "axios";
2
2
  import { Address, AddressExtraction, AddressValidation } from "./types";
3
+ /**
4
+ * # Addresses API module - /v1/addresses
5
+ */
3
6
  export declare class AddressesAPI {
4
7
  private client;
5
8
  constructor(client: AxiosInstance);
9
+ /**
10
+ * The `validate` method validates a list of addresses.
11
+ *
12
+ * @params Address[] The addresses to be validated.
13
+ */
6
14
  validate: (addresses: Address[]) => Promise<import("axios").AxiosResponse<AddressValidation[], any>>;
15
+ /**
16
+ * The `parse` method parses a string of text to extract addresses.
17
+ */
7
18
  parse: (text: string, address?: Partial<Address>) => Promise<import("axios").AxiosResponse<AddressExtraction, any>>;
8
19
  }
package/carriers/api.d.ts CHANGED
@@ -1,17 +1,84 @@
1
1
  import { AxiosInstance } from "axios";
2
- import { Money } from "../payments";
3
- import { Carrier, CarrierAutoFundingSettings, CarrierAutoFundingSettingsResponse, CarrierConnection } from "./types";
2
+ import { Currency, Money } from "../payments";
3
+ import { Carrier, CarrierAutoFundingSettings, CarrierAutoFundingSettingsResponse, CarrierConnection, CarrierService, CarrierZone, PackageRatingType } from "./types";
4
+ /**
5
+ * # Carriers API module - /v1/carriers
6
+ */
4
7
  export declare class CarriersAPI {
5
8
  private client;
6
9
  constructor(client: AxiosInstance);
10
+ /**
11
+ * The `list` method retrieves a list of connected carriers for a given user.
12
+ */
7
13
  list: () => Promise<import("axios").AxiosResponse<{
8
14
  carriers: Carrier[];
9
15
  }, any>>;
16
+ /**
17
+ * The `get` method retrieves a specific carrier by `carrierId`.
18
+ */
10
19
  get: (carrierId: string) => Promise<import("axios").AxiosResponse<Carrier, any>>;
20
+ /**
21
+ * The `connect` method connects a carrier account to a user's ShipEngine account.
22
+ */
11
23
  connect: ({ carrierCode, ...connection }: CarrierConnection) => Promise<import("axios").AxiosResponse<void, any>>;
24
+ /**
25
+ * The `addFunds` method allows a user to add funds to their carrier account balance.
26
+ * Not all carrier providers allow you to maintain a balance.
27
+ *
28
+ * - For example, FedEx does
29
+ * not require you to maintain a balance that will be used when purchasing labels.
30
+ */
12
31
  addFunds: (carrierId: string, funds: Money) => Promise<import("axios").AxiosResponse<{
13
32
  balance: Money;
14
33
  }, any>>;
34
+ /**
35
+ * The `updateAutoFunding` method allows a user to update the auto-funding settings
36
+ * on their ShipEngine account.
37
+ *
38
+ * e.g. Enable auto-funding, set a balance threshold, and a maximum number of time
39
+ * per day you wish to auto-fund your account.
40
+ */
15
41
  updateAutoFunding: (carrierId: string, options: CarrierAutoFundingSettings) => Promise<import("axios").AxiosResponse<CarrierAutoFundingSettingsResponse, any>>;
42
+ /**
43
+ * The `getAutoFunding` method retrieves the current auto-funding settings.
44
+ *
45
+ * If no auto-funding rules have been set, the response will contain the default
46
+ * values for auto-funding. Auto-funding is disabled by default.
47
+ */
16
48
  getAutoFunding: (carrierId: string) => Promise<import("axios").AxiosResponse<CarrierAutoFundingSettingsResponse, any>>;
49
+ /**
50
+ * The `getServices` method retrieves a list of shipping services that a given carrier offers.
51
+ */
52
+ getServices: (carrierId: string) => Promise<import("axios").AxiosResponse<{
53
+ services: CarrierService[];
54
+ }, any>>;
55
+ /**
56
+ * The `getPackageRatingGroup` method retrieves a list of package rating groups.
57
+ * This is primarily used for carriers that support negotiated rates, and a user
58
+ * has a rate card with multiple package rating groups.
59
+ */
60
+ getPackageRatingGroup: (carrierId: string) => Promise<import("axios").AxiosResponse<{
61
+ packageRatingGroup: PackageRatingType[];
62
+ }, any>>;
63
+ /**
64
+ * The `getCountries` method retrieves a list of countries that a given carrier
65
+ * supports shipping to.
66
+ */
67
+ getCountries: (carrierId: string) => Promise<import("axios").AxiosResponse<{
68
+ countries: string[];
69
+ }, any>>;
70
+ /**
71
+ * The `getCurrencies` method retrieves a list of currencies that a given carrier
72
+ * supports the usage of.
73
+ */
74
+ getCurrencies: (carrierId: string) => Promise<import("axios").AxiosResponse<{
75
+ currencies: Currency[];
76
+ }, any>>;
77
+ /**
78
+ * The `getZones` method retrieves a list of zones for which the attached carrier
79
+ * provides support to.
80
+ */
81
+ getZones: (carrierId: string) => Promise<import("axios").AxiosResponse<{
82
+ zones: CarrierZone[];
83
+ }, any>>;
17
84
  }
@@ -1,6 +1,7 @@
1
1
  import { Address } from "../addresses";
2
2
  import { DimensionsWithUnit } from "../dimensions";
3
3
  import { CreditCard, Money } from "../payments";
4
+ import { WeightWithUnit } from "../weight";
4
5
  /**
5
6
  * @category Entities
6
7
  */
@@ -47,6 +48,20 @@ export interface CarrierPackage {
47
48
  packageCode: string;
48
49
  packageId?: string;
49
50
  }
51
+ /**
52
+ * @category Entities
53
+ */
54
+ export interface PackageRatingType {
55
+ apiCode?: string;
56
+ carrierPackageTypeCode: string;
57
+ description: string;
58
+ dimensions: DimensionsWithUnit;
59
+ maxWeight: WeightWithUnit;
60
+ name: string;
61
+ packageId: string;
62
+ packageTypeId?: string;
63
+ status: string;
64
+ }
50
65
  /**
51
66
  * @category Entities
52
67
  */
@@ -86,12 +101,11 @@ export type CarrierConnection = {
86
101
  carrierCode: "dhl_express_walleted";
87
102
  nickname: string;
88
103
  };
89
- export type WalletTransactionType = "adjustment" | "fund" | "purchase" | "reload" | "void";
104
+ export type WalletTransactionType = "adjustment" | "purchase" | "reload" | "void";
90
105
  export type WalletTransaction = {
91
106
  amount: number;
92
107
  balance: number;
93
- carrierId: string;
94
- carrierProvider: string;
108
+ carrier: Pick<Carrier, "carrierId" | "carrierCode" | "friendlyName">;
95
109
  labelId: string;
96
110
  transactionDate: string;
97
111
  transactionId: string;
@@ -107,3 +121,7 @@ export type WalletTransactionHistory = {
107
121
  total: number;
108
122
  transactions: WalletTransaction[];
109
123
  };
124
+ export type CarrierZone = {
125
+ apiCode: string;
126
+ name: string;
127
+ };
package/client.d.ts CHANGED
@@ -1,34 +1,188 @@
1
- import { AxiosRequestHeaders } from "axios";
1
+ import { AxiosError, AxiosRequestHeaders } from "axios";
2
+ import { AccountBillingPlanAPI } from "./account-billing-plan";
2
3
  import { AccountSettingsAPI } from "./account-settings";
3
4
  import { AddressesAPI } from "./addresses";
4
5
  import { CarriersAPI } from "./carriers";
6
+ import { ConnectionsAPI } from "./connections";
5
7
  import { CustomPackagesAPI } from "./custom-packages";
8
+ import { CodedError } from "./errors";
9
+ import { FundingSourcesAPI } from "./funding-sources";
6
10
  import { InsuranceAPI } from "./insurance";
7
11
  import { LabelsAPI } from "./labels";
8
12
  import { OrderSourcesAPI } from "./order-sources";
13
+ import { RateCardsAPI } from "./rate-cards";
9
14
  import { RatesAPI } from "./rates";
10
15
  import { SalesOrderShipmentsAPI } from "./sales-order-shipments";
11
16
  import { SalesOrdersAPI } from "./sales-orders";
17
+ import { ShipmentsAPI } from "./shipments";
18
+ import { ShippingRulesAPI } from "./shipping-rules";
19
+ import { ThemesAPI } from "./themes";
12
20
  import { WarehousesAPI } from "./warehouses";
21
+ /**
22
+ * # ShipEngine API Client Headers
23
+ */
13
24
  export type ShipEngineAPIHeaders = AxiosRequestHeaders;
25
+ /**
26
+ * # ShipEngine API axios error response
27
+ */
28
+ export type ApiError = AxiosError<{
29
+ errors: CodedError[];
30
+ } | CodedError[] | CodedError | string>;
31
+ /**
32
+ * # ShipEngine API Client Configuration
33
+ */
14
34
  export interface ShipEngineAPIConfig {
35
+ /**
36
+ * `baseURL` is an optional string that represents the base URL to be used for all requests.
37
+ */
15
38
  baseURL?: string;
39
+ /**
40
+ * `getToken` is an optional callback function that returns a token to used to authenticate all requests.
41
+ */
16
42
  getToken: () => Promise<string> | string;
43
+ /**
44
+ * `headers` are optional HTTP headers to be sent with all requests.
45
+ */
17
46
  headers?: ShipEngineAPIHeaders;
47
+ /**
48
+ * `onApiError` is an optional callback function that will be executed whenever there is an error.
49
+ */
50
+ onApiError?: (errors: CodedError[], error: ApiError) => void;
18
51
  }
52
+ /**
53
+ * # ShipEngine API Client
54
+ *
55
+ * - This class is the ShipEngine API Client that facilitates all requests. e.g.
56
+ * Rate Shopping, Label Creation, etc.
57
+ */
19
58
  export declare class ShipEngineAPI {
20
59
  private client;
21
- constructor(token: string, { baseURL, headers, getToken }: ShipEngineAPIConfig);
60
+ constructor(token: string, { baseURL, headers, getToken, onApiError }: ShipEngineAPIConfig);
61
+ /**
62
+ * The `token` method takes in a string and sets it as the Authorization header for all requests.
63
+ */
22
64
  set token(token: string);
65
+ /**
66
+ * The `accountSettings` method provides access to the Account Settings endpoints
67
+ * in ShipEngine API.
68
+ *
69
+ * @see {@link AccountSettingsAPI | The Account Settings API module}
70
+ */
23
71
  get accountSettings(): AccountSettingsAPI;
72
+ /**
73
+ * The `accountBillingPlan` method provides access to the Account Billing Plan endpoints
74
+ * in ShipEngine API.
75
+ */
76
+ get accountBillingPlan(): AccountBillingPlanAPI;
77
+ /**
78
+ * The `addresses` method provides access to the Address Validation endpoints
79
+ * in ShipEngine API. e.g. Validate Addresses, Parse Addresses, etc.
80
+ *
81
+ * @see {@link AddressesAPI | The Addresses API module}
82
+ */
24
83
  get addresses(): AddressesAPI;
84
+ /**
85
+ * The `carriers` method provides access to the Carrier endpoints in ShipEngine
86
+ * API. e.g. List Carriers, Get Carrier, Connect Carrier, etc.
87
+ *
88
+ * @see {@link CarriersAPI | The Carriers API module}
89
+ */
25
90
  get carriers(): CarriersAPI;
91
+ /**
92
+ * The `connections` method provides access to the Connections endpoints in ShipEngine
93
+ * API. e.g. List Carrier Connections, Get Carrier Connection Form
94
+ *
95
+ * @see {@link ConnectionsAPI | The Connections API module}
96
+ */
97
+ get connections(): ConnectionsAPI;
98
+ /**
99
+ * The `customPackages` method provides access to the Packages endpoint in ShipEngine
100
+ * API. e.g. List Packages
101
+ *
102
+ * @see {@link CustomPackagesAPI | The Custom Packages API module}
103
+ */
26
104
  get customPackages(): CustomPackagesAPI;
105
+ /**
106
+ * The `fundingSources` method provides access to the Funding Sources endpoints
107
+ * in ShipEngine API.
108
+ *
109
+ * @see {@link FundingSourcesAPI | The Funding Sources API module}
110
+ */
111
+ get fundingSources(): FundingSourcesAPI;
112
+ /**
113
+ * The `insurance` method provides access to the Insurance endpoint in ShipEngine
114
+ * API. e.g. Get Insurance Balance
115
+ *
116
+ * @see {@link InsuranceAPI | The Insurance API module}
117
+ */
27
118
  get insurance(): InsuranceAPI;
119
+ /**
120
+ * The `labels` method provides access to the Label endpoints in ShipEngine API.
121
+ * e.g. Create Label, Get Label, Void Label, etc.
122
+ *
123
+ * @see {@link LabelsAPI | The Labels API module}
124
+ */
28
125
  get labels(): LabelsAPI;
126
+ /**
127
+ * The `orderSources` method provides access to the Order Sources endpoints in
128
+ * ShipEngine API. e.g. List Order Sources, Get Order Source, Refresh Order Source, etc.
129
+ *
130
+ * @see {@link OrderSourcesAPI | The Order Sources API module}
131
+ */
29
132
  get orderSources(): OrderSourcesAPI;
133
+ /**
134
+ * The `rateCards` method provides access to the Rate Cards endpoints in ShipEngine
135
+ * API.
136
+ *
137
+ * @see {@link RateCardsAPI | The Rate Cards API module}
138
+ */
139
+ get rateCards(): RateCardsAPI;
140
+ /**
141
+ * The `rates` method provides access to the Rate endpoints in ShipEngine API.
142
+ * e.g. Get Rates
143
+ *
144
+ * @see {@link RatesAPI | The Rates API module}
145
+ */
30
146
  get rates(): RatesAPI;
147
+ /**
148
+ * The `salesOrderShipments` method provides access to the `v-beta` Sales
149
+ * Order Shipments endpoints in ShipEngine API.
150
+ *
151
+ * @see {@link SalesOrderShipmentsAPI | The Sales Order Shipments API module}
152
+ */
31
153
  get salesOrderShipments(): SalesOrderShipmentsAPI;
154
+ /**
155
+ * The `salesOrders` method provides access to the `v-beta` Sales Order endpoints
156
+ * in ShipEngine API.
157
+ *
158
+ * @see {@link SalesOrdersAPI | The Sales Orders API module}
159
+ */
32
160
  get salesOrders(): SalesOrdersAPI;
161
+ /**
162
+ * The `shipments` method provides access to the Shipment endpoints in ShipEngine
163
+ * API. e.g. Create Shipment, Get Shipment, etc.
164
+ *
165
+ * @see {@link ShipmentsAPI | The Shipments API module}
166
+ */
167
+ get shipments(): ShipmentsAPI;
168
+ /**
169
+ * The `themes` method provides access to the Themes endpoints in ShipEngine API.
170
+ *
171
+ * @see {@link ThemesAPI | The Themes API module}
172
+ */
173
+ get themes(): ThemesAPI;
174
+ /**
175
+ * The `warehouses` method provides access to the Warehouses endpoints in ShipEngine
176
+ * API. e.g. List Warehouses, Get Warehouse, etc.
177
+ *
178
+ * @see {@link WarehousesAPI | The Warehouses API module}
179
+ */
33
180
  get warehouses(): WarehousesAPI;
181
+ /**
182
+ * The `shippingRules` method provides access to the Shipping Rules endpoints in ShipEngine
183
+ * API.
184
+ *
185
+ * @see {@link ShippingRulesAPI | The Shipping Rules API module}
186
+ */
187
+ get shippingRules(): ShippingRulesAPI;
34
188
  }
@@ -0,0 +1,18 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { GetCarrierConnectionFormParams, GetCarrierConnectionFormResponse, ListCarrierConnectionsParams, ListCarrierConnectionsResponse } from "./types";
3
+ /**
4
+ * # Carriers API module - /v1/carriers
5
+ */
6
+ export declare class ConnectionsAPI {
7
+ private client;
8
+ constructor(client: AxiosInstance);
9
+ /**
10
+ * The `listCarriers` method retrieves a list of carriers available to be connected.
11
+ */
12
+ listCarriers: (params?: ListCarrierConnectionsParams) => Promise<import("axios").AxiosResponse<ListCarrierConnectionsResponse, any>>;
13
+ /**
14
+ * The `getCarrierConnectionForm` method retrieves a JSON Form Schema for collecting
15
+ * information required to connect to the carrier.
16
+ */
17
+ getCarrierConnectionForm: (carrierName: string, params: GetCarrierConnectionFormParams) => Promise<import("axios").AxiosResponse<GetCarrierConnectionFormResponse, any>>;
18
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./api";
2
+ export * from "./types";
@@ -0,0 +1,36 @@
1
+ import { GenericObject, LocaleBasedQuery } from "../resources";
2
+ /**
3
+ * @category Requests
4
+ */
5
+ export type ListCarrierConnectionsParams = LocaleBasedQuery;
6
+ export type GetCarrierConnectionFormParams = LocaleBasedQuery;
7
+ /**
8
+ * @category Responses
9
+ */
10
+ export type GetCarrierConnectionFormResponse = {
11
+ formMetadata: {
12
+ connectionNames?: string[];
13
+ defaultConnectionName?: string;
14
+ formSchema: {
15
+ jsonSchema: GenericObject;
16
+ uiSchema: GenericObject;
17
+ };
18
+ };
19
+ };
20
+ export type ListCarrierConnectionsResponse = [
21
+ {
22
+ beta: boolean;
23
+ carrierFeatures?: [
24
+ {
25
+ country: string;
26
+ featureList: string[];
27
+ }
28
+ ];
29
+ carrierName: string;
30
+ description: string;
31
+ iconUrl: string;
32
+ logoUrl: string;
33
+ name: string;
34
+ searchTerms?: string[];
35
+ }
36
+ ];
@@ -1,8 +1,14 @@
1
1
  import { AxiosInstance } from "axios";
2
2
  import { CustomPackage } from "./types";
3
+ /**
4
+ * # Custom Packages API module - /v1/packages
5
+ */
3
6
  export declare class CustomPackagesAPI {
4
7
  private client;
5
8
  constructor(client: AxiosInstance);
9
+ /**
10
+ * The `list` method retrieves a list of custom packages a given user has created.
11
+ */
6
12
  list: () => Promise<import("axios").AxiosResponse<{
7
13
  packages: CustomPackage[];
8
14
  }, any>>;
@@ -6,8 +6,13 @@ export type DimensionUnit = "inch" | "centimeter";
6
6
  * @category Entities
7
7
  */
8
8
  export interface Dimensions {
9
+ girth?: number;
9
10
  height: number;
10
11
  length: number;
12
+ lengthPlusGirth?: number;
13
+ noThreeSidesExceed?: number;
14
+ noTwoSidesExceed?: number;
15
+ volume?: number;
11
16
  width: number;
12
17
  }
13
18
  /**
package/errors/types.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * @category Entities
3
3
  */
4
- export type CodedErrorCode = "auto_fund_not_supported" | "batch_cannot_be_modified" | "carrier_conflict" | "carrier_disconnected" | "carrier_not_connected" | "carrier_not_supported" | "confirmation_not_supported" | "default_warehouse_cannot_be_deleted" | "field_conflict" | "field_value_required" | "forbidden" | "identifier_conflict" | "identifiers_must_match" | "insufficient_funds" | "invalid_address" | "invalid_billing_plan" | "invalid_field_value" | "invalid_identifier" | "invalid_status" | "invalid_string_length" | "label_images_not_supported" | "meter_failure" | "order_source_not_active" | "rate_limit_exceeded" | "refresh_not_supported" | "request_body_required" | "return_label_not_supported" | "settings_not_supported" | "subscription_inactive" | "terms_not_accepted" | "tracking_not_supported" | "trial_expired" | "unauthorized" | "unknown" | "unspecified" | "verification_failure" | "warehouse_conflict" | "webhook_event_type_conflict";
4
+ export type CodedErrorCode = "auto_fund_not_supported" | "batch_cannot_be_modified" | "carrier_conflict" | "carrier_disconnected" | "carrier_not_connected" | "carrier_not_supported" | "confirmation_not_supported" | "default_warehouse_cannot_be_deleted" | "duplicated_name" | "duplicated_rate_card" | "empty_file" | "field_conflict" | "field_value_required" | "forbidden" | "identifier_conflict" | "identifiers_must_match" | "insufficient_funds" | "insufficient_rate_card_data" | "invalid_address" | "invalid_billing_plan" | "invalid_currency" | "invalid_field_value" | "invalid_file_size" | "invalid_file_type" | "invalid_identifier" | "invalid_packages" | "invalid_rates" | "invalid_service" | "invalid_shipping_rule" | "invalid_status" | "invalid_string_length" | "invalid_weight_bands_rates" | "invalid_weight_bands" | "invalid_zones" | "label_images_not_supported" | "meter_failure" | "not_found" | "order_source_not_active" | "rate_limit_exceeded" | "refresh_not_supported" | "repeated_surcharges_in_rate_card" | "repeated_surcharges_in_services" | "repeated_surcharges_in_zone" | "request_body_required" | "return_label_not_supported" | "settings_not_supported" | "subscription_inactive" | "terms_not_accepted" | "tracking_not_supported" | "trial_expired" | "unauthorized" | "unknown" | "unspecified" | "verification_failure" | "warehouse_conflict" | "webhook_event_type_conflict";
5
5
  /**
6
6
  * @category Entities
7
7
  */
8
- export type CodedErrorSource = "carrier" | "order_source" | "shipengine" | "elements" | "client";
8
+ export type CodedErrorSource = "carrier" | "client" | "elements" | "order_source" | "rate_card_manager" | "shipengine" | "shipping_rule_api";
9
9
  /**
10
10
  * @category Entities
11
11
  */
package/errors/utils.d.ts CHANGED
@@ -1,3 +1,7 @@
1
1
  import { CodedError } from "./types";
2
2
  export declare const isCodedErrors: (errs: any) => errs is CodedError[];
3
3
  export declare const isCodedError: (err: any) => err is CodedError;
4
+ export declare const isDataCodedErrors: (data: any) => data is {
5
+ errors: CodedError[];
6
+ };
7
+ export declare const parseError: (err: any) => CodedError[];