@shipengine/connect-carrier-api 2.4.6 → 2.5.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 (83) hide show
  1. package/lib/app/carrier-app-definition.d.ts +7 -2
  2. package/lib/app/carrier-app.js +10 -2
  3. package/lib/app/carrier-app.js.map +1 -1
  4. package/lib/app/constants.d.ts +1 -0
  5. package/lib/app/constants.js +1 -0
  6. package/lib/app/constants.js.map +1 -1
  7. package/lib/app/internal/carrier-specification.d.ts +1 -0
  8. package/lib/app/internal/carrier-specification.js +1 -0
  9. package/lib/app/internal/carrier-specification.js.map +1 -1
  10. package/lib/app/internal/metadata.js +3 -0
  11. package/lib/app/internal/metadata.js.map +1 -1
  12. package/lib/app/metadata/carrier.d.ts +1 -0
  13. package/lib/app/metadata/carrier.js +1 -0
  14. package/lib/app/metadata/carrier.js.map +1 -1
  15. package/lib/models/labels/index.d.ts +3 -0
  16. package/lib/models/labels/index.js +3 -0
  17. package/lib/models/labels/index.js.map +1 -1
  18. package/lib/models/labels/label-details.d.ts +36 -0
  19. package/lib/models/labels/label-details.js +8 -0
  20. package/lib/models/labels/label-details.js.map +1 -0
  21. package/lib/models/labels/label-payment-result.d.ts +10 -0
  22. package/lib/models/labels/label-payment-result.js +17 -0
  23. package/lib/models/labels/label-payment-result.js.map +1 -0
  24. package/lib/models/labels/label-request.d.ts +35 -0
  25. package/lib/models/labels/label-request.js +3 -0
  26. package/lib/models/labels/label-request.js.map +1 -0
  27. package/lib/models/manifests/index.d.ts +2 -0
  28. package/lib/models/manifests/index.js +2 -0
  29. package/lib/models/manifests/index.js.map +1 -1
  30. package/lib/models/manifests/manifest-error.d.ts +6 -0
  31. package/lib/models/manifests/manifest-error.js +10 -0
  32. package/lib/models/manifests/manifest-error.js.map +1 -0
  33. package/lib/models/manifests/manifest-request-shipment.d.ts +4 -0
  34. package/lib/models/manifests/manifest-request-shipment.js +8 -0
  35. package/lib/models/manifests/manifest-request-shipment.js.map +1 -0
  36. package/lib/models/manifests/manifest.d.ts +1 -0
  37. package/lib/models/manifests/manifest.js +1 -0
  38. package/lib/models/manifests/manifest.js.map +1 -1
  39. package/lib/requests/create-label-payment-request.d.ts +6 -0
  40. package/lib/requests/create-label-payment-request.js +9 -0
  41. package/lib/requests/create-label-payment-request.js.map +1 -0
  42. package/lib/requests/create-label-request.d.ts +3 -2
  43. package/lib/requests/create-label-request.js.map +1 -1
  44. package/lib/requests/create-manifest-request.d.ts +3 -3
  45. package/lib/requests/get-manifest-request.d.ts +3 -0
  46. package/lib/requests/get-manifest-request.js.map +1 -1
  47. package/lib/requests/index.d.ts +1 -0
  48. package/lib/requests/index.js +1 -0
  49. package/lib/requests/index.js.map +1 -1
  50. package/lib/responses/create-label-payment-response.d.ts +9 -0
  51. package/lib/responses/create-label-payment-response.js +16 -0
  52. package/lib/responses/create-label-payment-response.js.map +1 -0
  53. package/lib/responses/create-manifest-response.d.ts +2 -1
  54. package/lib/responses/create-manifest-response.js +1 -0
  55. package/lib/responses/create-manifest-response.js.map +1 -1
  56. package/lib/responses/index.d.ts +1 -0
  57. package/lib/responses/index.js +1 -0
  58. package/lib/responses/index.js.map +1 -1
  59. package/package.json +1 -1
  60. package/spec.json +823 -218
  61. package/src/app/carrier-app-definition.ts +9 -0
  62. package/src/app/carrier-app.ts +12 -2
  63. package/src/app/constants.ts +1 -0
  64. package/src/app/internal/carrier-specification.ts +2 -0
  65. package/src/app/internal/metadata.ts +4 -0
  66. package/src/app/metadata/carrier.ts +2 -0
  67. package/src/models/labels/index.ts +3 -0
  68. package/src/models/labels/label-details.ts +55 -0
  69. package/src/models/labels/label-payment-result.ts +17 -0
  70. package/src/models/labels/label-request.ts +53 -0
  71. package/src/models/manifests/index.ts +2 -0
  72. package/src/models/manifests/manifest-error.ts +11 -0
  73. package/src/models/manifests/manifest-request-shipment.ts +5 -0
  74. package/src/models/manifests/manifest.ts +2 -0
  75. package/src/requests/create-label-payment-request.ts +7 -0
  76. package/src/requests/create-label-request.ts +4 -1
  77. package/src/requests/create-manifest-request.ts +3 -3
  78. package/src/requests/get-manifest-request.ts +7 -0
  79. package/src/requests/index.ts +1 -0
  80. package/src/responses/create-label-payment-response.ts +14 -0
  81. package/src/responses/create-manifest-response.ts +3 -1
  82. package/src/responses/index.ts +1 -0
  83. package/tsconfig.tsbuildinfo +1 -1
