btrz-api-client 9.7.0 → 9.9.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.
@@ -5,7 +5,28 @@ const {
5
5
  /**
6
6
  * Query params for GET /manifest-notifications (btrz-api-notifications). See get-manifest-notifications-handler getSpec().
7
7
  * @typedef {Object} ManifestNotificationsListQuery
8
- * @property {string} [manifestId] - Manifest id (ObjectId format)
8
+ * @property {string} [manifestId] - Manifest id (ObjectId format). When present, response includes attemptSummary.
9
+ */
10
+
11
+ /**
12
+ * Per-passenger attempt rollup returned when manifestId is provided on GET.
13
+ * @typedef {Object} ManifestNotificationAttemptSummary
14
+ * @property {Array<{id: string, subject?: string, hasReliableTracking: boolean, sentAt?: string|null}>} parents
15
+ * @property {number} trackedParentCount
16
+ * @property {Object<string, {attemptedCount: number, byParent: Object<string, string>}>} byTicket
17
+ * @property {{id: string, resendEligibleTicketIds: string[]}|null} latestParent
18
+ */
19
+
20
+ /**
21
+ * GET /manifest-notifications response when manifestId query param is used.
22
+ * @typedef {Object} ManifestNotificationsListResponse
23
+ * @property {Array<Object>} manifestNotifications
24
+ * @property {ManifestNotificationAttemptSummary} [attemptSummary]
25
+ */
26
+
27
+ /**
28
+ * Optional query params forwarded to POST /manifest-notifications as-is.
29
+ * @typedef {Object.<string, *>} ManifestNotificationsCreateQuery
9
30
  */
10
31
 
11
32
  /**
@@ -24,7 +45,7 @@ function manifestNotificationsFactory({
24
45
  * @param {Object} opts
25
46
  * @param {string} [opts.token] - API key
26
47
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
27
- * @param {ManifestNotificationsQuery} [opts.query] - Optional query params (forwarded to API)
48
+ * @param {ManifestNotificationsCreateQuery} [opts.query] - Optional query params (forwarded to API)
28
49
  * @param {Object} opts.data - Request body
29
50
  * @param {Object} [opts.headers] - Optional headers
30
51
  * @returns {Promise<import("axios").AxiosResponse>}
@@ -56,7 +77,7 @@ function manifestNotificationsFactory({
56
77
  * @param {string} [opts.token] - API key
57
78
  * @param {ManifestNotificationsListQuery} [opts.query] - Query params (manifestId optional)
58
79
  * @param {Object} [opts.headers] - Optional headers
59
- * @returns {Promise<import("axios").AxiosResponse>}
80
+ * @returns {Promise<import("axios").AxiosResponse<ManifestNotificationsListResponse>>}
60
81
  */
61
82
  function all({
62
83
  token,
@@ -292,6 +292,33 @@ function notifyTicketFactory({
292
292
  headers
293
293
  })
294
294
  });
295
+ },
296
+ /**
297
+ * POST /notify-manifest/{parentId}/resend - resend a parent manifest notification to
298
+ * Resend-eligible (unnotified) passengers. Server computes eligibility; no request body.
299
+ * @param {Object} opts
300
+ * @param {string} [opts.token] - API key
301
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
302
+ * @param {string} opts.parentId - Parent manifest notification shared id
303
+ * @param {Object} [opts.headers] - Optional headers
304
+ * @returns {Promise<import("axios").AxiosResponse>}
305
+ */
306
+ resend({
307
+ token,
308
+ jwtToken,
309
+ parentId,
310
+ headers
311
+ }) {
312
+ return client({
313
+ url: `/notify-manifest/${parentId}/resend`,
314
+ method: "post",
315
+ headers: authorizationHeaders({
316
+ token,
317
+ jwtToken,
318
+ internalAuthTokenProvider,
319
+ headers
320
+ })
321
+ });
295
322
  }
