@shipengine/connect-carrier-api 4.0.0-beta.2 → 4.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 (107) hide show
  1. package/lib/app/create-endpoint-mapping.js +2 -0
  2. package/lib/app/create-endpoint-mapping.js.map +1 -1
  3. package/lib/constants.d.ts +1 -0
  4. package/lib/constants.js +6 -0
  5. package/lib/constants.js.map +1 -0
  6. package/lib/index.d.ts +1 -0
  7. package/lib/index.js +1 -0
  8. package/lib/index.js.map +1 -1
  9. package/lib/models/advanced-options.d.ts +5 -0
  10. package/lib/models/advanced-options.js.map +1 -1
  11. package/lib/models/bill-to.d.ts +14 -0
  12. package/lib/models/bill-to.js +14 -0
  13. package/lib/models/bill-to.js.map +1 -0
  14. package/lib/models/billing/billing-to-party.d.ts +10 -0
  15. package/lib/models/billing/billing-to-party.js +15 -0
  16. package/lib/models/billing/billing-to-party.js.map +1 -0
  17. package/lib/models/billing/index.d.ts +1 -0
  18. package/lib/models/billing/index.js +1 -0
  19. package/lib/models/billing/index.js.map +1 -1
  20. package/lib/models/cod-payment-type.d.ts +9 -0
  21. package/lib/models/cod-payment-type.js +14 -0
  22. package/lib/models/cod-payment-type.js.map +1 -0
  23. package/lib/models/collect-on-delivery.d.ts +9 -0
  24. package/lib/models/collect-on-delivery.js +8 -0
  25. package/lib/models/collect-on-delivery.js.map +1 -0
  26. package/lib/models/customs/customs-charges.d.ts +2 -0
  27. package/lib/models/customs/customs-charges.js.map +1 -1
  28. package/lib/models/customs/customs.d.ts +1 -1
  29. package/lib/models/index.d.ts +4 -0
  30. package/lib/models/index.js +4 -0
  31. package/lib/models/index.js.map +1 -1
  32. package/lib/models/native-rating/context-results.d.ts +3 -0
  33. package/lib/models/native-rating/context-results.js +3 -0
  34. package/lib/models/native-rating/context-results.js.map +1 -0
  35. package/lib/models/native-rating/get-rates.d.ts +7 -0
  36. package/lib/models/native-rating/get-rates.js +3 -0
  37. package/lib/models/native-rating/get-rates.js.map +1 -0
  38. package/lib/models/native-rating/get-variables.d.ts +6 -0
  39. package/lib/models/native-rating/get-variables.js +3 -0
  40. package/lib/models/native-rating/get-variables.js.map +1 -0
  41. package/lib/models/native-rating/get-zone.d.ts +6 -0
  42. package/lib/models/native-rating/get-zone.js +3 -0
  43. package/lib/models/native-rating/get-zone.js.map +1 -0
  44. package/lib/models/native-rating/implementation-type.d.ts +30 -0
  45. package/lib/models/native-rating/implementation-type.js +8 -0
  46. package/lib/models/native-rating/implementation-type.js.map +1 -0
  47. package/lib/models/native-rating/index.d.ts +7 -0
  48. package/lib/models/native-rating/index.js +11 -0
  49. package/lib/models/native-rating/index.js.map +1 -0
  50. package/lib/models/native-rating/numeric-currency.d.ts +5 -0
  51. package/lib/models/native-rating/numeric-currency.js +3 -0
  52. package/lib/models/native-rating/numeric-currency.js.map +1 -0
  53. package/lib/models/native-rating/rating-context.d.ts +15 -0
  54. package/lib/models/native-rating/rating-context.js +3 -0
  55. package/lib/models/native-rating/rating-context.js.map +1 -0
  56. package/lib/models/taxes/tax-identifier.d.ts +3 -1
  57. package/lib/models/taxes/tax-identifier.js.map +1 -1
  58. package/lib/requests/create-label-request.d.ts +3 -1
  59. package/lib/requests/create-label-request.js.map +1 -1
  60. package/lib/requests/get-rates-request.d.ts +3 -1
  61. package/lib/requests/get-rates-request.js.map +1 -1
  62. package/package.json +4 -4
  63. package/spec.json +54 -1
  64. package/src/app/create-endpoint-mapping.ts +2 -0
  65. package/src/constants.ts +2 -0
  66. package/src/index.ts +1 -0
  67. package/src/models/advanced-options.ts +5 -0
  68. package/src/models/bill-to.ts +15 -0
  69. package/src/models/billing/billing-to-party.ts +10 -0
  70. package/src/models/billing/index.ts +1 -0
  71. package/src/models/cod-payment-type.ts +9 -0
  72. package/src/models/collect-on-delivery.ts +10 -0
  73. package/src/models/customs/customs-charges.ts +2 -0
  74. package/src/models/customs/customs.ts +1 -1
  75. package/src/models/index.ts +4 -0
  76. package/src/models/native-rating/context-results.ts +3 -0
  77. package/src/models/native-rating/get-rates.ts +9 -0
  78. package/src/models/native-rating/get-variables.ts +8 -0
  79. package/src/models/native-rating/get-zone.ts +9 -0
  80. package/src/models/native-rating/implementation-type.ts +33 -0
  81. package/src/models/native-rating/index.ts +7 -0
  82. package/src/models/native-rating/numeric-currency.ts +5 -0
  83. package/src/models/native-rating/rating-context.ts +19 -0
  84. package/src/models/taxes/tax-identifier.ts +3 -1
  85. package/src/requests/create-label-request.ts +3 -0
  86. package/src/requests/get-rates-request.ts +3 -0
  87. package/tsconfig.tsbuildinfo +1 -1
  88. package/lib/models/addresses/address-base-schema.d.ts +0 -2
  89. package/lib/models/addresses/address-base-schema.js +0 -24
  90. package/lib/models/addresses/address-base-schema.js.map +0 -1
  91. package/lib/models/addresses/pudo-location-schema.d.ts +0 -2
  92. package/lib/models/addresses/pudo-location-schema.js +0 -11
  93. package/lib/models/addresses/pudo-location-schema.js.map +0 -1
  94. package/lib/models/addresses/ship-to-schema.d.ts +0 -2
  95. package/lib/models/addresses/ship-to-schema.js +0 -11
  96. package/lib/models/addresses/ship-to-schema.js.map +0 -1
  97. package/lib/models/pickup/shipped-shipment-schema.d.ts +0 -3
  98. package/lib/models/pickup/shipped-shipment-schema.js +0 -21
  99. package/lib/models/pickup/shipped-shipment-schema.js.map +0 -1
  100. package/lib/requests/cancel-notification-request-schema.d.ts +0 -2
  101. package/lib/requests/cancel-notification-request-schema.js +0 -12
  102. package/lib/requests/cancel-notification-request-schema.js.map +0 -1
  103. package/src/models/addresses/address-base-schema.ts +0 -20
  104. package/src/models/addresses/pudo-location-schema.ts +0 -7
  105. package/src/models/addresses/ship-to-schema.ts +0 -7
  106. package/src/models/pickup/shipped-shipment-schema.ts +0 -18
  107. package/src/requests/cancel-notification-request-schema.ts +0 -8
