@shipengine/connect-carrier-api 2.3.3 → 2.4.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 (62) hide show
  1. package/lib/app/carrier-app-definition.d.ts +12 -2
  2. package/lib/app/carrier-app.js +7 -2
  3. package/lib/app/carrier-app.js.map +1 -1
  4. package/lib/app/constants.d.ts +3 -1
  5. package/lib/app/constants.js +2 -0
  6. package/lib/app/constants.js.map +1 -1
  7. package/lib/app/internal/metadata.js +3 -0
  8. package/lib/app/internal/metadata.js.map +1 -1
  9. package/lib/models/index.d.ts +1 -0
  10. package/lib/models/index.js +1 -0
  11. package/lib/models/index.js.map +1 -1
  12. package/lib/models/manifest-status.d.ts +10 -0
  13. package/lib/models/manifest-status.js +16 -0
  14. package/lib/models/manifest-status.js.map +1 -0
  15. package/lib/models/relay-points/index.d.ts +2 -0
  16. package/lib/models/relay-points/index.js +6 -0
  17. package/lib/models/relay-points/index.js.map +1 -0
  18. package/lib/models/relay-points/opening-times.d.ts +11 -0
  19. package/lib/models/relay-points/opening-times.js +18 -0
  20. package/lib/models/relay-points/opening-times.js.map +1 -0
  21. package/lib/models/relay-points/relay-point.d.ts +17 -0
  22. package/lib/models/relay-points/relay-point.js +24 -0
  23. package/lib/models/relay-points/relay-point.js.map +1 -0
  24. package/lib/requests/create-label-request.d.ts +2 -1
  25. package/lib/requests/create-label-request.js.map +1 -1
  26. package/lib/requests/get-manifest-request.d.ts +9 -0
  27. package/lib/requests/get-manifest-request.js +9 -0
  28. package/lib/requests/get-manifest-request.js.map +1 -0
  29. package/lib/requests/get-relay-points-request.d.ts +6 -0
  30. package/lib/requests/get-relay-points-request.js +8 -0
  31. package/lib/requests/get-relay-points-request.js.map +1 -0
  32. package/lib/requests/index.d.ts +2 -0
  33. package/lib/requests/index.js +2 -0
  34. package/lib/requests/index.js.map +1 -1
  35. package/lib/responses/create-manifest-response.d.ts +6 -0
  36. package/lib/responses/create-manifest-response.js +6 -0
  37. package/lib/responses/create-manifest-response.js.map +1 -1
  38. package/lib/responses/get-relay-points-response.d.ts +8 -0
  39. package/lib/responses/get-relay-points-response.js +15 -0
  40. package/lib/responses/get-relay-points-response.js.map +1 -0
  41. package/lib/responses/index.d.ts +1 -0
  42. package/lib/responses/index.js +1 -0
  43. package/lib/responses/index.js.map +1 -1
  44. package/package.json +1 -1
  45. package/spec.json +107 -0
  46. package/src/app/carrier-app-definition.ts +17 -0
  47. package/src/app/carrier-app.ts +8 -0
  48. package/src/app/constants.ts +2 -0
  49. package/src/app/internal/metadata.ts +4 -0
  50. package/src/models/index.ts +1 -0
  51. package/src/models/manifest-status.ts +11 -0
  52. package/src/models/relay-points/index.ts +2 -0
  53. package/src/models/relay-points/opening-times.ts +21 -0
  54. package/src/models/relay-points/relay-point.ts +31 -0
  55. package/src/requests/create-label-request.ts +2 -0
  56. package/src/requests/get-manifest-request.ts +13 -0
  57. package/src/requests/get-relay-points-request.ts +7 -0
  58. package/src/requests/index.ts +2 -0
  59. package/src/responses/create-manifest-response.ts +11 -0
  60. package/src/responses/get-relay-points-response.ts +12 -0
  61. package/src/responses/index.ts +1 -0
  62. package/tsconfig.tsbuildinfo +1 -1
