@shipengine/js-api 0.38.0 → 0.39.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
@@ -3644,6 +3644,12 @@ class ShippingRulesAPI {
3644
3644
  this.list = () => {
3645
3645
  return this.client.get(`/v1/shipping_rules`);
3646
3646
  };
3647
+ /**
3648
+ * The `create` method creates a new shipping rule for a given user.
3649
+ */
3650
+ this.create = (shippingRule) => {
3651
+ return this.client.post("/v1/shipping_rules", shippingRule);
3652
+ };
3647
3653
  this.client = client;
3648
3654
  }
3649
3655
  }
package/index.mjs CHANGED
@@ -3640,6 +3640,12 @@ class ShippingRulesAPI {
3640
3640
  this.list = () => {
3641
3641
  return this.client.get(`/v1/shipping_rules`);
3642
3642
  };
3643
+ /**
3644
+ * The `create` method creates a new shipping rule for a given user.
3645
+ */
3646
+ this.create = (shippingRule) => {
3647
+ return this.client.post("/v1/shipping_rules", shippingRule);
3648
+ };
3643
3649
  this.client = client;
3644
3650
  }
3645
3651
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shipengine/js-api",
3
- "version": "0.38.0",
3
+ "version": "0.39.0",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {
@@ -1,4 +1,5 @@
1
1
  import { AxiosInstance } from "axios";
2
+ import { RequiredFields } from "../types";
2
3
  import { ShippingRule } from "./types";
3
4
  /**
4
5
  * # Shipping Rules API module - /v1/shipping_rules
@@ -12,4 +13,8 @@ export declare class ShippingRulesAPI {
12
13
  list: () => Promise<import("axios").AxiosResponse<{
13
14
  shippingRules: ShippingRule[];
14
15
  }, any>>;
16
+ /**
17
+ * The `create` method creates a new shipping rule for a given user.
18
+ */
19
+ create: (shippingRule: ShippingRule) => Promise<import("axios").AxiosResponse<RequiredFields<ShippingRule, "id">, any>>;
15
20
  }
@@ -10,7 +10,7 @@ type RuleTypeCondition = "is" | "is_less" | "is_more" | "is_not";
10
10
  /**
11
11
  * @category Entities
12
12
  */
13
- export interface Conditions {
13
+ export interface ShippingRulesConditions {
14
14
  identifier: RuleType;
15
15
  operation: RuleTypeCondition;
16
16
  value: string;
@@ -18,7 +18,7 @@ export interface Conditions {
18
18
  /**
19
19
  * @category Entities
20
20
  */
21
- export interface SelectedService {
21
+ export interface ShippingRuleSelectedService {
22
22
  carrierId: string;
23
23
  carrierServiceCode: string;
24
24
  }
@@ -30,8 +30,8 @@ export interface ShippingRule {
30
30
  code?: string;
31
31
  createdAt?: ISOString;
32
32
  default: {
33
- services: SelectedService[];
34
- sortBy: string;
33
+ services: ShippingRuleSelectedService[];
34
+ sortBy?: string;
35
35
  };
36
36
  deleted?: boolean;
37
37
  deletedAt?: ISOString;
@@ -39,10 +39,10 @@ export interface ShippingRule {
39
39
  name: string;
40
40
  rules?: [
41
41
  {
42
- conditions: Conditions[];
42
+ conditions: ShippingRulesConditions[];
43
43
  priority: number;
44
- services: SelectedService[];
45
- sortBy: string;
44
+ services: ShippingRuleSelectedService[];
45
+ sortBy?: string;
46
46
  }
47
47
  ];
48
48
  updatedAt?: ISOString;
package/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export type RequiredFields<T, K extends keyof T> = T & Required<Pick<T, K>>;
1
2
  export * from "./account-settings/types";
2
3
  export * from "./addresses/types";
3
4
  export * from "./carriers/types";
@@ -16,6 +17,7 @@ export * from "./resources/types";
16
17
  export * from "./sales-order-shipments/types";
17
18
  export * from "./sales-orders/types";
18
19
  export * from "./shipments/types";
20
+ export * from "./shipping-rules/types";
19
21
  export * from "./warehouses/types";
20
22
  export * from "./weight/types";
21
23
  export * from "./weight-band/types";