@@ -13,6 +13,7 @@ import {
13
13
  ValidateInboundDataRequest,
14
14
  NormalizeTrackingDataRequest,
15
15
  GetRelayPointsRequest,
16
+ CreateLabelPaymentRequest,
16
17
  } from '../requests';
17
18
 
18
19
  import {
@@ -29,6 +30,7 @@ import {
29
30
  ValidateInboundDataResponse,
30
31
  NormalizeTrackingDataResponse,
31
32
  GetRelayPointsResponse,
33
+ CreateLabelPaymentResponse,
32
34
  } from '../responses';
33
35
 
34
36
  import { CarrierAppMetadata } from './metadata/carrier-app-metadata';
@@ -48,6 +50,13 @@ export interface CarrierAppDefinition {
48
50
  * @param request Data needed by the provider to create a label
49
51
  */
50
52
  CreateLabel?: (request: CreateLabelRequest) => CreateLabelResponse | Promise<CreateLabelResponse>;
53
+ /**
54
+ * @description This method is used to create a label
55
+ * @param request Data needed by the provider to create a label
56
+ */
57
+ CreateLabelPayment?: (
58
+ request: CreateLabelPaymentRequest,
59
+ ) => CreateLabelPaymentResponse | Promise<CreateLabelPaymentResponse>;
51
60
  /**
52
61
  * @description This method is used to void multiple labels
53
62
  * @param request Data needed by the provider to void multiple labels
@@ -15,6 +15,7 @@ import {
15
15
  GetRatesResponseSchema,
16
16
  VoidLabelsResponseSchema,
17
17
  CreateLabelResponseSchema,
18
+ CreateLabelPaymentResponseSchema,
18
19
  CreateManifestResponseSchema,
19
20
  CreateNotificationResponseSchema,
20
21
  ValidateInboundDataResponseSchema,
@@ -25,8 +26,11 @@ import { Schema } from 'joi';
25
26
 
26
27
  const handleRequest = (implementation?: Function): any => {
27
28
  if (implementation) {
28
- return (request: any) => {
29
- return implementation(request.body);
29
+ return async (request: any) => {
30
+ const { transaction_id } = request.body;
31
+ const result = await implementation(request.body);
32
+ result.transaction_id = transaction_id;
33
+ return result;
30
34
  };
31
35
  }
32
36
  };
@@ -69,6 +73,12 @@ export class CarrierApp implements ConnectRuntimeApp {
69
73
  ],
70
74
  [Method.POST, ApiEndpoints.CancelPickup, definition.CancelPickup, CancelPickupResponseSchema],
71
75
  [Method.POST, ApiEndpoints.CreateLabel, definition.CreateLabel, CreateLabelResponseSchema],
76
+ [
77
+ Method.POST,
78
+ ApiEndpoints.CreateLabelPayment,
79
+ definition.CreateLabelPayment,
80
+ CreateLabelPaymentResponseSchema,
81
+ ],
72
82
  [
73
83
  Method.POST,
74
84
  ApiEndpoints.CreateManifest,
@@ -1,6 +1,7 @@
1
1
  export enum ApiEndpoints {
2
2
  Register = '/Register',
3
3
  CreateLabel = '/CreateLabel',
4
+ CreateLabelPayment = '/CreateLabelPayment',
4
5
  VoidLabels = '/VoidLabels',
5
6
  GetRates = '/GetRates',
6
7
  CreateManifest = '/CreateManifest',
@@ -95,6 +95,7 @@ export class CarrierSpecification {
95
95
  AppId: string;
96
96
  DefaultRateCard: string;
97
97
  };
98
+ RequiresLabelPayment?: boolean;
98
99
 
99
100
  constructor(definition: Carrier) {
100
101
  this.Images = {
@@ -116,5 +117,6 @@ export class CarrierSpecification {
116
117
  this.CarrierUrl = definition.CarrierUrl;
117
118
  this.Description = definition.Description;
118
119
  this.NativeRating = definition.NativeRating;
120
+ this.RequiresLabelPayment = definition.RequiresLabelPayment;
119
121
  }
120
122
  }
@@ -22,6 +22,10 @@ const mapFunctions = (app: CarrierAppDefinition): FunctionSpecification[] => {
22
22
  fns.push(fn('CreateLabel'));
23
23
  }
24
24
 
25
+ if (app.CreateLabelPayment) {
26
+ fns.push(fn('CreateLabelPayment'));
27
+ }
28
+
25
29
  if (app.VoidLabels) {
26
30
  fns.push(fn('VoidLabels'));
27
31
  }
@@ -39,6 +39,7 @@ export interface Carrier {
39
39
  /** @description Default rate card to use for rating */
40
40
  DefaultRateCard: string;
41
41
  };
42
+ RequiresLabelPayment?: boolean;
42
43
  }
