@shipengine/js-api 0.47.0 → 0.47.1

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 (2) hide show
  1. package/README.md +30 -0
  2. package/package.json +1 -1
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
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipengine/js-api",
3
- "version": "0.47.0",
3
+ "version": "0.47.1",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {