btrz-api-client 8.73.0 → 8.75.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 +42 -17
- package/lib/endpoints/accounts/agency-types.js +151 -0
- package/lib/endpoints/bpes/configuration.js +92 -0
- package/lib/endpoints/inventory/marketplace-modifiers.js +2 -0
- package/lib/productionDefaults.js +3 -0
- package/package.json +1 -1
- package/src/client.js +18 -0
- package/src/endpoints/accounts/agency-types.js +118 -0
- package/src/endpoints/bpes/configuration.js +70 -0
- package/src/endpoints/inventory/marketplace-modifiers.js +2 -0
- package/src/productionDefaults.js +3 -0
- package/test/all.test.js +2 -0
- package/test/endpoints/accounts/agency-types.test.js +95 -0
- package/test/endpoints/bpes/configuration.test.js +38 -0
- package/types/client.d.ts +1 -0
- package/types/endpoints/accounts/agency-types.d.ts +34 -0
- package/types/endpoints/bpes/configuration.d.ts +18 -0
- package/types/initializedClient.d.ts +1 -0
- package/types/productionDefaults.d.ts +1 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
const {
|
|
2
|
+
axiosMock,
|
|
3
|
+
expectRequest
|
|
4
|
+
} = require("./../../test-helpers.js");
|
|
5
|
+
const api = require("./../../../src/client.js").createApiClient({
|
|
6
|
+
baseURL: "http://test.com"
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
describe("accounts/agency-types", () => {
|
|
10
|
+
const token = "I owe you a token";
|
|
11
|
+
const jwtToken = "I owe you a JWT token";
|
|
12
|
+
|
|
13
|
+
afterEach(() => {
|
|
14
|
+
axiosMock.reset();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("should GET a list of agency types", () => {
|
|
18
|
+
axiosMock.onGet("/agency-types").reply(expectRequest({
|
|
19
|
+
statusCode: 200,
|
|
20
|
+
token,
|
|
21
|
+
jwtToken
|
|
22
|
+
}));
|
|
23
|
+
return api.accounts.agencyTypes.all({
|
|
24
|
+
token,
|
|
25
|
+
jwtToken,
|
|
26
|
+
query: {
|
|
27
|
+
page: 1
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("should GET an agency type by id", () => {
|
|
33
|
+
const agencyTypeId = "507f1f77bcf86cd799439011";
|
|
34
|
+
axiosMock.onGet(`/agency-types/${agencyTypeId}`).reply(expectRequest({
|
|
35
|
+
statusCode: 200,
|
|
36
|
+
token,
|
|
37
|
+
jwtToken
|
|
38
|
+
}));
|
|
39
|
+
return api.accounts.agencyTypes.get({
|
|
40
|
+
token,
|
|
41
|
+
jwtToken,
|
|
42
|
+
agencyTypeId
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("should POST an agency type", () => {
|
|
47
|
+
const agencyType = {
|
|
48
|
+
name: "Retail"
|
|
49
|
+
};
|
|
50
|
+
axiosMock.onPost("/agency-types").reply(expectRequest({
|
|
51
|
+
statusCode: 200,
|
|
52
|
+
token,
|
|
53
|
+
jwtToken,
|
|
54
|
+
body: {agencyType}
|
|
55
|
+
}));
|
|
56
|
+
return api.accounts.agencyTypes.create({
|
|
57
|
+
token,
|
|
58
|
+
jwtToken,
|
|
59
|
+
agencyType
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("should PUT an agency type", () => {
|
|
64
|
+
const agencyTypeId = "507f1f77bcf86cd799439011";
|
|
65
|
+
const agencyType = {
|
|
66
|
+
name: "Updated Retail"
|
|
67
|
+
};
|
|
68
|
+
axiosMock.onPut(`/agency-types/${agencyTypeId}`).reply(expectRequest({
|
|
69
|
+
statusCode: 200,
|
|
70
|
+
token,
|
|
71
|
+
jwtToken,
|
|
72
|
+
body: {agencyType}
|
|
73
|
+
}));
|
|
74
|
+
return api.accounts.agencyTypes.update({
|
|
75
|
+
token,
|
|
76
|
+
jwtToken,
|
|
77
|
+
agencyTypeId,
|
|
78
|
+
agencyType
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("should DELETE an agency type", () => {
|
|
83
|
+
const agencyTypeId = "507f1f77bcf86cd799439011";
|
|
84
|
+
axiosMock.onDelete(`/agency-types/${agencyTypeId}`).reply(expectRequest({
|
|
85
|
+
statusCode: 200,
|
|
86
|
+
token,
|
|
87
|
+
jwtToken
|
|
88
|
+
}));
|
|
89
|
+
return api.accounts.agencyTypes.remove({
|
|
90
|
+
token,
|
|
91
|
+
jwtToken,
|
|
92
|
+
agencyTypeId
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const {axiosMock, expectRequest} = require("../../test-helpers.js");
|
|
2
|
+
const api = require("../../../src/client.js").createApiClient({baseURL: "http://test.com"});
|
|
3
|
+
|
|
4
|
+
describe("bpes/configuration", () => {
|
|
5
|
+
const token = "I owe you a token";
|
|
6
|
+
const jwtToken = "I owe you a JWT token";
|
|
7
|
+
|
|
8
|
+
afterEach(() => {
|
|
9
|
+
axiosMock.restore();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("should get the BPE configuration", () => {
|
|
13
|
+
axiosMock.onGet("/bpe-configurations").reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
14
|
+
return api.bpes.configuration.get({token, jwtToken});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("should create the BPE configuration", () => {
|
|
18
|
+
axiosMock.onPost("/bpe-configurations").reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
19
|
+
return api.bpes.configuration.create({
|
|
20
|
+
token,
|
|
21
|
+
jwtToken,
|
|
22
|
+
bpeConfiguration: {
|
|
23
|
+
companyIdentificator: "00000000-0000-0000-0000-000000000000"
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("should update the BPE configuration", () => {
|
|
29
|
+
axiosMock.onPut("/bpe-configurations").reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
30
|
+
return api.bpes.configuration.update({
|
|
31
|
+
token,
|
|
32
|
+
jwtToken,
|
|
33
|
+
bpeConfiguration: {
|
|
34
|
+
companyIdentificator: "00000000-0000-0000-0000-000000000001"
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
});
|
package/types/client.d.ts
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export = agencyTypesFactory;
|
|
2
|
+
/**
|
|
3
|
+
* Query params for GET /agency-types (btrz-api-accounts).
|
|
4
|
+
* @typedef {Object} AgencyTypesListQuery
|
|
5
|
+
* @property {number} [page] - The page number to retrieve (positive integer)
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Factory for agency-types API (btrz-api-accounts).
|
|
9
|
+
* @param {Object} deps
|
|
10
|
+
* @param {import("axios").AxiosInstance} deps.client
|
|
11
|
+
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
12
|
+
* @returns {{ all: function, get: function, create: function, update: function, remove: function }}
|
|
13
|
+
*/
|
|
14
|
+
declare function agencyTypesFactory({ client, internalAuthTokenProvider }: {
|
|
15
|
+
client: import("axios").AxiosInstance;
|
|
16
|
+
internalAuthTokenProvider?: {
|
|
17
|
+
getToken: () => string;
|
|
18
|
+
};
|
|
19
|
+
}): {
|
|
20
|
+
all: Function;
|
|
21
|
+
get: Function;
|
|
22
|
+
create: Function;
|
|
23
|
+
update: Function;
|
|
24
|
+
remove: Function;
|
|
25
|
+
};
|
|
26
|
+
declare namespace agencyTypesFactory {
|
|
27
|
+
export { AgencyTypesListQuery };
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Query params for GET /agency-types (btrz-api-accounts).
|
|
31
|
+
*/
|
|
32
|
+
type AgencyTypesListQuery = {
|
|
33
|
+
page?: number;
|
|
34
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export = configurationFactory;
|
|
2
|
+
/**
|
|
3
|
+
* Factory for BPE configuration API (btrz-api-bpes).
|
|
4
|
+
* @param {Object} deps
|
|
5
|
+
* @param {import("axios").AxiosInstance} deps.client
|
|
6
|
+
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
7
|
+
* @returns {{ get: function, create: function, update: function }}
|
|
8
|
+
*/
|
|
9
|
+
declare function configurationFactory({ client }: {
|
|
10
|
+
client: import("axios").AxiosInstance;
|
|
11
|
+
internalAuthTokenProvider?: {
|
|
12
|
+
getToken: () => string;
|
|
13
|
+
};
|
|
14
|
+
}): {
|
|
15
|
+
get: Function;
|
|
16
|
+
create: Function;
|
|
17
|
+
update: Function;
|
|
18
|
+
};
|