43
44
 
44
45
  const fileExists = (value: string, helpers: any) => {
@@ -90,4 +91,5 @@ export const CarrierSchema = Joi.object({
90
91
  .pattern(new RegExp('^.*.(svg)$'))
91
92
  .message('Images.Logo must be a svg file.'),
92
93
  }).required(),
94
+ RequiresLabelPayment: Joi.boolean().optional(),
93
95
  });
@@ -4,6 +4,9 @@ export * from './label-download';
4
4
  export * from './document-formats';
5
5
  export * from './label-layouts';
6
6
  export * from './label-message';
7
+ export * from './label-details';
8
+ export * from './label-payment-result';
9
+ export * from './label-request';
7
10
  export * from './return-label-details';
8
11
  export * from './void-request';
9
12
  export * from './void-response';
@@ -0,0 +1,55 @@
1
+ import {
2
+ ConfirmationTypes,
3
+ Document,
4
+ DocumentFormat,
5
+ LabelRequest,
6
+ LabelLayouts,
7
+ AdvancedOptions,
8
+ InsuranceProviders,
9
+ Package,
10
+ ShipTo,
11
+ ShipFrom,
12
+ PudoLocation,
13
+ RelayPointDetails,
14
+ ShipFromDisplay,
15
+ ReturnLabelDetails,
16
+ FulfillmentPlanDetails,
17
+ TimeWindow,
18
+ Identifier,
19
+ } from '..';
20
+
21
+ /** @description Basic structure for a label */
22
+ export class LabelDetails implements LabelRequest {
23
+ correlation_id!: string;
24
+ service_code?: string;
25
+ ship_datetime!: string;
26
+ confirmation?: ConfirmationTypes;
27
+ label_format?: DocumentFormat;
28
+ label_layout?: LabelLayouts;
29
+ /** @description Whether the request is for a test */
30
+ is_test_label?: boolean;
31
+ /** @description Any additional options a shipment may require, including custom options */
32
+ advanced_options?: AdvancedOptions;
33
+ insurance_provider?: InsuranceProviders;
34
+ /** @description Whether the shipment is a return */
35
+ is_return_label!: boolean;
36
+ packages!: Package[];
37
+ ship_to!: ShipTo;
38
+ ship_from!: ShipFrom;
39
+ pickup_location?: PudoLocation;
40
+ relay_points?: RelayPointDetails;
41
+ ship_from_display?: ShipFromDisplay;
42
+ /** @description Whether the shipment requires next day shipping */
43
+ next_day?: boolean;
44
+ /** @description Whether the shipment is international */
45
+ international?: boolean;
46
+ reference?: string;
47
+ return_details?: ReturnLabelDetails;
48
+ fulfillment_plan_details?: FulfillmentPlanDetails;
49
+ attachments?: Document[];
50
+ /** @description The carrier pickup window is the time designated when the carrier will pickup your package from the initial location */
51
+ carrier_pickup_window?: TimeWindow;
52
+ /** @description Unique identifier for the carrier rate */
53
+ carrier_rate_id?: string;
54
+ alternative_identifiers?: Identifier[];
55
+ }
@@ -0,0 +1,17 @@
1
+ import Joi from 'joi';
2
+ import { Identifier, IdentifierSchema } from '../identifier';
3
+
4
+ /** @description Basic structure for a label payment result */
5
+ export class LabelPaymentResult {
6
+ correlation_id!: string;
7
+ alternative_identifiers!: Identifier[];
8
+ error_messages?: string[];
9
+ warning_messages?: string[];
10
+ }
11
+
12
+ export const LabelPaymentResultSchema = Joi.object({
13
+ correlation_id: Joi.string().required(),
14
+ alternative_identifiers: Joi.array().required().items(IdentifierSchema),
15
+ error_messages: Joi.array().optional().items(Joi.string()),
16
+ warning_messages: Joi.array().optional().items(Joi.string()),
17
+ });
@@ -0,0 +1,53 @@
1
+ import {
2
+ AdvancedOptions,
3
+ ConfirmationTypes,
4
+ FulfillmentPlanDetails,
5
+ InsuranceProviders,
6
+ DocumentFormat,
7
+ LabelLayouts,
8
+ Package,
9
+ ReturnLabelDetails,
10
+ ShipFrom,
11
+ PudoLocation,
12
+ ShipFromDisplay,
13
+ ShipTo,
14
+ Document,
15
+ TimeWindow,
16
+ RelayPointDetails,
17
+ Identifier,
18
+ } from '..';
19
+
20
+ /** @description Basic structure for a request to create a label */
21
+ export interface LabelRequest {
22
+ service_code?: string;
23
+ ship_datetime: string;
24
+ confirmation?: ConfirmationTypes;
25
+ label_format?: DocumentFormat;
26
+ label_layout?: LabelLayouts;
27
+ /** @description Whether the request is for a test */
28
+ is_test_label?: boolean;
29
+ /** @description Any additional options a shipment may require, including custom options */
30
+ advanced_options?: AdvancedOptions;
31
+ insurance_provider?: InsuranceProviders;
32
+ /** @description Whether the shipment is a return */
33
+ is_return_label: boolean;
34
+ packages: Package[];
35
+ ship_to: ShipTo;
36
+ ship_from: ShipFrom;
37
+ pickup_location?: PudoLocation;
38
+ relay_points?: RelayPointDetails;
39
+ ship_from_display?: ShipFromDisplay;
40
+ /** @description Whether the shipment requires next day shipping */
41
+ next_day?: boolean;
42
+ /** @description Whether the shipment is international */
43
+ international?: boolean;
44
+ reference?: string;
45
+ return_details?: ReturnLabelDetails;
46
+ fulfillment_plan_details?: FulfillmentPlanDetails;
47
+ attachments?: Document[];
48
+ /** @description The carrier pickup window is the time designated when the carrier will pickup your package from the initial location */
49
+ carrier_pickup_window?: TimeWindow;
50
+ /** @description Unique identifier for the carrier rate */
51
+ carrier_rate_id?: string;
52
+ alternative_identifiers?: Identifier[];
53
+ }
@@ -1,2 +1,4 @@
1
1
  export * from './label';
