@shipengine/connect-carrier-api 2.1.21 → 2.1.22

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 (171) hide show
  1. package/lib/app/carrier-app.js +79 -63
  2. package/lib/app/carrier-app.js.map +1 -1
  3. package/lib/app/constants.d.ts +14 -0
  4. package/lib/app/constants.js +19 -0
  5. package/lib/app/constants.js.map +1 -0
  6. package/lib/app/internal/route.d.ts +1 -0
  7. package/lib/models/billing/billing-categories.d.ts +2 -0
  8. package/lib/models/billing/billing-categories.js +4 -1
  9. package/lib/models/billing/billing-categories.js.map +1 -1
  10. package/lib/models/billing/billing-line-item.d.ts +2 -0
  11. package/lib/models/billing/billing-line-item.js +12 -1
  12. package/lib/models/billing/billing-line-item.js.map +1 -1
  13. package/lib/models/currency.d.ts +2 -0
  14. package/lib/models/currency.js +7 -1
  15. package/lib/models/currency.js.map +1 -1
  16. package/lib/models/documents/document-type.d.ts +2 -0
  17. package/lib/models/documents/document-type.js +4 -1
  18. package/lib/models/documents/document-type.js.map +1 -1
  19. package/lib/models/documents/document.d.ts +2 -0
  20. package/lib/models/documents/document.js +10 -1
  21. package/lib/models/documents/document.js.map +1 -1
  22. package/lib/models/identifier.d.ts +2 -0
  23. package/lib/models/identifier.js +7 -1
  24. package/lib/models/identifier.js.map +1 -1
  25. package/lib/models/inbound-content-types.d.ts +2 -0
  26. package/lib/models/inbound-content-types.js +4 -1
  27. package/lib/models/inbound-content-types.js.map +1 -1
  28. package/lib/models/labels/document-formats.d.ts +2 -0
  29. package/lib/models/labels/document-formats.js +4 -1
  30. package/lib/models/labels/document-formats.js.map +1 -1
  31. package/lib/models/labels/form-download.d.ts +2 -0
  32. package/lib/models/labels/form-download.js +6 -1
  33. package/lib/models/labels/form-download.js.map +1 -1
  34. package/lib/models/labels/label-download.d.ts +2 -0
  35. package/lib/models/labels/label-download.js +6 -1
  36. package/lib/models/labels/label-download.js.map +1 -1
  37. package/lib/models/labels/label-package.d.ts +2 -0
  38. package/lib/models/labels/label-package.js +10 -1
  39. package/lib/models/labels/label-package.js.map +1 -1
  40. package/lib/models/labels/void-response.d.ts +3 -1
  41. package/lib/models/labels/void-response.js +10 -1
  42. package/lib/models/labels/void-response.js.map +1 -1
  43. package/lib/models/manifests/manifest.d.ts +2 -0
  44. package/lib/models/manifests/manifest.js +10 -1
  45. package/lib/models/manifests/manifest.js.map +1 -1
  46. package/lib/models/pickup/pickup-confirmation.d.ts +2 -0
  47. package/lib/models/pickup/pickup-confirmation.js +10 -1
  48. package/lib/models/pickup/pickup-confirmation.js.map +1 -1
  49. package/lib/models/pickup/pickup-window.d.ts +2 -0
  50. package/lib/models/pickup/pickup-window.js +9 -1
  51. package/lib/models/pickup/pickup-window.js.map +1 -1
  52. package/lib/models/pickup/shipment-identifier.d.ts +2 -0
  53. package/lib/models/pickup/shipment-identifier.js +8 -1
  54. package/lib/models/pickup/shipment-identifier.js.map +1 -1
  55. package/lib/models/rates/rate.d.ts +2 -0
  56. package/lib/models/rates/rate.js +18 -1
  57. package/lib/models/rates/rate.js.map +1 -1
  58. package/lib/models/registration/credentials.d.ts +2 -0
  59. package/lib/models/registration/credentials.js +7 -1
  60. package/lib/models/registration/credentials.js.map +1 -1
  61. package/lib/models/resource-download.d.ts +2 -0
  62. package/lib/models/resource-download.js +7 -1
  63. package/lib/models/resource-download.js.map +1 -1
  64. package/lib/models/time-window.d.ts +2 -0
  65. package/lib/models/time-window.js +8 -1
  66. package/lib/models/time-window.js.map +1 -1
  67. package/lib/models/tracking/lat-long.d.ts +2 -0
  68. package/lib/models/tracking/lat-long.js +7 -1
  69. package/lib/models/tracking/lat-long.js.map +1 -1
  70. package/lib/models/tracking/service.d.ts +2 -0
  71. package/lib/models/tracking/service.js +7 -1
  72. package/lib/models/tracking/service.js.map +1 -1
  73. package/lib/models/tracking/standardized-status-codes.d.ts +2 -0
  74. package/lib/models/tracking/standardized-status-codes.js +4 -1
  75. package/lib/models/tracking/standardized-status-codes.js.map +1 -1
  76. package/lib/models/tracking/track-event.d.ts +2 -0
  77. package/lib/models/tracking/track-event.js +18 -1
  78. package/lib/models/tracking/track-event.js.map +1 -1
  79. package/lib/models/tracking/tracking-info.d.ts +2 -0
  80. package/lib/models/tracking/tracking-info.js +27 -1
  81. package/lib/models/tracking/tracking-info.js.map +1 -1
  82. package/lib/models/tracking/update-method.d.ts +2 -0
  83. package/lib/models/tracking/update-method.js +4 -1
  84. package/lib/models/tracking/update-method.js.map +1 -1
  85. package/lib/models/units/dimensions.d.ts +2 -0
  86. package/lib/models/units/dimensions.js +8 -1
  87. package/lib/models/units/dimensions.js.map +1 -1
  88. package/lib/responses/base-response.d.ts +2 -0
  89. package/lib/responses/base-response.js +6 -1
  90. package/lib/responses/base-response.js.map +1 -1
  91. package/lib/responses/cancel-notification-response.d.ts +2 -0
  92. package/lib/responses/cancel-notification-response.js +7 -1
  93. package/lib/responses/cancel-notification-response.js.map +1 -1
  94. package/lib/responses/cancel-pickup-response.d.ts +2 -0
  95. package/lib/responses/cancel-pickup-response.js +9 -1
  96. package/lib/responses/cancel-pickup-response.js.map +1 -1
  97. package/lib/responses/create-label-response.d.ts +2 -0
  98. package/lib/responses/create-label-response.js +19 -1
  99. package/lib/responses/create-label-response.js.map +1 -1
  100. package/lib/responses/create-manifest-response.d.ts +2 -0
  101. package/lib/responses/create-manifest-response.js +8 -1
  102. package/lib/responses/create-manifest-response.js.map +1 -1
  103. package/lib/responses/create-notification-response.d.ts +2 -0
  104. package/lib/responses/create-notification-response.js +6 -1
  105. package/lib/responses/create-notification-response.js.map +1 -1
  106. package/lib/responses/get-rates-response.d.ts +2 -0
  107. package/lib/responses/get-rates-response.js +7 -1
  108. package/lib/responses/get-rates-response.js.map +1 -1
  109. package/lib/responses/normalize-tracking-data-response.d.ts +3 -1
  110. package/lib/responses/normalize-tracking-data-response.js +13 -0
  111. package/lib/responses/normalize-tracking-data-response.js.map +1 -1
  112. package/lib/responses/register-response.d.ts +2 -0
  113. package/lib/responses/register-response.js +8 -1
  114. package/lib/responses/register-response.js.map +1 -1
  115. package/lib/responses/schedule-pickup-response.d.ts +2 -0
  116. package/lib/responses/schedule-pickup-response.js +11 -1
  117. package/lib/responses/schedule-pickup-response.js.map +1 -1
  118. package/lib/responses/tracking-response.d.ts +1 -0
  119. package/lib/responses/tracking-response.js +5 -1
  120. package/lib/responses/tracking-response.js.map +1 -1
  121. package/lib/responses/validate-inbound-data-response.d.ts +3 -1
  122. package/lib/responses/validate-inbound-data-response.js +12 -0
  123. package/lib/responses/validate-inbound-data-response.js.map +1 -1
  124. package/lib/responses/void-labels-response.d.ts +2 -0
  125. package/lib/responses/void-labels-response.js +7 -1
  126. package/lib/responses/void-labels-response.js.map +1 -1
  127. package/package.json +1 -1
  128. package/src/app/carrier-app.ts +107 -65
  129. package/src/app/constants.ts +14 -0
  130. package/src/app/internal/route.ts +1 -0
  131. package/src/models/billing/billing-categories.ts +6 -0
  132. package/src/models/billing/billing-line-item.ts +14 -2
  133. package/src/models/currency.ts +7 -0
  134. package/src/models/documents/document-type.ts +6 -0
  135. package/src/models/documents/document.ts +11 -2
  136. package/src/models/identifier.ts +7 -0
  137. package/src/models/inbound-content-types.ts +5 -0
  138. package/src/models/labels/document-formats.ts +5 -0
  139. package/src/models/labels/form-download.ts +6 -1
  140. package/src/models/labels/label-download.ts +6 -1
  141. package/src/models/labels/label-package.ts +9 -2
  142. package/src/models/labels/void-response.ts +9 -2
  143. package/src/models/manifests/manifest.ts +9 -1
  144. package/src/models/pickup/pickup-confirmation.ts +11 -2
  145. package/src/models/pickup/pickup-window.ts +8 -0
  146. package/src/models/pickup/shipment-identifier.ts +7 -1
  147. package/src/models/rates/rate.ts +20 -2
  148. package/src/models/registration/credentials.ts +7 -0
  149. package/src/models/resource-download.ts +7 -0
  150. package/src/models/time-window.ts +8 -0
  151. package/src/models/tracking/lat-long.ts +7 -0
  152. package/src/models/tracking/service.ts +6 -0
  153. package/src/models/tracking/standardized-status-codes.ts +6 -0
  154. package/src/models/tracking/track-event.ts +16 -0
  155. package/src/models/tracking/tracking-info.ts +29 -4
  156. package/src/models/tracking/update-method.ts +6 -0
  157. package/src/models/units/dimensions.ts +7 -0
  158. package/src/responses/base-response.ts +6 -0
  159. package/src/responses/cancel-notification-response.ts +7 -1
  160. package/src/responses/cancel-pickup-response.ts +9 -1
  161. package/src/responses/create-label-response.ts +25 -1
  162. package/src/responses/create-manifest-response.ts +8 -2
  163. package/src/responses/create-notification-response.ts +6 -1
  164. package/src/responses/get-rates-response.ts +7 -2
  165. package/src/responses/normalize-tracking-data-response.ts +16 -5
  166. package/src/responses/register-response.ts +6 -1
  167. package/src/responses/schedule-pickup-response.ts +18 -2
  168. package/src/responses/tracking-response.ts +6 -2
  169. package/src/responses/validate-inbound-data-response.ts +12 -4
  170. package/src/responses/void-labels-response.ts +7 -2
  171. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,14 @@
