btrz-api-client 8.64.0 → 8.66.1
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/.eslint-report.json +1 -0
- package/.eslintignore +2 -0
- package/fetch-test.js +5 -6
- package/index.js +2 -2
- package/lib/client-standalone-min.js +3 -3
- package/lib/client.js +50 -38
- package/lib/endpoints/accounts/journey-prices-settings.js +2 -2
- package/lib/endpoints/accounts/market-pricing-settings.js +3 -3
- package/lib/endpoints/accounts/multiproduct-sales-settings.js +6 -2
- package/lib/endpoints/accounts/operation-settings.js +3 -1
- package/lib/endpoints/btrzpay/referenced-payments.js +6 -2
- package/lib/endpoints/btrzpay/square.js +12 -3
- package/lib/endpoints/btrzpay/stripe-terminals.js +9 -3
- package/lib/endpoints/btrzpay/terminalPayments.js +14 -4
- package/lib/endpoints/inventory/document-types.js +2 -1
- package/lib/endpoints/inventory/products.js +1 -0
- package/lib/endpoints/notifications/pdf-data.js +3 -6
- package/lib/endpoints/operations/movements.js +7 -2
- package/lib/endpoints/operations/pago-express.js +9 -3
- package/lib/endpoints/operations/parcels.js +3 -1
- package/lib/endpoints/sales/cancellations.js +31 -8
- package/package.json +6 -8
- package/src/client.js +0 -1
- package/src/endpoints/accounts/journey-prices-settings.js +2 -2
- package/src/endpoints/accounts/market-pricing-settings.js +3 -3
- package/src/endpoints/accounts/multiproduct-sales-settings.js +6 -2
- package/src/endpoints/accounts/operation-settings.js +3 -1
- package/src/endpoints/btrzpay/referenced-payments.js +6 -2
- package/src/endpoints/btrzpay/square.js +12 -3
- package/src/endpoints/btrzpay/stripe-terminals.js +9 -3
- package/src/endpoints/btrzpay/terminalPayments.js +14 -4
- package/src/endpoints/inventory/document-types.js +2 -1
- package/src/endpoints/inventory/products.js +1 -0
- package/src/endpoints/notifications/pdf-data.js +3 -6
- package/src/endpoints/operations/movements.js +7 -2
- package/src/endpoints/operations/pago-express.js +9 -3
- package/src/endpoints/operations/parcels.js +3 -1
- package/src/endpoints/sales/cancellations.js +31 -8
- package/test/all.test.js +218 -0
- package/test/client.test.js +58 -44
- package/test/endpoints/accounts/application-settings.test.js +2 -2
- package/test/endpoints/accounts/applications.test.js +2 -2
- package/test/endpoints/accounts/current-shifts.test.js +2 -2
- package/test/endpoints/accounts/customers.js +17 -17
- package/test/endpoints/accounts/domains.test.js +6 -8
- package/test/endpoints/accounts/exchange-rates.test.js +3 -3
- package/test/endpoints/accounts/exchange-receipts.test.js +3 -3
- package/test/endpoints/accounts/images.test.js +2 -2
- package/test/endpoints/accounts/interline.test.js +10 -12
- package/test/endpoints/accounts/network.test.js +3 -5
- package/test/endpoints/accounts/people-lookups.test.js +13 -13
- package/test/endpoints/accounts/print-templates.test.js +3 -3
- package/test/endpoints/accounts/printers.test.js +2 -2
- package/test/endpoints/accounts/tokens.js +2 -2
- package/test/endpoints/accounts/trusted-machines.test.js +2 -2
- package/test/endpoints/accounts/websales-config.test.js +47 -50
- package/test/endpoints/btrzpay/carpointe.tests.js +2 -2
- package/test/endpoints/btrzpay/datalogicPayments.tests.js +2 -2
- package/test/endpoints/btrzpay/datalogicReferenceNumber.tests.js +2 -2
- package/test/endpoints/btrzpay/oxxoPayments.tests.js +2 -2
- package/test/endpoints/btrzpay/oxxoToken.tests.js +2 -2
- package/test/endpoints/btrzpay/payment-methods.test.js +3 -3
- package/test/endpoints/btrzpay/payments.tests.js +6 -6
- package/test/endpoints/btrzpay/reference-numbers.test.js +5 -5
- package/test/endpoints/btrzpay/referenced-payments.test.js +2 -2
- package/test/endpoints/btrzpay/square.tests.js +2 -2
- package/test/endpoints/btrzpay/terminalPayments.tests.js +2 -2
- package/test/endpoints/endpoints_helpers.test.js +28 -24
- package/test/endpoints/inventory/amenities.test.js +20 -20
- package/test/endpoints/inventory/amenity-groups.test.js +15 -15
- package/test/endpoints/inventory/bare-routes.test.js +2 -2
- package/test/endpoints/inventory/brands.test.js +9 -9
- package/test/endpoints/inventory/bundle-fares.test.js +10 -11
- package/test/endpoints/inventory/bundles.test.js +9 -9
- package/test/endpoints/inventory/companies.test.js +6 -6
- package/test/endpoints/inventory/custom-content.test.js +4 -4
- package/test/endpoints/inventory/custom-fields.test.js +2 -2
- package/test/endpoints/inventory/document-types.test.js +2 -2
- package/test/endpoints/inventory/fare-classes.test.js +10 -10
- package/test/endpoints/inventory/fares.test.js +14 -16
- package/test/endpoints/inventory/fees.test.js +14 -15
- package/test/endpoints/inventory/filtered-trips-v2.test.js +5 -5
- package/test/endpoints/inventory/insurances.test.js +2 -2
- package/test/endpoints/inventory/insurancesCost.test.js +2 -2
- package/test/endpoints/inventory/journey-prices.test.js +13 -15
- package/test/endpoints/inventory/labels.test.js +2 -2
- package/test/endpoints/inventory/marital-status.test.js +2 -2
- package/test/endpoints/inventory/mit-terminal-settings.test.js +2 -2
- package/test/endpoints/inventory/mit-terminals.test.js +7 -7
- package/test/endpoints/inventory/operating-companies.test.js +14 -14
- package/test/endpoints/inventory/operation-messages.test.js +10 -10
- package/test/endpoints/inventory/parcel-zones.test.js +12 -13
- package/test/endpoints/inventory/payment-terminals.test.js +7 -7
- package/test/endpoints/inventory/prisma-terminals.test.js +2 -2
- package/test/endpoints/inventory/products.test.js +25 -20
- package/test/endpoints/inventory/promos.test.js +50 -50
- package/test/endpoints/inventory/seatclasses.test.js +2 -2
- package/test/endpoints/inventory/seatfees.test.js +6 -6
- package/test/endpoints/inventory/seatmaps.test.js +7 -7
- package/test/endpoints/inventory/segments-information.test.js +2 -2
- package/test/endpoints/inventory/service-numbers.test.js +6 -6
- package/test/endpoints/inventory/service-types.test.js +7 -7
- package/test/endpoints/inventory/shift-settings.test.js +2 -2
- package/test/endpoints/inventory/ssrs.test.js +10 -11
- package/test/endpoints/inventory/stations-zones.test.js +8 -9
- package/test/endpoints/inventory/stations.test.js +2 -2
- package/test/endpoints/inventory/travel-routes.test.js +2 -2
- package/test/endpoints/inventory/traveller-car-types.test.js +8 -8
- package/test/endpoints/inventory/traveller-card-providers-types.test.js +2 -2
- package/test/endpoints/inventory/traveller-card-providers.test.js +7 -7
- package/test/endpoints/inventory/vehicles.test.js +2 -2
- package/test/endpoints/inventory/zone-price-overages.test.js +2 -2
- package/test/endpoints/inventory/zone-prices.test.js +2 -2
- package/test/endpoints/invoices/dlink.test.js +2 -2
- package/test/endpoints/invoices/gti.test.js +2 -2
- package/test/endpoints/invoices/infile.test.js +2 -2
- package/test/endpoints/invoices/infileJson.test.js +2 -2
- package/test/endpoints/invoices/providers.test.js +4 -4
- package/test/endpoints/invoices/providersSequences.test.js +2 -2
- package/test/endpoints/invoices/system.test.js +2 -2
- package/test/endpoints/loyalty/movements.test.js +11 -11
- package/test/endpoints/loyalty/programs.test.js +21 -21
- package/test/endpoints/notifications/customers.test.js +6 -6
- package/test/endpoints/notifications/external-customers.test.js +10 -10
- package/test/endpoints/notifications/manifet-notifications.test.js +3 -3
- package/test/endpoints/notifications/notify.test.js +5 -5
- package/test/endpoints/notifications/orders-rules-validations.test.js +5 -6
- package/test/endpoints/notifications/pdf-data.test.js +4 -4
- package/test/endpoints/notifications/pdfs.test.js +4 -4
- package/test/endpoints/notifications/printed-tickets.test.js +17 -18
- package/test/endpoints/notifications/short-urls.test.js +9 -9
- package/test/endpoints/operations/applied_insurance.test.js +10 -14
- package/test/endpoints/operations/calendar_entries.test.js +8 -9
- package/test/endpoints/operations/cancellation_settings.test.js +2 -2
- package/test/endpoints/operations/loans.test.js +2 -2
- package/test/endpoints/operations/manifest.test.js +11 -9
- package/test/endpoints/operations/operations.test.js +42 -25
- package/test/endpoints/operations/parcel_manifests.test.js +3 -3
- package/test/endpoints/operations/parcels.test.js +27 -22
- package/test/endpoints/operations/passenger_check_in_info.test.js +2 -2
- package/test/endpoints/operations/redemption.test.js +2 -2
- package/test/endpoints/operations/sold-items-fulfillment.test.js +2 -2
- package/test/endpoints/operations/sold_items.test.js +3 -3
- package/test/endpoints/operations/tickets.test.js +4 -4
- package/test/endpoints/operations/transaction.test.js +12 -15
- package/test/endpoints/operations/transactions.test.js +11 -11
- package/test/endpoints/operations/transport_regulations.js +2 -4
- package/test/endpoints/operations/trip_change_info.test.js +9 -10
- package/test/endpoints/operations/vehicle-assignments.test.js +5 -7
- package/test/endpoints/operations/waitlists.test.js +3 -3
- package/test/endpoints/ratality/auth.test.js +5 -5
- package/test/endpoints/ratality/client.test.js +4 -4
- package/test/endpoints/ratality/integrations.test.js +15 -9
- package/test/endpoints/reports/custom-reports.test.js +12 -12
- package/test/endpoints/reports/email.test.js +3 -3
- package/test/endpoints/reports/report-types.test.js +6 -6
- package/test/endpoints/reports/trip-manifests.test.js +5 -6
- package/test/endpoints/sales/bundles.test.js +9 -10
- package/test/endpoints/sales/cart-promo.test.js +15 -16
- package/test/endpoints/sales/cart.test.js +7 -7
- package/test/endpoints/sales/check-in-info.test.js +3 -3
- package/test/endpoints/sales/custom-fields.test.js +10 -13
- package/test/endpoints/sales/flexpasses.test.js +2 -2
- package/test/endpoints/sales/git-certificates.test.js +10 -13
- package/test/endpoints/sales/order.test.js +19 -21
- package/test/endpoints/sales/payment-providers.test.js +14 -15
- package/test/endpoints/sales/redeemable-items.test.js +14 -15
- package/test/endpoints/sales/sync-entry.test.js +9 -11
- package/test/endpoints/sales/voucher.test.js +19 -17
- package/test/endpoints/seatmaps/access-ticket.test.js +6 -6
- package/test/endpoints/seatmaps/seat.test.js +6 -6
- package/test/endpoints/uploads/files.test.js +8 -7
- package/test/endpoints/uploads/images.test.js +8 -7
- package/test/endpoints/webhooks/subscriptions.test.js +27 -27
- package/test/endpoints/webhooks/undelivered.test.js +22 -22
- package/test/endpoints/webhooks/webhooks.test.js +7 -7
- package/test/node-test-globals.js +19 -0
- package/test/test-helpers.js +4 -4
- package/test-integration/all.test.js +63 -0
- package/test-integration/endpoints/accounts/current-shifts.test.js +4 -4
- package/test-integration/endpoints/accounts/docs.test.js +6 -6
- package/test-integration/endpoints/accounts/lexicons.test.js +42 -37
- package/test-integration/endpoints/accounts/shifts.test.js +5 -8
- package/test-integration/endpoints/accounts/users.test.js +4 -4
- package/test-integration/endpoints/btrzpay/customerCards.test.js +24 -48
- package/test-integration/endpoints/btrzpay/customers.test.js +20 -34
- package/test-integration/endpoints/btrzpay/payment-methods.test.js +34 -34
- package/test-integration/endpoints/btrzpay/payments.test.js +21 -21
- package/test-integration/endpoints/btrzpay/reference-numbers.test.js +15 -15
- package/test-integration/endpoints/btrzpay/referenced-payments.test.js +5 -5
- package/test-integration/endpoints/client.test.js +6 -10
- package/test-integration/endpoints/inventory/amenities.test.js +34 -34
- package/test-integration/endpoints/inventory/amenity-groups.test.js +30 -31
- package/test-integration/endpoints/inventory/bundle-fares.test.js +10 -12
- package/test-integration/endpoints/inventory/companies.test.js +7 -8
- package/test-integration/endpoints/inventory/countries.test.js +10 -12
- package/test-integration/endpoints/inventory/custom-fields.test.js +2 -2
- package/test-integration/endpoints/inventory/docs.test.js +5 -7
- package/test-integration/endpoints/inventory/fare-classes.test.js +12 -13
- package/test-integration/endpoints/inventory/fares.test.js +7 -9
- package/test-integration/endpoints/inventory/fees.test.js +8 -10
- package/test-integration/endpoints/inventory/filtered-trips.test.js +15 -12
- package/test-integration/endpoints/inventory/gift-certificate-definitions.test.js +5 -5
- package/test-integration/endpoints/inventory/insurances.test.js +36 -34
- package/test-integration/endpoints/inventory/items.js +10 -12
- package/test-integration/endpoints/inventory/journey-prices.test.js +11 -11
- package/test-integration/endpoints/inventory/parcel-zones.test.js +15 -18
- package/test-integration/endpoints/inventory/products.test.js +12 -14
- package/test-integration/endpoints/inventory/promos.test.js +46 -42
- package/test-integration/endpoints/inventory/routes.test.js +13 -15
- package/test-integration/endpoints/inventory/schedule-groups.test.js +23 -23
- package/test-integration/endpoints/inventory/ssrs.test.js +16 -11
- package/test-integration/endpoints/inventory/stations-zones.test.js +5 -6
- package/test-integration/endpoints/inventory/stations.test.js +17 -20
- package/test-integration/endpoints/inventory/trips.test.js +30 -16
- package/test-integration/endpoints/notifications/printed-tickets.test.js +2 -2
- package/test-integration/endpoints/operations/applied_insurance.test.js +9 -11
- package/test-integration/endpoints/operations/manifest.test.js +32 -34
- package/test-integration/endpoints/operations/parcel.test.js +36 -38
- package/test-integration/endpoints/operations/redemption.test.js +9 -12
- package/test-integration/endpoints/operations/segments.js +8 -10
- package/test-integration/endpoints/operations/tickets.test.js +11 -11
- package/test-integration/endpoints/operations/transaction.test.js +1 -1
- package/test-integration/endpoints/operations/transactions.test.js +2 -2
- package/test-integration/endpoints/operations/trip_change_info.test.js +11 -13
- package/test-integration/endpoints/reports/custom-reports.test.js +21 -21
- package/test-integration/endpoints/reports/report-types.test.js +22 -22
- package/test-integration/endpoints/sales/bundles.test.js +5 -5
- package/test-integration/endpoints/sales/cart-promo.test.js +17 -32
- package/test-integration/endpoints/sales/cart.test.js +45 -51
- package/test-integration/endpoints/sales/check-in-info.test.js +2 -2
- package/test-integration/endpoints/sales/custom-fields.test.js +8 -10
- package/test-integration/endpoints/sales/flexpasses.test.js +2 -2
- package/test-integration/endpoints/sales/gift-certificates.test.js +14 -18
- package/test-integration/endpoints/sales/order.test.js +42 -50
- package/test-integration/endpoints/sales/payment-providers.test.js +7 -9
- package/test-integration/endpoints/sales/redeemable-items.test.js +17 -19
- package/test-integration/endpoints/sales/voucher.test.js +12 -14
- package/test-integration/endpoints/seatmaps/access-ticket.test.js +7 -9
- package/test-integration/endpoints/seatmaps/seat.test.js +7 -9
- package/test-integration/endpoints/uploads/files.test.js +14 -14
- package/test-integration/endpoints/uploads/images.test.js +3 -5
- package/test-integration/ports.js +4 -4
- package/test-integration/test-integration-helpers.js +13 -9
package/test/client.test.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const
|
|
1
|
+
const assert = require("node:assert/strict");
|
|
2
2
|
const MockAdapter = require("axios-mock-adapter");
|
|
3
3
|
|
|
4
4
|
const {createApiClient} = require("./../src/client.js");
|
|
5
5
|
const {createTestServer, axiosMock} = require("./test-helpers.js");
|
|
6
6
|
|
|
7
7
|
function expectKnownEndpoints(api) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
assert.ok(api.inventory.products);
|
|
9
|
+
assert.ok(api.inventory.insurances);
|
|
10
|
+
assert.ok(api.inventory.trips);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
describe("client", () => {
|
|
@@ -17,16 +17,16 @@ describe("client", () => {
|
|
|
17
17
|
const api = createApiClient();
|
|
18
18
|
|
|
19
19
|
expectKnownEndpoints(api);
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
assert.deepStrictEqual(api.inventory.__test.client.defaults.baseURL, "https://api.betterez.com/inventory");
|
|
21
|
+
assert.deepStrictEqual(api.inventory.__test.client.defaults.timeout, 15000);
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
it("should create a client with default values", () => {
|
|
25
25
|
const api = createApiClient({baseURL});
|
|
26
26
|
|
|
27
27
|
expectKnownEndpoints(api);
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
assert.deepStrictEqual(api.inventory.__test.client.defaults.baseURL, baseURL);
|
|
29
|
+
assert.deepStrictEqual(api.inventory.__test.client.defaults.timeout, 0);
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
it("should create a client that uses the provided default request headers when making a request to any subsystem", () => {
|
|
@@ -37,13 +37,15 @@ describe("client", () => {
|
|
|
37
37
|
return !ignoredApiProperties.includes(property);
|
|
38
38
|
}
|
|
39
39
|
for (const subsystem of Object.keys(api).filter(propertyIsRelevant)) {
|
|
40
|
-
|
|
40
|
+
Object.entries({"x-amzn-trace-id": "some_value"}).forEach(([k, v]) => {
|
|
41
|
+
assert.deepStrictEqual(api[subsystem].__test.client.defaults.headers[k], v);
|
|
42
|
+
});
|
|
41
43
|
}
|
|
42
44
|
});
|
|
43
45
|
|
|
44
46
|
it("should expose a INTERNAL_AUTH_TOKEN constant", () => {
|
|
45
47
|
const api = createApiClient({baseURL});
|
|
46
|
-
|
|
48
|
+
assert.deepStrictEqual(api.constants.INTERNAL_AUTH_TOKEN_SYMBOL, "internal_auth_token");
|
|
47
49
|
});
|
|
48
50
|
|
|
49
51
|
it("should allow to override baseUrl for custom endpoints", () => {
|
|
@@ -56,12 +58,12 @@ describe("client", () => {
|
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
});
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
assert.ok(api.inventory.products);
|
|
62
|
+
assert.ok(api.inventory.insurances);
|
|
61
63
|
|
|
62
64
|
expectKnownEndpoints(api);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
assert.deepStrictEqual(api.inventory.__test.client.defaults.baseURL, `${baseURL}/somePath`);
|
|
66
|
+
assert.deepStrictEqual(api.inventory.__test.client.defaults.timeout, 10);
|
|
65
67
|
});
|
|
66
68
|
|
|
67
69
|
it("should allow a different baseUrl to be specified for trip search endpoints", () => {
|
|
@@ -75,18 +77,18 @@ describe("client", () => {
|
|
|
75
77
|
});
|
|
76
78
|
|
|
77
79
|
expectKnownEndpoints(api);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
assert.deepStrictEqual(api.inventory.__test.client.defaults.baseURL, "http://localhost:3010/inventory");
|
|
81
|
+
assert.deepStrictEqual(api.inventory.__test_trips.client.defaults.baseURL, "http://localhost:3090/inventory");
|
|
80
82
|
});
|
|
81
83
|
|
|
82
84
|
it("should allow to perform custom request on clean client", () => {
|
|
83
85
|
const api = createApiClient({baseURL, timeout: 0});
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
assert.ok(api.inventory.products);
|
|
87
|
+
assert.ok(api.inventory.insurances);
|
|
86
88
|
|
|
87
89
|
expectKnownEndpoints(api);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
assert.deepStrictEqual(api._cleanClient.defaults.baseURL, baseURL);
|
|
91
|
+
assert.deepStrictEqual(api._cleanClient.defaults.timeout, 0);
|
|
90
92
|
|
|
91
93
|
const mock = new MockAdapter(api._cleanClient);
|
|
92
94
|
mock.onPost("/custom/endpoint").reply(200);
|
|
@@ -100,24 +102,28 @@ describe("client", () => {
|
|
|
100
102
|
describe("with keepAlive enabled in a custom endpoint", () => {
|
|
101
103
|
let mockServer = null;
|
|
102
104
|
|
|
103
|
-
before((
|
|
105
|
+
before(async () => {
|
|
104
106
|
axiosMock.restore();
|
|
105
107
|
mockServer = createTestServer({
|
|
106
108
|
host: "localhost",
|
|
107
109
|
port: 8888,
|
|
108
110
|
maxSockets: 10
|
|
109
111
|
}, (req) => {
|
|
110
|
-
|
|
112
|
+
assert.deepStrictEqual(req.headers.connection, "keep-alive");
|
|
111
113
|
});
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
await new Promise((resolve, reject) => {
|
|
115
|
+
mockServer.create((err) => {
|
|
116
|
+
if (err) return reject(err);
|
|
117
|
+
return resolve();
|
|
118
|
+
});
|
|
115
119
|
});
|
|
116
120
|
});
|
|
117
121
|
|
|
118
|
-
after((
|
|
119
|
-
|
|
120
|
-
|
|
122
|
+
after(async () => {
|
|
123
|
+
await new Promise((resolve) => {
|
|
124
|
+
mockServer.close(() => {
|
|
125
|
+
resolve();
|
|
126
|
+
});
|
|
121
127
|
});
|
|
122
128
|
});
|
|
123
129
|
|
|
@@ -140,24 +146,28 @@ describe("client", () => {
|
|
|
140
146
|
describe("with keepAlive enabled in a known endpoint", () => {
|
|
141
147
|
let mockServer = null;
|
|
142
148
|
|
|
143
|
-
before((
|
|
149
|
+
before(async () => {
|
|
144
150
|
axiosMock.restore();
|
|
145
151
|
mockServer = createTestServer({
|
|
146
152
|
host: "localhost",
|
|
147
153
|
port: 8888,
|
|
148
154
|
maxSockets: 10
|
|
149
155
|
}, (req) => {
|
|
150
|
-
|
|
156
|
+
assert.deepStrictEqual(req.headers.connection, "keep-alive");
|
|
151
157
|
});
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
158
|
+
await new Promise((resolve, reject) => {
|
|
159
|
+
mockServer.create((err) => {
|
|
160
|
+
if (err) return reject(err);
|
|
161
|
+
return resolve();
|
|
162
|
+
});
|
|
155
163
|
});
|
|
156
164
|
});
|
|
157
165
|
|
|
158
|
-
after((
|
|
159
|
-
|
|
160
|
-
|
|
166
|
+
after(async () => {
|
|
167
|
+
await new Promise((resolve) => {
|
|
168
|
+
mockServer.close(() => {
|
|
169
|
+
resolve();
|
|
170
|
+
});
|
|
161
171
|
});
|
|
162
172
|
});
|
|
163
173
|
|
|
@@ -180,24 +190,28 @@ describe("client", () => {
|
|
|
180
190
|
describe.skip("with keepAlive disabled (default)", () => {
|
|
181
191
|
let mockServer = null;
|
|
182
192
|
|
|
183
|
-
before((
|
|
193
|
+
before(async () => {
|
|
184
194
|
axiosMock.restore();
|
|
185
195
|
mockServer = createTestServer({
|
|
186
196
|
host: "localhost",
|
|
187
197
|
port: 8888,
|
|
188
198
|
maxSockets: 120
|
|
189
199
|
}, (req) => {
|
|
190
|
-
|
|
200
|
+
assert.deepStrictEqual(req.headers.connection, "close");
|
|
191
201
|
});
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
202
|
+
await new Promise((resolve, reject) => {
|
|
203
|
+
mockServer.create((err) => {
|
|
204
|
+
if (err) return reject(err);
|
|
205
|
+
return resolve();
|
|
206
|
+
});
|
|
195
207
|
});
|
|
196
208
|
});
|
|
197
209
|
|
|
198
|
-
after((
|
|
199
|
-
|
|
200
|
-
|
|
210
|
+
after(async () => {
|
|
211
|
+
await new Promise((resolve) => {
|
|
212
|
+
mockServer.close(() => {
|
|
213
|
+
resolve();
|
|
214
|
+
});
|
|
201
215
|
});
|
|
202
216
|
});
|
|
203
217
|
|
|
@@ -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("accounts/application-settings/:providerId", () => {
|
|
5
5
|
const token = "I owe you a 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("accounts/applications/:id", () => {
|
|
5
5
|
const token = "I owe you a 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("accounts/users/:userId/current-shift", () => {
|
|
5
5
|
const token = "I owe you a token";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const
|
|
1
|
+
const assert = require("node:assert/strict");
|
|
2
2
|
const base64 = require("base-64");
|
|
3
|
-
const {axiosMock, expectRequest} = require("./../../test-helpers");
|
|
4
|
-
const api = require("./../../../src/client").createApiClient({baseURL: "http://test.com"});
|
|
3
|
+
const {axiosMock, expectRequest} = require("./../../test-helpers.js");
|
|
4
|
+
const api = require("./../../../src/client.js").createApiClient({baseURL: "http://test.com"});
|
|
5
5
|
|
|
6
6
|
describe("accounts/customers", () => {
|
|
7
7
|
const token = "I owe you a token";
|
|
@@ -57,8 +57,8 @@ describe("accounts/customers", () => {
|
|
|
57
57
|
axiosMock.onPost("/customers/cas", {
|
|
58
58
|
service, ticket
|
|
59
59
|
}).reply((response) => {
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
assert.deepStrictEqual(response.data, `{"service":"${service}","ticket":"${ticket}"}`);
|
|
61
|
+
assert.deepStrictEqual(response.headers["x-api-key"], token);
|
|
62
62
|
return [200];
|
|
63
63
|
});
|
|
64
64
|
|
|
@@ -81,17 +81,17 @@ describe("accounts/customers", () => {
|
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
axiosMock.onPost("/customers").reply((config) => {
|
|
84
|
-
|
|
84
|
+
assert.deepStrictEqual(config.params, {
|
|
85
85
|
"x-api-key": apiKey
|
|
86
86
|
});
|
|
87
|
-
|
|
87
|
+
assert.deepStrictEqual(config.headers.Authorization, `Basic ${encodedCredentials}`);
|
|
88
88
|
return [200, response];
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
return api.accounts.customers.signIn({email, password, apiKey})
|
|
92
92
|
.then((httpResponse) => {
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
assert.deepStrictEqual(httpResponse.status, 200);
|
|
94
|
+
assert.deepStrictEqual(httpResponse.data, response);
|
|
95
95
|
});
|
|
96
96
|
});
|
|
97
97
|
|
|
@@ -113,15 +113,15 @@ describe("accounts/customers", () => {
|
|
|
113
113
|
};
|
|
114
114
|
|
|
115
115
|
axiosMock.onPatch(`/customers/${customerId}`).reply((config) => {
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
assert.deepStrictEqual(config.headers.authorization, `Bearer ${jwtToken}`);
|
|
117
|
+
assert.deepStrictEqual(config.headers["x-api-key"], token);
|
|
118
118
|
return [200, response];
|
|
119
119
|
});
|
|
120
120
|
|
|
121
121
|
return api.accounts.customers.update({customerId, token, jwtToken, data})
|
|
122
122
|
.then((httpResponse) => {
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
assert.deepStrictEqual(httpResponse.status, 200);
|
|
124
|
+
assert.deepStrictEqual(httpResponse.data, response);
|
|
125
125
|
});
|
|
126
126
|
});
|
|
127
127
|
|
|
@@ -136,15 +136,15 @@ describe("accounts/customers", () => {
|
|
|
136
136
|
};
|
|
137
137
|
|
|
138
138
|
axiosMock.onPost("/customers/merge", data).reply((config) => {
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
assert.deepStrictEqual(config.headers.authorization, `Bearer ${jwtToken}`);
|
|
140
|
+
assert.deepStrictEqual(config.headers["x-api-key"], token);
|
|
141
141
|
return [200, response];
|
|
142
142
|
});
|
|
143
143
|
|
|
144
144
|
return api.accounts.customers.merge({destinationCustomerId, sourceCustomerIds, token, jwtToken})
|
|
145
145
|
.then((httpResponse) => {
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
assert.deepStrictEqual(httpResponse.status, 200);
|
|
147
|
+
assert.deepStrictEqual(httpResponse.data, response);
|
|
148
148
|
});
|
|
149
149
|
});
|
|
150
150
|
});
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
const {axiosMock, expectRequest} = require("../../test-helpers");
|
|
2
|
-
const api = require("../../../src/client").createApiClient({baseURL: "http://test.com"});
|
|
3
|
-
const
|
|
4
|
-
expect
|
|
5
|
-
} = require("chai");
|
|
1
|
+
const {axiosMock, expectRequest} = require("../../test-helpers.js");
|
|
2
|
+
const api = require("../../../src/client.js").createApiClient({baseURL: "http://test.com"});
|
|
3
|
+
const assert = require("node:assert/strict");
|
|
6
4
|
|
|
7
5
|
describe("accounts/domains", () => {
|
|
8
6
|
const token = "I owe you a token";
|
|
@@ -20,7 +18,7 @@ describe("accounts/domains", () => {
|
|
|
20
18
|
return api.accounts.domains.all({
|
|
21
19
|
token
|
|
22
20
|
}).then((httpResponse) => {
|
|
23
|
-
|
|
21
|
+
assert.deepStrictEqual(httpResponse.status, 200);
|
|
24
22
|
});
|
|
25
23
|
});
|
|
26
24
|
|
|
@@ -38,7 +36,7 @@ describe("accounts/domains", () => {
|
|
|
38
36
|
jwtToken,
|
|
39
37
|
data
|
|
40
38
|
}).then((httpResponse) => {
|
|
41
|
-
|
|
39
|
+
assert.deepStrictEqual(httpResponse.status, 200);
|
|
42
40
|
});
|
|
43
41
|
});
|
|
44
42
|
|
|
@@ -55,7 +53,7 @@ describe("accounts/domains", () => {
|
|
|
55
53
|
token,
|
|
56
54
|
jwtToken
|
|
57
55
|
}).then((httpResponse) => {
|
|
58
|
-
|
|
56
|
+
assert.deepStrictEqual(httpResponse.status, 204);
|
|
59
57
|
});
|
|
60
58
|
});
|
|
61
59
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const assert = require("node:assert/strict");
|
|
2
2
|
const {axiosMock, expectRequest} = require("./../../test-helpers.js");
|
|
3
3
|
const api = require("./../../../src/client.js").createApiClient({baseURL: "http://test.com"});
|
|
4
4
|
|
|
@@ -21,7 +21,7 @@ describe("accounts/exchange-rates", () => {
|
|
|
21
21
|
jwtToken,
|
|
22
22
|
isoCode
|
|
23
23
|
}).then((httpResponse) => {
|
|
24
|
-
|
|
24
|
+
assert.deepStrictEqual(httpResponse.status, 200);
|
|
25
25
|
});
|
|
26
26
|
});
|
|
27
27
|
|
|
@@ -39,7 +39,7 @@ describe("accounts/exchange-rates", () => {
|
|
|
39
39
|
jwtToken,
|
|
40
40
|
data
|
|
41
41
|
}).then((httpResponse) => {
|
|
42
|
-
|
|
42
|
+
assert.deepStrictEqual(httpResponse.status, 200);
|
|
43
43
|
});
|
|
44
44
|
});
|
|
45
45
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const assert = require("node:assert/strict");
|
|
2
2
|
const {axiosMock, expectRequest} = require("../../test-helpers.js");
|
|
3
3
|
const api = require("../../../src/client.js").createApiClient({baseURL: "http://test.com"});
|
|
4
4
|
|
|
@@ -24,7 +24,7 @@ describe("accounts/exchange-receipt-settings", () => {
|
|
|
24
24
|
jwtToken,
|
|
25
25
|
data
|
|
26
26
|
}).then((httpResponse) => {
|
|
27
|
-
|
|
27
|
+
assert.deepStrictEqual(httpResponse.status, 200);
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
30
|
|
|
@@ -38,7 +38,7 @@ describe("accounts/exchange-receipt-settings", () => {
|
|
|
38
38
|
token,
|
|
39
39
|
jwtToken
|
|
40
40
|
}).then((httpResponse) => {
|
|
41
|
-
|
|
41
|
+
assert.deepStrictEqual(httpResponse.status, 200);
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
44
|
});
|
|
@@ -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("accounts/images", () => {
|
|
5
5
|
const token = "I owe you a token";
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
const
|
|
2
|
-
expect
|
|
3
|
-
} = require("chai");
|
|
1
|
+
const assert = require("node:assert/strict");
|
|
4
2
|
const {
|
|
5
3
|
axiosMock,
|
|
6
4
|
expectRequest
|
|
@@ -23,7 +21,7 @@ describe("accounts/interline", () => {
|
|
|
23
21
|
return api.accounts.interline.invitations.all({
|
|
24
22
|
token
|
|
25
23
|
}).then((httpResponse) => {
|
|
26
|
-
|
|
24
|
+
assert.deepStrictEqual(httpResponse.status, 200);
|
|
27
25
|
});
|
|
28
26
|
});
|
|
29
27
|
|
|
@@ -38,7 +36,7 @@ describe("accounts/interline", () => {
|
|
|
38
36
|
invitationId,
|
|
39
37
|
token
|
|
40
38
|
}).then((httpResponse) => {
|
|
41
|
-
|
|
39
|
+
assert.deepStrictEqual(httpResponse.status, 200);
|
|
42
40
|
});
|
|
43
41
|
});
|
|
44
42
|
|
|
@@ -56,7 +54,7 @@ describe("accounts/interline", () => {
|
|
|
56
54
|
jwtToken,
|
|
57
55
|
data
|
|
58
56
|
}).then((httpResponse) => {
|
|
59
|
-
|
|
57
|
+
assert.deepStrictEqual(httpResponse.status, 200);
|
|
60
58
|
});
|
|
61
59
|
});
|
|
62
60
|
|
|
@@ -76,7 +74,7 @@ describe("accounts/interline", () => {
|
|
|
76
74
|
jwtToken,
|
|
77
75
|
data
|
|
78
76
|
}).then((httpResponse) => {
|
|
79
|
-
|
|
77
|
+
assert.deepStrictEqual(httpResponse.status, 200);
|
|
80
78
|
});
|
|
81
79
|
});
|
|
82
80
|
|
|
@@ -93,7 +91,7 @@ describe("accounts/interline", () => {
|
|
|
93
91
|
token,
|
|
94
92
|
jwtToken
|
|
95
93
|
}).then((httpResponse) => {
|
|
96
|
-
|
|
94
|
+
assert.deepStrictEqual(httpResponse.status, 204);
|
|
97
95
|
});
|
|
98
96
|
});
|
|
99
97
|
|
|
@@ -105,7 +103,7 @@ describe("accounts/interline", () => {
|
|
|
105
103
|
return api.accounts.interline.providers.all({
|
|
106
104
|
token
|
|
107
105
|
}).then((httpResponse) => {
|
|
108
|
-
|
|
106
|
+
assert.deepStrictEqual(httpResponse.status, 200);
|
|
109
107
|
});
|
|
110
108
|
});
|
|
111
109
|
|
|
@@ -117,7 +115,7 @@ describe("accounts/interline", () => {
|
|
|
117
115
|
return api.accounts.interline.consumers.all({
|
|
118
116
|
token
|
|
119
117
|
}).then((httpResponse) => {
|
|
120
|
-
|
|
118
|
+
assert.deepStrictEqual(httpResponse.status, 200);
|
|
121
119
|
});
|
|
122
120
|
});
|
|
123
121
|
|
|
@@ -136,7 +134,7 @@ describe("accounts/interline", () => {
|
|
|
136
134
|
|
|
137
135
|
return api.accounts.interline.network.update({interlineId, token, jwtToken, data})
|
|
138
136
|
.then((httpResponse) => {
|
|
139
|
-
|
|
137
|
+
assert.deepStrictEqual(httpResponse.status, 200);
|
|
140
138
|
});
|
|
141
139
|
});
|
|
142
140
|
|
|
@@ -151,7 +149,7 @@ describe("accounts/interline", () => {
|
|
|
151
149
|
interlineId,
|
|
152
150
|
token
|
|
153
151
|
}).then((httpResponse) => {
|
|
154
|
-
|
|
152
|
+
assert.deepStrictEqual(httpResponse.status, 200);
|
|
155
153
|
});
|
|
156
154
|
});
|
|
157
155
|
});
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
const
|
|
2
|
-
expect
|
|
3
|
-
} = require("chai");
|
|
1
|
+
const assert = require("node:assert/strict");
|
|
4
2
|
const {
|
|
5
3
|
axiosMock,
|
|
6
4
|
expectRequest
|
|
@@ -25,7 +23,7 @@ describe("accounts/interline", () => {
|
|
|
25
23
|
token,
|
|
26
24
|
jwtToken
|
|
27
25
|
}).then((httpResponse) => {
|
|
28
|
-
|
|
26
|
+
assert.deepStrictEqual(httpResponse.status, 200);
|
|
29
27
|
});
|
|
30
28
|
});
|
|
31
29
|
|
|
@@ -40,7 +38,7 @@ describe("accounts/interline", () => {
|
|
|
40
38
|
sellerId: "sellerId",
|
|
41
39
|
jwtToken
|
|
42
40
|
}).then((httpResponse) => {
|
|
43
|
-
|
|
41
|
+
assert.deepStrictEqual(httpResponse.status, 200);
|
|
44
42
|
});
|
|
45
43
|
});
|
|
46
44
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const {axiosMock, expectRequest} = require("./../../test-helpers.js");
|
|
2
2
|
const api = require("./../../../src/client.js").createApiClient({baseURL: "http://test.com"});
|
|
3
|
-
const
|
|
3
|
+
const assert = require("node:assert/strict");
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
describe("accounts/people-lookups", () => {
|
|
@@ -65,9 +65,9 @@ describe("accounts/people-lookups", () => {
|
|
|
65
65
|
jwtToken, token, personId, person
|
|
66
66
|
})
|
|
67
67
|
.then((res) => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
assert.deepStrictEqual(res.config.params, {});
|
|
69
|
+
assert.deepStrictEqual(res.config.data, JSON.stringify({person}));
|
|
70
|
+
assert.deepStrictEqual(res.status, 200);
|
|
71
71
|
});
|
|
72
72
|
});
|
|
73
73
|
|
|
@@ -87,9 +87,9 @@ describe("accounts/people-lookups", () => {
|
|
|
87
87
|
jwtToken, token, personId, person, providerId
|
|
88
88
|
})
|
|
89
89
|
.then((res) => {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
assert.deepStrictEqual(res.config.params, {providerId});
|
|
91
|
+
assert.deepStrictEqual(res.config.data, JSON.stringify({person}));
|
|
92
|
+
assert.deepStrictEqual(res.status, 200);
|
|
93
93
|
});
|
|
94
94
|
});
|
|
95
95
|
|
|
@@ -109,9 +109,9 @@ describe("accounts/people-lookups", () => {
|
|
|
109
109
|
token, jwtToken, person
|
|
110
110
|
})
|
|
111
111
|
.then((res) => {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
assert.deepStrictEqual(res.config.params, {});
|
|
113
|
+
assert.deepStrictEqual(res.config.data, JSON.stringify({person}));
|
|
114
|
+
assert.deepStrictEqual(res.status, 200);
|
|
115
115
|
});
|
|
116
116
|
});
|
|
117
117
|
|
|
@@ -131,9 +131,9 @@ describe("accounts/people-lookups", () => {
|
|
|
131
131
|
token, jwtToken, person, providerId
|
|
132
132
|
})
|
|
133
133
|
.then((res) => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
assert.deepStrictEqual(res.config.params, {providerId});
|
|
135
|
+
assert.deepStrictEqual(res.config.data, JSON.stringify({person}));
|
|
136
|
+
assert.deepStrictEqual(res.status, 200);
|
|
137
137
|
});
|
|
138
138
|
});
|
|
139
139
|
|
|
@@ -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("accounts/accounts/print-templates", () => {
|
|
5
5
|
const token = "I owe you a token";
|
|
@@ -60,7 +60,7 @@ describe("accounts/accounts/print-templates", () => {
|
|
|
60
60
|
jwtToken
|
|
61
61
|
}));
|
|
62
62
|
return api.accounts.printTemplates.versions.update({
|
|
63
|
-
token, jwtToken, query, versionId, printTemplateId
|
|
63
|
+
token, jwtToken, query, versionId, printTemplateId
|
|
64
64
|
});
|
|
65
65
|
});
|
|
66
66
|
|
|
@@ -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("accounts/printers", () => {
|
|
5
5
|
const token = "I owe you a 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("accounts/tokens", () => {
|
|
5
5
|
const token = "I owe you a 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("accounts/trusted-machines", () => {
|
|
5
5
|
const token = "I owe you a token";
|