296
323
  }
297
324
  };
@@ -1028,6 +1028,108 @@ function manifestFactory({
1028
1028
  });
1029
1029
  }
1030
1030
  };
1031
+
1032
+ /**
1033
+ * POST manifests/:manifestId/boarding/:stationId - board passengers at station.
1034
+ * @param {Object} opts
1035
+ * @param {string} [opts.token] - API key
1036
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
1037
+ * @param {Object} [opts.headers] - Optional headers
1038
+ * @param {string} opts.manifestId - Manifest id
1039
+ * @param {string} opts.stationId - Station id
1040
+ * @param {Object} opts.data - Request body
1041
+ * @returns {Promise<import("axios").AxiosResponse>}
1042
+ */
1043
+ function stationBoarding({
1044
+ token,
1045
+ jwtToken,
1046
+ headers,
1047
+ manifestId,
1048
+ stationId,
1049
+ data,
1050
+ query
1051
+ }) {
1052
+ return client({
1053
+ url: `/manifests/${manifestId}/boarding/${stationId}`,
1054
+ method: "post",
1055
+ headers: authorizationHeaders({
1056
+ token,
1057
+ jwtToken,
1058
+ internalAuthTokenProvider,
1059
+ headers
1060
+ }),
1061
+ data,
1062
+ params: query
1063
+ });
1064
+ }
1065
+
1066
+ /**
1067
+ * POST manifests/:manifestId/dispatch/:stationId - dispatch manifest at station.
1068
+ * @param {Object} opts
1069
+ * @param {string} [opts.token] - API key
1070
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
1071
+ * @param {Object} [opts.headers] - Optional headers
1072
+ * @param {string} opts.manifestId - Manifest id
1073
+ * @param {string} opts.stationId - Station id
1074
+ * @param {Object} opts.data - Request body
1075
+ * @returns {Promise<import("axios").AxiosResponse>}
1076
+ */
1077
+ function stationDispatch({
1078
+ token,
1079
+ jwtToken,
1080
+ headers,
1081
+ manifestId,
1082
+ stationId,
1083
+ data,
1084
+ query
1085
+ }) {
1086
+ return client({
1087
+ url: `/manifests/${manifestId}/dispatch/${stationId}`,
1088
+ method: "post",
1089
+ headers: authorizationHeaders({
1090
+ token,
1091
+ jwtToken,
1092
+ internalAuthTokenProvider,
1093
+ headers
1094
+ }),
1095
+ data,
1096
+ params: query
1097
+ });
1098
+ }
1099
+
1100
+ /**
1101
+ * POST manifests/:manifestId/sales-closure/:stationId - close sales at station.
1102
+ * @param {Object} opts
1103
+ * @param {string} [opts.token] - API key
1104
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
1105
+ * @param {Object} [opts.headers] - Optional headers
1106
+ * @param {string} opts.manifestId - Manifest id
1107
+ * @param {string} opts.stationId - Station id
1108
+ * @param {Object} opts.data - Request body
1109
+ * @returns {Promise<import("axios").AxiosResponse>}
1110
+ */
1111
+ function stationSalesClosure({
1112
+ token,
1113
+ jwtToken,
1114
+ headers,
1115
+ manifestId,
1116
+ stationId,
1117
+ data,
1118
+ query
1119
+ }) {
1120
+ return client({
1121
+ url: `/manifests/${manifestId}/sales-closure/${stationId}`,
1122
+ method: "post",
1123
+ headers: authorizationHeaders({
1124
+ token,
1125
+ jwtToken,
1126
+ internalAuthTokenProvider,
1127
+ headers
1128
+ }),
1129
+ data,
1130
+ params: query
1131
+ });
1132
+ }
1031
1133
  return {
1032
1134
  get,
1033
1135
  getAll,
@@ -1052,7 +1154,10 @@ function manifestFactory({
1052
1154
  reports,
1053
1155
  labels,
1054
1156
  driverRelays,
1055
- tripClose
1157
+ tripClose,
1158
+ stationBoarding,
1159
+ stationDispatch,
1160
+ stationSalesClosure
1056
1161
  };
1057
1162
  }
1058
1163
  module.exports = manifestFactory;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "btrz-api-client",
3
- "version": "9.7.0",
3
+ "version": "9.9.0",
4
4
  "description": "Api client for Betterez endpoints",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -5,7 +5,28 @@ const {
5
5
  /**
6
6
  * Query params for GET /manifest-notifications (btrz-api-notifications). See get-manifest-notifications-handler getSpec().
7
7
  * @typedef {Object} ManifestNotificationsListQuery
8
- * @property {string} [manifestId] - Manifest id (ObjectId format)
8
+ * @property {string} [manifestId] - Manifest id (ObjectId format). When present, response includes attemptSummary.
9
+ */
10
+
11
+ /**
12
+ * Per-passenger attempt rollup returned when manifestId is provided on GET.
13
+ * @typedef {Object} ManifestNotificationAttemptSummary
14
+ * @property {Array<{id: string, subject?: string, hasReliableTracking: boolean, sentAt?: string|null}>} parents
15
+ * @property {number} trackedParentCount
16
+ * @property {Object<string, {attemptedCount: number, byParent: Object<string, string>}>} byTicket
17
+ * @property {{id: string, resendEligibleTicketIds: string[]}|null} latestParent
18
+ */
19
+
20
+ /**
21
+ * GET /manifest-notifications response when manifestId query param is used.
22
+ * @typedef {Object} ManifestNotificationsListResponse
23
+ * @property {Array<Object>} manifestNotifications
24
+ * @property {ManifestNotificationAttemptSummary} [attemptSummary]
25
+ */
26
+
27
+ /**
28
+ * Optional query params forwarded to POST /manifest-notifications as-is.
29
+ * @typedef {Object.<string, *>} ManifestNotificationsCreateQuery
9
30
  */
10
31
 
11
32
  /**
@@ -24,7 +45,7 @@ function manifestNotificationsFactory({
24
45
  * @param {Object} opts
25
46
  * @param {string} [opts.token] - API key
26
47
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
27
- * @param {ManifestNotificationsQuery} [opts.query] - Optional query params (forwarded to API)
48
+ * @param {ManifestNotificationsCreateQuery} [opts.query] - Optional query params (forwarded to API)
28
49
  * @param {Object} opts.data - Request body
29
50
  * @param {Object} [opts.headers] - Optional headers
30
51
  * @returns {Promise<import("axios").AxiosResponse>}
@@ -47,7 +68,7 @@ function manifestNotificationsFactory({
47
68
  * @param {string} [opts.token] - API key
48
69
  * @param {ManifestNotificationsListQuery} [opts.query] - Query params (manifestId optional)
49
70
  * @param {Object} [opts.headers] - Optional headers
50
- * @returns {Promise<import("axios").AxiosResponse>}
71
+ * @returns {Promise<import("axios").AxiosResponse<ManifestNotificationsListResponse>>}
51
72
  */
52
73
  function all({
53
74
  token,
@@ -212,6 +212,23 @@ function notifyTicketFactory({
212
212
  data,
213
213
  headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
214
214
  });
215
+ },
216
+ /**
217
+ * POST /notify-manifest/{parentId}/resend - resend a parent manifest notification to
218
+ * Resend-eligible (unnotified) passengers. Server computes eligibility; no request body.
219
+ * @param {Object} opts
220
+ * @param {string} [opts.token] - API key
221
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
222
+ * @param {string} opts.parentId - Parent manifest notification shared id
223
+ * @param {Object} [opts.headers] - Optional headers
224
+ * @returns {Promise<import("axios").AxiosResponse>}
225
+ */
226
+ resend({token, jwtToken, parentId, headers}) {
227
+ return client({
228
+ url: `/notify-manifest/${parentId}/resend`,
229
+ method: "post",
230
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
231
+ });
215
232
  }
216
233
  }
217
234
  };
@@ -730,6 +730,69 @@ function manifestFactory({
730
730
  }
731
731
  };
732
732
 
733
+ /**
734
+ * POST manifests/:manifestId/boarding/:stationId - board passengers at station.
735
+ * @param {Object} opts
736
+ * @param {string} [opts.token] - API key
737
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
738
+ * @param {Object} [opts.headers] - Optional headers
739
+ * @param {string} opts.manifestId - Manifest id
740
+ * @param {string} opts.stationId - Station id
741
+ * @param {Object} opts.data - Request body
742
+ * @returns {Promise<import("axios").AxiosResponse>}
743
+ */
744
+ function stationBoarding({token, jwtToken, headers, manifestId, stationId, data, query}) {
745
+ return client({
746
+ url: `/manifests/${manifestId}/boarding/${stationId}`,
747
+ method: "post",
748
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
749
+ data,
750
+ params: query
751
+ });
752
+ }
753
+
754
+ /**
755
+ * POST manifests/:manifestId/dispatch/:stationId - dispatch manifest at station.
756
+ * @param {Object} opts
757
+ * @param {string} [opts.token] - API key
758
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
759
+ * @param {Object} [opts.headers] - Optional headers
760
+ * @param {string} opts.manifestId - Manifest id
761
+ * @param {string} opts.stationId - Station id
762
+ * @param {Object} opts.data - Request body
763
+ * @returns {Promise<import("axios").AxiosResponse>}
764
+ */
765
+ function stationDispatch({token, jwtToken, headers, manifestId, stationId, data, query}) {
766
+ return client({
767
+ url: `/manifests/${manifestId}/dispatch/${stationId}`,
768
+ method: "post",
769
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
770
+ data,
771
+ params: query
772
+ });
773
+ }
774
+
775
+ /**
776
+ * POST manifests/:manifestId/sales-closure/:stationId - close sales at station.
777
+ * @param {Object} opts
778
+ * @param {string} [opts.token] - API key
779
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
780
+ * @param {Object} [opts.headers] - Optional headers
781
+ * @param {string} opts.manifestId - Manifest id
782
+ * @param {string} opts.stationId - Station id
783
+ * @param {Object} opts.data - Request body
784
+ * @returns {Promise<import("axios").AxiosResponse>}
785
+ */
786
+ function stationSalesClosure({token, jwtToken, headers, manifestId, stationId, data, query}) {
787
+ return client({
788
+ url: `/manifests/${manifestId}/sales-closure/${stationId}`,
789
+ method: "post",
790
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
791
+ data,
792
+ params: query
793
+ });
794
+ }
795
+
733
796
  return {
734
797
  get,
735
798
  getAll,
@@ -754,7 +817,10 @@ function manifestFactory({
754
817
  reports,
755
818
  labels,
756
819
  driverRelays,
757
- tripClose
820
+ tripClose,
821
+ stationBoarding,
822
+ stationDispatch,
823
+ stationSalesClosure
758
824
  };
759
825
  }
760
826
 
@@ -118,6 +118,23 @@ describe("notifications/notify-manifest", () => {
118
118
  headers: {}
119
119
  });
120
120
  });