1
+ export enum ApiEndpoints {
2
+ Register = '/Register',
3
+ CreateLabel = '/CreateLabel',
4
+ VoidLabels = '/VoidLabels',
5
+ GetRates = '/GetRates',
6
+ CreateManifest = '/CreateManifest',
7
+ SchedulePickup = '/SchedulePickup',
8
+ CancelPickup = '/CancelPickup',
9
+ Track = '/Track',
10
+ CreateNotification = '/CreateNotification',
11
+ CancelNotification = '/CancelNotification',
12
+ ValidateInboundData = '/ValidateInboundData',
13
+ NormalizeTrackingData = '/NormalizeTrackingData',
14
+ }
@@ -10,4 +10,5 @@ export interface Route {
10
10
  path: string;
11
11
  method: Method;
12
12
  handler?: (req: any) => any | Promise<any>;
13
+ validateResponse?: (response: any) => string[] | undefined;
13
14
  }
@@ -1,3 +1,5 @@
1
+ import Joi from 'joi';
2
+
1
3
  /** @description Category for a billing line item */
2
4
  export enum BillingCategories {
3
5
  Uncategorized = 'uncategorized',
@@ -23,3 +25,7 @@ export enum BillingCategories {
23
25
  /** @description Amount to be paid to the driver, used for local delivery and courier services. */
24
26
  Tip = 'tip',
25
27
  }
28
+
29
+ export const BillingCategoriesSchema = Joi.string().valid(
30
+ ...Object.values(BillingCategories),
31
+ );
@@ -1,5 +1,9 @@
1
- import { BillingCategories } from './billing-categories';
2
- import { Currency } from '../currency';
1
+ import {
2
+ BillingCategories,
3
+ BillingCategoriesSchema,
4
+ } from './billing-categories';
5
+ import { Currency, CurrencySchema } from '../currency';
6
+ import Joi from 'joi';
3
7
 
4
8
  /** @description Basic structure of each charge or line item */
5
9
  export class BillingLineItem {
@@ -9,3 +13,11 @@ export class BillingLineItem {
9
13
  memo?: string;
10
14
  amount!: Currency;
11
15
  }
16
+
17
+ export const BillingLineItemSchema = Joi.object({
18
+ billing_category: BillingCategoriesSchema.required(),
19
+ carrier_description: Joi.string().optional().empty(),
20
+ carrier_billing_code: Joi.string().optional().empty(),
21
+ memo: Joi.string().optional().empty(),
22
+ amount: CurrencySchema.required(),
23
+ });
@@ -1,5 +1,12 @@
1
+ import Joi from 'joi';
2
+
1
3
  /** @description Basic structure for defining an amount of money and its currency */
2
4
  export class Currency {
3
5
  currency!: string;
4
6
  amount!: string;
5
7
  }
8
+
9
+ export const CurrencySchema = Joi.object({
10
+ currency: Joi.string().required(),
11
+ amount: Joi.string().required(),
12
+ });
@@ -1,3 +1,5 @@
1
+ import Joi from 'joi';
2
+
1
3
  /** @description Types of documents */
2
4
  export enum DocumentType {
3
5
  Label = 'label',
@@ -5,3 +7,7 @@ export enum DocumentType {
5
7
  CommercialInvoice = 'commercial_invoice',
6
8
  BillOfLading = 'bill_of_lading',
7
9
  }
10
+
11
+ export const DocumentTypeSchema = Joi.string().valid(
12
+ ...Object.values(DocumentType),
13
+ );
@@ -1,5 +1,9 @@
1
- import { DocumentType } from './document-type';
2
- import { DocumentFormat } from '../labels/document-formats';
1
+ import { DocumentType, DocumentTypeSchema } from './document-type';
2
+ import {
3
+ DocumentFormat,
4
+ DocumentFormatSchema,
5
+ } from '../labels/document-formats';
6
+ import Joi from 'joi';
3
7
 
4
8
  /** @description Basic structure for a document */
5
9
  export class Document {
@@ -7,3 +11,8 @@ export class Document {
7
11
  data!: string;
8
12
  format!: DocumentFormat;
9
13
  }
14
+ export const DocumentSchema = Joi.object({
15
+ type: Joi.array().required().min(1).items(DocumentTypeSchema),
16
+ data: Joi.string().required(),
17
+ format: DocumentFormatSchema.required(),
18
+ });
@@ -1,5 +1,12 @@
1
+ import Joi from 'joi';
2
+
1
3
  /** @description Key value pair to allow custom properties */
2
4
  export class Identifier {
3
5
  type!: string;
4
6
  value!: string;
5
7
  }
8
+
9
+ export const IdentifierSchema = Joi.object({
10
+ type: Joi.string().required(),
11
+ value: Joi.string().required(),
12
+ });
@@ -1,5 +1,10 @@
1
+ import Joi from 'joi';
2
+
1
3
  /** @description Types of inbound content */
2
4
  export enum InboundDataContentTypes {
3
5
  /** @description Tracking information */
4
6
  Tracking = 'tracking',
5
7
  }
8
+ export const InboundDataContentTypesSchema = Joi.string().valid(
9
+ ...Object.values(InboundDataContentTypes),
10
+ );
@@ -1,6 +1,11 @@
1
+ import Joi from 'joi';
2
+
1
3
  /** @description Label data type */
2
4
  export enum DocumentFormat {
3
5
  Pdf = 'PDF',
4
6
  Zpl = 'ZPL',
5
7
  Png = 'PNG',
6
8
  }
9
+ export const DocumentFormatSchema = Joi.string().valid(
10
+ ...Object.values(DocumentFormat),
11
+ );
@@ -1,5 +1,10 @@
1
- import { ResourceDownload } from '../resource-download';
1
+ import Joi from 'joi';
2
+ import { ResourceDownload, ResourceDownloadSchema } from '../resource-download';
2
3
 
3
4
  export class FormDownload extends ResourceDownload {
4
5
  form_data?: string;
5
6
  }
7
+
8
+ export const FormDownloadSchema = ResourceDownloadSchema.keys({
9
+ form_data: Joi.string().optional().empty(),
10
+ });
@@ -1,5 +1,10 @@
1
- import { ResourceDownload } from '../resource-download';
1
+ import Joi from 'joi';
2
+ import { ResourceDownload, ResourceDownloadSchema } from '../resource-download';
2
3
 
3
4
  export class LabelDownload extends ResourceDownload {
4
5
  label_data?: string;
5
6
  }
7
+
8
+ export const LabelDownloadSchema = ResourceDownloadSchema.keys({
9
+ label_data: Joi.string().optional().empty(),
10
+ });
@@ -1,5 +1,6 @@
1
- import { Identifier } from '../identifier';
2
- import { Document } from '../documents';
1
+ import { Identifier, IdentifierSchema } from '../identifier';
2
+ import { Document, DocumentSchema } from '../documents';
3
+ import Joi from 'joi';
3
4
 
4
5
  /** @description Package information provided by the carrier */
5
6
  export class LabelPackage {
@@ -8,3 +9,9 @@ export class LabelPackage {
8
9
  alternative_identifiers?: Identifier[];
9
10
  documents?: Document[];
10
11
  }
12
+
13
+ export const LabelPackageSchema = Joi.object({
14
+ tracking_number: Joi.string().optional().empty(),
15
+ alternative_identifiers: Joi.array().optional().items(IdentifierSchema),
16
+ documents: Joi.array().optional().items(DocumentSchema),
17
+ });
@@ -1,5 +1,5 @@
1
- import { BillingLineItem } from '..';
2
-
1
+ import Joi from 'joi';
2
+ import { BillingLineItem, BillingLineItemSchema } from '../billing';
3
3
  /** @description Basic structure for a response to void a label */
4
4
  export class VoidResponse {
5
5
  /** @description Id for the void response */
@@ -11,3 +11,10 @@ export class VoidResponse {
11
11
  /** @description Individual Billing Line items which remain after voiding the label, e.g. a cancellation fee. */
12
12
  billing_line_items?: BillingLineItem[];
13
13
  }
14
+
15
+ export const VoidResponseSchema = Joi.object({
16
+ void_request_id: Joi.string().required(),
17
+ message: Joi.string().optional().empty(),
18
+ errors: Joi.array().optional().items(Joi.string()),
19
+ billing_line_items: Joi.array().optional().items(BillingLineItemSchema),
20
+ });
@@ -1,4 +1,5 @@
1
- import { ResourceDownload } from '../resource-download';
1
+ import Joi from 'joi';
2
+ import { ResourceDownload, ResourceDownloadSchema } from '../resource-download';
2
3
 
3
4
  /** @description Basic structure of a manifest */
4
5
  export class Manifest {
@@ -7,3 +8,10 @@ export class Manifest {
7
8
  document_href?: string;
8
9
  document_data?: string;
9
10
  }
11
+
12
+ export const ManifestSchema = Joi.object({
13
+ manifest_id: Joi.string().optional().empty(),
14
+ document_download: ResourceDownloadSchema.optional(),
15
+ document_href: Joi.string().optional().empty(),
16
+ document_data: Joi.string().optional().empty(),
17
+ });
@@ -1,5 +1,9 @@
1
- import { Identifier } from '../identifier';
2
- import { ShipmentIdentifier } from './shipment-identifier';
1
+ import Joi from 'joi';
2
+ import { Identifier, IdentifierSchema } from '../identifier';
3
+ import {
4
+ ShipmentIdentifier,
5
+ ShipmentIdentifierSchema,
6
+ } from './shipment-identifier';
3
7
 
4
8
  /** @description Basic structure for a pickup confirmation */
5
9
  export class PickupConfirmation {
@@ -7,3 +11,8 @@ export class PickupConfirmation {
7
11
  alternate_identifiers?: Identifier[];
8
12
  shipment_identifiers?: ShipmentIdentifier[];
9
13
  }
14
+ export const PickupConfirmationSchema = Joi.object({
15
+ confirmation_id: Joi.string().optional().empty(),
16
+ alternate_identifiers: Joi.array().optional().items(IdentifierSchema),
17
+ shipment_identifiers: Joi.array().optional().items(ShipmentIdentifierSchema),
18
+ });
@@ -1,3 +1,5 @@
1
+ import Joi from 'joi';
2
+
1
3
  /** @description Time window for pickup */
2
4
  export class PickupWindow {
3
5
  time_zone_iana!: string;
@@ -5,3 +7,9 @@ export class PickupWindow {
5
7
  start_time?: string;
6
8
  end_time?: string;
7
9
  }
10
+ export const PickupWindowSchema = Joi.object({
11
+ time_zone_iana: Joi.string().required(),
12
+ pickup_date: Joi.string().required().isoDate(),
13
+ start_time: Joi.string().optional().isoDate(),
14
+ end_time: Joi.string().optional().isoDate(),
15
+ });
@@ -1,7 +1,13 @@
1
- import { Identifier } from '../identifier';
1
+ import Joi from 'joi';
2
+ import { Identifier, IdentifierSchema } from '../identifier';
2
3
 
3
4
  /** @description Identifier object for shiments */
4
5
  export class ShipmentIdentifier {
5
6
  tracking_number?: string;
6
7
  alternate_identifiers?: Identifier[];
7
8
  }
9
+
10
+ export const ShipmentIdentifierSchema = Joi.object({
11
+ tracking_number: Joi.string().optional().empty(),
12
+ alternate_identifiers: Joi.array().optional().items(IdentifierSchema),
13
+ });
@@ -1,5 +1,9 @@
1
- import { BillingLineItem } from '../billing/billing-line-item';
2
- import { TimeWindow } from '../time-window';
1
+ import Joi from 'joi';
2
+ import {
3
+ BillingLineItem,
4
+ BillingLineItemSchema,
5
+ } from '../billing/billing-line-item';
6
+ import { TimeWindow, TimeWindowSchema } from '../time-window';
3
7
 
4
8
  /** @description Basic structure for a rate */
5
9
  export class Rate {
@@ -28,3 +32,17 @@ export class Rate {
28
32
  */
29
33
  expiration_datetime?: string;
30
34
  }
35
+
36
+ export const RateSchema = Joi.object({
37
+ service_code: Joi.string().optional().empty(),
38
+ ship_datetime: Joi.string().optional().empty().isoDate(),
39
+ estimated_delivery_datetime: Joi.string().optional().empty().isoDate(),
40
+ billing_line_items: Joi.array().optional().items(BillingLineItemSchema),
41
+ error_messages: Joi.array().optional().items(Joi.string()),
42
+ warning_messages: Joi.array().optional().items(Joi.string()),
43
+ negotiated_rate: Joi.boolean().optional(),
44
+ carrier_pickup_window: TimeWindowSchema.optional(),
45
+ delivery_window: TimeWindowSchema.optional(),
46
+ carrier_rate_id: Joi.string().optional().empty(),
47
+ expiration_datetime: Joi.string().optional().empty().isoDate(),
48
+ });
@@ -1,5 +1,12 @@
1
+ import Joi from 'joi';
2
+
1
3
  /** @description Basic structure for credentials */
2
4
  export class Credentials {
3
5
  username!: string;
4
6
  password!: string;
5
7
  }
8
+
9
+ export const CredentialsSchema = Joi.object({
10
+ username: Joi.string().required(),
11
+ password: Joi.string().required(),
12
+ });
@@ -1,5 +1,12 @@
1
+ import Joi from 'joi';
2
+
1
3
  /** @description Basic structure for a resource to download */
2
4
  export class ResourceDownload {
3
5
  href?: string;
4
6
  data?: string;
5
7
  }
8
+
9
+ export const ResourceDownloadSchema = Joi.object({
10
+ href: Joi.string().optional().empty(),
11
+ data: Joi.string().optional().empty(),
12
+ });
@@ -1,3 +1,5 @@
1
+ import Joi from 'joi';
2
+
1
3
  /** @description Basic structure for defining a time window */
2
4
  export class TimeWindow {
3
5
  /** @description The local time zone represented in IANA. See https://www.iana.org/time-zones.
@@ -15,3 +17,9 @@ export class TimeWindow {
15
17
  */
16
18
  end_window?: string;
17
19
  }
20
+
21
+ export const TimeWindowSchema = Joi.object({
22
+ time_zone_iana: Joi.string().required(),
23
+ start_window: Joi.string().required().isoDate(),
24
+ end_window: Joi.string().optional().empty().isoDate(),
25
+ });
@@ -1,3 +1,5 @@
1
+ import Joi from 'joi';
2
+
1
3
  /** @description Latitude and longitude */
2
4
  export class LatLong {
3
5
  /** @description latitude */
@@ -5,3 +7,8 @@ export class LatLong {
5
7
  /** @description longitude */
6
8
  long!: number;
7
9
  }
10
+
11
+ export const LatLongSchema = Joi.object({
12
+ lat: Joi.number().required(),
13
+ long: Joi.number().required(),
14
+ });
@@ -1,5 +1,11 @@
1
+ import Joi from 'joi';
2
+
1
3
  /** @description Basic structure for a tracking service */
2
4
  export class Service {
3
5
  code?: string;
4
6
  name?: string;
5
7
  }
8
+ export const ServiceSchema = Joi.object({
9
+ code: Joi.string().optional().empty(),
10
+ name: Joi.string().optional().empty(),
11
+ });
@@ -1,3 +1,5 @@
1
+ import Joi from 'joi';
2
+
1
3
  /** @description Status codes for tracking */
2
4
  export enum StandardizedStatusCodes {
3
5
  Unknown = 'UN',
@@ -8,3 +10,7 @@ export enum StandardizedStatusCodes {
8
10
  DeliveryAttempt = 'AT',
9
11
  NotYetInSystem = 'NY',
10
12
  }
13
+
14
+ export const StandardizedStatusCodesSchema = Joi.string().valid(
15
+ ...Object.values(StandardizedStatusCodes),
16
+ );
@@ -1,3 +1,5 @@
1
+ import Joi from 'joi';
2
+ import { LatLongSchema, StandardizedStatusCodesSchema } from '.';
1
3
  import { LatLong } from './lat-long';
2
4
  import { StandardizedStatusCodes } from './standardized-status-codes';
3
5
 
@@ -19,3 +21,17 @@ export class TrackEvent {
19
21
  geo?: LatLong;
20
22
  status_code?: StandardizedStatusCodes;
21
23
  }
24
+ export const TrackEventSchema = Joi.object({
25
+ event_datetime: Joi.string().optional().empty().isoDate(),
26
+ event_datetime_local: Joi.string().optional().empty().isoDate(),
27
+ event_code: Joi.string().optional().empty(),
28
+ description: Joi.string().optional().empty(),
29
+ city: Joi.string().optional().empty(),
30
+ state: Joi.string().optional().empty(),
31
+ postal_code: Joi.string().optional().empty(),
32
+ country: Joi.string().optional().empty(),
33
+ company: Joi.string().optional().empty(),
34
+ signer: Joi.string().optional().empty(),
35
+ geo: LatLongSchema.optional(),
36
+ status_code: StandardizedStatusCodesSchema.optional(),
37
+ });
@@ -1,7 +1,11 @@
1
- import { StandardizedStatusCodes } from './standardized-status-codes';
2
- import { Dimensions } from '../units/dimensions';
3
- import { Service } from './service';
4
- import { TrackEvent } from './track-event';
1
+ import {
2
+ StandardizedStatusCodes,
3
+ StandardizedStatusCodesSchema,
4
+ } from './standardized-status-codes';
5
+ import { Dimensions, DimensionsSchema } from '../units/dimensions';
6
+ import { Service, ServiceSchema } from './service';
7
+ import { TrackEvent, TrackEventSchema } from './track-event';
8
+ import Joi from 'joi';
5
9
 
6
10
  /** @description Basic structure for tracking information */
7
11
  export class TrackingInfo {
@@ -24,3 +28,24 @@ export class TrackingInfo {
24
28
  shipping_problem_code?: string;
25
29
  error_description?: string;
26
30
  }
31
+
32
+ export const TrackingInfoSchema = Joi.object({
33
+ carrier_name: Joi.string().optional().empty(),
34
+ tracking_number: Joi.string().optional().empty(),
35
+ standardized_status_code: StandardizedStatusCodesSchema.required(),
36
+ carrier_status_code: Joi.string().optional().empty(),
37
+ carrier_status_description: Joi.string().optional().empty(),
38
+ shipped_datetime: Joi.string().optional().empty().isoDate(),
39
+ estimated_delivery_datetime: Joi.string().optional().empty(),
40
+ actual_delivery_datetime: Joi.string().optional().empty().isoDate(),
41
+ shipping_problem_description: Joi.string().optional().empty(),
42
+ weight: Joi.number().optional().empty(),
43
+ dimensions: DimensionsSchema.optional(),
44
+ service: ServiceSchema.optional(),
45
+ packaging: Joi.string().optional().empty(),
46
+ package_count: Joi.number().optional().empty(),
47
+ events: Joi.array().optional().items(TrackEventSchema),
48
+ shipping_problem: Joi.boolean().optional().empty(),
49
+ shipping_problem_code: Joi.string().optional().empty(),
50
+ error_description: Joi.string().optional().empty(),
51
+ });
@@ -1,3 +1,5 @@
1
+ import Joi from 'joi';
2
+
1
3
  /** @description Update method to use for the tracking information */
2
4
  export enum UpdateMethods {
3
5
  /** @description Append the new data to the existing data set */
@@ -5,3 +7,7 @@ export enum UpdateMethods {
5
7
  /** @description Replace the existing data set with the new data */
6
8
  Replace = 'replace',
7
9
  }
10
+
11
+ export const UpdateMethodsSchema = Joi.string().valid(
12
+ ...Object.values(UpdateMethods),
13
+ );
@@ -1,6 +1,13 @@
1
+ import Joi from 'joi';
2
+
1
3
  /** @description Basic structure for dimensions */
2
4
  export class Dimensions {
3
5
  length?: number;
4
6
  width?: number;
5
7
  height?: number;
6
8
  }
9
+ export const DimensionsSchema = Joi.object({
10
+ length: Joi.number().optional(),
11
+ width: Joi.number().optional(),
12
+ height: Joi.number().optional(),
13
+ });
@@ -1,3 +1,9 @@
1
+ import Joi from 'joi';
2
+
1
3
  export class BaseResponse {
2
4
  metadata?: { [key: string]: any };
3
5
  }
6
+
7
+ export const BaseResponseSchema = Joi.object({
8
+ metadata: Joi.object().pattern(/.*/, [Joi.any()]).optional(),
9
+ });
@@ -1,4 +1,5 @@
1
- import { BaseResponse } from './base-response';
1
+ import Joi from 'joi';
2
+ import { BaseResponse, BaseResponseSchema } from './base-response';
2
3
 
3
4
  export class CancelNotificationResponse extends BaseResponse {
4
5
  /** @description User facing text describing the cancellation process. May be left blank to present a default value */
@@ -6,3 +7,8 @@ export class CancelNotificationResponse extends BaseResponse {
6
7
  /** @description A list of errors preventing this notification from being cancelled. If no errors are returned the void is considered successful. If any errors are returned the void is considered failed. */
7
8
  errors?: string[];
8
9
  }
10
+
11
+ export const CancelNotificationResponseSchema = BaseResponseSchema.keys({
12
+ message: Joi.string().optional().empty(),
13
+ errors: Joi.array().optional().items(Joi.string()),
14
+ });
@@ -1,4 +1,5 @@
1
- import { BaseResponse } from './base-response';
1
+ import Joi from 'joi';
2
+ import { BaseResponse, BaseResponseSchema } from './base-response';
2
3
 
3
4
  /** @description Basic structure for a response to cancel pickup */
4
5
  export class CancelPickupResponse extends BaseResponse {
@@ -7,3 +8,10 @@ export class CancelPickupResponse extends BaseResponse {
7
8
  status?: string;
8
9
  custom_properties?: { [key: string]: string };
9
10
  }
11
+
12
+ export const CancelPickupResponseSchema = BaseResponseSchema.keys({
13
+ confirmationa_id: Joi.string().optional(),
14
+ successful: Joi.boolean().required(),
15
+ status: Joi.string().optional().empty(),
16
+ custom_properties: Joi.object().pattern(/.*/, [Joi.string()]).optional(),
17
+ });
@@ -1,4 +1,4 @@
1
- import { BaseResponse } from './base-response';
1
+ import { BaseResponse, BaseResponseSchema } from './base-response';
2
2
  import {
3
3
  LabelDownload,
4
4
  FormDownload,
@@ -7,7 +7,15 @@ import {
7
7
  LabelPackage,
8
8
  Identifier,
9
9
  TimeWindow,
10
+ LabelDownloadSchema,
11
+ FormDownloadSchema,
12
+ DocumentSchema,
13
+ LabelPackageSchema,
14
+ BillingLineItemSchema,
15
+ IdentifierSchema,
16
+ TimeWindowSchema,
10
17
  } from '../models';
18
+ import Joi from 'joi';
11
19
 
12
20
  /** @description Basic structure for a response to create a label */
13
21
  export class CreateLabelResponse extends BaseResponse {
@@ -27,3 +35,19 @@ export class CreateLabelResponse extends BaseResponse {
27
35
  /** @description The delivery window is the time designated when the carrier will drop off the package to the recipient */
28
36
  delivery_window?: TimeWindow;
29
37
  }
38
+
39
+ export const CreateLabelResponseSchema = BaseResponseSchema.keys({
40
+ transaction_id: Joi.string().required(),
41
+ label_download: LabelDownloadSchema.optional(),
42
+ form_download: FormDownloadSchema.optional(),
43
+ documents: Joi.array().optional().items(DocumentSchema),
44
+ packages: Joi.array().optional().items(LabelPackageSchema),
45
+ billing_line_items: Joi.array().optional().items(BillingLineItemSchema),
46
+ tracking_number: Joi.string().optional().empty(),
47
+ trackable: Joi.boolean().optional(),
48
+ alternative_identifiers: Joi.array().optional().items(IdentifierSchema),
49
+ estimated_delivery_datetime: Joi.string().optional().empty().isoDate(),
50
+ consolidator_service_code: Joi.string().optional().empty(),
51
+ carrier_pickup_window: TimeWindowSchema.optional(),
52
+ delivery_window: TimeWindowSchema.optional(),
53
+ });
@@ -1,8 +1,14 @@
1
- import { BaseResponse } from './base-response';
2
- import { Manifest } from '../models';
1
+ import { BaseResponse, BaseResponseSchema } from './base-response';
2
+ import { Manifest, ManifestSchema } from '../models';
3
+ import Joi from 'joi';
3
4
 
4
5
  /** @description Basic structure for a response to create a manifest */
5
6
  export class CreateManifestResponse extends BaseResponse {
6
7
  transaction_id!: string;
7
8
  manifests?: Manifest[];
8
9
  }
10
+
11
+ export const CreateManifestResponseSchema = BaseResponseSchema.keys({
12
+ transaction_id: Joi.string().required(),
13
+ manifests: Joi.array().optional().items(ManifestSchema),
14
+ });
@@ -1,6 +1,11 @@
1
- import { BaseResponse } from './base-response';
1
+ import Joi from 'joi';
2
+ import { BaseResponse, BaseResponseSchema } from './base-response';
2
3
 
3
4
  export class CreateNotificationResponse extends BaseResponse {
4
5
  /** @description The id of the sucessfully created notification*/
5
6
  notification_id!: string;
6
7
  }
8
+
9
+ export const CreateNotificationResponseSchema = BaseResponseSchema.keys({
10
+ notification_id: Joi.string().required(),
11
+ });
@@ -1,7 +1,12 @@
1
- import { BaseResponse } from './base-response';
2
- import { Rate } from '../models';
1
+ import { BaseResponse, BaseResponseSchema } from './base-response';
2
+ import { Rate, RateSchema } from '../models';
3
+ import Joi from 'joi';
3
4
 
4
5
  /** @description Basic structure for a response to get rates */
5
6
  export class GetRatesResponse extends BaseResponse {
6
7
  rates!: Rate[];
7
8
  }
9
+
10
+ export const GetRatesResponseSchema = BaseResponseSchema.keys({
11
+ rates: Joi.array().required().items(RateSchema),
12
+ });