btrz-api-client 9.8.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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "btrz-api-client",
3
- "version": "9.8.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
  };
@@ -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", () => {
@@ -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 {