btrz-api-client 5.132.0 → 5.134.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 -5
- package/lib/client.js +1 -0
- package/lib/endpoints/btrzpay/oxxo.js +45 -0
- package/lib/endpoints/inventory/operating-companies.js +31 -1
- package/package.json +1 -1
- package/src/client.js +1 -0
- package/src/endpoints/btrzpay/oxxo.js +31 -0
- package/src/endpoints/inventory/operating-companies.js +21 -2
- package/test/endpoints/btrzpay/oxxoPayments.tests.js +37 -0
- package/test/endpoints/btrzpay/oxxoToken.tests.js +32 -0
- package/test/endpoints/inventory/operating-companies.test.js +28 -0
- package/types/client.d.ts +33 -0
- package/types/endpoints/btrzpay/oxxo.d.ts +22 -0
- package/types/endpoints/inventory/operating-companies.d.ts +15 -0
- package/types/initializedClient.d.ts +33 -0
package/lib/client.js
CHANGED
|
@@ -427,6 +427,7 @@ function createBtrzPay(_ref13) {
|
|
|
427
427
|
customerCards: require("./endpoints/btrzpay/customerCards.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
428
428
|
squareTerminals: require("./endpoints/btrzpay/square.js").squareTerminalsFactory({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
429
429
|
squareWebhooks: require("./endpoints/btrzpay/square.js").squareWebhooksFactory({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
430
|
+
oxxo: require("./endpoints/btrzpay/oxxo.js")({ client: client, internalAuthTokenProvider: internalAuthTokenProvider }),
|
|
430
431
|
__test: {
|
|
431
432
|
client: client
|
|
432
433
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _require = require("./../endpoints_helpers"),
|
|
4
|
+
authorizationHeaders = _require.authorizationHeaders;
|
|
5
|
+
|
|
6
|
+
function oxxoFactory(_ref) {
|
|
7
|
+
var client = _ref.client,
|
|
8
|
+
internalAuthTokenProvider = _ref.internalAuthTokenProvider;
|
|
9
|
+
|
|
10
|
+
var token = {
|
|
11
|
+
get: function get(_ref2) {
|
|
12
|
+
var jwtToken = _ref2.jwtToken,
|
|
13
|
+
headers = _ref2.headers,
|
|
14
|
+
internalAuthTokenProvider = _ref2.internalAuthTokenProvider;
|
|
15
|
+
|
|
16
|
+
return client({
|
|
17
|
+
url: "/oxxo/token",
|
|
18
|
+
headers: authorizationHeaders({ jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
var payments = {
|
|
24
|
+
all: function all(_ref3) {
|
|
25
|
+
var jwtToken = _ref3.jwtToken,
|
|
26
|
+
headers = _ref3.headers,
|
|
27
|
+
oxxoToken = _ref3.oxxoToken,
|
|
28
|
+
query = _ref3.query,
|
|
29
|
+
internalAuthTokenProvider = _ref3.internalAuthTokenProvider;
|
|
30
|
+
|
|
31
|
+
return client({
|
|
32
|
+
url: "/oxxo/" + oxxoToken + "/payments",
|
|
33
|
+
params: query,
|
|
34
|
+
headers: authorizationHeaders({ jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
token: token,
|
|
41
|
+
payments: payments
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = oxxoFactory;
|
|
@@ -64,11 +64,41 @@ function operatingCompaniesFactory(_ref) {
|
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
var sequences = {
|
|
68
|
+
create: function create(_ref6) {
|
|
69
|
+
var jwtToken = _ref6.jwtToken,
|
|
70
|
+
token = _ref6.token,
|
|
71
|
+
operatingCompanyId = _ref6.operatingCompanyId,
|
|
72
|
+
sequence = _ref6.sequence,
|
|
73
|
+
headers = _ref6.headers;
|
|
74
|
+
|
|
75
|
+
return client({
|
|
76
|
+
url: "/operating-companies/" + operatingCompanyId + "/sequences",
|
|
77
|
+
method: "post",
|
|
78
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers }),
|
|
79
|
+
data: sequence
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
all: function all(_ref7) {
|
|
83
|
+
var jwtToken = _ref7.jwtToken,
|
|
84
|
+
token = _ref7.token,
|
|
85
|
+
operatingCompanyId = _ref7.operatingCompanyId,
|
|
86
|
+
headers = _ref7.headers;
|
|
87
|
+
|
|
88
|
+
return client({
|
|
89
|
+
url: "/operating-companies/" + operatingCompanyId + "/sequences",
|
|
90
|
+
method: "get",
|
|
91
|
+
headers: authorizationHeaders({ token: token, jwtToken: jwtToken, internalAuthTokenProvider: internalAuthTokenProvider, headers: headers })
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
67
96
|
return {
|
|
68
97
|
all: all,
|
|
69
98
|
create: create,
|
|
70
99
|
update: update,
|
|
71
|
-
get: get
|
|
100
|
+
get: get,
|
|
101
|
+
sequences: sequences
|
|
72
102
|
};
|
|
73
103
|
}
|
|
74
104
|
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -330,6 +330,7 @@ function createBtrzPay({baseURL, headers, timeout, overrideFn, internalAuthToken
|
|
|
330
330
|
customerCards: require("./endpoints/btrzpay/customerCards.js")({client, internalAuthTokenProvider}),
|
|
331
331
|
squareTerminals: require("./endpoints/btrzpay/square.js").squareTerminalsFactory({client, internalAuthTokenProvider}),
|
|
332
332
|
squareWebhooks: require("./endpoints/btrzpay/square.js").squareWebhooksFactory({client, internalAuthTokenProvider}),
|
|
333
|
+
oxxo: require("./endpoints/btrzpay/oxxo.js")({client, internalAuthTokenProvider}),
|
|
333
334
|
__test: {
|
|
334
335
|
client
|
|
335
336
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const {
|
|
2
|
+
authorizationHeaders
|
|
3
|
+
} = require("./../endpoints_helpers");
|
|
4
|
+
|
|
5
|
+
function oxxoFactory({client, internalAuthTokenProvider}) {
|
|
6
|
+
const token = {
|
|
7
|
+
get({jwtToken, headers, internalAuthTokenProvider}) {
|
|
8
|
+
return client({
|
|
9
|
+
url: "/oxxo/token",
|
|
10
|
+
headers: authorizationHeaders({jwtToken, internalAuthTokenProvider, headers})
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const payments = {
|
|
16
|
+
all({jwtToken, headers, oxxoToken, query, internalAuthTokenProvider}) {
|
|
17
|
+
return client({
|
|
18
|
+
url: `/oxxo/${oxxoToken}/payments`,
|
|
19
|
+
params: query,
|
|
20
|
+
headers: authorizationHeaders({jwtToken, internalAuthTokenProvider, headers})
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
token,
|
|
27
|
+
payments
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = oxxoFactory;
|
|
@@ -20,7 +20,7 @@ function operatingCompaniesFactory({ client, internalAuthTokenProvider }) {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
function update({ jwtToken, token, operatingCompanyId, operatingCompany, headers }) {
|
|
23
|
-
return client({
|
|
23
|
+
return client({
|
|
24
24
|
url: `/operating-companies/${operatingCompanyId}`,
|
|
25
25
|
method: "put",
|
|
26
26
|
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
|
|
@@ -36,11 +36,30 @@ function operatingCompaniesFactory({ client, internalAuthTokenProvider }) {
|
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
const sequences = {
|
|
40
|
+
create({jwtToken, token, operatingCompanyId, sequence, headers}) {
|
|
41
|
+
return client({
|
|
42
|
+
url: `/operating-companies/${operatingCompanyId}/sequences`,
|
|
43
|
+
method: "post",
|
|
44
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
|
|
45
|
+
data: sequence
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
all({jwtToken, token, operatingCompanyId, headers}) {
|
|
49
|
+
return client({
|
|
50
|
+
url: `/operating-companies/${operatingCompanyId}/sequences`,
|
|
51
|
+
method: "get",
|
|
52
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
39
57
|
return {
|
|
40
58
|
all,
|
|
41
59
|
create,
|
|
42
60
|
update,
|
|
43
|
-
get
|
|
61
|
+
get,
|
|
62
|
+
sequences
|
|
44
63
|
};
|
|
45
64
|
}
|
|
46
65
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const {
|
|
2
|
+
axiosMock, expectRequest
|
|
3
|
+
} = require("../../test-helpers");
|
|
4
|
+
const api = require("../../../src/client").createApiClient({
|
|
5
|
+
baseURL: "http://test.com"
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
describe("btrz-pay/oxxo/payments", () => {
|
|
9
|
+
const oxxoToken = "OXXO_1234567890";
|
|
10
|
+
const referenceNumber = "1234-1234-1234-1234";
|
|
11
|
+
const internalAuthTokenProvider = {
|
|
12
|
+
getToken: () => {
|
|
13
|
+
return "internalToken";
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
axiosMock.reset();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("should get a list of payments", () => {
|
|
22
|
+
axiosMock.onGet(`/oxxo/${oxxoToken}/payments`).reply(expectRequest({
|
|
23
|
+
statusCode: 200,
|
|
24
|
+
internalAuthTokenProvider,
|
|
25
|
+
withoutApiKey: true,
|
|
26
|
+
jwtToken: "internal_auth_token",
|
|
27
|
+
query: {referenceNumber}
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
return api.btrzpay.oxxo.payments.all({
|
|
31
|
+
internalAuthTokenProvider,
|
|
32
|
+
jwtToken: "internal_auth_token",
|
|
33
|
+
oxxoToken,
|
|
34
|
+
query: {referenceNumber}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const {
|
|
2
|
+
axiosMock, expectRequest
|
|
3
|
+
} = require("../../test-helpers");
|
|
4
|
+
const api = require("../../../src/client").createApiClient({
|
|
5
|
+
baseURL: "http://test.com"
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
describe("btrz-pay/oxxo/token", () => {
|
|
9
|
+
const internalAuthTokenProvider = {
|
|
10
|
+
getToken: () => {
|
|
11
|
+
return "internalToken";
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
axiosMock.reset();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("should get a new token", () => {
|
|
20
|
+
axiosMock.onGet("/oxxo/token").reply(expectRequest({
|
|
21
|
+
statusCode: 200,
|
|
22
|
+
internalAuthTokenProvider,
|
|
23
|
+
withoutApiKey: true,
|
|
24
|
+
jwtToken: "internal_auth_token"
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
return api.btrzpay.oxxo.token.get({
|
|
28
|
+
internalAuthTokenProvider,
|
|
29
|
+
jwtToken: "internal_auth_token"
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const { axiosMock, expectRequest } = require("./../../test-helpers");
|
|
2
|
+
const {expect} = require("chai");
|
|
2
3
|
const api = require("./../../../src/client").createApiClient({ baseURL: "http://test.com" });
|
|
3
4
|
|
|
4
5
|
describe('inventory/operating-companies', () => {
|
|
@@ -55,4 +56,31 @@ describe('inventory/operating-companies', () => {
|
|
|
55
56
|
operatingCompanyId
|
|
56
57
|
});
|
|
57
58
|
});
|
|
59
|
+
|
|
60
|
+
it("should create an operating company sequence", () => {
|
|
61
|
+
const operatingCompanyId = "1234";
|
|
62
|
+
const operatingCompanySequenceData = {};
|
|
63
|
+
// eslint-disable-next-line max-len
|
|
64
|
+
axiosMock.onPost(`/operating-companies/${operatingCompanyId}/sequences`).reply(expectRequest({statusCode: 200, token, jwtToken, body: operatingCompanySequenceData}));
|
|
65
|
+
return api.inventory.operatingCompanies.sequences.create({
|
|
66
|
+
jwtToken,
|
|
67
|
+
token,
|
|
68
|
+
operatingCompanyId,
|
|
69
|
+
sequence: operatingCompanySequenceData
|
|
70
|
+
}).then((httpResponse) => {
|
|
71
|
+
expect(httpResponse.status).eql(200);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("should get operating company sequences", () => {
|
|
76
|
+
const operatingCompanyId = "1234";
|
|
77
|
+
axiosMock.onGet(`/operating-companies/${operatingCompanyId}/sequences`).reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
78
|
+
return api.inventory.operatingCompanies.sequences.all({
|
|
79
|
+
jwtToken,
|
|
80
|
+
token,
|
|
81
|
+
operatingCompanyId
|
|
82
|
+
}).then((httpResponse) => {
|
|
83
|
+
expect(httpResponse.status).eql(200);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
58
86
|
});
|
package/types/client.d.ts
CHANGED
|
@@ -640,6 +640,21 @@ export function createApiClient(options: {
|
|
|
640
640
|
jwtToken: any;
|
|
641
641
|
headers: any;
|
|
642
642
|
}) => any;
|
|
643
|
+
sequences: {
|
|
644
|
+
create({ jwtToken, token, operatingCompanyId, sequence, headers }: {
|
|
645
|
+
jwtToken: any;
|
|
646
|
+
token: any;
|
|
647
|
+
operatingCompanyId: any;
|
|
648
|
+
sequence: any;
|
|
649
|
+
headers: any;
|
|
650
|
+
}): any;
|
|
651
|
+
all({ jwtToken, token, operatingCompanyId, headers }: {
|
|
652
|
+
jwtToken: any;
|
|
653
|
+
token: any;
|
|
654
|
+
operatingCompanyId: any;
|
|
655
|
+
headers: any;
|
|
656
|
+
}): any;
|
|
657
|
+
};
|
|
643
658
|
};
|
|
644
659
|
operationMessages: {
|
|
645
660
|
get: ({ token, operationMessageId, headers }: {
|
|
@@ -3555,6 +3570,24 @@ export function createApiClient(options: {
|
|
|
3555
3570
|
headers: any;
|
|
3556
3571
|
}) => any;
|
|
3557
3572
|
};
|
|
3573
|
+
oxxo: {
|
|
3574
|
+
token: {
|
|
3575
|
+
get({ jwtToken, headers, internalAuthTokenProvider }: {
|
|
3576
|
+
jwtToken: any;
|
|
3577
|
+
headers: any;
|
|
3578
|
+
internalAuthTokenProvider: any;
|
|
3579
|
+
}): any;
|
|
3580
|
+
};
|
|
3581
|
+
payments: {
|
|
3582
|
+
all({ jwtToken, headers, oxxoToken, query, internalAuthTokenProvider }: {
|
|
3583
|
+
jwtToken: any;
|
|
3584
|
+
headers: any;
|
|
3585
|
+
oxxoToken: any;
|
|
3586
|
+
query: any;
|
|
3587
|
+
internalAuthTokenProvider: any;
|
|
3588
|
+
}): any;
|
|
3589
|
+
};
|
|
3590
|
+
};
|
|
3558
3591
|
__test: {
|
|
3559
3592
|
client: axios.AxiosInstance;
|
|
3560
3593
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export = oxxoFactory;
|
|
2
|
+
declare function oxxoFactory({ client, internalAuthTokenProvider }: {
|
|
3
|
+
client: any;
|
|
4
|
+
internalAuthTokenProvider: any;
|
|
5
|
+
}): {
|
|
6
|
+
token: {
|
|
7
|
+
get({ jwtToken, headers, internalAuthTokenProvider }: {
|
|
8
|
+
jwtToken: any;
|
|
9
|
+
headers: any;
|
|
10
|
+
internalAuthTokenProvider: any;
|
|
11
|
+
}): any;
|
|
12
|
+
};
|
|
13
|
+
payments: {
|
|
14
|
+
all({ jwtToken, headers, oxxoToken, query, internalAuthTokenProvider }: {
|
|
15
|
+
jwtToken: any;
|
|
16
|
+
headers: any;
|
|
17
|
+
oxxoToken: any;
|
|
18
|
+
query: any;
|
|
19
|
+
internalAuthTokenProvider: any;
|
|
20
|
+
}): any;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -28,4 +28,19 @@ declare function operatingCompaniesFactory({ client, internalAuthTokenProvider }
|
|
|
28
28
|
jwtToken: any;
|
|
29
29
|
headers: any;
|
|
30
30
|
}) => any;
|
|
31
|
+
sequences: {
|
|
32
|
+
create({ jwtToken, token, operatingCompanyId, sequence, headers }: {
|
|
33
|
+
jwtToken: any;
|
|
34
|
+
token: any;
|
|
35
|
+
operatingCompanyId: any;
|
|
36
|
+
sequence: any;
|
|
37
|
+
headers: any;
|
|
38
|
+
}): any;
|
|
39
|
+
all({ jwtToken, token, operatingCompanyId, headers }: {
|
|
40
|
+
jwtToken: any;
|
|
41
|
+
token: any;
|
|
42
|
+
operatingCompanyId: any;
|
|
43
|
+
headers: any;
|
|
44
|
+
}): any;
|
|
45
|
+
};
|
|
31
46
|
};
|
|
@@ -594,6 +594,21 @@ declare const _exports: {
|
|
|
594
594
|
jwtToken: any;
|
|
595
595
|
headers: any;
|
|
596
596
|
}) => any;
|
|
597
|
+
sequences: {
|
|
598
|
+
create({ jwtToken, token, operatingCompanyId, sequence, headers }: {
|
|
599
|
+
jwtToken: any;
|
|
600
|
+
token: any;
|
|
601
|
+
operatingCompanyId: any;
|
|
602
|
+
sequence: any;
|
|
603
|
+
headers: any;
|
|
604
|
+
}): any;
|
|
605
|
+
all({ jwtToken, token, operatingCompanyId, headers }: {
|
|
606
|
+
jwtToken: any;
|
|
607
|
+
token: any;
|
|
608
|
+
operatingCompanyId: any;
|
|
609
|
+
headers: any;
|
|
610
|
+
}): any;
|
|
611
|
+
};
|
|
597
612
|
};
|
|
598
613
|
operationMessages: {
|
|
599
614
|
get: ({ token, operationMessageId, headers }: {
|
|
@@ -3509,6 +3524,24 @@ declare const _exports: {
|
|
|
3509
3524
|
headers: any;
|
|
3510
3525
|
}) => any;
|
|
3511
3526
|
};
|
|
3527
|
+
oxxo: {
|
|
3528
|
+
token: {
|
|
3529
|
+
get({ jwtToken, headers, internalAuthTokenProvider }: {
|
|
3530
|
+
jwtToken: any;
|
|
3531
|
+
headers: any;
|
|
3532
|
+
internalAuthTokenProvider: any;
|
|
3533
|
+
}): any;
|
|
3534
|
+
};
|
|
3535
|
+
payments: {
|
|
3536
|
+
all({ jwtToken, headers, oxxoToken, query, internalAuthTokenProvider }: {
|
|
3537
|
+
jwtToken: any;
|
|
3538
|
+
headers: any;
|
|
3539
|
+
oxxoToken: any;
|
|
3540
|
+
query: any;
|
|
3541
|
+
internalAuthTokenProvider: any;
|
|
3542
|
+
}): any;
|
|
3543
|
+
};
|
|
3544
|
+
};
|
|
3512
3545
|
__test: {
|
|
3513
3546
|
client: import("axios").AxiosInstance;
|
|
3514
3547
|
};
|