btrz-api-client 5.141.0 → 5.143.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/sales/cart.js +18 -3
- package/package.json +1 -1
- package/src/endpoints/sales/cart.js +24 -14
- package/test/endpoints/sales/cart.test.js +39 -33
- package/types/client.d.ts +8 -0
- package/types/constants.d.ts +1 -1
- package/types/endpoints/sales/cart.d.ts +8 -0
- package/types/initializedClient.d.ts +8 -0
- package/types/productionDefaults.d.ts +2 -2
|
@@ -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 cartFactory(_ref) {
|
|
7
7
|
var client = _ref.client,
|
|
8
8
|
internalAuthTokenProvider = _ref.internalAuthTokenProvider;
|
|
9
9
|
|
|
10
|
-
|
|
11
10
|
function get(_ref2) {
|
|
12
11
|
var token = _ref2.token,
|
|
13
12
|
id = _ref2.id,
|
|
@@ -115,6 +114,21 @@ function cartFactory(_ref) {
|
|
|
115
114
|
}
|
|
116
115
|
};
|
|
117
116
|
|
|
117
|
+
var payments = {
|
|
118
|
+
delete: function _delete(_ref9) {
|
|
119
|
+
var token = _ref9.token,
|
|
120
|
+
cartId = _ref9.cartId,
|
|
121
|
+
jwtToken = _ref9.jwtToken,
|
|
122
|
+
headers = _ref9.headers;
|
|
123
|
+
|
|
124
|
+
return client({
|
|
125
|
+
url: "/carts/" + cartId + "/payments",
|
|
126
|
+
method: "delete",
|
|
127
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
118
132
|
return {
|
|
119
133
|
get: get,
|
|
120
134
|
create: create,
|
|
@@ -122,7 +136,8 @@ function cartFactory(_ref) {
|
|
|
122
136
|
deleteItems: deleteItems,
|
|
123
137
|
loyaltyPointsAmount: loyaltyPointsAmount,
|
|
124
138
|
patch: patch,
|
|
125
|
-
partialDepositStatus: partialDepositStatus
|
|
139
|
+
partialDepositStatus: partialDepositStatus,
|
|
140
|
+
payments: payments
|
|
126
141
|
};
|
|
127
142
|
}
|
|
128
143
|
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const {authorizationHeaders} = require("./../endpoints_helpers.js");
|
|
2
2
|
|
|
3
|
-
function cartFactory({
|
|
4
|
-
|
|
5
|
-
function get({ token, id, providerId, headers }) {
|
|
3
|
+
function cartFactory({client, internalAuthTokenProvider}) {
|
|
4
|
+
function get({token, id, providerId, headers}) {
|
|
6
5
|
let url = `/cart/${id}`;
|
|
7
6
|
|
|
8
|
-
if(providerId) {
|
|
7
|
+
if (providerId) {
|
|
9
8
|
url = `${url}?providerId=${providerId}`;
|
|
10
9
|
}
|
|
11
10
|
|
|
@@ -15,8 +14,8 @@ function cartFactory({ client, internalAuthTokenProvider }) {
|
|
|
15
14
|
});
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
function create({
|
|
19
|
-
return client({
|
|
17
|
+
function create({token, cart, jwtToken, headers}) {
|
|
18
|
+
return client({
|
|
20
19
|
url: "/cart",
|
|
21
20
|
method: "post",
|
|
22
21
|
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
|
|
@@ -24,8 +23,8 @@ function cartFactory({ client, internalAuthTokenProvider }) {
|
|
|
24
23
|
});
|
|
25
24
|
}
|
|
26
25
|
|
|
27
|
-
function add({
|
|
28
|
-
return client({
|
|
26
|
+
function add({token, cartId, cart, jwtToken, headers}) {
|
|
27
|
+
return client({
|
|
29
28
|
url: `/cart/${cartId}/items`,
|
|
30
29
|
method: "post",
|
|
31
30
|
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
|
|
@@ -33,8 +32,8 @@ function cartFactory({ client, internalAuthTokenProvider }) {
|
|
|
33
32
|
});
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
function deleteItems({
|
|
37
|
-
return client({
|
|
35
|
+
function deleteItems({token, cartId, params, jwtToken, headers}) {
|
|
36
|
+
return client({
|
|
38
37
|
url: `/cart/${cartId}/items`,
|
|
39
38
|
method: "delete",
|
|
40
39
|
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
|
|
@@ -43,7 +42,7 @@ function cartFactory({ client, internalAuthTokenProvider }) {
|
|
|
43
42
|
}
|
|
44
43
|
|
|
45
44
|
const loyaltyPointsAmount = {
|
|
46
|
-
get({
|
|
45
|
+
get({token, jwtToken, cartId, query = {}, headers}) {
|
|
47
46
|
return client({
|
|
48
47
|
url: `/carts/${cartId}/loyalty-points-amount`,
|
|
49
48
|
params: query,
|
|
@@ -53,7 +52,7 @@ function cartFactory({ client, internalAuthTokenProvider }) {
|
|
|
53
52
|
};
|
|
54
53
|
|
|
55
54
|
|
|
56
|
-
function patch({
|
|
55
|
+
function patch({token, jwtToken, cartId, data, headers}) {
|
|
57
56
|
return client({
|
|
58
57
|
url: `/cart/${cartId}`,
|
|
59
58
|
method: "patch",
|
|
@@ -70,6 +69,16 @@ function cartFactory({ client, internalAuthTokenProvider }) {
|
|
|
70
69
|
}
|
|
71
70
|
};
|
|
72
71
|
|
|
72
|
+
const payments = {
|
|
73
|
+
delete({token, cartId, jwtToken, headers}) {
|
|
74
|
+
return client({
|
|
75
|
+
url: `/carts/${cartId}/payments`,
|
|
76
|
+
method: "delete",
|
|
77
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
73
82
|
return {
|
|
74
83
|
get,
|
|
75
84
|
create,
|
|
@@ -77,7 +86,8 @@ function cartFactory({ client, internalAuthTokenProvider }) {
|
|
|
77
86
|
deleteItems,
|
|
78
87
|
loyaltyPointsAmount,
|
|
79
88
|
patch,
|
|
80
|
-
partialDepositStatus
|
|
89
|
+
partialDepositStatus,
|
|
90
|
+
payments
|
|
81
91
|
};
|
|
82
92
|
}
|
|
83
93
|
|
|
@@ -1,66 +1,72 @@
|
|
|
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: ""});
|
|
3
3
|
const expect = require("chai").expect;
|
|
4
4
|
|
|
5
|
-
describe(
|
|
6
|
-
const token =
|
|
7
|
-
const jwtToken =
|
|
8
|
-
|
|
9
|
-
afterEach(
|
|
5
|
+
describe("sales/cart", () => {
|
|
6
|
+
const token = "I owe you a token";
|
|
7
|
+
const jwtToken = "I owe you a JWT token";
|
|
8
|
+
|
|
9
|
+
afterEach(() => {
|
|
10
10
|
axiosMock.reset();
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
it("should get a cart by id",
|
|
13
|
+
it("should get a cart by id", () => {
|
|
14
14
|
const cartId = "cartId1";
|
|
15
|
-
axiosMock.onGet(`/cart/${cartId}`).reply(expectRequest({
|
|
16
|
-
return api.sales.cart.get({
|
|
15
|
+
axiosMock.onGet(`/cart/${cartId}`).reply(expectRequest({statusCode: 200, token}));
|
|
16
|
+
return api.sales.cart.get({token, id: cartId});
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
it("should create a cart",
|
|
20
|
-
axiosMock.onPost(
|
|
21
|
-
return api.sales.cart.create({
|
|
19
|
+
it("should create a cart", () => {
|
|
20
|
+
axiosMock.onPost("/cart").reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
21
|
+
return api.sales.cart.create({jwtToken, token, cart: {operationId: 1234}});
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
it("should add to existing cart",
|
|
24
|
+
it("should add to existing cart", () => {
|
|
25
25
|
const cartId = "someCartId";
|
|
26
|
-
axiosMock.onPost(`/cart/${cartId}/items`).reply(expectRequest({
|
|
27
|
-
return api.sales.cart.add({
|
|
26
|
+
axiosMock.onPost(`/cart/${cartId}/items`).reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
27
|
+
return api.sales.cart.add({jwtToken, token, cartId, cart: {operationId: 1234}});
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
it("should delete item from existing cart",
|
|
30
|
+
it("should delete item from existing cart", () => {
|
|
31
31
|
const cartId = "someCartId";
|
|
32
|
-
axiosMock.onDelete(`/cart/${cartId}/items`).reply(
|
|
32
|
+
axiosMock.onDelete(`/cart/${cartId}/items`).reply((request) => {
|
|
33
33
|
expect(request.params).to.eql({operationId: 1234, providerId: 123});
|
|
34
|
-
expect(request.headers).to.eql({
|
|
35
|
-
Accept:
|
|
36
|
-
|
|
37
|
-
authorization:
|
|
34
|
+
expect(request.headers).to.eql({
|
|
35
|
+
"Accept": "application/json",
|
|
36
|
+
"x-api-key": "I owe you a token",
|
|
37
|
+
"authorization": "Bearer I owe you a JWT token"
|
|
38
38
|
});
|
|
39
39
|
expect(request.method).to.eql("delete");
|
|
40
40
|
expect(request.url).to.eql(`/cart/${cartId}/items`);
|
|
41
41
|
return [200];
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
return api.sales.cart.deleteItems({
|
|
44
|
+
return api.sales.cart.deleteItems({jwtToken, token, cartId, params: {operationId: 1234, providerId: 123}});
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
it("should get loyalty points amount of a cart",
|
|
47
|
+
it("should get loyalty points amount of a cart", () => {
|
|
48
48
|
const cartId = "cartId1";
|
|
49
|
-
axiosMock.onGet(`/carts/${cartId}/loyalty-points-amount`).reply(expectRequest({
|
|
50
|
-
return api.sales.cart.loyaltyPointsAmount.get({
|
|
49
|
+
axiosMock.onGet(`/carts/${cartId}/loyalty-points-amount`).reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
50
|
+
return api.sales.cart.loyaltyPointsAmount.get({token, jwtToken, cartId});
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
it("should update a cart",
|
|
54
|
-
const cartId = "someCartId"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
axiosMock.onPatch(`/cart/${cartId}`).reply(expectRequest({
|
|
58
|
-
return api.sales.cart.patch({
|
|
53
|
+
it("should update a cart", () => {
|
|
54
|
+
const cartId = "someCartId";
|
|
55
|
+
const providerId = "someProviderId";
|
|
56
|
+
const op = "overrideFees";
|
|
57
|
+
axiosMock.onPatch(`/cart/${cartId}`).reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
58
|
+
return api.sales.cart.patch({jwtToken, token, cartId, data: {providerId, operations: [{op}]}});
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
it("should get the shift partial deposit status",
|
|
61
|
+
it("should get the shift partial deposit status", () => {
|
|
62
62
|
const shiftId = "shiftId1";
|
|
63
63
|
axiosMock.onGet(`/cart/${shiftId}/partial-deposit-status`).reply(expectRequest({statusCode: 200, token}));
|
|
64
64
|
return api.sales.cart.partialDepositStatus.get({token, jwtToken, shiftId});
|
|
65
65
|
});
|
|
66
|
+
|
|
67
|
+
it("should delete payments from a cart", () => {
|
|
68
|
+
const cartId = "someCartId";
|
|
69
|
+
axiosMock.onDelete(`/carts/${cartId}/payments`).reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
70
|
+
return api.sales.cart.payments.delete({jwtToken, token, cartId});
|
|
71
|
+
});
|
|
66
72
|
});
|
package/types/client.d.ts
CHANGED
|
@@ -2371,6 +2371,14 @@ export function createApiClient(options: {
|
|
|
2371
2371
|
headers: any;
|
|
2372
2372
|
}): any;
|
|
2373
2373
|
};
|
|
2374
|
+
payments: {
|
|
2375
|
+
delete({ token, cartId, jwtToken, headers }: {
|
|
2376
|
+
token: any;
|
|
2377
|
+
cartId: any;
|
|
2378
|
+
jwtToken: any;
|
|
2379
|
+
headers: any;
|
|
2380
|
+
}): any;
|
|
2381
|
+
};
|
|
2374
2382
|
};
|
|
2375
2383
|
giftCertificates: {
|
|
2376
2384
|
get: ({ token, GCNumber, query, headers }: {
|
package/types/constants.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const INTERNAL_AUTH_TOKEN_SYMBOL: string;
|
|
@@ -53,4 +53,12 @@ declare function cartFactory({ client, internalAuthTokenProvider }: {
|
|
|
53
53
|
headers: any;
|
|
54
54
|
}): any;
|
|
55
55
|
};
|
|
56
|
+
payments: {
|
|
57
|
+
delete({ token, cartId, jwtToken, headers }: {
|
|
58
|
+
token: any;
|
|
59
|
+
cartId: any;
|
|
60
|
+
jwtToken: any;
|
|
61
|
+
headers: any;
|
|
62
|
+
}): any;
|
|
63
|
+
};
|
|
56
64
|
};
|
|
@@ -2325,6 +2325,14 @@ declare const _exports: {
|
|
|
2325
2325
|
headers: any;
|
|
2326
2326
|
}): any;
|
|
2327
2327
|
};
|
|
2328
|
+
payments: {
|
|
2329
|
+
delete({ token, cartId, jwtToken, headers }: {
|
|
2330
|
+
token: any;
|
|
2331
|
+
cartId: any;
|
|
2332
|
+
jwtToken: any;
|
|
2333
|
+
headers: any;
|
|
2334
|
+
}): any;
|
|
2335
|
+
};
|
|
2328
2336
|
};
|
|
2329
2337
|
giftCertificates: {
|
|
2330
2338
|
get: ({ token, GCNumber, query, headers }: {
|