121
+
122
+ it("should post a resend for a parent manifest notification", () => {
123
+ const parentId = "5f2a1b3c4d5e6f7a8b9c0d1e";
124
+ axiosMock.onPost(`/notify-manifest/${parentId}/resend`).reply(({headers}) => {
125
+ if (headers["x-api-key"] === token && headers.authorization === `Bearer ${jwtToken}`) {
126
+ return [200, {manifestNotifications: []}];
127
+ }
128
+ return [403];
129
+ });
130
+
131
+ return api.notifications.notify.manifest.resend({
132
+ token,
133
+ jwtToken,
134
+ parentId,
135
+ headers: {}
136
+ });
137
+ });
121
138
  });
122
139
 
123
140
  describe("notifications/notify/email", () => {
@@ -406,3 +406,83 @@ describe("operations/manifests/:manifestKey/manifests-exceptions", () => {
406
406
  return api.operations.manifest.manifestsExceptions.update({token, jwtToken, manifestKey, manifestException});
407
407
  });
408
408
  });
409
+
410
+ describe("operations/manifests/:manifestId/station operations", () => {
411
+ const token = "I owe you a token";
412
+ const jwtToken = "I owe you a JWT token";
413
+
414
+ afterEach(() => {
415
+ axiosMock.reset();
416
+ });
417
+
418
+ it("should board passengers at station", async () => {
419
+ const manifestId = "manifestId";
420
+ const stationId = "stationId";
421
+ const data = {
422
+ user: {
423
+ firstName: "Test",
424
+ lastName: "Testing",
425
+ email: "test@betterez.com"
426
+ }
427
+ };
428
+ const query = {bypassValidations: false};
429
+
430
+ axiosMock.onPost(`/manifests/${manifestId}/boarding/${stationId}`).reply(expectRequest({
431
+ statusCode: 200, token, jwtToken
432
+ }));
433
+ const call = await api.operations.manifest.stationBoarding({
434
+ token, jwtToken, manifestId, stationId, data, query
435
+ });
436
+ assert.deepStrictEqual(JSON.parse(call.config.data), data);
437
+ assert.deepStrictEqual(call.config.params, query);
438
+ return call;
439
+ });
440
+
441
+ it("should dispatch manifest at station", async () => {
442
+ const manifestId = "manifestId";
443
+ const stationId = "stationId";
444
+ const data = {
445
+ user: {
446
+ firstName: "Test",
447
+ lastName: "Testing",
448
+ email: "Test@betterez.com",
449
+ shiftId: "649f20a95679910784326e81",
450
+ shiftNumber: "S-WTN6LDX"
451
+ }
452
+ };
453
+ const query = {bypassValidations: false};
454
+
455
+ axiosMock.onPost(`/manifests/${manifestId}/dispatch/${stationId}`).reply(expectRequest({
456
+ statusCode: 200, token, jwtToken
457
+ }));
458
+ const call = await api.operations.manifest.stationDispatch({
459
+ token, jwtToken, manifestId, stationId, data, query
460
+ });
461
+ assert.deepStrictEqual(JSON.parse(call.config.data), data);
462
+ assert.deepStrictEqual(call.config.params, query);
463
+ return call;
464
+ });
465
+
466
+ it("should close sales at station", async () => {
467
+ const manifestId = "manifestId";
468
+ const stationId = "stationId";
469
+ const data = {
470
+ user: {
471
+ firstName: "Test",
472
+ lastName: "Testing",
473
+ email: "Test@betterez.com"
474
+ }
475
+ };
476
+ const query = {bypassValidations: false};
477
+
478
+ axiosMock.onPost(`/manifests/${manifestId}/sales-closure/${stationId}`).reply(expectRequest({
479
+ statusCode: 200, token, jwtToken
480
+ }));
481
+ const call = await api.operations.manifest.stationSalesClosure({
482
+ token, jwtToken, manifestId, stationId, data, query
483
+ });
484
+ assert.deepStrictEqual(JSON.parse(call.config.data), data);
485
+ assert.deepStrictEqual(call.config.params, query);
486
+ return call;
487
+ });
488
+ });
@@ -35,6 +35,7 @@ declare function notifyTicketFactory({ client, internalAuthTokenProvider }: {
35
35
  };
36
36
  manifest: {
37
37
  create: Function;
38
+ resend: Function;
38
39
  };
39
40
  };
40
41
  declare namespace notifyTicketFactory {