package/spec.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "info": {
4
4
  "title": "Shipping API",
5
5
  "description": "This API specification describes the canonical ShipEngine Shipping API connector module.",
6
- "version": "1.17.1"
6
+ "version": "1.17.3"
7
7
  },
8
8
  "paths": {
9
9
  "/Register": {
@@ -754,6 +754,13 @@
754
754
  },
755
755
  "description": "Amount to be paid to the driver, used for local delivery and courier services.",
756
756
  "nullable": true
757
+ },
758
+ "additional_handling": {
759
+ "type": "boolean",
760
+ "description": "Describes whether Additional Handling is requested for the shipment."
761
+ },
762
+ "collect_on_delivery": {
763
+ "$ref": "#/components/schemas/CollectOnDelivery"
757
764
  }
758
765
  },
759
766
  "additionalProperties": { },
@@ -1085,6 +1092,47 @@
1085
1092
  "additionalProperties": false,
1086
1093
  "description": "This model represents a response for a successful cancel pickup request."
1087
1094
  },
1095
+ "CodPaymentType": {
1096
+ "enum": [
1097
+ "any",
1098
+ "cash",
1099
+ "guaranteed_funds"
1100
+ ],
1101
+ "type": "string",
1102
+ "description": "Specifies which payment method is permitted when Collect on Delivery (COD) is requested on a shipment.\r\nany - Any payment method is permitted.\r\ncash - Only cash is permitted.\r\nguaranteed_funds - Only guaranteed funds are permitted, such as a money order or cashier's check."
1103
+ },
1104
+ "CollectOnDelivery": {
1105
+ "required": [
1106
+ "payment_amount"
1107
+ ],
1108
+ "type": "object",
1109
+ "properties": {
1110
+ "payment_amount": {
1111
+ "required": [
1112
+ "currency",
1113
+ "amount"
1114
+ ],
1115
+ "type": "object",
1116
+ "properties": {
1117
+ "amount": {
1118
+ "type": "string",
1119
+ "description": "Decimal currency value, as a string."
1120
+ },
1121
+ "currency": {
1122
+ "type": "string",
1123
+ "description": "Alpha-3 currency code complying with ISO 4217."
1124
+ }
1125
+ },
1126
+ "description": "The payment amount for Collect on Delivery (COD).",
1127
+ "nullable": true
1128
+ },
1129
+ "payment_type": {
1130
+ "$ref": "#/components/schemas/CodPaymentType"
1131
+ }
1132
+ },
1133
+ "additionalProperties": false,
1134
+ "description": "This model represents the option to defer payment for a shipment, otherwise known as Collect on Delivery (COD)."
1135
+ },
1088
1136
  "ConfirmationTypes": {
1089
1137
  "enum": [
1090
1138
  "None",
@@ -1527,6 +1575,11 @@
1527
1575
  "description": "Other Charge for international shipments.",
1528
1576
  "nullable": true
1529
1577
  },
1578
+ "other_charge_description": {
1579
+ "type": "string",
1580
+ "description": "Description for other_charge",
1581
+ "nullable": true
1582
+ },
1530
1583
  "insurance_charge": {
1531
1584
  "required": [
1532
1585
  "currency",
@@ -5,6 +5,8 @@ import { CarrierAppDefinition } from './carrier-app-definition';
5
5
  export const createEndpointMapping = (
6
6
  definition: CarrierAppDefinition,
7
7
  ): [Method, ApiEndpoints, ((req: any) => any | Promise<any>) | undefined][] => [
8
+ //TODO: Remove `Method.POST` from this and all other maps since they are ALL post
9
+ //TODO: Remove JOI validation from all endpoints and replace them with OpenAPI validation
8
10
  [Method.POST, ApiEndpoints.CancelNotification, definition.CancelNotification],
9
11
  [Method.POST, ApiEndpoints.CancelPickup, definition.CancelPickup],
10
12
  [Method.POST, ApiEndpoints.CreateLabel, definition.CreateLabel],
@@ -0,0 +1,2 @@
1
+ // Name of the file that will contain rating logic used by Native Rating
2
+ export const rateLogicName = 'rate-shipments.js';
package/src/index.ts CHANGED
@@ -3,6 +3,7 @@ export * as requests from './requests';
3
3
  export * as responses from './responses';
4
4
 
5
5
  export * from './app';
6
+ export * from './constants';
6
7
  export * from './models';
7
8
  export * from './requests';
8
9
  export * from './responses';
@@ -1,3 +1,4 @@
1
+ import { CollectOnDelivery } from './collect-on-delivery';
1
2
  import { Currency } from './currency';
2
3
 
3
4
  /** @description Basic structure for shipping options */
@@ -14,6 +15,10 @@ export class AdvancedOptions {
14
15
  saturday_delivery?: boolean;
15
16
  /** @description Amount to be paid to the driver, used for local delivery and courier services */
16
17
  tip?: Currency;
18
+ /** @description Describes whether Additional Handling is requested for the shipment */
19
+ additional_handling?: boolean;
20
+ /** @description Describes details for Collect on Delivery (COD) if requested for the shipment */
21
+ collect_on_delivery?: CollectOnDelivery;
17
22
  /** @description Any other custom shipping options */
18
23
  [key: string]: any;
19
24
  }
@@ -0,0 +1,15 @@
1
+ import { AddressBase } from './addresses';
2
+ import { BillToParty } from './billing';
3
+
4
+ /**
5
+ * @description Bill to is a generic object used for billing a part of the shipment, duties, taxes, or otherwise to a party
6
+ other than the shipper (the shipper is considered the default party responsible). Ref: BillTo extends AddressBase.
7
+ since address fields are often required when associating billing to
8
+ another account. Additionally, this allows for a contact to be specified, if necessary.
9
+ */
10
+ export class BillTo extends AddressBase {
11
+ /** @description The bill_to_party mentions the type of billing option*/
12
+ bill_to_party?: BillToParty;
13
+ /** @description Specified if there is an account number associated with the Bill To Party, and the Bill To Party is not the account holder. */
14
+ account_number?: string;
15
+ }
@@ -0,0 +1,10 @@
1
+ /** @description The type of party responsible for a given category of charges associated with a shipment, such as
2
+ * shipping charges or import duties. */
3
+ export enum BillToParty {
4
+ /** @description The shipper is generally regarded as the party responsible for the billing. */
5
+ Shipper = 'shipper',
6
+ /** @description The recipient may be responsible for the billing of some entities, that could include the shipping cost. */
7
+ Recipient = 'recipient',
8
+ /** @description A shipper may want to bill to a third-party; especially common for 3PLs and larger volume. merchants */
9
+ ThirdPartyAccount = 'third_party_account',
10
+ }
@@ -2,3 +2,4 @@ export * from './billing-categories';
2
2
  export * from './billing-categories-schema';
3
3
  export * from './billing-line-item';
4
4
  export * from './billing-line-item-schema';
5
+ export * from './billing-to-party';
@@ -0,0 +1,9 @@
1
+ /** @description Specifies which payment method is permitted when Collect on Delivery (COD) is requested on a shipment */
2
+ export enum CodPaymentType {
3
+ /** @description Any payment method is permitted */
4
+ Any = 'any',
5
+ /** @description Only cash is permitted */
6
+ Cash = 'cash',
7
+ /** @description Only guaranteed funds are permitted, such as a money order or cashier's check */
8
+ GuaranteedFunds = 'guaranteed_funds',
9
+ }
@@ -0,0 +1,10 @@
1
+ import { CodPaymentType } from './cod-payment-type';
2
+ import { Currency } from './currency';
3
+
4
+ /** @description This model represents the option to defer payment for a shipment, otherwise known as Collect on Delivery (COD) */
5
+ export class CollectOnDelivery {
6
+ /** @description The payment amount for Collect on Delivery (COD) */
7
+ payment_amount!: Currency;
8
+ /** @description The payment method permitted for Collect on Delivery (COD) */
9
+ payment_type?: CodPaymentType;
10
+ }
@@ -6,6 +6,8 @@ export class CustomsCharges {
6
6
  freight_charge?: Currency;
7
7
  /** @description Other charge for international shipments. */
8
8
  other_charge?: Currency;
9
+ /** @description : Description for other charge for international shipments.*/
10
+ other_charge_description?: string;
9
11
  /** @description Insurance charge for international shipments. */
10
12
  insurance_charge?: Currency;
11
13
  /** @description Discount for international shipments. */
@@ -21,7 +21,7 @@ export class Customs {
21
21
  /** @description Declaration statement to be placed on the commercial invoice */
22
22
  declaration?: string;
23
23
  /** @description Incoterms specify who is responsible for paying for and managing the shipment*/
24
- termsOfTradeCode?: TermsOfTradeCode;
24
+ terms_of_trade_code?: TermsOfTradeCode;
25
25
  /** @description The owner or purchaser of the products being imported into a destination country.*/
26
26
  importer_of_record?: ImporterOfRecord;
27
27
  /** @description The charges related with customs.*/
@@ -1,6 +1,8 @@
1
1
  export * from './addresses';
2
2
  export * from './advanced-options';
3
3
  export * from './authorization';
4
+ export * from './cod-payment-type';
5
+ export * from './collect-on-delivery';
4
6
  export * from './billing';
5
7
  export * from './confirmation-types';
6
8
  export * from './currency-schema';
@@ -18,6 +20,7 @@ export * from './inbound-content-types';
18
20
  export * from './insurance-providers';
19
21
  export * from './labels';
20
22
  export * from './manifests';
23
+ export * from './native-rating';
21
24
  export * from './package';
22
25
  export * from './pickup';
23
26
  export * from './rates';
@@ -30,3 +33,4 @@ export * from './time-window-schema';
30
33
  export * from './time-window';
31
34
  export * from './tracking';
32
35
  export * from './units';
36
+ export * from './bill-to';
@@ -0,0 +1,3 @@
1
+ export interface ContextResults<T> {
2
+ [dataKey: string]: T;
3
+ }
@@ -0,0 +1,9 @@
1
+ import { ContextResults } from './context-results';
2
+ import { NumericCurrency } from './numeric-currency';
3
+
4
+ export type GetRatesResults = ContextResults<NumericCurrency>;
5
+
6
+ /** Function to get rates from the context */
7
+ export interface GetRates {
8
+ (dataKeys: string[]): Promise<GetRatesResults>;
9
+ }
@@ -0,0 +1,8 @@
1
+ import { ContextResults } from './context-results';
2
+
3
+ export type GetVariableResults = ContextResults<any>;
4
+
5
+ /** Function to get rating variables from the context */
6
+ export interface GetVariables {
7
+ (dataKeys: string[]): Promise<GetVariableResults>;
8
+ }
@@ -0,0 +1,9 @@
1
+ import { ContextResults } from './context-results';
2
+
3
+ export type GetZoneResults = ContextResults<any>;
4
+
5
+ /** Function to get zone data from the context */
6
+ export interface GetZone {
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ (dataKeys: string[]): Promise<GetZoneResults>;
9
+ }
@@ -0,0 +1,33 @@
1
+ import type { GetRatesRequest, Rate } from '@shipengine/connect-carrier-api';
2
+ import type { RatingContext } from './rating-context';
3
+
4
+ /** A rate request shipment with its corresponding id */
5
+ export interface ShipmentAndId {
6
+ /** rate_request_identifier for the rate request */
7
+ id: string;
8
+ /** Shipment for the rate request */
9
+ shipment: GetRatesRequest;
10
+ }
11
+
12
+ /** Rate results with its corresponding rate request id */
13
+ export interface RateResultsAndId {
14
+ /** rate_request_identifier for the corresponding rate request */
15
+ id: string;
16
+ /** Error, if any */
17
+ error?: unknown;
18
+ /** Rates for a given rate request */
19
+ rates: Rate[];
20
+ }
21
+
22
+ /** Implementation of a carrier */
23
+ export interface RatingCarrier {
24
+ /** Rate shipments
25
+ * @param context Native Rating context that can be used by the implementation to interact with the underlying service
26
+ * @param shipment Shipments that should be rated
27
+ * @returns List of rates for the given shipments
28
+ */
29
+ rateShipments: (context: RatingContext, shipment: ShipmentAndId[]) => Promise<RateResultsAndId[]>;
30
+ }
31
+
32
+ /** Signify a validation error from the carrier */
33
+ export class CarrierValidationError extends Error {}
@@ -0,0 +1,7 @@
1
+ export * from './context-results';
2
+ export * from './get-rates';
3
+ export * from './get-variables';
4
+ export * from './get-zone';
5
+ export * from './implementation-type';
6
+ export * from './numeric-currency';
7
+ export * from './rating-context';
@@ -0,0 +1,5 @@
1
+ /** NumericCurrency so that we don't have to convert from the string Currency all over the place */
2
+ export interface NumericCurrency {
3
+ currency: string;
4
+ amount: number | undefined;
5
+ }
@@ -0,0 +1,19 @@
1
+ import { Logger } from 'winston';
2
+ import { GetVariables } from './get-variables';
3
+ import { GetRates } from './get-rates';
4
+ import { GetZone } from './get-zone';
5
+
6
+ /** Rates request context */
7
+ export interface RatingContext {
8
+ /** Function to get rates for given keys */
9
+ getRates: GetRates;
10
+
11
+ /** Function to get variables for given keys */
12
+ getVariables: GetVariables;
13
+
14
+ /** Function to get zone for given keys */
15
+ getZone: GetZone;
16
+
17
+ /** Logger that implementers can use */
18
+ log: Logger;
19
+ }
@@ -6,8 +6,10 @@ export class TaxIdentifier {
6
6
  id!: string;
7
7
  /** @description The Tax ID type */
8
8
  type!: TaxIdentifierType;
9
- /** @description The country where the Tax ID is registered with */
9
+ /** @deprecated This property has been deprecated, please use registration_country instead */
10
10
  registration_county?: string;
11
+ /** @description The country where the Tax ID is registered with */
12
+ registration_country?: string;
11
13
  /** @description Description of the tax ID that may give the customs agent more context */
12
14
  description?: string;
13
15
  }
@@ -17,6 +17,7 @@ import {
17
17
  RelayPointDetails,
18
18
  DisplayScheme,
19
19
  Customs,
20
+ BillTo,
20
21
  } from '../models';
21
22
 
22
23
  /** @description Basic structure for a request to create a label */
@@ -54,4 +55,6 @@ export class CreateLabelRequest extends BaseRequest {
54
55
  /** @description Display schemes that the label will be returned in. Label is returned by default */
55
56
  display_schemes?: DisplayScheme[];
56
57
  customs?: Customs;
58
+ /** @description Bill the shipping charges to this entity. If null, it should be assumed the "shipper" is responsible for the shipping charges. */
59
+ bill_shipping_to?: BillTo;
57
60
  }
@@ -10,6 +10,7 @@ import {
10
10
  PudoLocation,
11
11
  FulfillmentPlanDetails,
12
12
  TimeWindow,
13
+ BillTo,
13
14
  } from '../models';
14
15
  import { ShipmentItem } from '../models/shipment-item';
15
16
 
@@ -33,4 +34,6 @@ export class GetRatesRequest extends BaseRequest {
33
34
  carrier_pickup_window?: TimeWindow;
34
35
  /** Items included in the shipment */
35
36
  items?: ShipmentItem[];
37
+ /** @description Bill the shipping charges to this entity. If null, it should be assumed the "shipper" is responsible for the shipping charges. */
38
+ bill_shipping_to?: BillTo;
36
39
  }