2
2
  export * from './manifest';
3
+ export * from './manifest-request-shipment';
4
+ export * from './manifest-error';
@@ -0,0 +1,11 @@
1
+ import Joi from 'joi';
2
+
3
+ export interface ManifestError {
4
+ manifest_request_shipment_ids: string[];
5
+ message: string;
6
+ }
7
+
8
+ export const ManifestErrorSchema = Joi.object({
9
+ manifest_request_shipment_ids: Joi.array().required(),
10
+ message: Joi.string().optional(),
11
+ });
@@ -0,0 +1,5 @@
1
+ import { ShippedShipment } from '../pickup/shipped-shipment';
2
+
3
+ export class ManifestRequestShipment extends ShippedShipment {
4
+ manifest_request_shipment_id!: string;
5
+ }
@@ -11,6 +11,7 @@ export class Manifest {
11
11
  document_href?: string;
12
12
  /** @deprecated This property is no longer used please use the document_download */
13
13
  document_data?: string;
14
+ manifest_request_shipment_ids?: string[];
14
15
  }
15
16
 
16
17
  export const ManifestSchema = Joi.object({
@@ -18,4 +19,5 @@ export const ManifestSchema = Joi.object({
18
19
  document_download: ResourceDownloadSchema.optional(),
19
20
  document_href: Joi.string().optional().empty(),
20
21
  document_data: Joi.string().optional().empty(),
22
+ manifest_request_shipment_ids: Joi.array().optional().items(Joi.string()),
21
23
  });
@@ -0,0 +1,7 @@
1
+ import { BaseRequest } from './base-request';
2
+ import { LabelDetails } from '../models';
3
+
4
+ /** @description Basic structure for a request to create one or more label payments */
5
+ export class CreateLabelPaymentRequest extends BaseRequest {
6
+ labels!: LabelDetails[];
7
+ }
@@ -15,10 +15,12 @@ import {
15
15
  Document,
16
16
  TimeWindow,
17
17
  RelayPointDetails,
18
+ LabelRequest,
19
+ Identifier,
18
20
  } from '../models';
19
21
 
20
22
  /** @description Basic structure for a request to create a label */
21
- export class CreateLabelRequest extends BaseRequest {
23
+ export class CreateLabelRequest extends BaseRequest implements LabelRequest {
22
24
  service_code?: string;
23
25
  ship_datetime!: string;
24
26
  confirmation?: ConfirmationTypes;
@@ -49,4 +51,5 @@ export class CreateLabelRequest extends BaseRequest {
49
51
  carrier_pickup_window?: TimeWindow;
50
52
  /** @description Unique identifier for the carrier rate */
51
53
  carrier_rate_id?: string;
54
+ alternative_identifiers?: Identifier[];
52
55
  }
@@ -1,11 +1,11 @@
1
1
  import { BaseRequest } from './base-request';
2
- import { ShipFrom, AdvancedOptions, ShippedShipment } from '../models';
2
+ import { ShipFrom, AdvancedOptions, ManifestRequestShipment } from '../models';
3
3
 
4
4
  /** @description Basic structure for a request to create manifests */
5
5
  export class CreateManifestRequest extends BaseRequest {
6
6
  ship_from?: ShipFrom;
7
- included_labels?: ShippedShipment[];
8
- excluded_labels?: ShippedShipment[];
7
+ included_labels?: ManifestRequestShipment[];
8
+ excluded_labels?: ManifestRequestShipment[];
9
9
  open_datetime?: string;
10
10
  close_datetime!: string;
11
11
  advanced_options?: AdvancedOptions;
@@ -1,3 +1,4 @@
1
+ import { ManifestRequestShipment } from '../models';
1
2
  import { BaseRequest } from './base-request';
2
3
 
3
4
  /** @description Basic structure for a request to get previousely created manifests */
@@ -10,4 +11,10 @@ export class GetManifestRequest extends BaseRequest {
10
11
 
11
12
  // Default false: Allow up to 5 checks to DHL before returning.
12
13
  return_immediately?: boolean;
14
+
15
+ // Labels included, identical to the labels send on the create manifest call
16
+ included_labels?: ManifestRequestShipment[];
17
+
18
+ // Labels excluded, identical to the labels send on the create manifest call
19
+ excluded_labels?: ManifestRequestShipment[];
13
20
  }
@@ -1,5 +1,6 @@
1
1
  export * from './cancel-pickup-request';
2
2
  export * from './create-label-request';
3
+ export * from './create-label-payment-request';
3
4
  export * from './create-manifest-request';
4
5
  export * from './get-manifest-request';
5
6
  export * from './get-rates-request';
@@ -0,0 +1,14 @@
1
+ import Joi from 'joi';
2
+ import { BaseResponse, BaseResponseSchema } from './base-response';
3
+ import { LabelPaymentResult, LabelPaymentResultSchema } from '../models';
4
+
5
+ /** @description Basic structure for a response to create a label */
6
+ export class CreateLabelPaymentResponse extends BaseResponse {
7
+ transaction_id!: string;
8
+ results!: LabelPaymentResult[];
9
+ }
10
+
11
+ export const CreateLabelPaymentResponseSchema = BaseResponseSchema.keys({
12
+ transaction_id: Joi.string().required(),
13
+ results: Joi.array().required().items(LabelPaymentResultSchema),
14
+ });
@@ -1,5 +1,5 @@
1
1
  import { BaseResponse, BaseResponseSchema } from './base-response';
2
- import { Manifest, ManifestSchema } from '../models';
2
+ import { Manifest, ManifestSchema, ManifestError, ManifestErrorSchema } from '../models';
3
3
  import Joi from 'joi';
4
4
  import { ManifestStatus, ManifestStatusSchema } from '../models/manifest-status';
5
5
 
@@ -7,6 +7,7 @@ import { ManifestStatus, ManifestStatusSchema } from '../models/manifest-status'
7
7
  export class CreateManifestResponse extends BaseResponse {
8
8
  transaction_id!: string;
9
9
  manifests?: Manifest[];
10
+ errors?: ManifestError[];
10
11
  manifest_request_id?: number;
11
12
  manifest_status?: ManifestStatus;
12
13
  total_shipments?: number;
@@ -17,6 +18,7 @@ export class CreateManifestResponse extends BaseResponse {
17
18
  export const CreateManifestResponseSchema = BaseResponseSchema.keys({
18
19
  transaction_id: Joi.string().required(),
19
20
  manifests: Joi.array().optional().items(ManifestSchema),
21
+ errors: ManifestErrorSchema.optional(),
20
22
  manifest_request_id: Joi.number().optional(),
21
23
  manifest_status: ManifestStatusSchema.optional,
22
24
  total_shipments: Joi.number().optional(),
@@ -1,5 +1,6 @@
1
1
  export * from './cancel-pickup-response';
2
2
  export * from './create-label-response';
3
+ export * from './create-label-payment-response';
3
4
  export * from './create-manifest-response';
4
5
  export * from './get-rates-response';
5
6
  export * from './register-response';