@@ -3,6 +3,7 @@ import {
3
3
  CreateLabelRequest,
4
4
  VoidLabelsRequest,
5
5
  CreateManifestRequest,
6
+ GetManifestRequest,
6
7
  SchedulePickupRequest,
7
8
  CancelPickupRequest,
8
9
  GetRatesRequest,
@@ -11,6 +12,7 @@ import {
11
12
  CreateNotificationRequest,
12
13
  ValidateInboundDataRequest,
13
14
  NormalizeTrackingDataRequest,
15
+ GetRelayPointsRequest,
14
16
  } from '../requests';
15
17
 
16
18
  import {
@@ -26,6 +28,7 @@ import {
26
28
  CreateNotificationResponse,
27
29
  ValidateInboundDataResponse,
28
30
  NormalizeTrackingDataResponse,
31
+ GetRelayPointsResponse,
29
32
  } from '../responses';
30
33
 
31
34
  import { CarrierAppMetadata } from './metadata/carrier-app-metadata';
@@ -57,6 +60,13 @@ export interface CarrierAppDefinition {
57
60
  CreateManifest?: (
58
61
  request: CreateManifestRequest,
59
62
  ) => CreateManifestResponse | Promise<CreateManifestResponse>;
63
+ /**
64
+ * @description This method is used to retrieve a manifest with a carrier
65
+ * @param request Data needed by the provider to retrieve a previousely created manifest
66
+ */
67
+ GetManifest?: (
68
+ request: GetManifestRequest,
69
+ ) => CreateManifestResponse | Promise<CreateManifestResponse>;
60
70
  /**
61
71
  * @description This endpoint is used to schedule an adhoc pickup with the shipping provider
62
72
  * @param request Data needed by the provider to schedule adhoc pickups
@@ -109,4 +119,11 @@ export interface CarrierAppDefinition {
109
119
  NormalizeTrackingData?: (
110
120
  request: NormalizeTrackingDataRequest,
111
121
  ) => NormalizeTrackingDataResponse | Promise<NormalizeTrackingDataResponse>;
122
+ /**
123
+ * @description This endpoint is used to get all relay points for carrier
124
+ * @param request Data needed by the provider about the relay points to be returned
125
+ */
126
+ GetRelayPoints?: (
127
+ request: GetRelayPointsRequest,
128
+ ) => GetRelayPointsResponse | Promise<GetRelayPointsResponse>;
112
129
  }
@@ -19,6 +19,7 @@ import {
19
19
  CreateNotificationResponseSchema,
20
20
  ValidateInboundDataResponseSchema,
21
21
  NormalizeTrackingDataResponseSchema,
22
+ GetRelayPointsResponseSchema,
22
23
  } from '../responses';
23
24
  import { Schema } from 'joi';
24
25
 
@@ -74,6 +75,7 @@ export class CarrierApp implements ConnectRuntimeApp {
74
75
  definition.CreateManifest,
75
76
  CreateManifestResponseSchema,
76
77
  ],
78
+ [Method.POST, ApiEndpoints.GetManifest, definition.GetManifest, CreateManifestResponseSchema],
77
79
  [
78
80
  Method.POST,
79
81
  ApiEndpoints.CreateNotification,
@@ -102,6 +104,12 @@ export class CarrierApp implements ConnectRuntimeApp {
102
104
  ValidateInboundDataResponseSchema,
103
105
  ],
104
106
  [Method.POST, ApiEndpoints.VoidLabels, definition.VoidLabels, VoidLabelsResponseSchema],
107
+ [
108
+ Method.POST,
109
+ ApiEndpoints.GetRelayPoints,
110
+ definition.GetRelayPoints,
111
+ GetRelayPointsResponseSchema,
112
+ ],
105
113
  ).forEach(([method, path, implementation, schema]) => {
106
114
  if (implementation) {
107
115
  this.routes.push({
@@ -4,6 +4,7 @@ export enum ApiEndpoints {
4
4
  VoidLabels = '/VoidLabels',
5
5
  GetRates = '/GetRates',
6
6
  CreateManifest = '/CreateManifest',
7
+ GetManifest = '/GetManifest',
7
8
  SchedulePickup = '/SchedulePickup',
8
9
  CancelPickup = '/CancelPickup',
9
10
  Track = '/Track',
@@ -11,4 +12,5 @@ export enum ApiEndpoints {
11
12
  CancelNotification = '/CancelNotification',
12
13
  ValidateInboundData = '/ValidateInboundData',
13
14
  NormalizeTrackingData = '/NormalizeTrackingData',
15
+ GetRelayPoints = '/RelayPoints',
14
16
  }
@@ -30,6 +30,10 @@ const mapFunctions = (app: CarrierAppDefinition): FunctionSpecification[] => {
30
30
  fns.push(fn('CreateManifest'));
31
31
  }
32
32
 
33
+ if (app.GetManifest) {
34
+ fns.push(fn('GetManifest'));
35
+ }
36
+
33
37
  if (app.SchedulePickup) {
34
38
  fns.push(fn('SchedulePickup'));
35
39
  }
@@ -22,3 +22,4 @@ export * from './taxes';
22
22
  export * from './documents';
23
23
  export * from './time-window';
24
24
  export * from './inbound-content-types';
25
+ export * from './relay-points';
@@ -0,0 +1,11 @@
1
+ import Joi from 'joi';
2
+
3
+ /** @description Possible status values for Created Manifest */
4
+ export enum ManifestStatus {
5
+ /** @description Unknown, The request is in process */
6
+ Unknown = 'unknown',
7
+ InProgress = 'in_progress',
8
+ Completed = 'completed',
9
+ Failed = 'failed',
10
+ }
11
+ export const ManifestStatusSchema = Joi.string().valid(...Object.values(ManifestStatus));
@@ -0,0 +1,2 @@
1
+ export * from './relay-point';
2
+ export * from './opening-times';
@@ -0,0 +1,21 @@
1
+ import Joi from 'joi';
2
+
3
+ export class OpeningTimes {
4
+ monday!: string;
5
+ tuesday!: string;
6
+ wednesday!: string;
7
+ thursday!: string;
8
+ friday!: string;
9
+ saturday!: string;
10
+ sunday!: string;
11
+ }
12
+
13
+ export const OpeningTimesSchema = Joi.object({
14
+ monday: Joi.string().required().empty(),
15
+ tuesday: Joi.string().required().empty(),
16
+ wednesday: Joi.string().required().empty(),
17
+ thursday: Joi.string().required().empty(),
18
+ friday: Joi.string().required().empty(),
19
+ saturday: Joi.string().required().empty(),
20
+ sunday: Joi.string().required().empty(),
21
+ });
@@ -0,0 +1,31 @@
1
+ import Joi from 'joi';
2
+ import { OpeningTimes, OpeningTimesSchema } from './opening-times';
3
+
4
+ /** @description Basic structure for a relay point */
5
+ export class RelayPoint {
6
+ relay_point_id!: string;
7
+ company_name?: string;
8
+ address_line1!: string;
9
+ city_locality!: string;
10
+ state_province!: string;
11
+ postal_code!: string;
12
+ country_code!: string;
13
+ phone?: string;
14
+ long?: number;
15
+ lat?: number;
16
+ opening_times!: OpeningTimes;
17
+ }
18
+
19
+ export const RelayPointSchema = Joi.object({
20
+ relay_point_id: Joi.string().required(),
21
+ company_name: Joi.string().optional().empty(),
22
+ address_line1: Joi.string().required(),
23
+ city_locality: Joi.string().required(),
24
+ state_province: Joi.string().required(),
25
+ postal_code: Joi.string().required(),
26
+ country_code: Joi.string().required(),
27
+ phone: Joi.string().required(),
28
+ long: Joi.number().optional(),
29
+ lat: Joi.number().optional(),
30
+ opening_times: OpeningTimesSchema.required(),
31
+ });
@@ -14,6 +14,7 @@ import {
14
14
  ShipTo,
15
15
  Document,
16
16
  TimeWindow,
17
+ RelayPoint,
17
18
  } from '../models';
18
19
 
19
20
  /** @description Basic structure for a request to create a label */
@@ -34,6 +35,7 @@ export class CreateLabelRequest extends BaseRequest {
34
35
  ship_to!: ShipTo;
35
36
  ship_from!: ShipFrom;
36
37
  pickup_location?: PudoLocation;
38
+ relay_points?: RelayPoint[];
37
39
  ship_from_display?: ShipFromDisplay;
38
40
  /** @description Whether the shipment requires next day shipping */
39
41
  next_day?: boolean;
@@ -0,0 +1,13 @@
1
+ import { BaseRequest } from './base-request';
2
+
3
+ /** @description Basic structure for a request to get previousely created manifests */
4
+ export class GetManifestRequest extends BaseRequest {
5
+ // Identifier to retrieve manifest
6
+ manifest_request_id?: number;
7
+
8
+ // Data required to retrieve manifests
9
+ manifest_identifiers?: { [key: string]: any };
10
+
11
+ // Default false: Allow up to 5 checks to DHL before returning.
12
+ return_immediately?: boolean;
13
+ }
@@ -0,0 +1,7 @@
1
+ import { BaseRequest } from './base-request';
2
+
3
+ export class GetRelayPointsRequest extends BaseRequest {
4
+ service_code!: string;
5
+ postal_code!: string;
6
+ country_code!: string;
7
+ }
@@ -1,6 +1,7 @@
1
1
  export * from './cancel-pickup-request';
2
2
  export * from './create-label-request';
3
3
  export * from './create-manifest-request';
4
+ export * from './get-manifest-request';
4
5
  export * from './get-rates-request';
5
6
  export * from './register-request';
6
7
  export * from './schedule-pickup-request';
@@ -10,3 +11,4 @@ export * from './create-notification-request';
10
11
  export * from './cancel-notification-request';
11
12
  export * from './validate-inbound-data-request';
12
13
  export * from './normalize-tracking-data-request';
14
+ export * from './get-relay-points-request';
@@ -1,14 +1,25 @@
1
1
  import { BaseResponse, BaseResponseSchema } from './base-response';
2
2
  import { Manifest, ManifestSchema } from '../models';
3
3
  import Joi from 'joi';
4
+ import { ManifestStatus, ManifestStatusSchema } from '../models/manifest-status';
4
5
 
5
6
  /** @description Basic structure for a response to create a manifest */
6
7
  export class CreateManifestResponse extends BaseResponse {
7
8
  transaction_id!: string;
8
9
  manifests?: Manifest[];
10
+ manifest_request_id?: number;
11
+ manifest_status?: ManifestStatus;
12
+ total_shipments?: number;
13
+ total_invalid?: number;
14
+ manifest_identifiers?: any;
9
15
  }
10
16
 
11
17
  export const CreateManifestResponseSchema = BaseResponseSchema.keys({
12
18
  transaction_id: Joi.string().required(),
13
19
  manifests: Joi.array().optional().items(ManifestSchema),
20
+ manifest_request_id: Joi.number().optional(),
21
+ manifest_status: ManifestStatusSchema.optional,
22
+ total_shipments: Joi.number().optional(),
23
+ total_invalid: Joi.number().optional(),
24
+ manifest_identifiers: Joi.any().optional(),
14
25
  });
@@ -0,0 +1,12 @@
1
+ import { BaseResponse, BaseResponseSchema } from './base-response';
2
+ import { RelayPoint, RelayPointSchema } from '../models';
3
+ import Joi from 'joi';
4
+
5
+ /** @description Basic structure for a response to create a label */
6
+ export class GetRelayPointsResponse extends BaseResponse {
7
+ relay_points!: RelayPoint[];
8
+ }
9
+
10
+ export const GetRelayPointsResponseSchema = BaseResponseSchema.keys({
11
+ relay_points: Joi.array().required().items(RelayPointSchema),
12
+ });
@@ -11,3 +11,4 @@ export * from './cancel-notification-response';
11
11
  export * from './create-notification-response';
12
12
  export * from './validate-inbound-data-response';
13
13
  export * from './normalize-tracking-data-response';
14
+ export * from './get-relay-points-response';