btrz-api-client 5.224.1 → 5.226.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.
- package/lib/client-standalone-min.js +3 -3
- package/lib/client.js +1 -0
- package/lib/endpoints/endpoints_helpers.js +4 -0
- package/lib/endpoints/operations/transport_regulations.js +32 -0
- package/package.json +1 -1
- package/src/client.js +1 -0
- package/src/endpoints/endpoints_helpers.js +4 -0
- package/src/endpoints/operations/transport_regulations.js +23 -0
- package/test/endpoints/endpoints_helpers.test.js +10 -0
- package/test/endpoints/operations/transport_regulations.js +35 -0
- package/types/client.d.ts +10 -0
- package/types/endpoints/endpoints_helpers.d.ts +1 -0
- package/types/endpoints/operations/transport_regulations.d.ts +14 -0
- package/types/initializedClient.d.ts +10 -0
package/lib/client.js
CHANGED
|
@@ -303,6 +303,7 @@ function createOperations(_ref6) {
|
|
|
303
303
|
vehicleAssignments: require("./endpoints/operations/vehicle_assignments.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
304
304
|
vouchers: require("./endpoints/operations/vouchers.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
305
305
|
waitlists: require("./endpoints/operations/waitlists.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
306
|
+
transportRegulations: require("./endpoints/operations/transport_regulations.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
306
307
|
__test: {
|
|
307
308
|
client: client
|
|
308
309
|
}
|
|
@@ -16,6 +16,10 @@ function authorizationHeaders(_ref) {
|
|
|
16
16
|
_headers["x-api-key"] = "" + token;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
if (headers && headers.cookie && headers.cookie.includes("btrz-trusted")) {
|
|
20
|
+
_headers.cookie = headers.cookie;
|
|
21
|
+
}
|
|
22
|
+
|
|
19
23
|
if (jwtToken && jwtToken === constants.INTERNAL_AUTH_TOKEN_SYMBOL) {
|
|
20
24
|
if (!internalAuthTokenProvider || typeof internalAuthTokenProvider.getToken !== "function") {
|
|
21
25
|
throw new Error("Tried to make an internal API request, but no 'internalAuthTokenProvider' with a 'getToken' function " + "was supplied to the API client");
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// /transport-regulations/cnrt/manifests
|
|
4
|
+
var _require = require("../endpoints_helpers.js"),
|
|
5
|
+
authorizationHeaders = _require.authorizationHeaders;
|
|
6
|
+
|
|
7
|
+
function transportRegulationsFactory(_ref) {
|
|
8
|
+
var client = _ref.client,
|
|
9
|
+
internalAuthTokenProvider = _ref.internalAuthTokenProvider;
|
|
10
|
+
|
|
11
|
+
var cnrt = {
|
|
12
|
+
create: function create(_ref2) {
|
|
13
|
+
var data = _ref2.data,
|
|
14
|
+
token = _ref2.token,
|
|
15
|
+
jwtToken = _ref2.jwtToken,
|
|
16
|
+
headers = _ref2.headers;
|
|
17
|
+
|
|
18
|
+
return client({
|
|
19
|
+
url: "/transport-regulations/cnrt/manifests",
|
|
20
|
+
method: "post",
|
|
21
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers }),
|
|
22
|
+
data: data
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
cnrt: cnrt
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = transportRegulationsFactory;
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -255,6 +255,7 @@ function createOperations({baseURL, headers, timeout, overrideFn, internalAuthTo
|
|
|
255
255
|
vehicleAssignments: require("./endpoints/operations/vehicle_assignments.js")({client, internalAuthTokenProvider}),
|
|
256
256
|
vouchers: require("./endpoints/operations/vouchers.js")({client, internalAuthTokenProvider}),
|
|
257
257
|
waitlists: require("./endpoints/operations/waitlists.js")({client, internalAuthTokenProvider}),
|
|
258
|
+
transportRegulations: require("./endpoints/operations/transport_regulations.js")({client, internalAuthTokenProvider}),
|
|
258
259
|
__test: {
|
|
259
260
|
client
|
|
260
261
|
}
|
|
@@ -9,6 +9,10 @@ function authorizationHeaders({
|
|
|
9
9
|
_headers["x-api-key"] = `${token}`;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
if (headers && headers.cookie && headers.cookie.includes("btrz-trusted")) {
|
|
13
|
+
_headers.cookie = headers.cookie;
|
|
14
|
+
}
|
|
15
|
+
|
|
12
16
|
if (jwtToken && jwtToken === constants.INTERNAL_AUTH_TOKEN_SYMBOL) {
|
|
13
17
|
if (!internalAuthTokenProvider || typeof internalAuthTokenProvider.getToken !== "function") {
|
|
14
18
|
throw new Error("Tried to make an internal API request, but no 'internalAuthTokenProvider' with a 'getToken' function " +
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// /transport-regulations/cnrt/manifests
|
|
2
|
+
const {
|
|
3
|
+
authorizationHeaders
|
|
4
|
+
} = require("../endpoints_helpers.js");
|
|
5
|
+
|
|
6
|
+
function transportRegulationsFactory({client, internalAuthTokenProvider}) {
|
|
7
|
+
const cnrt = {
|
|
8
|
+
create({data, token, jwtToken, headers}) {
|
|
9
|
+
return client({
|
|
10
|
+
url: "/transport-regulations/cnrt/manifests",
|
|
11
|
+
method: "post",
|
|
12
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
|
|
13
|
+
data
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
cnrt
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = transportRegulationsFactory;
|
|
@@ -16,6 +16,16 @@ describe("endpoints helpers", () => {
|
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
+
it("should return a headers object which includes the btrz-trusted cookie", () => {
|
|
20
|
+
const jwtToken = "7A0mvzROJIucrSPYHlgd";
|
|
21
|
+
const headers = authorizationHeaders({jwtToken, headers: {cookie: "btrz-trusted=teststuff"}});
|
|
22
|
+
|
|
23
|
+
expect(headers).to.deep.equal({
|
|
24
|
+
authorization: `Bearer ${jwtToken}`,
|
|
25
|
+
cookie: "btrz-trusted=teststuff"
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
19
29
|
it("should return a headers object which includes an auth token created using the 'internalAuthTokenProvider', when the caller " +
|
|
20
30
|
"is trying to make an internal service-to-service API request", () => {
|
|
21
31
|
const jwtToken = constants.INTERNAL_AUTH_TOKEN_SYMBOL,
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const {
|
|
2
|
+
expect
|
|
3
|
+
} = require("chai");
|
|
4
|
+
const {
|
|
5
|
+
axiosMock,
|
|
6
|
+
expectRequest
|
|
7
|
+
} = require("../../test-helpers.js");
|
|
8
|
+
const api = require("../../../src/client.js").createApiClient({baseURL: "http://test.com"});
|
|
9
|
+
|
|
10
|
+
describe("operations/transport-regulations", () => {
|
|
11
|
+
const token = "I owe you a token";
|
|
12
|
+
const jwtToken = "I owe you a JWT token";
|
|
13
|
+
|
|
14
|
+
afterEach(() => {
|
|
15
|
+
axiosMock.reset();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("should POST a new CNRT transpor-regulation", () => {
|
|
19
|
+
const data = {
|
|
20
|
+
manifestId: "123"
|
|
21
|
+
};
|
|
22
|
+
axiosMock.onPost("/transport-regulations/cnrt/manifests").reply(expectRequest({
|
|
23
|
+
statusCode: 200,
|
|
24
|
+
token,
|
|
25
|
+
jwtToken
|
|
26
|
+
}));
|
|
27
|
+
return api.operations.transportRegulations.cnrt.create({
|
|
28
|
+
token,
|
|
29
|
+
jwtToken,
|
|
30
|
+
data
|
|
31
|
+
}).then((httpResponse) => {
|
|
32
|
+
expect(httpResponse.status).eql(200);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
package/types/client.d.ts
CHANGED
|
@@ -3824,6 +3824,16 @@ export function createApiClient(options: {
|
|
|
3824
3824
|
headers: any;
|
|
3825
3825
|
}) => any;
|
|
3826
3826
|
};
|
|
3827
|
+
transportRegulations: {
|
|
3828
|
+
cnrt: {
|
|
3829
|
+
create({ data, token, jwtToken, headers }: {
|
|
3830
|
+
data: any;
|
|
3831
|
+
token: any;
|
|
3832
|
+
jwtToken: any;
|
|
3833
|
+
headers: any;
|
|
3834
|
+
}): any;
|
|
3835
|
+
};
|
|
3836
|
+
};
|
|
3827
3837
|
__test: {
|
|
3828
3838
|
client: axios.AxiosInstance;
|
|
3829
3839
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export = transportRegulationsFactory;
|
|
2
|
+
declare function transportRegulationsFactory({ client, internalAuthTokenProvider }: {
|
|
3
|
+
client: any;
|
|
4
|
+
internalAuthTokenProvider: any;
|
|
5
|
+
}): {
|
|
6
|
+
cnrt: {
|
|
7
|
+
create({ data, token, jwtToken, headers }: {
|
|
8
|
+
data: any;
|
|
9
|
+
token: any;
|
|
10
|
+
jwtToken: any;
|
|
11
|
+
headers: any;
|
|
12
|
+
}): any;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -3778,6 +3778,16 @@ declare const _exports: {
|
|
|
3778
3778
|
headers: any;
|
|
3779
3779
|
}) => any;
|
|
3780
3780
|
};
|
|
3781
|
+
transportRegulations: {
|
|
3782
|
+
cnrt: {
|
|
3783
|
+
create({ data, token, jwtToken, headers }: {
|
|
3784
|
+
data: any;
|
|
3785
|
+
token: any;
|
|
3786
|
+
jwtToken: any;
|
|
3787
|
+
headers: any;
|
|
3788
|
+
}): any;
|
|
3789
|
+
};
|
|
3790
|
+
};
|
|
3781
3791
|
__test: {
|
|
3782
3792
|
client: import("axios").AxiosInstance;
|
|
3783
3793
|
};
|