btrz-api-client 8.74.0 → 8.75.1
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/accounts/agency-types.js +151 -0
- package/lib/endpoints/inventory/control-classes.js +33 -0
- package/package.json +1 -1
- package/src/client.js +1 -0
- package/src/endpoints/accounts/agency-types.js +118 -0
- package/src/endpoints/inventory/control-classes.js +27 -0
- package/test/all.test.js +1 -0
- package/test/endpoints/accounts/agency-types.test.js +95 -0
- package/test/endpoints/inventory/control-classes.js +14 -0
- package/types/endpoints/accounts/agency-types.d.ts +34 -0
- package/types/endpoints/inventory/control-classes.d.ts +4 -0
package/lib/client.js
CHANGED
|
@@ -219,6 +219,7 @@ function createAccounts(_ref4) {
|
|
|
219
219
|
return {
|
|
220
220
|
accounts: require("./endpoints/accounts/accounts.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
221
221
|
agencies: require("./endpoints/accounts/agencies.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
222
|
+
agencyTypes: require("./endpoints/accounts/agency-types.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
222
223
|
application: require("./endpoints/accounts/application.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
223
224
|
applications: require("./endpoints/accounts/applications.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
224
225
|
applicationSettings: require("./endpoints/accounts/application-settings.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _require = require("../endpoints_helpers.js"),
|
|
4
|
+
authorizationHeaders = _require.authorizationHeaders;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Query params for GET /agency-types (btrz-api-accounts).
|
|
8
|
+
* @typedef {Object} AgencyTypesListQuery
|
|
9
|
+
* @property {number} [page] - The page number to retrieve (positive integer)
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Factory for agency-types API (btrz-api-accounts).
|
|
14
|
+
* @param {Object} deps
|
|
15
|
+
* @param {import("axios").AxiosInstance} deps.client
|
|
16
|
+
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
17
|
+
* @returns {{ all: function, get: function, create: function, update: function, remove: function }}
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
function agencyTypesFactory(_ref) {
|
|
22
|
+
var client = _ref.client,
|
|
23
|
+
internalAuthTokenProvider = _ref.internalAuthTokenProvider;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* GET /agency-types - list agency types for the account.
|
|
27
|
+
* @param {Object} opts
|
|
28
|
+
* @param {string} [opts.token] - API key
|
|
29
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
30
|
+
* @param {AgencyTypesListQuery} [opts.query] - Query params (page)
|
|
31
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
32
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
33
|
+
*/
|
|
34
|
+
function all(_ref2) {
|
|
35
|
+
var token = _ref2.token,
|
|
36
|
+
jwtToken = _ref2.jwtToken,
|
|
37
|
+
_ref2$query = _ref2.query,
|
|
38
|
+
query = _ref2$query === undefined ? {} : _ref2$query,
|
|
39
|
+
headers = _ref2.headers;
|
|
40
|
+
|
|
41
|
+
return client.get("/agency-types", {
|
|
42
|
+
params: query,
|
|
43
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* GET /agency-types/:agencyTypeId - get an agency type by id.
|
|
49
|
+
* @param {Object} opts
|
|
50
|
+
* @param {string} [opts.token] - API key
|
|
51
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
52
|
+
* @param {string} opts.agencyTypeId - Agency type id (ObjectId)
|
|
53
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
54
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
55
|
+
*/
|
|
56
|
+
function get(_ref3) {
|
|
57
|
+
var token = _ref3.token,
|
|
58
|
+
jwtToken = _ref3.jwtToken,
|
|
59
|
+
agencyTypeId = _ref3.agencyTypeId,
|
|
60
|
+
headers = _ref3.headers;
|
|
61
|
+
|
|
62
|
+
return client({
|
|
63
|
+
url: "/agency-types/" + agencyTypeId,
|
|
64
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* POST /agency-types - create an agency type.
|
|
70
|
+
* @param {Object} opts
|
|
71
|
+
* @param {string} [opts.token] - API key
|
|
72
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
73
|
+
* @param {Object} opts.agencyType - Agency type payload (name required)
|
|
74
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
75
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
76
|
+
*/
|
|
77
|
+
function create(_ref4) {
|
|
78
|
+
var token = _ref4.token,
|
|
79
|
+
jwtToken = _ref4.jwtToken,
|
|
80
|
+
agencyType = _ref4.agencyType,
|
|
81
|
+
headers = _ref4.headers;
|
|
82
|
+
|
|
83
|
+
return client({
|
|
84
|
+
url: "/agency-types",
|
|
85
|
+
method: "post",
|
|
86
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers }),
|
|
87
|
+
data: {
|
|
88
|
+
agencyType: agencyType
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* PUT /agency-types/:agencyTypeId - update an agency type.
|
|
95
|
+
* @param {Object} opts
|
|
96
|
+
* @param {string} [opts.token] - API key
|
|
97
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
98
|
+
* @param {string} opts.agencyTypeId - Agency type id (24-char hex ObjectId)
|
|
99
|
+
* @param {Object} opts.agencyType - Agency type payload (name required)
|
|
100
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
101
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
102
|
+
*/
|
|
103
|
+
function update(_ref5) {
|
|
104
|
+
var token = _ref5.token,
|
|
105
|
+
jwtToken = _ref5.jwtToken,
|
|
106
|
+
agencyTypeId = _ref5.agencyTypeId,
|
|
107
|
+
agencyType = _ref5.agencyType,
|
|
108
|
+
headers = _ref5.headers;
|
|
109
|
+
|
|
110
|
+
return client({
|
|
111
|
+
url: "/agency-types/" + agencyTypeId,
|
|
112
|
+
method: "put",
|
|
113
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers }),
|
|
114
|
+
data: {
|
|
115
|
+
agencyType: agencyType
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* DELETE /agency-types/:agencyTypeId - delete an agency type.
|
|
122
|
+
* @param {Object} opts
|
|
123
|
+
* @param {string} [opts.token] - API key
|
|
124
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
125
|
+
* @param {string} opts.agencyTypeId - Agency type id (24-char hex ObjectId)
|
|
126
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
127
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
128
|
+
*/
|
|
129
|
+
function remove(_ref6) {
|
|
130
|
+
var token = _ref6.token,
|
|
131
|
+
jwtToken = _ref6.jwtToken,
|
|
132
|
+
agencyTypeId = _ref6.agencyTypeId,
|
|
133
|
+
headers = _ref6.headers;
|
|
134
|
+
|
|
135
|
+
return client({
|
|
136
|
+
url: "/agency-types/" + agencyTypeId,
|
|
137
|
+
method: "delete",
|
|
138
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return {
|
|
143
|
+
all: all,
|
|
144
|
+
get: get,
|
|
145
|
+
create: create,
|
|
146
|
+
update: update,
|
|
147
|
+
remove: remove
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
module.exports = agencyTypesFactory;
|
|
@@ -202,12 +202,45 @@ function controlClassesFactory(_ref) {
|
|
|
202
202
|
}
|
|
203
203
|
};
|
|
204
204
|
|
|
205
|
+
/**
|
|
206
|
+
* POST /control-classes/:rootClassId/clones — Clone a full control class nesting from a root class.
|
|
207
|
+
* Body: { controlClassCloneOptions }. Emits controlclasses.created for each cloned class.
|
|
208
|
+
* @param {Object} opts
|
|
209
|
+
* @param {string} [opts.token] - API key
|
|
210
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth
|
|
211
|
+
* @param {string} opts.rootClassId - Root control class id (24 hex)
|
|
212
|
+
* @param {{ newRootName?: string, cloneWithPrefix?: string }} opts.controlClassCloneOptions - Clone options
|
|
213
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
214
|
+
* @returns {Promise<import("axios").AxiosResponse<{ controlClass: Object }>>}
|
|
215
|
+
* @throws 400 WRONG_DATA, INVALID_ROOTCLASS_ID, CONTROLCLASS_NOT_ROOT
|
|
216
|
+
* @throws 401 Unauthorized
|
|
217
|
+
* @throws 404 CONTROLCLASS_NOT_FOUND
|
|
218
|
+
* @throws 500 Internal server error
|
|
219
|
+
*/
|
|
220
|
+
function clone(_ref8) {
|
|
221
|
+
var jwtToken = _ref8.jwtToken,
|
|
222
|
+
token = _ref8.token,
|
|
223
|
+
rootClassId = _ref8.rootClassId,
|
|
224
|
+
controlClassCloneOptions = _ref8.controlClassCloneOptions,
|
|
225
|
+
headers = _ref8.headers;
|
|
226
|
+
|
|
227
|
+
return client({
|
|
228
|
+
url: "/control-classes/" + rootClassId + "/clones",
|
|
229
|
+
method: "post",
|
|
230
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers }),
|
|
231
|
+
data: {
|
|
232
|
+
controlClassCloneOptions: controlClassCloneOptions
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
205
237
|
return {
|
|
206
238
|
all: all,
|
|
207
239
|
get: get,
|
|
208
240
|
create: create,
|
|
209
241
|
update: update,
|
|
210
242
|
remove: remove,
|
|
243
|
+
clone: clone,
|
|
211
244
|
schedules: schedules
|
|
212
245
|
};
|
|
213
246
|
}
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -185,6 +185,7 @@ function createAccounts({baseURL, headers, timeout, overrideFn, internalAuthToke
|
|
|
185
185
|
return {
|
|
186
186
|
accounts: require("./endpoints/accounts/accounts.js")({client, internalAuthTokenProvider}),
|
|
187
187
|
agencies: require("./endpoints/accounts/agencies.js")({client, internalAuthTokenProvider}),
|
|
188
|
+
agencyTypes: require("./endpoints/accounts/agency-types.js")({client, internalAuthTokenProvider}),
|
|
188
189
|
application: require("./endpoints/accounts/application.js")({client, internalAuthTokenProvider}),
|
|
189
190
|
applications: require("./endpoints/accounts/applications.js")({client, internalAuthTokenProvider}),
|
|
190
191
|
applicationSettings: require("./endpoints/accounts/application-settings.js")({client, internalAuthTokenProvider}),
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
const {
|
|
2
|
+
authorizationHeaders
|
|
3
|
+
} = require("../endpoints_helpers.js");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Query params for GET /agency-types (btrz-api-accounts).
|
|
7
|
+
* @typedef {Object} AgencyTypesListQuery
|
|
8
|
+
* @property {number} [page] - The page number to retrieve (positive integer)
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Factory for agency-types API (btrz-api-accounts).
|
|
13
|
+
* @param {Object} deps
|
|
14
|
+
* @param {import("axios").AxiosInstance} deps.client
|
|
15
|
+
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
16
|
+
* @returns {{ all: function, get: function, create: function, update: function, remove: function }}
|
|
17
|
+
*/
|
|
18
|
+
function agencyTypesFactory({client, internalAuthTokenProvider}) {
|
|
19
|
+
/**
|
|
20
|
+
* GET /agency-types - list agency types for the account.
|
|
21
|
+
* @param {Object} opts
|
|
22
|
+
* @param {string} [opts.token] - API key
|
|
23
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
24
|
+
* @param {AgencyTypesListQuery} [opts.query] - Query params (page)
|
|
25
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
26
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
27
|
+
*/
|
|
28
|
+
function all({token, jwtToken, query = {}, headers}) {
|
|
29
|
+
return client.get("/agency-types", {
|
|
30
|
+
params: query,
|
|
31
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* GET /agency-types/:agencyTypeId - get an agency type by id.
|
|
37
|
+
* @param {Object} opts
|
|
38
|
+
* @param {string} [opts.token] - API key
|
|
39
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
40
|
+
* @param {string} opts.agencyTypeId - Agency type id (ObjectId)
|
|
41
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
42
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
43
|
+
*/
|
|
44
|
+
function get({token, jwtToken, agencyTypeId, headers}) {
|
|
45
|
+
return client({
|
|
46
|
+
url: `/agency-types/${agencyTypeId}`,
|
|
47
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* POST /agency-types - create an agency type.
|
|
53
|
+
* @param {Object} opts
|
|
54
|
+
* @param {string} [opts.token] - API key
|
|
55
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
56
|
+
* @param {Object} opts.agencyType - Agency type payload (name required)
|
|
57
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
58
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
59
|
+
*/
|
|
60
|
+
function create({token, jwtToken, agencyType, headers}) {
|
|
61
|
+
return client({
|
|
62
|
+
url: "/agency-types",
|
|
63
|
+
method: "post",
|
|
64
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
|
|
65
|
+
data: {
|
|
66
|
+
agencyType
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* PUT /agency-types/:agencyTypeId - update an agency type.
|
|
73
|
+
* @param {Object} opts
|
|
74
|
+
* @param {string} [opts.token] - API key
|
|
75
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
76
|
+
* @param {string} opts.agencyTypeId - Agency type id (24-char hex ObjectId)
|
|
77
|
+
* @param {Object} opts.agencyType - Agency type payload (name required)
|
|
78
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
79
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
80
|
+
*/
|
|
81
|
+
function update({token, jwtToken, agencyTypeId, agencyType, headers}) {
|
|
82
|
+
return client({
|
|
83
|
+
url: `/agency-types/${agencyTypeId}`,
|
|
84
|
+
method: "put",
|
|
85
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
|
|
86
|
+
data: {
|
|
87
|
+
agencyType
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* DELETE /agency-types/:agencyTypeId - delete an agency type.
|
|
94
|
+
* @param {Object} opts
|
|
95
|
+
* @param {string} [opts.token] - API key
|
|
96
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
97
|
+
* @param {string} opts.agencyTypeId - Agency type id (24-char hex ObjectId)
|
|
98
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
99
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
100
|
+
*/
|
|
101
|
+
function remove({token, jwtToken, agencyTypeId, headers}) {
|
|
102
|
+
return client({
|
|
103
|
+
url: `/agency-types/${agencyTypeId}`,
|
|
104
|
+
method: "delete",
|
|
105
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
all,
|
|
111
|
+
get,
|
|
112
|
+
create,
|
|
113
|
+
update,
|
|
114
|
+
remove
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
module.exports = agencyTypesFactory;
|
|
@@ -166,12 +166,39 @@ function controlClassesFactory({client, internalAuthTokenProvider}) {
|
|
|
166
166
|
}
|
|
167
167
|
};
|
|
168
168
|
|
|
169
|
+
/**
|
|
170
|
+
* POST /control-classes/:rootClassId/clones — Clone a full control class nesting from a root class.
|
|
171
|
+
* Body: { controlClassCloneOptions }. Emits controlclasses.created for each cloned class.
|
|
172
|
+
* @param {Object} opts
|
|
173
|
+
* @param {string} [opts.token] - API key
|
|
174
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth
|
|
175
|
+
* @param {string} opts.rootClassId - Root control class id (24 hex)
|
|
176
|
+
* @param {{ newRootName?: string, cloneWithPrefix?: string }} opts.controlClassCloneOptions - Clone options
|
|
177
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
178
|
+
* @returns {Promise<import("axios").AxiosResponse<{ controlClass: Object }>>}
|
|
179
|
+
* @throws 400 WRONG_DATA, INVALID_ROOTCLASS_ID, CONTROLCLASS_NOT_ROOT
|
|
180
|
+
* @throws 401 Unauthorized
|
|
181
|
+
* @throws 404 CONTROLCLASS_NOT_FOUND
|
|
182
|
+
* @throws 500 Internal server error
|
|
183
|
+
*/
|
|
184
|
+
function clone({jwtToken, token, rootClassId, controlClassCloneOptions, headers}) {
|
|
185
|
+
return client({
|
|
186
|
+
url: `/control-classes/${rootClassId}/clones`,
|
|
187
|
+
method: "post",
|
|
188
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
|
|
189
|
+
data: {
|
|
190
|
+
controlClassCloneOptions
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
|
|
169
195
|
return {
|
|
170
196
|
all,
|
|
171
197
|
get,
|
|
172
198
|
create,
|
|
173
199
|
update,
|
|
174
200
|
remove,
|
|
201
|
+
clone,
|
|
175
202
|
schedules
|
|
176
203
|
};
|
|
177
204
|
}
|
package/test/all.test.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require("./client.test.js");
|
|
4
4
|
require("./endpoints/accounts/accounts.js");
|
|
5
5
|
require("./endpoints/accounts/agencies.test.js");
|
|
6
|
+
require("./endpoints/accounts/agency-types.test.js");
|
|
6
7
|
require("./endpoints/accounts/application-settings.test.js");
|
|
7
8
|
require("./endpoints/accounts/applications.test.js");
|
|
8
9
|
require("./endpoints/accounts/current-shifts.test.js");
|
|
@@ -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
|
+
});
|
|
@@ -74,4 +74,18 @@ describe("inventory/control-classes", () => {
|
|
|
74
74
|
data: {scheduleIds: ["schedule1", "schedule2"]}
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
|
+
|
|
78
|
+
it("should clone a control class nesting", () => {
|
|
79
|
+
const rootClassId = "1234";
|
|
80
|
+
axiosMock.onPost(`/control-classes/${rootClassId}/clones`).reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
81
|
+
return api.inventory.controlClasses.clone({
|
|
82
|
+
jwtToken,
|
|
83
|
+
token,
|
|
84
|
+
rootClassId,
|
|
85
|
+
controlClassCloneOptions: {
|
|
86
|
+
newRootName: "ClonedRoot",
|
|
87
|
+
cloneWithPrefix: "copy"
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
});
|
|
77
91
|
});
|
|
@@ -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
|
+
};
|