btrz-api-client 5.226.0 → 5.228.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.js CHANGED
@@ -66,6 +66,7 @@ function createInventory(_ref) {
66
66
  stationsZones: require("./endpoints/inventory/stations-zones.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
67
67
  parcelZones: require("./endpoints/inventory/parcel-zones.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
68
68
  countries: require("./endpoints/inventory/countries.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
69
+ controlClasses: require("./endpoints/inventory/control-classes.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
69
70
  fares: require("./endpoints/inventory/fares.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
70
71
  promos: require("./endpoints/inventory/promos.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
71
72
  labels: require("./endpoints/inventory/labels.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+
3
+ var _require = require("./../endpoints_helpers.js"),
4
+ authorizationHeaders = _require.authorizationHeaders;
5
+
6
+ function controlClassesFactory(_ref) {
7
+ var client = _ref.client,
8
+ internalAuthTokenProvider = _ref.internalAuthTokenProvider;
9
+
10
+ function all(_ref2) {
11
+ var token = _ref2.token,
12
+ jwtToken = _ref2.jwtToken,
13
+ _ref2$query = _ref2.query,
14
+ query = _ref2$query === undefined ? {} : _ref2$query,
15
+ headers = _ref2.headers;
16
+
17
+ return client.get("/control-classes", {
18
+ params: query,
19
+ headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
20
+ });
21
+ }
22
+
23
+ function get(_ref3) {
24
+ var controlClassId = _ref3.controlClassId,
25
+ token = _ref3.token,
26
+ headers = _ref3.headers,
27
+ jwtToken = _ref3.jwtToken;
28
+
29
+ return client.get("/control-classes/" + controlClassId, {
30
+ headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
31
+ });
32
+ }
33
+
34
+ function create(_ref4) {
35
+ var jwtToken = _ref4.jwtToken,
36
+ token = _ref4.token,
37
+ controlClass = _ref4.controlClass,
38
+ headers = _ref4.headers;
39
+
40
+ return client({
41
+ url: "/control-classes",
42
+ method: "post",
43
+ headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers }),
44
+ data: {
45
+ controlClass: controlClass
46
+ }
47
+ });
48
+ }
49
+
50
+ function remove(_ref5) {
51
+ var jwtToken = _ref5.jwtToken,
52
+ controlClassId = _ref5.controlClassId,
53
+ token = _ref5.token,
54
+ headers = _ref5.headers;
55
+
56
+ return client({
57
+ url: "/control-classes/" + controlClassId,
58
+ method: "delete",
59
+ headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
60
+ });
61
+ }
62
+
63
+ function update(_ref6) {
64
+ var jwtToken = _ref6.jwtToken,
65
+ token = _ref6.token,
66
+ controlClassId = _ref6.controlClassId,
67
+ controlClass = _ref6.controlClass,
68
+ headers = _ref6.headers;
69
+
70
+ return client({
71
+ url: "/control-classes/" + controlClassId,
72
+ method: "put",
73
+ headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers }),
74
+ data: {
75
+ controlClass: controlClass
76
+ }
77
+ });
78
+ }
79
+
80
+ return {
81
+ all: all,
82
+ get: get,
83
+ create: create,
84
+ update: update,
85
+ remove: remove
86
+ };
87
+ }
88
+
89
+ module.exports = controlClassesFactory;
@@ -7,7 +7,6 @@ function promosFactory(_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,
@@ -75,29 +74,44 @@ function promosFactory(_ref) {
75
74
  });
76
75
  }
77
76
 
78
- function addRule(_ref7) {
77
+ function patch(_ref7) {
79
78
  var jwtToken = _ref7.jwtToken,
80
79
  token = _ref7.token,
81
80
  promoId = _ref7.promoId,
82
- rule = _ref7.rule,
81
+ operations = _ref7.operations,
83
82
  headers = _ref7.headers;
84
83
 
85
84
  return client({
86
- url: "/promos/" + promoId + "/rules",
87
- method: "post",
85
+ url: "/promo/" + promoId,
86
+ method: "patch",
88
87
  headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers }),
89
- data: { rule: rule }
88
+ data: { operations: operations }
90
89
  });
91
90
  }
92
91
 
93
- function updateRule(_ref8) {
92
+ function addRule(_ref8) {
94
93
  var jwtToken = _ref8.jwtToken,
95
94
  token = _ref8.token,
96
95
  promoId = _ref8.promoId,
97
- ruleId = _ref8.ruleId,
98
96
  rule = _ref8.rule,
99
97
  headers = _ref8.headers;
100
98
 
99
+ return client({
100
+ url: "/promos/" + promoId + "/rules",
101
+ method: "post",
102
+ headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers }),
103
+ data: { rule: rule }
104
+ });
105
+ }
106
+
107
+ function updateRule(_ref9) {
108
+ var jwtToken = _ref9.jwtToken,
109
+ token = _ref9.token,
110
+ promoId = _ref9.promoId,
111
+ ruleId = _ref9.ruleId,
112
+ rule = _ref9.rule,
113
+ headers = _ref9.headers;
114
+
101
115
  return client({
102
116
  url: "/promos/" + promoId + "/rules/" + ruleId,
103
117
  method: "put",
@@ -111,6 +125,7 @@ function promosFactory(_ref) {
111
125
  get: get,
112
126
  create: create,
113
127
  update: update,
128
+ patch: patch,
114
129
  remove: remove,
115
130
  addRule: addRule,
116
131
  updateRule: updateRule
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "btrz-api-client",
3
- "version": "5.226.0",
3
+ "version": "5.228.0",
4
4
  "description": "Api client for Betterez endpoints",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/client.js CHANGED
@@ -53,6 +53,7 @@ function createInventory({baseURL, headers, timeout, overrideFn, internalAuthTok
53
53
  stationsZones: require("./endpoints/inventory/stations-zones.js")({client, internalAuthTokenProvider}),
54
54
  parcelZones: require("./endpoints/inventory/parcel-zones.js")({client, internalAuthTokenProvider}),
55
55
  countries: require("./endpoints/inventory/countries.js")({client, internalAuthTokenProvider}),
56
+ controlClasses: require("./endpoints/inventory/control-classes.js")({client, internalAuthTokenProvider}),
56
57
  fares: require("./endpoints/inventory/fares.js")({client, internalAuthTokenProvider}),
57
58
  promos: require("./endpoints/inventory/promos.js")({client, internalAuthTokenProvider}),
58
59
  labels: require("./endpoints/inventory/labels.js")({client, internalAuthTokenProvider}),
@@ -0,0 +1,63 @@
1
+ const {
2
+ authorizationHeaders
3
+ } = require("./../endpoints_helpers.js");
4
+
5
+ function controlClassesFactory({client, internalAuthTokenProvider}) {
6
+ function all({
7
+ token,
8
+ jwtToken,
9
+ query = {},
10
+ headers
11
+ }) {
12
+ return client.get("/control-classes", {
13
+ params: query,
14
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
15
+ });
16
+ }
17
+
18
+ function get({controlClassId, token, headers, jwtToken}) {
19
+ return client.get(`/control-classes/${controlClassId}`, {
20
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
21
+ });
22
+ }
23
+
24
+ function create({jwtToken, token, controlClass, headers}) {
25
+ return client({
26
+ url: "/control-classes",
27
+ method: "post",
28
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
29
+ data: {
30
+ controlClass
31
+ }
32
+ });
33
+ }
34
+
35
+ function remove({jwtToken, controlClassId, token, headers}) {
36
+ return client({
37
+ url: `/control-classes/${controlClassId}`,
38
+ method: "delete",
39
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
40
+ });
41
+ }
42
+
43
+ function update({jwtToken, token, controlClassId, controlClass, headers}) {
44
+ return client({
45
+ url: `/control-classes/${controlClassId}`,
46
+ method: "put",
47
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
48
+ data: {
49
+ controlClass
50
+ }
51
+ });
52
+ }
53
+
54
+ return {
55
+ all,
56
+ get,
57
+ create,
58
+ update,
59
+ remove
60
+ };
61
+ }
62
+
63
+ module.exports = controlClassesFactory;
@@ -1,31 +1,30 @@
1
- const { authorizationHeaders } = require("./../endpoints_helpers");
1
+ const {authorizationHeaders} = require("./../endpoints_helpers");
2
2
 
3
3
  function promosFactory({client, internalAuthTokenProvider}) {
4
-
5
- function all({ token, query = {}, headers }) {
4
+ function all({token, query = {}, headers}) {
6
5
  return client.get("/promos", {
7
6
  params: query,
8
7
  headers: authorizationHeaders({token, internalAuthTokenProvider, headers})
9
8
  });
10
9
  }
11
10
 
12
- function get({ promoId, token, query = {}, headers }) {
11
+ function get({promoId, token, query = {}, headers}) {
13
12
  return client.get(`/promos/${promoId}`, {
14
13
  params: query,
15
14
  headers: authorizationHeaders({token, internalAuthTokenProvider, headers})
16
15
  });
17
16
  }
18
17
 
19
- function create({ jwtToken, promo, token, headers }) {
18
+ function create({jwtToken, promo, token, headers}) {
20
19
  return client({
21
20
  url: "/promos",
22
21
  method: "post",
23
22
  headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
24
- data: { promo }
23
+ data: {promo}
25
24
  });
26
25
  }
27
26
 
28
- function remove({ jwtToken, promoId, token, headers }) {
27
+ function remove({jwtToken, promoId, token, headers}) {
29
28
  return client({
30
29
  url: `/promos/${promoId}`,
31
30
  method: "delete",
@@ -33,30 +32,39 @@ function promosFactory({client, internalAuthTokenProvider}) {
33
32
  });
34
33
  }
35
34
 
36
- function update({ jwtToken, token, promoId, update, headers }) {
35
+ function update({jwtToken, token, promoId, update, headers}) {
37
36
  return client({
38
37
  url: `/promos/${promoId}`,
39
38
  method: "patch",
40
39
  headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
41
- data: { update }
40
+ data: {update}
41
+ });
42
+ }
43
+
44
+ function patch({jwtToken, token, promoId, operations, headers}) {
45
+ return client({
46
+ url: `/promo/${promoId}`,
47
+ method: "patch",
48
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
49
+ data: {operations}
42
50
  });
43
51
  }
44
52
 
45
- function addRule({ jwtToken, token, promoId, rule, headers }) {
53
+ function addRule({jwtToken, token, promoId, rule, headers}) {
46
54
  return client({
47
55
  url: `/promos/${promoId}/rules`,
48
56
  method: "post",
49
57
  headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
50
- data: { rule }
58
+ data: {rule}
51
59
  });
52
60
  }
53
61
 
54
- function updateRule({ jwtToken, token, promoId, ruleId, rule, headers }) {
62
+ function updateRule({jwtToken, token, promoId, ruleId, rule, headers}) {
55
63
  return client({
56
64
  url: `/promos/${promoId}/rules/${ruleId}`,
57
65
  method: "put",
58
66
  headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
59
- data: { rule }
67
+ data: {rule}
60
68
  });
61
69
  }
62
70
 
@@ -65,11 +73,11 @@ function promosFactory({client, internalAuthTokenProvider}) {
65
73
  get,
66
74
  create,
67
75
  update,
76
+ patch,
68
77
  remove,
69
78
  addRule,
70
79
  updateRule
71
80
  };
72
-
73
81
  }
74
82
 
75
83
  module.exports = promosFactory;
@@ -0,0 +1,66 @@
1
+ const {
2
+ axiosMock, expectRequest
3
+ } = require("./../../test-helpers.js");
4
+ const api = require("./../../../src/client.js").createApiClient({baseURL: "http://test.com"});
5
+
6
+ describe("inventory/control-classes", () => {
7
+ const token = "I owe you a token";
8
+ const jwtToken = "I owe you a JWT token";
9
+
10
+ afterEach(() => {
11
+ axiosMock.reset();
12
+ });
13
+
14
+ it("should create a control class", () => {
15
+ axiosMock.onPost("/control-classes").reply(expectRequest({statusCode: 200, token, jwtToken}));
16
+ return api.inventory.controlClasses.create({
17
+ jwtToken,
18
+ token,
19
+ controlClass: {
20
+ name: "My controlClass"
21
+ }
22
+ });
23
+ });
24
+
25
+ it("should get all pieces of controlClass", () => {
26
+ axiosMock.onGet("/control-classes").reply(expectRequest({statusCode: 200, token, jwtToken}));
27
+ return api.inventory.controlClasses.all({
28
+ jwtToken,
29
+ token,
30
+ query: {}
31
+ });
32
+ });
33
+
34
+ it("should update a controlClass", () => {
35
+ const controlClassId = "1234";
36
+ axiosMock.onPut(`/control-classes/${controlClassId}`).reply(expectRequest({statusCode: 200, token, jwtToken}));
37
+ return api.inventory.controlClasses.update({
38
+ jwtToken,
39
+ token,
40
+ controlClassId,
41
+ controlClass: {
42
+ name: "My Updated controlClass"
43
+ }
44
+ });
45
+ });
46
+
47
+ it("should get a controlClass", () => {
48
+ const controlClassId = "1234";
49
+ axiosMock.onGet(`/control-classes/${controlClassId}`).reply(expectRequest({statusCode: 200, token, jwtToken}));
50
+ return api.inventory.controlClasses.get({
51
+ jwtToken,
52
+ token,
53
+ controlClassId
54
+ });
55
+ });
56
+
57
+ it("should delete a controlClass", () => {
58
+ const controlClassId = "1234";
59
+ axiosMock.onDelete(`/control-classes/${controlClassId}`).reply(expectRequest({statusCode: 200, token, jwtToken}));
60
+ return api.inventory.controlClasses.remove({
61
+ jwtToken,
62
+ token,
63
+ controlClassId
64
+ });
65
+ });
66
+ });
package/types/client.d.ts CHANGED
@@ -266,6 +266,39 @@ export function createApiClient(options: {
266
266
  headers: any;
267
267
  }) => any;
268
268
  };
269
+ controlClasses: {
270
+ all: ({ token, jwtToken, query, headers }: {
271
+ token: any;
272
+ jwtToken: any;
273
+ query?: {};
274
+ headers: any;
275
+ }) => any;
276
+ get: ({ controlClassId, token, headers, jwtToken }: {
277
+ controlClassId: any;
278
+ token: any;
279
+ headers: any;
280
+ jwtToken: any;
281
+ }) => any;
282
+ create: ({ jwtToken, token, controlClass, headers }: {
283
+ jwtToken: any;
284
+ token: any;
285
+ controlClass: any;
286
+ headers: any;
287
+ }) => any;
288
+ update: ({ jwtToken, token, controlClassId, controlClass, headers }: {
289
+ jwtToken: any;
290
+ token: any;
291
+ controlClassId: any;
292
+ controlClass: any;
293
+ headers: any;
294
+ }) => any;
295
+ remove: ({ jwtToken, controlClassId, token, headers }: {
296
+ jwtToken: any;
297
+ controlClassId: any;
298
+ token: any;
299
+ headers: any;
300
+ }) => any;
301
+ };
269
302
  fares: {
270
303
  all: ({ token, query, headers }: {
271
304
  token: any;
@@ -332,6 +365,13 @@ export function createApiClient(options: {
332
365
  update: any;
333
366
  headers: any;
334
367
  }) => any;
368
+ patch: ({ jwtToken, token, promoId, operations, headers }: {
369
+ jwtToken: any;
370
+ token: any;
371
+ promoId: any;
372
+ operations: any;
373
+ headers: any;
374
+ }) => any;
335
375
  remove: ({ jwtToken, promoId, token, headers }: {
336
376
  jwtToken: any;
337
377
  promoId: any;
@@ -0,0 +1,37 @@
1
+ export = controlClassesFactory;
2
+ declare function controlClassesFactory({ client, internalAuthTokenProvider }: {
3
+ client: any;
4
+ internalAuthTokenProvider: any;
5
+ }): {
6
+ all: ({ token, jwtToken, query, headers }: {
7
+ token: any;
8
+ jwtToken: any;
9
+ query?: {};
10
+ headers: any;
11
+ }) => any;
12
+ get: ({ controlClassId, token, headers, jwtToken }: {
13
+ controlClassId: any;
14
+ token: any;
15
+ headers: any;
16
+ jwtToken: any;
17
+ }) => any;
18
+ create: ({ jwtToken, token, controlClass, headers }: {
19
+ jwtToken: any;
20
+ token: any;
21
+ controlClass: any;
22
+ headers: any;
23
+ }) => any;
24
+ update: ({ jwtToken, token, controlClassId, controlClass, headers }: {
25
+ jwtToken: any;
26
+ token: any;
27
+ controlClassId: any;
28
+ controlClass: any;
29
+ headers: any;
30
+ }) => any;
31
+ remove: ({ jwtToken, controlClassId, token, headers }: {
32
+ jwtToken: any;
33
+ controlClassId: any;
34
+ token: any;
35
+ headers: any;
36
+ }) => any;
37
+ };
@@ -27,6 +27,13 @@ declare function promosFactory({ client, internalAuthTokenProvider }: {
27
27
  update: any;
28
28
  headers: any;
29
29
  }) => any;
30
+ patch: ({ jwtToken, token, promoId, operations, headers }: {
31
+ jwtToken: any;
32
+ token: any;
33
+ promoId: any;
34
+ operations: any;
35
+ headers: any;
36
+ }) => any;
30
37
  remove: ({ jwtToken, promoId, token, headers }: {
31
38
  jwtToken: any;
32
39
  promoId: any;
@@ -220,6 +220,39 @@ declare const _exports: {
220
220
  headers: any;
221
221
  }) => any;
222
222
  };
223
+ controlClasses: {
224
+ all: ({ token, jwtToken, query, headers }: {
225
+ token: any;
226
+ jwtToken: any;
227
+ query?: {};
228
+ headers: any;
229
+ }) => any;
230
+ get: ({ controlClassId, token, headers, jwtToken }: {
231
+ controlClassId: any;
232
+ token: any;
233
+ headers: any;
234
+ jwtToken: any;
235
+ }) => any;
236
+ create: ({ jwtToken, token, controlClass, headers }: {
237
+ jwtToken: any;
238
+ token: any;
239
+ controlClass: any;
240
+ headers: any;
241
+ }) => any;
242
+ update: ({ jwtToken, token, controlClassId, controlClass, headers }: {
243
+ jwtToken: any;
244
+ token: any;
245
+ controlClassId: any;
246
+ controlClass: any;
247
+ headers: any;
248
+ }) => any;
249
+ remove: ({ jwtToken, controlClassId, token, headers }: {
250
+ jwtToken: any;
251
+ controlClassId: any;
252
+ token: any;
253
+ headers: any;
254
+ }) => any;
255
+ };
223
256
  fares: {
224
257
  all: ({ token, query, headers }: {
225
258
  token: any;
@@ -286,6 +319,13 @@ declare const _exports: {
286
319
  update: any;
287
320
  headers: any;
288
321
  }) => any;
322
+ patch: ({ jwtToken, token, promoId, operations, headers }: {
323
+ jwtToken: any;
324
+ token: any;
325
+ promoId: any;
326
+ operations: any;
327
+ headers: any;
328
+ }) => any;
289
329
  remove: ({ jwtToken, promoId, token, headers }: {
290
330
  jwtToken: any;
291
331
  promoId: any;