btrz-api-client 8.34.0 → 8.35.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 +3 -3
- package/lib/client.js +4 -0
- package/lib/endpoints/inventory/banks.js +39 -21
- package/lib/endpoints/inventory/change-requests.js +59 -31
- package/lib/endpoints/inventory/control-classes.js +39 -20
- package/lib/endpoints/inventory/countries.js +25 -9
- package/lib/endpoints/inventory/custom-content.js +39 -21
- package/lib/endpoints/inventory/custom-fields.js +25 -17
- package/lib/endpoints/inventory/document-types.js +33 -42
- package/lib/endpoints/inventory/external-wallets.js +26 -20
- package/lib/endpoints/inventory/fees.js +19 -13
- package/lib/endpoints/inventory/filtered-trips.js +34 -8
- package/lib/endpoints/inventory/financing-costs.js +19 -14
- package/lib/endpoints/inventory/garages.js +19 -14
- package/lib/endpoints/inventory/getnet-terminals.js +20 -15
- package/lib/endpoints/inventory/gift-certificate-definitions.js +10 -5
- package/lib/endpoints/inventory/holidays.js +158 -0
- package/lib/endpoints/inventory/insurances.js +17 -13
- package/lib/endpoints/inventory/items.js +13 -9
- package/lib/endpoints/inventory/labels.js +16 -11
- package/lib/endpoints/inventory/marital-status.js +16 -11
- package/lib/endpoints/inventory/marketplace-modifiers.js +16 -11
- package/lib/endpoints/inventory/mit-terminal-settings.js +15 -10
- package/lib/endpoints/inventory/mit-terminals.js +16 -11
- package/lib/endpoints/inventory/operation-messages.js +18 -12
- package/lib/endpoints/inventory/operation-reasons.js +15 -10
- package/lib/endpoints/inventory/pay-on-accounts.js +5 -4
- package/lib/endpoints/inventory/payment-terminals.js +15 -10
- package/lib/endpoints/inventory/products.js +22 -10
- package/lib/endpoints/inventory/promos.js +27 -18
- package/lib/endpoints/inventory/station-groups.js +2 -4
- package/lib/endpoints/inventory/taxes.js +11 -2
- package/lib/endpoints/inventory/traveller-card-providers-types.js +6 -6
- package/lib/endpoints/inventory/vehicle-types.js +2 -5
- package/lib/endpoints/inventory/vehicles.js +4 -2
- package/lib/endpoints/notifications/customers.js +1 -1
- package/lib/endpoints/notifications/external-customers.js +54 -0
- package/lib/endpoints/notifications/pdfs.js +0 -3
- package/lib/endpoints/operations/accounting_items.js +7 -1
- package/lib/endpoints/operations/flexpasses.js +9 -7
- package/lib/endpoints/operations/gift-certificates.js +53 -0
- package/lib/endpoints/operations/loans.js +16 -10
- package/lib/endpoints/operations/movements.js +17 -6
- package/lib/endpoints/operations/pago-express.js +96 -0
- package/lib/endpoints/operations/parcels.js +11 -11
- package/lib/endpoints/operations/parcels_manifests.js +7 -4
- package/package.json +1 -1
- package/src/client.js +4 -0
- package/src/endpoints/inventory/banks.js +39 -21
- package/src/endpoints/inventory/change-requests.js +59 -31
- package/src/endpoints/inventory/control-classes.js +39 -20
- package/src/endpoints/inventory/countries.js +25 -10
- package/src/endpoints/inventory/custom-content.js +39 -22
- package/src/endpoints/inventory/custom-fields.js +25 -19
- package/src/endpoints/inventory/document-types.js +34 -33
- package/src/endpoints/inventory/external-wallets.js +25 -20
- package/src/endpoints/inventory/fees.js +19 -14
- package/src/endpoints/inventory/filtered-trips.js +29 -8
- package/src/endpoints/inventory/financing-costs.js +19 -14
- package/src/endpoints/inventory/garages.js +19 -14
- package/src/endpoints/inventory/getnet-terminals.js +20 -15
- package/src/endpoints/inventory/gift-certificate-definitions.js +10 -5
- package/src/endpoints/inventory/holidays.js +121 -0
- package/src/endpoints/inventory/insurances.js +17 -13
- package/src/endpoints/inventory/items.js +13 -9
- package/src/endpoints/inventory/labels.js +16 -11
- package/src/endpoints/inventory/marital-status.js +16 -11
- package/src/endpoints/inventory/marketplace-modifiers.js +16 -11
- package/src/endpoints/inventory/mit-terminal-settings.js +15 -10
- package/src/endpoints/inventory/mit-terminals.js +16 -11
- package/src/endpoints/inventory/operation-messages.js +18 -12
- package/src/endpoints/inventory/operation-reasons.js +15 -10
- package/src/endpoints/inventory/pay-on-accounts.js +5 -4
- package/src/endpoints/inventory/payment-terminals.js +15 -10
- package/src/endpoints/inventory/products.js +22 -10
- package/src/endpoints/inventory/promos.js +27 -18
- package/src/endpoints/inventory/station-groups.js +2 -4
- package/src/endpoints/inventory/taxes.js +11 -2
- package/src/endpoints/inventory/traveller-card-providers-types.js +6 -5
- package/src/endpoints/inventory/vehicle-types.js +3 -4
- package/src/endpoints/inventory/vehicles.js +4 -3
- package/src/endpoints/notifications/customers.js +1 -1
- package/src/endpoints/notifications/external-customers.js +41 -0
- package/src/endpoints/notifications/pdfs.js +0 -3
- package/src/endpoints/operations/accounting_items.js +7 -2
- package/src/endpoints/operations/flexpasses.js +9 -7
- package/src/endpoints/operations/gift-certificates.js +39 -0
- package/src/endpoints/operations/loans.js +16 -11
- package/src/endpoints/operations/movements.js +17 -6
- package/src/endpoints/operations/pago-express.js +73 -0
- package/src/endpoints/operations/parcels.js +11 -11
- package/src/endpoints/operations/parcels_manifests.js +7 -5
- package/test/endpoints/inventory/banks.test.js +8 -10
- package/test/endpoints/inventory/filtered-trips.test.js +6 -0
- package/test/endpoints/inventory/holidays.test.js +52 -0
- package/test/endpoints/inventory/traveller-card-providers-types.test.js +3 -2
- package/test/endpoints/notifications/external-customers.test.js +30 -0
- package/test/endpoints/operations/gift_certificates.test.js +37 -0
- package/test/endpoints/operations/operations.test.js +30 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
const {authorizationHeaders} = require("../endpoints_helpers.js");
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pago Express (Datalogic) endpoints for the Operations API.
|
|
5
|
+
* Used to get info, pay, and reverse reference payments.
|
|
6
|
+
* @param {Object} deps
|
|
7
|
+
* @param {import("axios").AxiosInstance} deps.client
|
|
8
|
+
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
9
|
+
* @returns {Object} pagoExpress API methods
|
|
10
|
+
*/
|
|
11
|
+
function pagoExpressFactory({client, internalAuthTokenProvider}) {
|
|
12
|
+
/**
|
|
13
|
+
* POST /pago-express/info - get transaction information for a Pago Express reference.
|
|
14
|
+
* @param {Object} opts
|
|
15
|
+
* @param {string} [opts.token] - API key (x-api-key)
|
|
16
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth
|
|
17
|
+
* @param {Object} opts.payment - Request body: folio (20-digit string), id_terminal (number), local_date (string DD/MM/YYYY HH:mm:ss), trx_no (number)
|
|
18
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
19
|
+
* @returns {Promise<import("axios").AxiosResponse>} 200 PostInfoResponse (code, message, result with folio, id_terminal, local_date, saldo, trx_no, responsecode, descriptioncode)
|
|
20
|
+
*/
|
|
21
|
+
function info({token, jwtToken, payment, headers}) {
|
|
22
|
+
return client({
|
|
23
|
+
method: "post",
|
|
24
|
+
url: "/pago-express/info",
|
|
25
|
+
data: {payment},
|
|
26
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* POST /pago-express/pay - pay a Pago Express reference payment.
|
|
32
|
+
* @param {Object} opts
|
|
33
|
+
* @param {string} [opts.token] - API key (x-api-key)
|
|
34
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth
|
|
35
|
+
* @param {Object} opts.payment - Request body: folio, id_terminal, local_date, trx_no, amount (string)
|
|
36
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
37
|
+
* @returns {Promise<import("axios").AxiosResponse>} 200 PostPayResponse (code, message, result with folio, id_terminal, local_date, trx_no, noauto, amount, responsecode, descriptioncode)
|
|
38
|
+
*/
|
|
39
|
+
function pay({token, jwtToken, payment, headers}) {
|
|
40
|
+
return client({
|
|
41
|
+
method: "post",
|
|
42
|
+
url: "/pago-express/pay",
|
|
43
|
+
data: {payment},
|
|
44
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* POST /pago-express/reverse - reverse (cancel) a Pago Express reference payment. Emits transaction.reversed webhook.
|
|
50
|
+
* @param {Object} opts
|
|
51
|
+
* @param {string} [opts.token] - API key (x-api-key)
|
|
52
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth
|
|
53
|
+
* @param {Object} opts.reversePayment - Request body: folio, id_terminal, local_date, trx_no, amount (string)
|
|
54
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
55
|
+
* @returns {Promise<import("axios").AxiosResponse>} 200 PostReverseResponse (code, message, result)
|
|
56
|
+
*/
|
|
57
|
+
function reverse({token, jwtToken, reversePayment, headers}) {
|
|
58
|
+
return client({
|
|
59
|
+
method: "post",
|
|
60
|
+
url: "/pago-express/reverse",
|
|
61
|
+
data: {reversePayment},
|
|
62
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return {
|
|
67
|
+
info,
|
|
68
|
+
pay,
|
|
69
|
+
reverse
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
module.exports = pagoExpressFactory;
|
|
@@ -28,13 +28,13 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
|
|
|
28
28
|
*/
|
|
29
29
|
function parcelFactory({client, internalAuthTokenProvider}) {
|
|
30
30
|
/**
|
|
31
|
-
* GET /parcels
|
|
31
|
+
* GET /parcels/{parcelId} - get parcel by id. Requires JwtAuth. No query params.
|
|
32
32
|
* @param {Object} opts
|
|
33
33
|
* @param {string} [opts.token] - API key
|
|
34
34
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
35
|
-
* @param {string} opts.id - Parcel id
|
|
35
|
+
* @param {string} opts.id - Parcel id (24 hex characters)
|
|
36
36
|
* @param {Object} [opts.headers] - Optional headers
|
|
37
|
-
* @returns {Promise<import("axios").AxiosResponse>}
|
|
37
|
+
* @returns {Promise<import("axios").AxiosResponse>} 200 { parcel }; 400 INVALID_PARCEL_ID; 401 Unauthorized; 404 PARCEL_NOT_FOUND; 500
|
|
38
38
|
*/
|
|
39
39
|
function get({token, jwtToken, id, headers}) {
|
|
40
40
|
return client({
|
|
@@ -83,14 +83,14 @@ function parcelFactory({client, internalAuthTokenProvider}) {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
|
-
* POST /parcels
|
|
86
|
+
* POST /parcels/{parcelId}/user-comments - add user comment to parcel. Requires JwtAuth. Body: { comment } (string).
|
|
87
87
|
* @param {Object} opts
|
|
88
88
|
* @param {string} [opts.token] - API key
|
|
89
89
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
90
|
-
* @param {string} opts.id - Parcel id
|
|
91
|
-
* @param {
|
|
90
|
+
* @param {string} opts.id - Parcel id (path parcelId)
|
|
91
|
+
* @param {string} opts.comment - Comment text (sent as body.comment)
|
|
92
92
|
* @param {Object} [opts.headers] - Optional headers
|
|
93
|
-
* @returns {Promise<import("axios").AxiosResponse>}
|
|
93
|
+
* @returns {Promise<import("axios").AxiosResponse>} 200 ParcelUserComment; 400 MISSING_*; 401; 403; 404 PARCEL_NOT_FOUND; 409
|
|
94
94
|
*/
|
|
95
95
|
function addComment({token, jwtToken, headers, id, comment}) {
|
|
96
96
|
return client({
|
|
@@ -102,14 +102,14 @@ function parcelFactory({client, internalAuthTokenProvider}) {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
|
-
* DELETE /parcels
|
|
105
|
+
* DELETE /parcels/{parcelId}/user-comments/{commentId} - delete user comment from parcel. Requires JwtAuth.
|
|
106
106
|
* @param {Object} opts
|
|
107
107
|
* @param {string} [opts.token] - API key
|
|
108
108
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
109
|
-
* @param {string} opts.id - Parcel id
|
|
110
|
-
* @param {string} opts.commentId - Comment id
|
|
109
|
+
* @param {string} opts.id - Parcel id (path parcelId)
|
|
110
|
+
* @param {string} opts.commentId - Comment id (path)
|
|
111
111
|
* @param {Object} [opts.headers] - Optional headers
|
|
112
|
-
* @returns {Promise<import("axios").AxiosResponse>}
|
|
112
|
+
* @returns {Promise<import("axios").AxiosResponse>} 200 deleted ParcelUserComment; 400 MISSING_*; 401; 403; 404 PARCEL_NOT_FOUND, COMMENT_NOT_FOUND; 409
|
|
113
113
|
*/
|
|
114
114
|
function deleteComment({token, jwtToken, headers, id, commentId}) {
|
|
115
115
|
return client({
|
|
@@ -40,19 +40,21 @@ function parcelsManifestsFactory({client, internalAuthTokenProvider}) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
* GET /parcels-manifests/:id - get parcels manifest by id.
|
|
43
|
+
* GET /parcels-manifests/:id - get parcels manifest by id.
|
|
44
44
|
* @param {Object} opts
|
|
45
45
|
* @param {string} [opts.token] - API key
|
|
46
46
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
47
|
-
* @param {string} opts.id - Parcel manifest id (ObjectId)
|
|
47
|
+
* @param {string} opts.id - Parcel manifest id (ObjectId, 24 hex chars)
|
|
48
|
+
* @param {"standard"|"webhook"} [opts.format="standard"] - Response format (standard | webhook)
|
|
48
49
|
* @param {Object} [opts.headers] - Optional request headers
|
|
49
|
-
* @returns {Promise<import("axios").AxiosResponse>} response.data parcel manifest; 404 PARCELMANIFEST_NOT_FOUND
|
|
50
|
+
* @returns {Promise<import("axios").AxiosResponse>} response.data parcel manifest; 400 WRONG_DATA; 404 MANIFEST_NOT_FOUND, PARCELMANIFEST_NOT_FOUND
|
|
50
51
|
*/
|
|
51
|
-
function get({token, jwtToken, id, headers}) {
|
|
52
|
+
function get({token, jwtToken, id, format, headers}) {
|
|
52
53
|
return client({
|
|
53
54
|
url: `/parcels-manifests/${id}`,
|
|
54
55
|
method: "get",
|
|
55
|
-
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
|
|
56
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
|
|
57
|
+
params: format != null ? {format} : undefined
|
|
56
58
|
});
|
|
57
59
|
}
|
|
58
60
|
|
|
@@ -12,18 +12,17 @@ describe("inventory/banks", () => {
|
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
it("should create a bank", () => {
|
|
15
|
-
|
|
15
|
+
const bank = {name: "My bank", accountNumbers: [{number: "123", currency: "USD", alias: "Main"}]};
|
|
16
|
+
axiosMock.onPost("/banks", {bank}).reply(expectRequest({statusCode: 200, token, jwtToken, body: {bank}}));
|
|
16
17
|
return api.inventory.banks.create({
|
|
17
18
|
jwtToken,
|
|
18
19
|
token,
|
|
19
|
-
|
|
20
|
-
name: "My bankl"
|
|
21
|
-
}
|
|
20
|
+
bank
|
|
22
21
|
});
|
|
23
22
|
});
|
|
24
23
|
|
|
25
24
|
it("should get all pieces of bank", () => {
|
|
26
|
-
axiosMock.onGet("/banks").reply(expectRequest({statusCode: 200, token, jwtToken
|
|
25
|
+
axiosMock.onGet("/banks").reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
27
26
|
return api.inventory.banks.all({
|
|
28
27
|
jwtToken,
|
|
29
28
|
token,
|
|
@@ -31,16 +30,15 @@ describe("inventory/banks", () => {
|
|
|
31
30
|
});
|
|
32
31
|
});
|
|
33
32
|
|
|
34
|
-
it("should update a
|
|
33
|
+
it("should update a bank", () => {
|
|
35
34
|
const bankId = "1234";
|
|
36
|
-
|
|
35
|
+
const bank = {name: "My Updated bank", accountNumbers: [{number: "123", currency: "USD", alias: "Main"}]};
|
|
36
|
+
axiosMock.onPut(`/banks/${bankId}`, {bank}).reply(expectRequest({statusCode: 200, token, jwtToken, body: {bank}}));
|
|
37
37
|
return api.inventory.banks.update({
|
|
38
38
|
jwtToken,
|
|
39
39
|
token,
|
|
40
40
|
bankId,
|
|
41
|
-
|
|
42
|
-
name: "My Updated bank"
|
|
43
|
-
}
|
|
41
|
+
bank
|
|
44
42
|
});
|
|
45
43
|
});
|
|
46
44
|
|
|
@@ -28,4 +28,10 @@ describe("inventory/filtered-trips", () => {
|
|
|
28
28
|
axiosMock.onPost("/filtered-trips").reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
29
29
|
return api.inventory.filteredTrips.create({token, jwtToken, tripSegmentsId: "myTripSegmentId"});
|
|
30
30
|
});
|
|
31
|
+
|
|
32
|
+
it("should remove a filtered trip", () => {
|
|
33
|
+
const filteredTripId = "60c9200d17bda93f5c896bf3";
|
|
34
|
+
axiosMock.onDelete(`/filtered-trip/${filteredTripId}`).reply(expectRequest({statusCode: 204, token, jwtToken}));
|
|
35
|
+
return api.inventory.filteredTrips.remove({token, jwtToken, filteredTripId});
|
|
36
|
+
});
|
|
31
37
|
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
describe("inventory/holidays", () => {
|
|
2
|
+
const {axiosMock, expectRequest} = require("./../../test-helpers.js");
|
|
3
|
+
const api = require("./../../../src/client.js").createApiClient({
|
|
4
|
+
baseURL: "http://test.com"
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
const token = "I owe you a token";
|
|
8
|
+
const jwtToken = "I owe you a JWT token";
|
|
9
|
+
const holidayId = "holiday-id-1";
|
|
10
|
+
|
|
11
|
+
afterEach(() => {
|
|
12
|
+
axiosMock.reset();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("should list holidays", () => {
|
|
16
|
+
const query = {page: 1, providerId: "providerId1"};
|
|
17
|
+
axiosMock.onGet("/holidays").reply(expectRequest({statusCode: 200, token, query}));
|
|
18
|
+
return api.inventory.holidays.all({token, query});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("should get a specific holiday by id", () => {
|
|
22
|
+
axiosMock.onGet(`/holidays/${holidayId}`).reply(expectRequest({
|
|
23
|
+
statusCode: 200, token, jwtToken
|
|
24
|
+
}));
|
|
25
|
+
return api.inventory.holidays.get({token, jwtToken, holidayId});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("should create a new holiday", () => {
|
|
29
|
+
const holiday = {day: 25, month: 12, year: 2024, name: "Christmas"};
|
|
30
|
+
axiosMock.onPost("/holidays").reply(expectRequest({
|
|
31
|
+
statusCode: 200, token, jwtToken, body: {holiday}
|
|
32
|
+
}));
|
|
33
|
+
return api.inventory.holidays.create({jwtToken, token, holiday});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("should update an existing holiday", () => {
|
|
37
|
+
const holiday = {day: 26, month: 12, year: 2024, name: "Boxing Day"};
|
|
38
|
+
axiosMock.onPut(`/holidays/${holidayId}`).reply(expectRequest({
|
|
39
|
+
statusCode: 200, token, jwtToken, body: {holiday}
|
|
40
|
+
}));
|
|
41
|
+
return api.inventory.holidays.update({
|
|
42
|
+
jwtToken, token, holiday, holidayId
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("should delete an existing holiday", () => {
|
|
47
|
+
axiosMock.onDelete(`/holidays/${holidayId}`).reply(expectRequest({
|
|
48
|
+
statusCode: 200, token, jwtToken
|
|
49
|
+
}));
|
|
50
|
+
return api.inventory.holidays.remove({jwtToken, token, holidayId});
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable import/extensions */
|
|
1
2
|
const {axiosMock, expectRequest} = require("./../../test-helpers");
|
|
2
3
|
const api = require("./../../../src/client").createApiClient({baseURL: "http://test.com"});
|
|
3
4
|
|
|
@@ -8,8 +9,8 @@ describe("inventory/traveller-card-providers-types", () => {
|
|
|
8
9
|
axiosMock.reset();
|
|
9
10
|
});
|
|
10
11
|
|
|
11
|
-
it("should call the traveller card providers types endpoint",
|
|
12
|
+
it("should call the traveller card providers types endpoint", () => {
|
|
12
13
|
axiosMock.onGet("/traveller-card-providers/types").reply(expectRequest({statusCode: 200, token}));
|
|
13
|
-
api.inventory.travellerCardProvidersTypes.all({token});
|
|
14
|
+
return api.inventory.travellerCardProvidersTypes.all({token});
|
|
14
15
|
});
|
|
15
16
|
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const {expect} = require("chai");
|
|
2
|
+
const {axiosMock} = require("./../../test-helpers.js");
|
|
3
|
+
const api = require("./../../../src/client.js").createApiClient({baseURL: "http://test.com"});
|
|
4
|
+
|
|
5
|
+
describe("notifications/external-customers", () => {
|
|
6
|
+
const jwtToken = "myJwtToken";
|
|
7
|
+
const token = "myApiKey";
|
|
8
|
+
|
|
9
|
+
afterEach(() => {
|
|
10
|
+
axiosMock.reset();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("should POST to request Saldo Max verification code (ado/registration)", () => {
|
|
14
|
+
const data = {email: "user@example.com"};
|
|
15
|
+
axiosMock.onPost("/external-customers/ado/registration").reply((config) => {
|
|
16
|
+
expect(config.data).to.equal(JSON.stringify(data));
|
|
17
|
+
expect(config.headers["x-api-key"]).to.eql(token);
|
|
18
|
+
expect(config.headers.authorization).to.eql(`Bearer ${jwtToken}`);
|
|
19
|
+
return [200, {code: "success", message: "Registration successful"}];
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return api.notifications.externalCustomers.requestSaldoMaxVerificationCode({
|
|
23
|
+
token,
|
|
24
|
+
jwtToken,
|
|
25
|
+
data
|
|
26
|
+
}).then((res) => {
|
|
27
|
+
expect(res.data).to.eql({code: "success", message: "Registration successful"});
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const {axiosMock, expectRequest} = require("../../test-helpers.js");
|
|
2
|
+
const api = require("../../../src/client.js").createApiClient({baseURL: "http://test.com"});
|
|
3
|
+
|
|
4
|
+
describe("operations/gift-certificates", () => {
|
|
5
|
+
const token = "test-api-key";
|
|
6
|
+
const jwtToken = "customer-jwt-token";
|
|
7
|
+
|
|
8
|
+
afterEach(() => {
|
|
9
|
+
axiosMock.reset();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("should GET gift certificates for the given customer", () => {
|
|
13
|
+
const customer = "123-456-789";
|
|
14
|
+
axiosMock.onGet("/gift-certificates")
|
|
15
|
+
.reply(expectRequest({statusCode: 200, token, jwtToken, query: {customer}}));
|
|
16
|
+
|
|
17
|
+
return api.operations.giftCertificates.list({
|
|
18
|
+
jwtToken,
|
|
19
|
+
token,
|
|
20
|
+
customer
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("should GET gift certificates with optional page", () => {
|
|
25
|
+
const customer = "123-456-789";
|
|
26
|
+
const page = 2;
|
|
27
|
+
axiosMock.onGet("/gift-certificates")
|
|
28
|
+
.reply(expectRequest({statusCode: 200, token, jwtToken, query: {customer, page}}));
|
|
29
|
+
|
|
30
|
+
return api.operations.giftCertificates.list({
|
|
31
|
+
jwtToken,
|
|
32
|
+
token,
|
|
33
|
+
customer,
|
|
34
|
+
page
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -17,3 +17,33 @@ describe('operations/segments', function() {
|
|
|
17
17
|
return api.operations.segments.all({ token, jwtToken, productId, ticketId });
|
|
18
18
|
});
|
|
19
19
|
});
|
|
20
|
+
|
|
21
|
+
describe("operations/pagoExpress", function() {
|
|
22
|
+
const token = "I owe you a token";
|
|
23
|
+
const jwtToken = "I owe you a JWT token";
|
|
24
|
+
|
|
25
|
+
afterEach(function() {
|
|
26
|
+
axiosMock.reset();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("should post pago-express info", function() {
|
|
30
|
+
const payment = { folio: "10305108982123541235", id_terminal: 45875263254987452135, local_date: "18/06/1988 15:04:20", trx_no: 12345 };
|
|
31
|
+
axiosMock.onPost("/pago-express/info")
|
|
32
|
+
.reply(expectRequest({ statusCode: 200, token, jwtToken, body: { payment } }));
|
|
33
|
+
return api.operations.pagoExpress.info({ token, jwtToken, payment });
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("should post pago-express pay", function() {
|
|
37
|
+
const payment = { folio: "10305108982123541235", id_terminal: 45875263254987452135, local_date: "18/06/1988 15:04:20", trx_no: 12345, amount: "999.00" };
|
|
38
|
+
axiosMock.onPost("/pago-express/pay")
|
|
39
|
+
.reply(expectRequest({ statusCode: 200, token, jwtToken, body: { payment } }));
|
|
40
|
+
return api.operations.pagoExpress.pay({ token, jwtToken, payment });
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("should post pago-express reverse", function() {
|
|
44
|
+
const reversePayment = { folio: "10305108982123541235", id_terminal: 45875263254987452135, local_date: "18/06/1988 15:04:20", trx_no: 12345, amount: "999.00" };
|
|
45
|
+
axiosMock.onPost("/pago-express/reverse")
|
|
46
|
+
.reply(expectRequest({ statusCode: 200, token, jwtToken, body: { reversePayment } }));
|
|
47
|
+
return api.operations.pagoExpress.reverse({ token, jwtToken, reversePayment });
|
|
48
|
+
});
|
|
49
|
+
});
|