@shipengine/js-api 0.18.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -3311,8 +3311,10 @@ class RatesAPI {
3311
3311
  class SalesOrderShipmentsAPI {
3312
3312
  constructor(client) {
3313
3313
  this.client = client;
3314
- this.list = (params = {}) => {
3315
- return this.client.post("/v-beta/shipments/list", params);
3314
+ this.list = (body = {}, params) => {
3315
+ return this.client.post("/v-beta/shipments/list", body, {
3316
+ params
3317
+ });
3316
3318
  };
3317
3319
  this.get = (shipmentId) => {
3318
3320
  return this.client.get(`/v-beta/shipments/${shipmentId}`);
@@ -3375,6 +3377,9 @@ class ShipmentsAPI {
3375
3377
  createdAtStart !== void 0 ? { params: { createdAtStart } } : void 0
3376
3378
  );
3377
3379
  };
3380
+ this.list = (options) => {
3381
+ return this.client.get("/v1/shipments", { params: options });
3382
+ };
3378
3383
  this.create = (...shipments) => __async$1(this, null, function* () {
3379
3384
  return this.client.post("/v1/shipments", {
3380
3385
  shipments
package/index.mjs CHANGED
@@ -3307,8 +3307,10 @@ class RatesAPI {
3307
3307
  class SalesOrderShipmentsAPI {
3308
3308
  constructor(client) {
3309
3309
  this.client = client;
3310
- this.list = (params = {}) => {
3311
- return this.client.post("/v-beta/shipments/list", params);
3310
+ this.list = (body = {}, params) => {
3311
+ return this.client.post("/v-beta/shipments/list", body, {
3312
+ params
3313
+ });
3312
3314
  };
3313
3315
  this.get = (shipmentId) => {
3314
3316
  return this.client.get(`/v-beta/shipments/${shipmentId}`);
@@ -3371,6 +3373,9 @@ class ShipmentsAPI {
3371
3373
  createdAtStart !== void 0 ? { params: { createdAtStart } } : void 0
3372
3374
  );
3373
3375
  };
3376
+ this.list = (options) => {
3377
+ return this.client.get("/v1/shipments", { params: options });
3378
+ };
3374
3379
  this.create = (...shipments) => __async$1(this, null, function* () {
3375
3380
  return this.client.post("/v1/shipments", {
3376
3381
  shipments
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipengine/js-api",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {
@@ -14,3 +14,37 @@ export interface LinkedResource {
14
14
  href: string;
15
15
  type: string;
16
16
  }
17
+ export type ISOString = string;
18
+ export type PageableQuery = {
19
+ page?: number;
20
+ pageSize?: number;
21
+ };
22
+ export type PageableResult = {
23
+ links: {
24
+ first: LinkedResource;
25
+ last: LinkedResource;
26
+ next: LinkedResource;
27
+ prev: LinkedResource;
28
+ };
29
+ page: number;
30
+ pages: number;
31
+ total: number;
32
+ };
33
+ export type BatchableQuery = {
34
+ batchId?: string;
35
+ };
36
+ export type TaggableQuery = {
37
+ tag?: string;
38
+ };
39
+ export type CreationRangeQuery = {
40
+ createdAtEnd?: ISOString;
41
+ createdAtStart?: ISOString;
42
+ };
43
+ export type ModificationRangeQuery = {
44
+ modifiedAtEnd?: ISOString;
45
+ modifiedAtStart?: ISOString;
46
+ };
47
+ export type SortableQuery<TSortKeys = "created_at" | "modified_at"> = {
48
+ sortBy?: TSortKeys;
49
+ sortDir?: "asc" | "desc";
50
+ };
@@ -1,14 +1,29 @@
1
1
  import { AxiosInstance } from "axios";
2
+ import { CreationRangeQuery, ISOString, ModificationRangeQuery, PageableQuery, PageableResult, SortableQuery } from "../resources";
3
+ import { FulfillmentStatus, PaymentStatus } from "../sales-orders";
2
4
  import { SalesOrderShipment } from "./types";
3
- export interface ListSalesOrderShipmentsParams {
5
+ export type ListSalesOrderShipmentsParams = {
6
+ cancelled?: boolean;
7
+ externalOrderId?: string;
8
+ externalOrderNumber?: string;
9
+ fulfillmentStatus?: FulfillmentStatus;
10
+ orderDateEnd?: ISOString;
11
+ orderDateStart?: ISOString;
12
+ orderSourceId?: string;
13
+ paymentStatus?: PaymentStatus;
4
14
  salesOrderIds?: string[];
5
- }
15
+ } & PageableQuery & CreationRangeQuery & ModificationRangeQuery & SortableQuery<"created_at" | "modified_at" | "order_date">;
16
+ export type ListSalesOrderShipmentBody = {
17
+ salesOrderIds?: string[];
18
+ shipments?: SalesOrderShipment[];
19
+ };
20
+ export type ListSalesOrderShipmentsResult = {
21
+ shipments: SalesOrderShipment[];
22
+ } & PageableResult;
6
23
  export declare class SalesOrderShipmentsAPI {
7
24
  private client;
8
25
  constructor(client: AxiosInstance);
9
- list: (params?: ListSalesOrderShipmentsParams) => Promise<import("axios").AxiosResponse<{
10
- shipments: SalesOrderShipment[];
11
- }, any>>;
26
+ list: (body?: ListSalesOrderShipmentBody | undefined, params?: ListSalesOrderShipmentsParams) => Promise<import("axios").AxiosResponse<ListSalesOrderShipmentsResult, any>>;
12
27
  get: (shipmentId: string) => Promise<import("axios").AxiosResponse<SalesOrderShipment, any>>;
13
28
  create: (salesOrderId: string, shipment: Partial<SalesOrderShipment>) => Promise<import("axios").AxiosResponse<SalesOrderShipment, any>>;
14
29
  update: (shipmentId: string, shipment: Partial<SalesOrderShipment>) => Promise<import("axios").AxiosResponse<SalesOrderShipment, any>>;
@@ -1,5 +1,6 @@
1
1
  import { AxiosInstance } from "axios";
2
- import { Shipment, ShipmentRateResponse } from "./types";
2
+ import { BatchableQuery, CreationRangeQuery, ModificationRangeQuery, PageableQuery, PageableResult, SortableQuery, TaggableQuery } from "../resources";
3
+ import { Shipment, ShipmentRateResponse, ShipmentStatus } from "./types";
3
4
  export type GetShipmentRatesOptions = {
4
5
  /**
5
6
  * Date to filter rates by (they must be more recent than this date if passed)
@@ -8,12 +9,21 @@ export type GetShipmentRatesOptions = {
8
9
  createdAtStart?: string;
9
10
  shipmentId: string;
10
11
  };
12
+ export type ListShipmentOptions = {
13
+ salesOrderId?: string;
14
+ shipmentStatus?: ShipmentStatus;
15
+ } & BatchableQuery & PageableQuery & CreationRangeQuery & ModificationRangeQuery & SortableQuery & TaggableQuery;
16
+ export type ListShipmentResult = {
17
+ shipments: Shipment[];
18
+ } & PageableResult;
19
+ export type CreateShipmentResult = {
20
+ hasErrors: boolean;
21
+ shipments: Shipment[];
22
+ };
11
23
  export declare class ShipmentsAPI {
12
24
  private client;
13
25
  constructor(client: AxiosInstance);
14
26
  getShipmentRates: ({ shipmentId, createdAtStart }: GetShipmentRatesOptions) => Promise<import("axios").AxiosResponse<ShipmentRateResponse, any>>;
15
- create: (...shipments: Partial<Omit<Shipment, "items">>[]) => Promise<import("axios").AxiosResponse<{
16
- has_errors: boolean;
17
- shipments: Shipment[];
18
- }, any>>;
27
+ list: (options?: ListShipmentOptions) => Promise<import("axios").AxiosResponse<ListShipmentResult, any>>;
28
+ create: (...shipments: Partial<Omit<Shipment, "items">>[]) => Promise<import("axios").AxiosResponse<CreateShipmentResult, any>>;
19
29
  }
@@ -1 +0,0 @@
1
- export type RequireField<T, K extends keyof T> = T & Required<Pick<T, K>>;