btrz-api-client 5.232.0 → 5.233.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 +1 -1
- package/lib/endpoints/inventory/countries.js +17 -3
- package/package.json +1 -1
- package/src/endpoints/inventory/countries.js +15 -8
- package/test/endpoints/inventory/countries.test.js +24 -11
- package/types/client.d.ts +6 -0
- package/types/endpoints/inventory/countries.d.ts +6 -0
- package/types/initializedClient.d.ts +6 -0
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _require = require("./../endpoints_helpers"),
|
|
3
|
+
var _require = require("./../endpoints_helpers.js"),
|
|
4
4
|
authorizationHeaders = _require.authorizationHeaders;
|
|
5
5
|
|
|
6
6
|
function countriesFactory(_ref) {
|
|
7
7
|
var client = _ref.client,
|
|
8
8
|
internalAuthTokenProvider = _ref.internalAuthTokenProvider;
|
|
9
9
|
|
|
10
|
-
|
|
11
10
|
function all(_ref2) {
|
|
12
11
|
var token = _ref2.token,
|
|
13
12
|
_ref2$query = _ref2.query,
|
|
@@ -21,8 +20,23 @@ function countriesFactory(_ref) {
|
|
|
21
20
|
});
|
|
22
21
|
}
|
|
23
22
|
|
|
23
|
+
function get(_ref3) {
|
|
24
|
+
var token = _ref3.token,
|
|
25
|
+
id = _ref3.id,
|
|
26
|
+
_ref3$query = _ref3.query,
|
|
27
|
+
query = _ref3$query === undefined ? {} : _ref3$query,
|
|
28
|
+
headers = _ref3.headers;
|
|
29
|
+
|
|
30
|
+
return client({
|
|
31
|
+
url: "/countries/" + id,
|
|
32
|
+
params: query,
|
|
33
|
+
headers: authorizationHeaders({ token: token, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
24
37
|
return {
|
|
25
|
-
all: all
|
|
38
|
+
all: all,
|
|
39
|
+
get: get
|
|
26
40
|
};
|
|
27
41
|
}
|
|
28
42
|
|
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const {authorizationHeaders} = require("./../endpoints_helpers.js");
|
|
2
2
|
|
|
3
|
-
function countriesFactory({
|
|
4
|
-
|
|
5
|
-
function all({ token, query = {}, headers }) {
|
|
3
|
+
function countriesFactory({client, internalAuthTokenProvider}) {
|
|
4
|
+
function all({token, query = {}, headers}) {
|
|
6
5
|
return client({
|
|
7
6
|
url: "/countries",
|
|
8
7
|
params: query,
|
|
@@ -10,10 +9,18 @@ function countriesFactory({ client, internalAuthTokenProvider }) {
|
|
|
10
9
|
});
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
function get({token, id, query = {}, headers}) {
|
|
13
|
+
return client({
|
|
14
|
+
url: `/countries/${id}`,
|
|
15
|
+
params: query,
|
|
16
|
+
headers: authorizationHeaders({token, internalAuthTokenProvider, headers})
|
|
17
|
+
});
|
|
18
|
+
}
|
|
16
19
|
|
|
20
|
+
return {
|
|
21
|
+
all,
|
|
22
|
+
get
|
|
23
|
+
};
|
|
17
24
|
}
|
|
18
25
|
|
|
19
|
-
module.exports = countriesFactory;
|
|
26
|
+
module.exports = countriesFactory;
|
|
@@ -1,16 +1,29 @@
|
|
|
1
|
-
const {
|
|
2
|
-
const api = require("./../../../src/client").createApiClient({
|
|
1
|
+
const {axiosMock, expectRequest} = require("./../../test-helpers.js");
|
|
2
|
+
const api = require("./../../../src/client.js").createApiClient({baseURL: "http://test.com"});
|
|
3
3
|
|
|
4
|
-
describe(
|
|
5
|
-
const token =
|
|
6
|
-
|
|
7
|
-
afterEach(
|
|
4
|
+
describe("inventory/countries", () => {
|
|
5
|
+
const token = "I owe you a token";
|
|
6
|
+
|
|
7
|
+
afterEach(() => {
|
|
8
8
|
axiosMock.restore();
|
|
9
|
-
})
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("should list countries", () => {
|
|
12
|
+
axiosMock.onGet("/countries").reply(expectRequest({statusCode: 200, token}));
|
|
13
|
+
return api.inventory.countries.all({token});
|
|
14
|
+
});
|
|
10
15
|
|
|
11
|
-
it("should
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
it("should get a country by id", () => {
|
|
17
|
+
const countryId = "countryId";
|
|
18
|
+
axiosMock.onGet(`/countries/${countryId}`).reply(expectRequest({statusCode: 200, token}));
|
|
19
|
+
return api.inventory.countries.get({id: countryId, token});
|
|
14
20
|
});
|
|
15
21
|
|
|
16
|
-
|
|
22
|
+
it("should get a country by id and support query parameters", () => {
|
|
23
|
+
const countryId = "countryId";
|
|
24
|
+
const query = {param1: "value1"};
|
|
25
|
+
|
|
26
|
+
axiosMock.onGet(`/countries/${countryId}?param1=value1`).reply(expectRequest({statusCode: 200, token}));
|
|
27
|
+
return api.inventory.countries.get({id: countryId, query, token});
|
|
28
|
+
});
|
|
29
|
+
});
|
package/types/client.d.ts
CHANGED
|
@@ -265,6 +265,12 @@ export function createApiClient(options: {
|
|
|
265
265
|
query?: {};
|
|
266
266
|
headers: any;
|
|
267
267
|
}) => any;
|
|
268
|
+
get: ({ token, id, query, headers }: {
|
|
269
|
+
token: any;
|
|
270
|
+
id: any;
|
|
271
|
+
query?: {};
|
|
272
|
+
headers: any;
|
|
273
|
+
}) => any;
|
|
268
274
|
};
|
|
269
275
|
controlClasses: {
|
|
270
276
|
all: ({ token, jwtToken, query, headers }: {
|
|
@@ -219,6 +219,12 @@ declare const _exports: {
|
|
|
219
219
|
query?: {};
|
|
220
220
|
headers: any;
|
|
221
221
|
}) => any;
|
|
222
|
+
get: ({ token, id, query, headers }: {
|
|
223
|
+
token: any;
|
|
224
|
+
id: any;
|
|
225
|
+
query?: {};
|
|
226
|
+
headers: any;
|
|
227
|
+
}) => any;
|
|
222
228
|
};
|
|
223
229
|
controlClasses: {
|
|
224
230
|
all: ({ token, jwtToken, query, headers }: {
|