btrz-api-client 5.231.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.
@@ -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
 
@@ -69,14 +69,28 @@ function cartFactory(_ref) {
69
69
  });
70
70
  }
71
71
 
72
+ function deletePaidInItem(_ref6) {
73
+ var token = _ref6.token,
74
+ cartId = _ref6.cartId,
75
+ itemId = _ref6.itemId,
76
+ jwtToken = _ref6.jwtToken,
77
+ headers = _ref6.headers;
78
+
79
+ return client({
80
+ url: "/cart/" + cartId + "/paid-in-items/" + itemId,
81
+ method: "delete",
82
+ headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
83
+ });
84
+ }
85
+
72
86
  var loyaltyPointsAmount = {
73
- get: function get(_ref6) {
74
- var token = _ref6.token,
75
- jwtToken = _ref6.jwtToken,
76
- cartId = _ref6.cartId,
77
- _ref6$query = _ref6.query,
78
- query = _ref6$query === undefined ? {} : _ref6$query,
79
- headers = _ref6.headers;
87
+ get: function get(_ref7) {
88
+ var token = _ref7.token,
89
+ jwtToken = _ref7.jwtToken,
90
+ cartId = _ref7.cartId,
91
+ _ref7$query = _ref7.query,
92
+ query = _ref7$query === undefined ? {} : _ref7$query,
93
+ headers = _ref7.headers;
80
94
 
81
95
  return client({
82
96
  url: "/carts/" + cartId + "/loyalty-points-amount",
@@ -86,12 +100,12 @@ function cartFactory(_ref) {
86
100
  }
87
101
  };
88
102
 
89
- function patch(_ref7) {
90
- var token = _ref7.token,
91
- jwtToken = _ref7.jwtToken,
92
- cartId = _ref7.cartId,
93
- data = _ref7.data,
94
- headers = _ref7.headers;
103
+ function patch(_ref8) {
104
+ var token = _ref8.token,
105
+ jwtToken = _ref8.jwtToken,
106
+ cartId = _ref8.cartId,
107
+ data = _ref8.data,
108
+ headers = _ref8.headers;
95
109
 
96
110
  return client({
97
111
  url: "/cart/" + cartId,
@@ -102,11 +116,11 @@ function cartFactory(_ref) {
102
116
  }
103
117
 
104
118
  var partialDepositStatus = {
105
- get: function get(_ref8) {
106
- var token = _ref8.token,
107
- jwtToken = _ref8.jwtToken,
108
- shiftId = _ref8.shiftId,
109
- headers = _ref8.headers;
119
+ get: function get(_ref9) {
120
+ var token = _ref9.token,
121
+ jwtToken = _ref9.jwtToken,
122
+ shiftId = _ref9.shiftId,
123
+ headers = _ref9.headers;
110
124
 
111
125
  return client.get("/cart/" + shiftId + "/partial-deposit-status", {
112
126
  headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
@@ -115,11 +129,11 @@ function cartFactory(_ref) {
115
129
  };
116
130
 
117
131
  var payments = {
118
- delete: function _delete(_ref9) {
119
- var token = _ref9.token,
120
- cartId = _ref9.cartId,
121
- jwtToken = _ref9.jwtToken,
122
- headers = _ref9.headers;
132
+ delete: function _delete(_ref10) {
133
+ var token = _ref10.token,
134
+ cartId = _ref10.cartId,
135
+ jwtToken = _ref10.jwtToken,
136
+ headers = _ref10.headers;
123
137
 
124
138
  return client({
125
139
  url: "/carts/" + cartId + "/payments",
@@ -127,12 +141,12 @@ function cartFactory(_ref) {
127
141
  headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
128
142
  });
129
143
  },
130
- put: function put(_ref10) {
131
- var token = _ref10.token,
132
- cartId = _ref10.cartId,
133
- jwtToken = _ref10.jwtToken,
134
- headers = _ref10.headers,
135
- payment = _ref10.payment;
144
+ put: function put(_ref11) {
145
+ var token = _ref11.token,
146
+ cartId = _ref11.cartId,
147
+ jwtToken = _ref11.jwtToken,
148
+ headers = _ref11.headers,
149
+ payment = _ref11.payment;
136
150
 
137
151
  return client({
138
152
  url: "/carts/" + cartId + "/payments",
@@ -144,13 +158,13 @@ function cartFactory(_ref) {
144
158
  };
145
159
 
146
160
  var taxExemptPaymentMethod = {
147
- post: function post(_ref11) {
148
- var token = _ref11.token,
149
- cartId = _ref11.cartId,
150
- jwtToken = _ref11.jwtToken,
151
- headers = _ref11.headers,
152
- _ref11$data = _ref11.data,
153
- data = _ref11$data === undefined ? {} : _ref11$data;
161
+ post: function post(_ref12) {
162
+ var token = _ref12.token,
163
+ cartId = _ref12.cartId,
164
+ jwtToken = _ref12.jwtToken,
165
+ headers = _ref12.headers,
166
+ _ref12$data = _ref12.data,
167
+ data = _ref12$data === undefined ? {} : _ref12$data;
154
168
 
155
169
  return client({
156
170
  url: "/carts/" + cartId + "/tax-exempt-payment-method",
@@ -162,14 +176,14 @@ function cartFactory(_ref) {
162
176
  };
163
177
 
164
178
  var financingCosts = {
165
- create: function create(_ref12) {
166
- var token = _ref12.token,
167
- jwtToken = _ref12.jwtToken,
168
- headers = _ref12.headers,
169
- cartId = _ref12.cartId,
170
- financingCost = _ref12.financingCost,
171
- _ref12$query = _ref12.query,
172
- query = _ref12$query === undefined ? {} : _ref12$query;
179
+ create: function create(_ref13) {
180
+ var token = _ref13.token,
181
+ jwtToken = _ref13.jwtToken,
182
+ headers = _ref13.headers,
183
+ cartId = _ref13.cartId,
184
+ financingCost = _ref13.financingCost,
185
+ _ref13$query = _ref13.query,
186
+ query = _ref13$query === undefined ? {} : _ref13$query;
173
187
 
174
188
  return client({
175
189
  url: "/carts/" + cartId + "/financing-costs",
@@ -181,13 +195,13 @@ function cartFactory(_ref) {
181
195
  }
182
196
  });
183
197
  },
184
- delete: function _delete(_ref13) {
185
- var token = _ref13.token,
186
- jwtToken = _ref13.jwtToken,
187
- headers = _ref13.headers,
188
- cartId = _ref13.cartId,
189
- _ref13$query = _ref13.query,
190
- query = _ref13$query === undefined ? {} : _ref13$query;
198
+ delete: function _delete(_ref14) {
199
+ var token = _ref14.token,
200
+ jwtToken = _ref14.jwtToken,
201
+ headers = _ref14.headers,
202
+ cartId = _ref14.cartId,
203
+ _ref14$query = _ref14.query,
204
+ query = _ref14$query === undefined ? {} : _ref14$query;
191
205
 
192
206
  return client({
193
207
  url: "/carts/" + cartId + "/financing-costs",
@@ -203,6 +217,7 @@ function cartFactory(_ref) {
203
217
  create: create,
204
218
  add: add,
205
219
  deleteItems: deleteItems,
220
+ deletePaidInItem: deletePaidInItem,
206
221
  loyaltyPointsAmount: loyaltyPointsAmount,
207
222
  patch: patch,
208
223
  partialDepositStatus: partialDepositStatus,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "btrz-api-client",
3
- "version": "5.231.0",
3
+ "version": "5.233.0",
4
4
  "description": "Api client for Betterez endpoints",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,8 +1,7 @@
1
- const { authorizationHeaders } = require("./../endpoints_helpers");
1
+ const {authorizationHeaders} = require("./../endpoints_helpers.js");
2
2
 
3
- function countriesFactory({ client, internalAuthTokenProvider }) {
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
- return {
14
- all
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;
@@ -41,6 +41,14 @@ function cartFactory({client, internalAuthTokenProvider}) {
41
41
  });
42
42
  }
43
43
 
44
+ function deletePaidInItem({token, cartId, itemId, jwtToken, headers}) {
45
+ return client({
46
+ url: `/cart/${cartId}/paid-in-items/${itemId}`,
47
+ method: "delete",
48
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
49
+ });
50
+ }
51
+
44
52
  const loyaltyPointsAmount = {
45
53
  get({token, jwtToken, cartId, query = {}, headers}) {
46
54
  return client({
@@ -125,6 +133,7 @@ function cartFactory({client, internalAuthTokenProvider}) {
125
133
  create,
126
134
  add,
127
135
  deleteItems,
136
+ deletePaidInItem,
128
137
  loyaltyPointsAmount,
129
138
  patch,
130
139
  partialDepositStatus,
@@ -1,16 +1,29 @@
1
- const { axiosMock, expectRequest } = require("./../../test-helpers");
2
- const api = require("./../../../src/client").createApiClient({ baseURL: "http://test.com" });
1
+ const {axiosMock, expectRequest} = require("./../../test-helpers.js");
2
+ const api = require("./../../../src/client.js").createApiClient({baseURL: "http://test.com"});
3
3
 
4
- describe('inventory/countries', function() {
5
- const token = 'I owe you a token';
6
-
7
- afterEach(function() {
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 list countries", function() {
12
- axiosMock.onGet(`/countries`).reply(expectRequest({ statusCode: 200, token }));
13
- return api.inventory.countries.all({ token });
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
+ });
@@ -94,4 +94,11 @@ describe("sales/cart", () => {
94
94
  axiosMock.onPost(`/carts/${cartId}/financing-costs`).reply(expectRequest({statusCode: 204, token, jwtToken}));
95
95
  return api.sales.cart.financingCosts.create({jwtToken, token, cartId, financingCost});
96
96
  });
97
+
98
+ it("should delete a paid in item from a cart", () => {
99
+ const cartId = "someCartId";
100
+ const itemId = "itemId";
101
+ axiosMock.onDelete(`/cart/${cartId}/paid-in-items/${itemId}`).reply(expectRequest({statusCode: 200, token, jwtToken}));
102
+ return api.sales.cart.deletePaidInItem({jwtToken, token, cartId, itemId});
103
+ });
97
104
  });
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 }: {
@@ -2963,6 +2969,13 @@ export function createApiClient(options: {
2963
2969
  jwtToken: any;
2964
2970
  headers: any;
2965
2971
  }) => any;
2972
+ deletePaidInItem: ({ token, cartId, itemId, jwtToken, headers }: {
2973
+ token: any;
2974
+ cartId: any;
2975
+ itemId: any;
2976
+ jwtToken: any;
2977
+ headers: any;
2978
+ }) => any;
2966
2979
  loyaltyPointsAmount: {
2967
2980
  get({ token, jwtToken, cartId, query, headers }: {
2968
2981
  token: any;
@@ -8,4 +8,10 @@ declare function countriesFactory({ client, internalAuthTokenProvider }: {
8
8
  query?: {};
9
9
  headers: any;
10
10
  }) => any;
11
+ get: ({ token, id, query, headers }: {
12
+ token: any;
13
+ id: any;
14
+ query?: {};
15
+ headers: any;
16
+ }) => any;
11
17
  };
@@ -29,6 +29,13 @@ declare function cartFactory({ client, internalAuthTokenProvider }: {
29
29
  jwtToken: any;
30
30
  headers: any;
31
31
  }) => any;
32
+ deletePaidInItem: ({ token, cartId, itemId, jwtToken, headers }: {
33
+ token: any;
34
+ cartId: any;
35
+ itemId: any;
36
+ jwtToken: any;
37
+ headers: any;
38
+ }) => any;
32
39
  loyaltyPointsAmount: {
33
40
  get({ token, jwtToken, cartId, query, headers }: {
34
41
  token: any;
@@ -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 }: {
@@ -2917,6 +2923,13 @@ declare const _exports: {
2917
2923
  jwtToken: any;
2918
2924
  headers: any;
2919
2925
  }) => any;
2926
+ deletePaidInItem: ({ token, cartId, itemId, jwtToken, headers }: {
2927
+ token: any;
2928
+ cartId: any;
2929
+ itemId: any;
2930
+ jwtToken: any;
2931
+ headers: any;
2932
+ }) => any;
2920
2933
  loyaltyPointsAmount: {
2921
2934
  get({ token, jwtToken, cartId, query, headers }: {
2922
2935
  token: any;