btrz-api-client 8.65.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/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/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/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
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
const {
|
|
2
|
-
const api = require("./../../../src/client").createApiClient({
|
|
3
|
-
const expect = require("chai").expect;
|
|
1
|
+
const {axiosMock, expectRequest} = require("./../../test-helpers.js");
|
|
2
|
+
const api = require("./../../../src/client.js").createApiClient({baseURL: ""});
|
|
4
3
|
|
|
5
|
-
describe(
|
|
6
|
-
const token =
|
|
7
|
-
const jwtToken =
|
|
4
|
+
describe("sales/sync-entry", () => {
|
|
5
|
+
const token = "I owe you a token";
|
|
6
|
+
const jwtToken = "I owe you a JWT token";
|
|
8
7
|
|
|
9
|
-
afterEach(
|
|
8
|
+
afterEach(() => {
|
|
10
9
|
axiosMock.reset();
|
|
11
10
|
});
|
|
12
11
|
|
|
13
|
-
it("should call patch for entries in synchrotron",
|
|
12
|
+
it("should call patch for entries in synchrotron", () => {
|
|
14
13
|
const data = {};
|
|
15
|
-
axiosMock.onPatch("/sync-entry").reply(expectRequest({
|
|
16
|
-
return api.sales.syncEntry.patch({
|
|
14
|
+
axiosMock.onPatch("/sync-entry").reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
15
|
+
return api.sales.syncEntry.patch({jwtToken, token, data});
|
|
17
16
|
});
|
|
18
|
-
|
|
19
17
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
const {
|
|
2
|
-
const api = require("./../../../src/client").createApiClient({
|
|
3
|
-
const expect = require("chai").expect;
|
|
1
|
+
const {axiosMock, expectRequest} = require("./../../test-helpers.js");
|
|
2
|
+
const api = require("./../../../src/client.js").createApiClient({baseURL: "http://test.com"});
|
|
4
3
|
|
|
5
|
-
describe(
|
|
6
|
-
const token =
|
|
4
|
+
describe("sales/voucher", () => {
|
|
5
|
+
const token = "I owe you a token";
|
|
6
|
+
let voucher = null;
|
|
7
7
|
|
|
8
|
-
beforeEach(
|
|
9
|
-
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
voucher = {
|
|
10
10
|
number: "1234",
|
|
11
11
|
firstName: "joe",
|
|
12
12
|
lastName: "joe",
|
|
@@ -14,26 +14,28 @@ describe('sales/voucher', function() {
|
|
|
14
14
|
};
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
afterEach(
|
|
17
|
+
afterEach(() => {
|
|
18
18
|
axiosMock.reset();
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
it("should get a voucher",
|
|
21
|
+
it("should get a voucher", () => {
|
|
22
22
|
axiosMock
|
|
23
|
-
.onGet(`/vouchers/${voucher.number}?cartId=${voucher.cartId}
|
|
23
|
+
.onGet(`/vouchers/${voucher.number}?cartId=${voucher.cartId}` +
|
|
24
|
+
`&firstName=${voucher.firstName}&lastName=${voucher.lastName}&displayCurrencyCode=`)
|
|
24
25
|
.reply(
|
|
25
|
-
expectRequest({
|
|
26
|
+
expectRequest({statusCode: 200, token})
|
|
26
27
|
);
|
|
27
|
-
return api.sales.voucher.get({
|
|
28
|
+
return api.sales.voucher.get({token, voucher});
|
|
28
29
|
});
|
|
29
30
|
|
|
30
|
-
it("should get a voucher with displayCurrencyCode",
|
|
31
|
+
it("should get a voucher with displayCurrencyCode", () => {
|
|
31
32
|
voucher.displayCurrencyCode = "GBP";
|
|
32
33
|
axiosMock
|
|
33
|
-
.onGet(`/vouchers/${voucher.number}?cartId=${voucher.cartId}
|
|
34
|
+
.onGet(`/vouchers/${voucher.number}?cartId=${voucher.cartId}` +
|
|
35
|
+
`&firstName=${voucher.firstName}&lastName=${voucher.lastName}&displayCurrencyCode=GBP`)
|
|
34
36
|
.reply(
|
|
35
|
-
expectRequest({
|
|
37
|
+
expectRequest({statusCode: 200, token})
|
|
36
38
|
);
|
|
37
|
-
return api.sales.voucher.get({
|
|
39
|
+
return api.sales.voucher.get({token, voucher});
|
|
38
40
|
});
|
|
39
|
-
});
|
|
41
|
+
});
|
|
@@ -1,16 +1,16 @@
|
|
|
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: "http://test.com"});
|
|
3
3
|
|
|
4
4
|
describe("seatmaps/ticket", () => {
|
|
5
|
-
const token =
|
|
6
|
-
|
|
5
|
+
const token = "I owe you a token";
|
|
6
|
+
const jwtToken = "I owe you a JWT token";
|
|
7
7
|
|
|
8
|
-
afterEach(
|
|
8
|
+
afterEach(() => {
|
|
9
9
|
axiosMock.restore();
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
it("should return an access ticket", () => {
|
|
13
|
-
axiosMock.onPost(
|
|
13
|
+
axiosMock.onPost("/access-ticket").reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
14
14
|
return api.seatmaps.accessTicket.create({
|
|
15
15
|
jwtToken,
|
|
16
16
|
token
|
|
@@ -1,11 +1,11 @@
|
|
|
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: "http://test.com"});
|
|
3
3
|
|
|
4
4
|
describe("seatmaps/seat", () => {
|
|
5
|
-
const token =
|
|
6
|
-
|
|
5
|
+
const token = "I owe you a token";
|
|
6
|
+
const jwtToken = "I owe you a JWT token";
|
|
7
7
|
|
|
8
|
-
afterEach(
|
|
8
|
+
afterEach(() => {
|
|
9
9
|
axiosMock.restore();
|
|
10
10
|
});
|
|
11
11
|
|
|
@@ -15,7 +15,7 @@ describe("seatmaps/seat", () => {
|
|
|
15
15
|
"seatmap_id": "123",
|
|
16
16
|
"seat_id": "555"
|
|
17
17
|
};
|
|
18
|
-
axiosMock.onPost(
|
|
18
|
+
axiosMock.onPost("/seat").reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
19
19
|
return api.seatmaps.seat.update({
|
|
20
20
|
jwtToken,
|
|
21
21
|
token,
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
const {
|
|
2
|
-
const api = require("./../../../src/client").createApiClient({
|
|
1
|
+
const {axiosMock} = require("./../../test-helpers.js");
|
|
2
|
+
const api = require("./../../../src/client.js").createApiClient({baseURL: "http://test.com"});
|
|
3
3
|
|
|
4
|
-
describe(
|
|
5
|
-
const token =
|
|
4
|
+
describe("uploads/files", () => {
|
|
5
|
+
const token = "I owe you a token";
|
|
6
6
|
|
|
7
7
|
afterEach(() => {
|
|
8
8
|
axiosMock.reset();
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
it("should upload the provided form data", () => {
|
|
12
|
-
axiosMock.onPost(
|
|
13
|
-
if(headers[
|
|
12
|
+
axiosMock.onPost("/files").reply(({headers, method}) => {
|
|
13
|
+
if (headers["x-api-key"] && headers["x-api-key"] === token &&
|
|
14
14
|
method === "post") {
|
|
15
15
|
return [200];
|
|
16
16
|
}
|
|
17
|
+
return [403];
|
|
17
18
|
});
|
|
18
19
|
|
|
19
20
|
return api.uploads.files.upload({
|
|
@@ -23,7 +24,7 @@ describe('uploads/files', () => {
|
|
|
23
24
|
type: "journey-prices",
|
|
24
25
|
file: null,
|
|
25
26
|
cbType: "email",
|
|
26
|
-
cbValue: "noreply@betterez.com"
|
|
27
|
+
cbValue: "noreply@betterez.com"
|
|
27
28
|
}
|
|
28
29
|
});
|
|
29
30
|
});
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
const {
|
|
2
|
-
const api = require("./../../../src/client").createApiClient({
|
|
1
|
+
const {axiosMock} = require("./../../test-helpers.js");
|
|
2
|
+
const api = require("./../../../src/client.js").createApiClient({baseURL: "http://test.com"});
|
|
3
3
|
|
|
4
|
-
describe(
|
|
5
|
-
const token =
|
|
4
|
+
describe("uploads/images", () => {
|
|
5
|
+
const token = "I owe you a token";
|
|
6
6
|
|
|
7
7
|
afterEach(() => {
|
|
8
8
|
axiosMock.reset();
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
it("should upload the provided form data", () => {
|
|
12
|
-
axiosMock.onPost(
|
|
13
|
-
if (headers[
|
|
12
|
+
axiosMock.onPost("/images").reply(({headers, method}) => {
|
|
13
|
+
if (headers["x-api-key"] && headers["x-api-key"] === token &&
|
|
14
14
|
method === "post") {
|
|
15
15
|
return [200];
|
|
16
16
|
}
|
|
17
|
+
return [403];
|
|
17
18
|
});
|
|
18
19
|
|
|
19
20
|
return api.uploads.images.create({
|
|
20
21
|
token,
|
|
21
22
|
formData: {
|
|
22
|
-
file: null
|
|
23
|
+
file: null
|
|
23
24
|
}
|
|
24
25
|
});
|
|
25
26
|
});
|
|
@@ -1,34 +1,34 @@
|
|
|
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: "http://test.com"});
|
|
3
3
|
|
|
4
4
|
describe("webhooks/subscriptions", () => {
|
|
5
|
-
const token =
|
|
6
|
-
|
|
5
|
+
const token = "I owe you a token";
|
|
6
|
+
const jwtToken = "I owe you a JWT token";
|
|
7
7
|
|
|
8
|
-
afterEach(
|
|
8
|
+
afterEach(() => {
|
|
9
9
|
axiosMock.restore();
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
it("should list subscriptions", () => {
|
|
13
|
-
axiosMock.onGet("/subscriptions").reply(expectRequest({
|
|
14
|
-
return api.webhooks.subscriptions.all({token, jwtToken})
|
|
13
|
+
axiosMock.onGet("/subscriptions").reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
14
|
+
return api.webhooks.subscriptions.all({token, jwtToken});
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
it("should get a subscription by id",
|
|
17
|
+
it("should get a subscription by id", () => {
|
|
18
18
|
const id = "subscriptionId";
|
|
19
|
-
axiosMock.onGet(`/subscriptions/${id}`).reply(expectRequest({
|
|
20
|
-
return api.webhooks.subscriptions.getById({
|
|
19
|
+
axiosMock.onGet(`/subscriptions/${id}`).reply(expectRequest({statusCode: 200, token}));
|
|
20
|
+
return api.webhooks.subscriptions.getById({token, id});
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
it("should delete a subscription by id",
|
|
23
|
+
it("should delete a subscription by id", () => {
|
|
24
24
|
const id = "subscriptionId";
|
|
25
|
-
axiosMock.onDelete(`/subscriptions/${id}`).reply(expectRequest({
|
|
26
|
-
return api.webhooks.subscriptions.deleteById({
|
|
25
|
+
axiosMock.onDelete(`/subscriptions/${id}`).reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
26
|
+
return api.webhooks.subscriptions.deleteById({token, id, jwtToken});
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
it("should create a subscription", () => {
|
|
31
|
-
axiosMock.onPost(
|
|
31
|
+
axiosMock.onPost("/subscriptions").reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
32
32
|
return api.webhooks.subscriptions.create({
|
|
33
33
|
jwtToken,
|
|
34
34
|
token,
|
|
@@ -44,18 +44,18 @@ describe("webhooks/subscriptions", () => {
|
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
it("should PUT a subscription",
|
|
48
|
-
const id = "123123123123"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
axiosMock.onPut(`/subscriptions/${id}`).reply(expectRequest({
|
|
59
|
-
return api.webhooks.subscriptions.put({
|
|
47
|
+
it("should PUT a subscription", () => {
|
|
48
|
+
const id = "123123123123";
|
|
49
|
+
const subscription = {
|
|
50
|
+
accumulateOn: "redemption",
|
|
51
|
+
disabled: false,
|
|
52
|
+
expirationDays: 20,
|
|
53
|
+
name: "An updated subscription",
|
|
54
|
+
terms: "Updated webhooks subscription terms",
|
|
55
|
+
paymentMethods: ["cash"],
|
|
56
|
+
products: ["123123123"]
|
|
57
|
+
};
|
|
58
|
+
axiosMock.onPut(`/subscriptions/${id}`).reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
59
|
+
return api.webhooks.subscriptions.put({jwtToken, token, id, subscription});
|
|
60
60
|
});
|
|
61
61
|
});
|
|
@@ -1,29 +1,29 @@
|
|
|
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: "http://test.com"});
|
|
3
3
|
|
|
4
4
|
describe("webhooks/undelivered", () => {
|
|
5
|
-
const token =
|
|
6
|
-
|
|
5
|
+
const token = "I owe you a token";
|
|
6
|
+
const jwtToken = "I owe you a JWT token";
|
|
7
7
|
|
|
8
|
-
afterEach(
|
|
8
|
+
afterEach(() => {
|
|
9
9
|
axiosMock.restore();
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
it("should list undelivered", () => {
|
|
13
|
-
axiosMock.onGet("/undelivered").reply(expectRequest({
|
|
14
|
-
return api.webhooks.undelivered.all({token, jwtToken})
|
|
13
|
+
axiosMock.onGet("/undelivered").reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
14
|
+
return api.webhooks.undelivered.all({token, jwtToken});
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
it("should get an undelivered by id",
|
|
17
|
+
it("should get an undelivered by id", () => {
|
|
18
18
|
const id = "undeliveredId";
|
|
19
|
-
axiosMock.onGet(`/undelivered/${id}`).reply(expectRequest({
|
|
20
|
-
return api.webhooks.undelivered.getById({
|
|
19
|
+
axiosMock.onGet(`/undelivered/${id}`).reply(expectRequest({statusCode: 200, token}));
|
|
20
|
+
return api.webhooks.undelivered.getById({token, id});
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
it("should delete an undelivered by id",
|
|
23
|
+
it("should delete an undelivered by id", () => {
|
|
24
24
|
const id = "undeliveredId";
|
|
25
|
-
axiosMock.onDelete(`/undelivered/${id}`).reply(expectRequest({
|
|
26
|
-
return api.webhooks.undelivered.deleteById({
|
|
25
|
+
axiosMock.onDelete(`/undelivered/${id}`).reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
26
|
+
return api.webhooks.undelivered.deleteById({token, jwtToken, id});
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
it("should delete all undelivered webhooks", () => {
|
|
@@ -31,19 +31,19 @@ describe("webhooks/undelivered", () => {
|
|
|
31
31
|
return api.webhooks.undelivered.deleteAll({token, jwtToken});
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
it("should patch an undelivered",
|
|
35
|
-
axiosMock.onPatch("/undelivered").reply(expectRequest({
|
|
36
|
-
return api.webhooks.undelivered.patch({
|
|
34
|
+
it("should patch an undelivered", () => {
|
|
35
|
+
axiosMock.onPatch("/undelivered").reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
36
|
+
return api.webhooks.undelivered.patch({jwtToken, token, operation: {}});
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
-
it("should resend an undelivered",
|
|
39
|
+
it("should resend an undelivered", () => {
|
|
40
40
|
const id = "123123123123";
|
|
41
|
-
axiosMock.onPut(`/undelivered/${id}/retry`).reply(expectRequest({
|
|
42
|
-
return api.webhooks.undelivered.resend({
|
|
41
|
+
axiosMock.onPut(`/undelivered/${id}/retry`).reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
42
|
+
return api.webhooks.undelivered.resend({jwtToken, token, id});
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
it("should resend all the undelivered",
|
|
46
|
-
axiosMock.onPut(
|
|
47
|
-
return api.webhooks.undelivered.resendAll({
|
|
45
|
+
it("should resend all the undelivered", () => {
|
|
46
|
+
axiosMock.onPut("/undelivered/retry-all").reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
47
|
+
return api.webhooks.undelivered.resendAll({jwtToken, token});
|
|
48
48
|
});
|
|
49
49
|
});
|
|
@@ -1,22 +1,22 @@
|
|
|
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: "http://test.com"});
|
|
3
3
|
|
|
4
4
|
describe("webhooks/", () => {
|
|
5
|
-
const token =
|
|
6
|
-
|
|
5
|
+
const token = "I owe you a token";
|
|
6
|
+
const jwtToken = "I owe you a JWT token";
|
|
7
7
|
|
|
8
|
-
afterEach(
|
|
8
|
+
afterEach(() => {
|
|
9
9
|
axiosMock.restore();
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
it("should emit a webhook", () => {
|
|
13
|
-
axiosMock.onPost(
|
|
13
|
+
axiosMock.onPost("/emit").reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
14
14
|
return api.webhooks.webhooks.emit({
|
|
15
15
|
jwtToken,
|
|
16
16
|
token,
|
|
17
17
|
webhook: {
|
|
18
18
|
id: "5d4c7e96135a4f9b05d37ba2",
|
|
19
|
-
event: "transaction.completed",
|
|
19
|
+
event: "transaction.completed",
|
|
20
20
|
url: "https://httpbin.org/post"
|
|
21
21
|
}
|
|
22
22
|
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
describe,
|
|
5
|
+
it,
|
|
6
|
+
before,
|
|
7
|
+
after,
|
|
8
|
+
beforeEach,
|
|
9
|
+
afterEach,
|
|
10
|
+
test
|
|
11
|
+
} = require("node:test");
|
|
12
|
+
|
|
13
|
+
global.describe = describe;
|
|
14
|
+
global.it = it;
|
|
15
|
+
global.before = before;
|
|
16
|
+
global.after = after;
|
|
17
|
+
global.beforeEach = beforeEach;
|
|
18
|
+
global.afterEach = afterEach;
|
|
19
|
+
global.test = test;
|
package/test/test-helpers.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const axios = require("axios");
|
|
2
2
|
const MockAdapter = require("axios-mock-adapter");
|
|
3
3
|
const http = require("http");
|
|
4
|
-
const
|
|
4
|
+
const assert = require("node:assert/strict");
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
7
|
axiosMock: new MockAdapter(axios),
|
|
@@ -11,10 +11,10 @@ module.exports = {
|
|
|
11
11
|
}) {
|
|
12
12
|
return ({headers, method, data, params}) => {
|
|
13
13
|
if (body) {
|
|
14
|
-
|
|
14
|
+
assert.deepStrictEqual(data, JSON.stringify(body));
|
|
15
15
|
}
|
|
16
16
|
if (query) {
|
|
17
|
-
|
|
17
|
+
assert.deepStrictEqual(params, query);
|
|
18
18
|
}
|
|
19
19
|
if ((headers["x-api-key"] && headers["x-api-key"] === token) || withoutApiKey) {
|
|
20
20
|
const methods = ["post", "put", "delete", "patch"];
|
|
@@ -44,7 +44,7 @@ module.exports = {
|
|
|
44
44
|
mockServer.on("connection", (socket) => {
|
|
45
45
|
sockets.add(socket);
|
|
46
46
|
if (config.maxSockets) {
|
|
47
|
-
|
|
47
|
+
assert.ok(sockets.size <= config.maxSockets);
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
50
|
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
require("./endpoints/accounts/current-shifts.test.js");
|
|
2
|
+
require("./endpoints/accounts/docs.test.js");
|
|
3
|
+
require("./endpoints/accounts/lexicons.test.js");
|
|
4
|
+
require("./endpoints/accounts/shifts.test.js");
|
|
5
|
+
require("./endpoints/accounts/users.test.js");
|
|
6
|
+
require("./endpoints/btrzpay/customerCards.test.js");
|
|
7
|
+
require("./endpoints/btrzpay/customers.test.js");
|
|
8
|
+
require("./endpoints/btrzpay/payment-methods.test.js");
|
|
9
|
+
require("./endpoints/btrzpay/payments.test.js");
|
|
10
|
+
require("./endpoints/btrzpay/reference-numbers.test.js");
|
|
11
|
+
require("./endpoints/btrzpay/referenced-payments.test.js");
|
|
12
|
+
require("./endpoints/client.test.js");
|
|
13
|
+
require("./endpoints/inventory/amenities.test.js");
|
|
14
|
+
require("./endpoints/inventory/amenity-groups.test.js");
|
|
15
|
+
require("./endpoints/inventory/bundle-fares.test.js");
|
|
16
|
+
require("./endpoints/inventory/companies.test.js");
|
|
17
|
+
require("./endpoints/inventory/countries.test.js");
|
|
18
|
+
require("./endpoints/inventory/custom-fields.test.js");
|
|
19
|
+
require("./endpoints/inventory/docs.test.js");
|
|
20
|
+
require("./endpoints/inventory/fare-classes.test.js");
|
|
21
|
+
require("./endpoints/inventory/fares.test.js");
|
|
22
|
+
require("./endpoints/inventory/fees.test.js");
|
|
23
|
+
require("./endpoints/inventory/filtered-trips.test.js");
|
|
24
|
+
require("./endpoints/inventory/gift-certificate-definitions.test.js");
|
|
25
|
+
require("./endpoints/inventory/insurances.test.js");
|
|
26
|
+
require("./endpoints/inventory/items.js");
|
|
27
|
+
require("./endpoints/inventory/journey-prices.test.js");
|
|
28
|
+
require("./endpoints/inventory/parcel-zones.test.js");
|
|
29
|
+
require("./endpoints/inventory/products.test.js");
|
|
30
|
+
require("./endpoints/inventory/promos.test.js");
|
|
31
|
+
require("./endpoints/inventory/routes.test.js");
|
|
32
|
+
require("./endpoints/inventory/schedule-groups.test.js");
|
|
33
|
+
require("./endpoints/inventory/ssrs.test.js");
|
|
34
|
+
require("./endpoints/inventory/stations-zones.test.js");
|
|
35
|
+
require("./endpoints/inventory/stations.test.js");
|
|
36
|
+
require("./endpoints/inventory/trips.test.js");
|
|
37
|
+
require("./endpoints/notifications/printed-tickets.test.js");
|
|
38
|
+
require("./endpoints/operations/applied_insurance.test.js");
|
|
39
|
+
require("./endpoints/operations/manifest.test.js");
|
|
40
|
+
require("./endpoints/operations/parcel.test.js");
|
|
41
|
+
require("./endpoints/operations/redemption.test.js");
|
|
42
|
+
require("./endpoints/operations/segments.js");
|
|
43
|
+
require("./endpoints/operations/tickets.test.js");
|
|
44
|
+
require("./endpoints/operations/transaction.test.js");
|
|
45
|
+
require("./endpoints/operations/transactions.test.js");
|
|
46
|
+
require("./endpoints/operations/trip_change_info.test.js");
|
|
47
|
+
require("./endpoints/reports/custom-reports.test.js");
|
|
48
|
+
require("./endpoints/reports/report-types.test.js");
|
|
49
|
+
require("./endpoints/sales/bundles.test.js");
|
|
50
|
+
require("./endpoints/sales/cart-promo.test.js");
|
|
51
|
+
require("./endpoints/sales/cart.test.js");
|
|
52
|
+
require("./endpoints/sales/check-in-info.test.js");
|
|
53
|
+
require("./endpoints/sales/custom-fields.test.js");
|
|
54
|
+
require("./endpoints/sales/flexpasses.test.js");
|
|
55
|
+
require("./endpoints/sales/gift-certificates.test.js");
|
|
56
|
+
require("./endpoints/sales/order.test.js");
|
|
57
|
+
require("./endpoints/sales/payment-providers.test.js");
|
|
58
|
+
require("./endpoints/sales/redeemable-items.test.js");
|
|
59
|
+
require("./endpoints/sales/voucher.test.js");
|
|
60
|
+
require("./endpoints/seatmaps/access-ticket.test.js");
|
|
61
|
+
require("./endpoints/seatmaps/seat.test.js");
|
|
62
|
+
require("./endpoints/uploads/files.test.js");
|
|
63
|
+
require("./endpoints/uploads/images.test.js");
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
const port = process.env.ACCOUNTS_API_PORT;
|
|
2
2
|
const token = process.env.API_TOKEN;
|
|
3
3
|
|
|
4
|
-
const api = require("./../../../src/client").createApiClient({
|
|
5
|
-
baseURL: `http://localhost:${port}`,
|
|
4
|
+
const api = require("./../../../src/client.js").createApiClient({
|
|
5
|
+
baseURL: `http://localhost:${port}`,
|
|
6
6
|
baseURLOverride: {
|
|
7
|
-
accounts: (baseUrl) => `${baseUrl}/accounts
|
|
7
|
+
accounts: (baseUrl) => { return `${baseUrl}/accounts`; }
|
|
8
8
|
}
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
describe("accounts/users/:userId/current-shift", () => {
|
|
12
12
|
it("should get the shift of the user specified", () => {
|
|
13
13
|
const userId = "5818b94537e32ee60c000005";
|
|
14
|
-
return api.accounts.currentShifts.get({
|
|
14
|
+
return api.accounts.currentShifts.get({token, userId});
|
|
15
15
|
});
|
|
16
16
|
});
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
describe("accounts/docs", () => {
|
|
2
|
-
const
|
|
2
|
+
const assert = require("node:assert/strict");
|
|
3
3
|
const port = process.env.ACCOUNTS_API_PORT;
|
|
4
4
|
|
|
5
|
-
const api = require("./../../../src/client").createApiClient({
|
|
5
|
+
const api = require("./../../../src/client.js").createApiClient({
|
|
6
6
|
baseURL: `http://localhost:${port}`,
|
|
7
7
|
baseURLOverride: {
|
|
8
|
-
accounts: (baseUrl) => `${baseUrl}/accounts
|
|
8
|
+
accounts: (baseUrl) => { return `${baseUrl}/accounts`; }
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
it("should get the docs", () => {
|
|
12
12
|
return api.accounts.docs.get({})
|
|
13
|
-
.then(({
|
|
14
|
-
|
|
13
|
+
.then(({status, data}) => {
|
|
14
|
+
assert.deepStrictEqual(status, 200);
|
|
15
15
|
console.log(data);
|
|
16
|
-
|
|
16
|
+
assert.ok(data);
|
|
17
17
|
});
|
|
18
18
|
});
|
|
19
19
|
});
|