btrz-api-client 9.27.0 → 9.28.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.
|
@@ -127,6 +127,7 @@ const {
|
|
|
127
127
|
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
128
128
|
* @returns {Object} manifest API methods
|
|
129
129
|
*/
|
|
130
|
+
// eslint-disable-next-line max-statements
|
|
130
131
|
function manifestFactory({
|
|
131
132
|
client,
|
|
132
133
|
internalAuthTokenProvider
|
|
@@ -595,6 +596,66 @@ function manifestFactory({
|
|
|
595
596
|
});
|
|
596
597
|
}
|
|
597
598
|
|
|
599
|
+
/**
|
|
600
|
+
* GET /manifests/:manifestKey/fare-capacity-limits - get the manifest's per-fare capacity limit overrides.
|
|
601
|
+
* @param {Object} opts
|
|
602
|
+
* @param {string} [opts.token] - API key
|
|
603
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
604
|
+
* @param {string} opts.manifestKey - Manifest id or {scheduleId}+{date}
|
|
605
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
606
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
607
|
+
*/
|
|
608
|
+
function getFareCapacityLimits({
|
|
609
|
+
token,
|
|
610
|
+
jwtToken,
|
|
611
|
+
manifestKey,
|
|
612
|
+
headers
|
|
613
|
+
}) {
|
|
614
|
+
return client({
|
|
615
|
+
url: `/manifests/${manifestKey}/fare-capacity-limits`,
|
|
616
|
+
method: "get",
|
|
617
|
+
headers: authorizationHeaders({
|
|
618
|
+
token,
|
|
619
|
+
jwtToken,
|
|
620
|
+
internalAuthTokenProvider,
|
|
621
|
+
headers
|
|
622
|
+
})
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* PUT /manifests/:manifestKey/fare-capacity-limits - replace the per-fare capacity limit overrides.
|
|
628
|
+
* @param {Object} opts
|
|
629
|
+
* @param {string} [opts.token] - API key
|
|
630
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
631
|
+
* @param {string} opts.manifestKey - Manifest id or {scheduleId}+{date}
|
|
632
|
+
* @param {Object} [opts.query] - Optional query, e.g. {routeId}
|
|
633
|
+
* @param {Object} opts.data - Request body, {passengerLimitOverrides: [...]}
|
|
634
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
635
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
636
|
+
*/
|
|
637
|
+
function updateFareCapacityLimits({
|
|
638
|
+
token,
|
|
639
|
+
jwtToken,
|
|
640
|
+
manifestKey,
|
|
641
|
+
query = {},
|
|
642
|
+
data,
|
|
643
|
+
headers
|
|
644
|
+
}) {
|
|
645
|
+
return client({
|
|
646
|
+
url: `/manifests/${manifestKey}/fare-capacity-limits`,
|
|
647
|
+
method: "put",
|
|
648
|
+
headers: authorizationHeaders({
|
|
649
|
+
token,
|
|
650
|
+
jwtToken,
|
|
651
|
+
internalAuthTokenProvider,
|
|
652
|
+
headers
|
|
653
|
+
}),
|
|
654
|
+
params: query,
|
|
655
|
+
data
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
|
|
598
659
|
/**
|
|
599
660
|
* DELETE /manifests/:manifestId/capacity-exceptions/:exceptionId - remove capacity exception.
|
|
600
661
|
* @param {Object} opts
|
|
@@ -1241,6 +1302,8 @@ function manifestFactory({
|
|
|
1241
1302
|
updateStatus,
|
|
1242
1303
|
addCapacityException,
|
|
1243
1304
|
removeCapacityException,
|
|
1305
|
+
getFareCapacityLimits,
|
|
1306
|
+
updateFareCapacityLimits,
|
|
1244
1307
|
dispatch,
|
|
1245
1308
|
updateDispatchReporting,
|
|
1246
1309
|
createDispatchReporting,
|
package/package.json
CHANGED
|
@@ -123,6 +123,7 @@ const {
|
|
|
123
123
|
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
124
124
|
* @returns {Object} manifest API methods
|
|
125
125
|
*/
|
|
126
|
+
// eslint-disable-next-line max-statements
|
|
126
127
|
function manifestFactory({
|
|
127
128
|
client, internalAuthTokenProvider
|
|
128
129
|
}) {
|
|
@@ -447,6 +448,52 @@ function manifestFactory({
|
|
|
447
448
|
}
|
|
448
449
|
|
|
449
450
|
|
|
451
|
+
/**
|
|
452
|
+
* GET /manifests/:manifestKey/fare-capacity-limits - get the manifest's per-fare capacity limit overrides.
|
|
453
|
+
* @param {Object} opts
|
|
454
|
+
* @param {string} [opts.token] - API key
|
|
455
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
456
|
+
* @param {string} opts.manifestKey - Manifest id or {scheduleId}+{date}
|
|
457
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
458
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
459
|
+
*/
|
|
460
|
+
function getFareCapacityLimits({
|
|
461
|
+
token, jwtToken, manifestKey, headers
|
|
462
|
+
}) {
|
|
463
|
+
return client({
|
|
464
|
+
url: `/manifests/${manifestKey}/fare-capacity-limits`,
|
|
465
|
+
method: "get",
|
|
466
|
+
headers: authorizationHeaders({
|
|
467
|
+
token, jwtToken, internalAuthTokenProvider, headers
|
|
468
|
+
})
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* PUT /manifests/:manifestKey/fare-capacity-limits - replace the per-fare capacity limit overrides.
|
|
474
|
+
* @param {Object} opts
|
|
475
|
+
* @param {string} [opts.token] - API key
|
|
476
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
477
|
+
* @param {string} opts.manifestKey - Manifest id or {scheduleId}+{date}
|
|
478
|
+
* @param {Object} [opts.query] - Optional query, e.g. {routeId}
|
|
479
|
+
* @param {Object} opts.data - Request body, {passengerLimitOverrides: [...]}
|
|
480
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
481
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
482
|
+
*/
|
|
483
|
+
function updateFareCapacityLimits({
|
|
484
|
+
token, jwtToken, manifestKey, query = {}, data, headers
|
|
485
|
+
}) {
|
|
486
|
+
return client({
|
|
487
|
+
url: `/manifests/${manifestKey}/fare-capacity-limits`,
|
|
488
|
+
method: "put",
|
|
489
|
+
headers: authorizationHeaders({
|
|
490
|
+
token, jwtToken, internalAuthTokenProvider, headers
|
|
491
|
+
}),
|
|
492
|
+
params: query,
|
|
493
|
+
data
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
|
|
450
497
|
/**
|
|
451
498
|
* DELETE /manifests/:manifestId/capacity-exceptions/:exceptionId - remove capacity exception.
|
|
452
499
|
* @param {Object} opts
|
|
@@ -885,6 +932,8 @@ function manifestFactory({
|
|
|
885
932
|
updateStatus,
|
|
886
933
|
addCapacityException,
|
|
887
934
|
removeCapacityException,
|
|
935
|
+
getFareCapacityLimits,
|
|
936
|
+
updateFareCapacityLimits,
|
|
888
937
|
dispatch,
|
|
889
938
|
updateDispatchReporting,
|
|
890
939
|
createDispatchReporting,
|
|
@@ -222,6 +222,40 @@ describe("operations/manifest", () => {
|
|
|
222
222
|
});
|
|
223
223
|
});
|
|
224
224
|
|
|
225
|
+
it("should read the fare capacity limits from the manifest", async () => {
|
|
226
|
+
const manifestKey = "theId";
|
|
227
|
+
|
|
228
|
+
axiosMock.onGet(`/manifests/${manifestKey}/fare-capacity-limits`).reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
229
|
+
return api.operations.manifest.getFareCapacityLimits({token, jwtToken, manifestKey});
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it("should replace the fare capacity limits on the manifest", async () => {
|
|
233
|
+
const manifestKey = "theId";
|
|
234
|
+
const data = {
|
|
235
|
+
passengerLimitOverrides: [
|
|
236
|
+
{fareId: "610aebf7476dc22c1f2d0fee", maxPassengers: 5},
|
|
237
|
+
{fareId: "60b94ceb1516d01a41ccbbc4", unlimited: true}
|
|
238
|
+
]
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
axiosMock.onPut(`/manifests/${manifestKey}/fare-capacity-limits`).reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
242
|
+
const call = await api.operations.manifest.updateFareCapacityLimits({token, jwtToken, manifestKey, data});
|
|
243
|
+
assert.deepStrictEqual(JSON.parse(call.config.data), data);
|
|
244
|
+
return call;
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it("should replace the fare capacity limits addressed by a composite key, passing routeId", async () => {
|
|
248
|
+
// routeId is required only when the composite key names a manifest that does not exist yet.
|
|
249
|
+
const manifestKey = "5cab127c-2c70-4fea-9031-4131e2751cdb+2024-07-25";
|
|
250
|
+
const data = {passengerLimitOverrides: []};
|
|
251
|
+
const query = {routeId: "61a8d5e4adb79606bba26a3f"};
|
|
252
|
+
|
|
253
|
+
axiosMock.onPut(`/manifests/${manifestKey}/fare-capacity-limits`).reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
254
|
+
const call = await api.operations.manifest.updateFareCapacityLimits({token, jwtToken, manifestKey, data, query});
|
|
255
|
+
assert.deepStrictEqual(call.config.params, query);
|
|
256
|
+
return call;
|
|
257
|
+
});
|
|
258
|
+
|
|
225
259
|
it("should add user to the manifest", async () => {
|
|
226
260
|
const manifestId = "theId";
|
|
227
261
|
const data = {
|