btrz-api-client 8.61.0 → 8.62.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/fetch-test.js +16 -0
- package/lib/client-standalone-min.js +3 -3
- package/lib/endpoints/inventory/promos.js +4 -2
- package/package.json +7 -6
- package/src/endpoints/inventory/promos.js +4 -4
- package/test/endpoints/inventory/promos.test.js +21 -0
- package/test/endpoints/invoices/invoices.test.js +4 -4
- package/test/endpoints/sales/cart.test.js +3 -5
|
@@ -67,13 +67,14 @@ function promosFactory(_ref) {
|
|
|
67
67
|
*/
|
|
68
68
|
function all(_ref2) {
|
|
69
69
|
var token = _ref2.token,
|
|
70
|
+
jwtToken = _ref2.jwtToken,
|
|
70
71
|
_ref2$query = _ref2.query,
|
|
71
72
|
query = _ref2$query === undefined ? {} : _ref2$query,
|
|
72
73
|
headers = _ref2.headers;
|
|
73
74
|
|
|
74
75
|
return client.get("/promos", {
|
|
75
76
|
params: query,
|
|
76
|
-
headers: authorizationHeaders({ token: token, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
|
|
77
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
|
|
77
78
|
});
|
|
78
79
|
}
|
|
79
80
|
|
|
@@ -89,13 +90,14 @@ function promosFactory(_ref) {
|
|
|
89
90
|
function get(_ref3) {
|
|
90
91
|
var promoId = _ref3.promoId,
|
|
91
92
|
token = _ref3.token,
|
|
93
|
+
jwtToken = _ref3.jwtToken,
|
|
92
94
|
_ref3$query = _ref3.query,
|
|
93
95
|
query = _ref3$query === undefined ? {} : _ref3$query,
|
|
94
96
|
headers = _ref3.headers;
|
|
95
97
|
|
|
96
98
|
return client.get("/promos/" + promoId, {
|
|
97
99
|
params: query,
|
|
98
|
-
headers: authorizationHeaders({ token: token, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
|
|
100
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
|
|
99
101
|
});
|
|
100
102
|
}
|
|
101
103
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "btrz-api-client",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.62.0",
|
|
4
4
|
"description": "Api client for Betterez endpoints",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://github.com/Betterez/btrz-api-client#readme",
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"axios-mock-adapter": "
|
|
29
|
+
"axios-mock-adapter": "2.1.0",
|
|
30
30
|
"babel-cli": "^6.26.0",
|
|
31
31
|
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
|
32
32
|
"babel-preset-es2015": "^6.24.1",
|
|
@@ -40,11 +40,12 @@
|
|
|
40
40
|
"eslint-plugin-mocha": "^5.3.0",
|
|
41
41
|
"form-data": "^3.0.0",
|
|
42
42
|
"mocha": "11.7.5",
|
|
43
|
-
"tinyify": "
|
|
44
|
-
"uuid": "
|
|
43
|
+
"tinyify": "4.0.0",
|
|
44
|
+
"uuid": "14.0.0"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"axios": "
|
|
48
|
-
"base-64": "^1.0.0"
|
|
47
|
+
"axios": "1.15.2",
|
|
48
|
+
"base-64": "^1.0.0",
|
|
49
|
+
"undici": "^8.1.0"
|
|
49
50
|
}
|
|
50
51
|
}
|
|
@@ -57,10 +57,10 @@ function promosFactory({client, internalAuthTokenProvider}) {
|
|
|
57
57
|
* Resolves with paginated promos; response.data has Promos shape.
|
|
58
58
|
* @throws When the request fails (400/401/404/500). Body: WRONG_DATA, PROMO_NOT_FOUND.
|
|
59
59
|
*/
|
|
60
|
-
function all({token, query = {}, headers}) {
|
|
60
|
+
function all({token, jwtToken, query = {}, headers}) {
|
|
61
61
|
return client.get("/promos", {
|
|
62
62
|
params: query,
|
|
63
|
-
headers: authorizationHeaders({token, internalAuthTokenProvider, headers})
|
|
63
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
|
|
@@ -73,10 +73,10 @@ function promosFactory({client, internalAuthTokenProvider}) {
|
|
|
73
73
|
* @param {Object} [opts.headers] - Optional headers
|
|
74
74
|
* @returns {Promise<import("axios").AxiosResponse>}
|
|
75
75
|
*/
|
|
76
|
-
function get({promoId, token, query = {}, headers}) {
|
|
76
|
+
function get({promoId, token, jwtToken, query = {}, headers}) {
|
|
77
77
|
return client.get(`/promos/${promoId}`, {
|
|
78
78
|
params: query,
|
|
79
|
-
headers: authorizationHeaders({token, internalAuthTokenProvider, headers})
|
|
79
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
|
|
@@ -32,12 +32,33 @@ describe('inventory/promos', function() {
|
|
|
32
32
|
return api.inventory.promos.all({ token });
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
+
it("should send jwt token when listing promos", function() {
|
|
36
|
+
axiosMock.onGet(`/promos`).reply(expectRequest({
|
|
37
|
+
statusCode: 200,
|
|
38
|
+
token,
|
|
39
|
+
jwtToken,
|
|
40
|
+
requireJwtTokenOnGet: true
|
|
41
|
+
}));
|
|
42
|
+
return api.inventory.promos.all({ token, jwtToken });
|
|
43
|
+
});
|
|
44
|
+
|
|
35
45
|
it("should get single promo", function() {
|
|
36
46
|
axiosMock.onGet(`/promos/${promoId}`).reply(expectRequest({ statusCode: 200, token }));
|
|
37
47
|
const query = {accountId};
|
|
38
48
|
return api.inventory.promos.get({ promoId, accountId, token, query });
|
|
39
49
|
});
|
|
40
50
|
|
|
51
|
+
it("should send jwt token when getting a promo by id", function() {
|
|
52
|
+
axiosMock.onGet(`/promos/${promoId}`).reply(expectRequest({
|
|
53
|
+
statusCode: 200,
|
|
54
|
+
token,
|
|
55
|
+
jwtToken,
|
|
56
|
+
requireJwtTokenOnGet: true
|
|
57
|
+
}));
|
|
58
|
+
const query = {accountId};
|
|
59
|
+
return api.inventory.promos.get({ promoId, accountId, token, jwtToken, query });
|
|
60
|
+
});
|
|
61
|
+
|
|
41
62
|
it("should create new promo", function() {
|
|
42
63
|
axiosMock.onPost(`/promos`).reply(expectRequest({ statusCode: 200, token, jwtToken }));
|
|
43
64
|
return api.inventory.promos.create({ jwtToken, promo, token });
|
|
@@ -1,5 +1,5 @@
|
|
|
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
4
|
describe("invoices/invoices", () => {
|
|
5
5
|
const token = "I owe you a token";
|
|
@@ -11,7 +11,7 @@ describe("invoices/invoices", () => {
|
|
|
11
11
|
|
|
12
12
|
it("should list invoices", () => {
|
|
13
13
|
const query = {transactionId: "12312312312312"};
|
|
14
|
-
axiosMock.onGet("/invoices", query).reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
14
|
+
axiosMock.onGet("/invoices", {params: query}).reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
15
15
|
return api.invoices.invoices.all({token, jwtToken, query});
|
|
16
16
|
});
|
|
17
17
|
|
|
@@ -28,7 +28,7 @@ describe("invoices/invoices", () => {
|
|
|
28
28
|
|
|
29
29
|
it("should list invoices failures", () => {
|
|
30
30
|
const query = {transactionId: "12312312312312"};
|
|
31
|
-
axiosMock.onGet("/failures", query).reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
31
|
+
axiosMock.onGet("/failures", {params: query}).reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
32
32
|
return api.invoices.invoices.getInvoicesFailures({token, jwtToken, query});
|
|
33
33
|
});
|
|
34
34
|
|
|
@@ -31,11 +31,9 @@ describe("sales/cart", () => {
|
|
|
31
31
|
const cartId = "someCartId";
|
|
32
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
|
-
|
|
36
|
-
|
|
37
|
-
"authorization": "Bearer I owe you a JWT token"
|
|
38
|
-
});
|
|
34
|
+
expect(request.headers.Accept).to.eql("application/json");
|
|
35
|
+
expect(request.headers["x-api-key"]).to.eql("I owe you a token");
|
|
36
|
+
expect(request.headers.authorization).to.eql("Bearer I owe you a JWT token");
|
|
39
37
|
expect(request.method).to.eql("delete");
|
|
40
38
|
expect(request.url).to.eql(`/cart/${cartId}/items`);
|
|
41
39
|
return [200];
|