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,48 +1,33 @@
|
|
|
1
|
-
const { expect } = require("chai"),
|
|
2
|
-
uuid = require("uuid");
|
|
3
1
|
|
|
4
2
|
const portSales = process.env.SALES_API_PORT;
|
|
5
|
-
const portInventory = process.env.INVENTORY_API_PORT;
|
|
6
3
|
const token = process.env.API_TOKEN;
|
|
7
4
|
const jwtToken = process.env.JWT_TOKEN;
|
|
8
5
|
|
|
9
|
-
const apiSales = require("./../../../src/client").createApiClient({
|
|
10
|
-
baseURL: `http://localhost:${portSales}`,
|
|
6
|
+
const apiSales = require("./../../../src/client.js").createApiClient({
|
|
7
|
+
baseURL: `http://localhost:${portSales}`,
|
|
11
8
|
baseURLOverride: {
|
|
12
|
-
sales: (baseUrl) => `${baseUrl}/sales
|
|
9
|
+
sales: (baseUrl) => { return `${baseUrl}/sales`; }
|
|
13
10
|
}
|
|
14
11
|
});
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const { matchHeaders, statusCode } = require("./../../test-integration-helpers");
|
|
25
|
-
|
|
26
|
-
describe("sales/cart", function() {
|
|
27
|
-
|
|
28
|
-
it("should apply a promo to the cart", function() {
|
|
29
|
-
const cartId = "5b2d3d1c931c8c0d2543c4fb",
|
|
30
|
-
promoCode = "PetPromo",
|
|
31
|
-
query = {
|
|
32
|
-
providerId: "595f9c7007ee12686d000032",
|
|
33
|
-
promoCode
|
|
34
|
-
};
|
|
13
|
+
describe("sales/cart", () => {
|
|
14
|
+
it("should apply a promo to the cart", () => {
|
|
15
|
+
const cartId = "5b2d3d1c931c8c0d2543c4fb";
|
|
16
|
+
const promoCode = "PetPromo";
|
|
17
|
+
const query = {
|
|
18
|
+
providerId: "595f9c7007ee12686d000032",
|
|
19
|
+
promoCode
|
|
20
|
+
};
|
|
35
21
|
|
|
36
22
|
return apiSales.sales.cartPromo.create({token, jwtToken, cartId, query});
|
|
37
23
|
});
|
|
38
24
|
|
|
39
|
-
it("should remove promos from cart",
|
|
40
|
-
const cartId = "5af231ff85d4b8a302d2b343"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
25
|
+
it("should remove promos from cart", () => {
|
|
26
|
+
const cartId = "5af231ff85d4b8a302d2b343";
|
|
27
|
+
const query = {
|
|
28
|
+
channel: "backoffice"
|
|
29
|
+
};
|
|
44
30
|
|
|
45
31
|
return apiSales.sales.cartPromo.remove({token, jwtToken, cartId, query});
|
|
46
32
|
});
|
|
47
|
-
|
|
48
|
-
});
|
|
33
|
+
});
|
|
@@ -1,80 +1,74 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
1
|
+
const assert = require("node:assert/strict");
|
|
2
|
+
const {randomUUID} = require("node:crypto");
|
|
3
3
|
|
|
4
4
|
const portSales = process.env.SALES_API_PORT;
|
|
5
5
|
const portInventory = process.env.INVENTORY_API_PORT;
|
|
6
6
|
const token = process.env.API_TOKEN;
|
|
7
7
|
const jwtToken = process.env.JWT_TOKEN;
|
|
8
8
|
|
|
9
|
-
const apiSales = require("./../../../src/client").createApiClient({
|
|
10
|
-
baseURL: `http://localhost:${portSales}`,
|
|
9
|
+
const apiSales = require("./../../../src/client.js").createApiClient({
|
|
10
|
+
baseURL: `http://localhost:${portSales}`,
|
|
11
11
|
baseURLOverride: {
|
|
12
|
-
sales: (baseUrl) => `${baseUrl}/sales
|
|
12
|
+
sales: (baseUrl) => { return `${baseUrl}/sales`; }
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
const apiInventory = require("./../../../src/client").createApiClient({
|
|
17
|
-
baseURL: `http://localhost:${portInventory}`,
|
|
16
|
+
const apiInventory = require("./../../../src/client.js").createApiClient({
|
|
17
|
+
baseURL: `http://localhost:${portInventory}`,
|
|
18
18
|
baseURLOverride: {
|
|
19
|
-
inventory: (baseUrl) => `${baseUrl}/inventory
|
|
19
|
+
inventory: (baseUrl) => { return `${baseUrl}/inventory`; }
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
describe("sales/cart", function() {
|
|
27
|
-
|
|
28
|
-
it("should not get a cart that does not exist", function() {
|
|
23
|
+
describe("sales/cart", () => {
|
|
24
|
+
it("should not get a cart that does not exist", () => {
|
|
29
25
|
const cartId = "thisCartIdShouldNotExistAnyWherePlease";
|
|
30
|
-
return apiSales.sales.cart.get({
|
|
26
|
+
return apiSales.sales.cart.get({token, id: cartId})
|
|
31
27
|
.catch((err) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
})
|
|
28
|
+
assert.ok(err);
|
|
29
|
+
assert.deepStrictEqual(err.response.status, 400);
|
|
30
|
+
assert.deepStrictEqual(err.response.data.code, "WRONG_CART_ID");
|
|
31
|
+
assert.deepStrictEqual(err.response.data.message, "CartId is not valid");
|
|
32
|
+
});
|
|
37
33
|
});
|
|
38
34
|
|
|
39
|
-
it("should create a cart",
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
fetchStations = apiInventory.inventory.stations.all({ token}),
|
|
44
|
-
fetchFares = apiInventory.inventory.fares.all({ token });
|
|
35
|
+
it("should create a cart", () => {
|
|
36
|
+
const fetchProducts = apiInventory.inventory.products.all({token, query: {isParcel: true}});
|
|
37
|
+
const fetchStations = apiInventory.inventory.stations.all({token});
|
|
38
|
+
const fetchFares = apiInventory.inventory.fares.all({token});
|
|
45
39
|
|
|
46
40
|
Promise.all([fetchProducts, fetchStations, fetchFares])
|
|
47
41
|
.then(([resProducts, resStations, resFares]) => {
|
|
48
42
|
const cart = {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
43
|
+
operationId: randomUUID(),
|
|
44
|
+
items: {
|
|
45
|
+
parcel: [{
|
|
46
|
+
productId: resProducts.data.products[0]._id,
|
|
47
|
+
declaredValue: 250000,
|
|
48
|
+
applyInsurance: true,
|
|
49
|
+
from: {
|
|
50
|
+
_id: resStations.data.stations[0]._id
|
|
51
|
+
},
|
|
52
|
+
to: {
|
|
53
|
+
_id: resStations.data.stations[1]._id
|
|
54
|
+
},
|
|
55
|
+
parcels: [
|
|
56
|
+
{weight: 10, fareId: resFares.data.fares[0]._id},
|
|
57
|
+
{weight: 20, fareId: resFares.data.fares[0]._id}
|
|
58
|
+
]
|
|
59
|
+
}]
|
|
60
|
+
}
|
|
61
|
+
};
|
|
68
62
|
return apiSales.sales.cart.create({token, jwtToken, cart});
|
|
69
63
|
});
|
|
70
64
|
});
|
|
71
65
|
|
|
72
|
-
it("should update a cart",
|
|
73
|
-
const cartId = "5bf579620ac672a52db14a88"
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
66
|
+
it("should update a cart", () => {
|
|
67
|
+
const cartId = "5bf579620ac672a52db14a88";
|
|
68
|
+
const data = {
|
|
69
|
+
providerId: "595f9c7007ee12686d000032",
|
|
70
|
+
operations: [{op: "overrideFees"}]
|
|
71
|
+
};
|
|
78
72
|
return apiSales.sales.cart.patch({token, jwtToken, cartId, data});
|
|
79
73
|
});
|
|
80
74
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const {matchHeaders, statusCode} = require("./../../test-integration-helpers");
|
|
2
|
-
const apiClient = require("./../../../src/client");
|
|
1
|
+
const {matchHeaders, statusCode} = require("./../../test-integration-helpers.js");
|
|
2
|
+
const apiClient = require("./../../../src/client.js");
|
|
3
3
|
|
|
4
4
|
describe("sales/check-in", () => {
|
|
5
5
|
const port = process.env.SALES_API_PORT;
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
const port = process.env.SALES_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
|
-
sales: (baseUrl) => `${baseUrl}/sales
|
|
7
|
+
sales: (baseUrl) => { return `${baseUrl}/sales`; }
|
|
8
8
|
}
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
const {
|
|
11
|
+
const {matchHeaders, statusCode} = require("./../../test-integration-helpers.js");
|
|
12
12
|
|
|
13
13
|
describe("sales/custom-fields", () => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
.then(
|
|
18
|
-
.then(statusCode(200))
|
|
14
|
+
it("should list the custom fields", () => {
|
|
15
|
+
return api.sales.customFields.all({token})
|
|
16
|
+
.then(matchHeaders("x-api-key"))
|
|
17
|
+
.then(statusCode(200));
|
|
19
18
|
});
|
|
20
|
-
|
|
21
19
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const {matchHeaders, statusCode} = require("./../../test-integration-helpers");
|
|
2
|
-
const apiClient = require("./../../../src/client");
|
|
1
|
+
const {matchHeaders, statusCode} = require("./../../test-integration-helpers.js");
|
|
2
|
+
const apiClient = require("./../../../src/client.js");
|
|
3
3
|
|
|
4
4
|
describe("sales/flexpasses", () => {
|
|
5
5
|
const port = process.env.SALES_API_PORT;
|
|
@@ -1,29 +1,25 @@
|
|
|
1
|
-
const
|
|
1
|
+
const assert = require("node:assert/strict");
|
|
2
2
|
|
|
3
3
|
const port = process.env.SALES_API_PORT;
|
|
4
4
|
const token = process.env.API_TOKEN;
|
|
5
|
-
const jwtToken = process.env.JWT_TOKEN;
|
|
6
5
|
|
|
7
|
-
const api = require("./../../../src/client").createApiClient({
|
|
8
|
-
baseURL: `http://localhost:${port}`,
|
|
6
|
+
const api = require("./../../../src/client.js").createApiClient({
|
|
7
|
+
baseURL: `http://localhost:${port}`,
|
|
9
8
|
baseURLOverride: {
|
|
10
|
-
sales: (baseUrl) => `${baseUrl}/sales
|
|
9
|
+
sales: (baseUrl) => { return `${baseUrl}/sales`; }
|
|
11
10
|
}
|
|
12
11
|
});
|
|
13
12
|
|
|
14
|
-
const { matchHeaders, statusCode } = require("./../../test-integration-helpers");
|
|
15
13
|
|
|
16
|
-
describe("sales/gift-certificates",
|
|
17
|
-
|
|
18
|
-
it("should not get a GC for a wrong GC number", function() {
|
|
14
|
+
describe("sales/gift-certificates", () => {
|
|
15
|
+
it("should not get a GC for a wrong GC number", () => {
|
|
19
16
|
const GCNumber = "thisGCNumberShouldNotExistAnyWherePlease";
|
|
20
|
-
return api.sales.giftCertificates.get({
|
|
17
|
+
return api.sales.giftCertificates.get({token, GCNumber})
|
|
21
18
|
.catch((err) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
})
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
});
|
|
19
|
+
assert.ok(err);
|
|
20
|
+
assert.deepStrictEqual(err.response.status, 400);
|
|
21
|
+
assert.deepStrictEqual(err.response.data.code, "WRONG_ID");
|
|
22
|
+
assert.deepStrictEqual(err.response.data.message, "Gift Certificate is not valid");
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -1,75 +1,69 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
1
|
+
const assert = require("node:assert/strict");
|
|
2
|
+
const {randomUUID} = require("node:crypto");
|
|
3
3
|
|
|
4
4
|
const portSales = process.env.SALES_API_PORT;
|
|
5
5
|
const portInventory = process.env.INVENTORY_API_PORT;
|
|
6
6
|
const token = process.env.API_TOKEN;
|
|
7
7
|
const jwtToken = process.env.JWT_TOKEN;
|
|
8
8
|
|
|
9
|
-
const apiSales = require("./../../../src/client").createApiClient({
|
|
10
|
-
baseURL: `http://localhost:${portSales}`,
|
|
9
|
+
const apiSales = require("./../../../src/client.js").createApiClient({
|
|
10
|
+
baseURL: `http://localhost:${portSales}`,
|
|
11
11
|
baseURLOverride: {
|
|
12
|
-
sales: (baseUrl) => `${baseUrl}/sales
|
|
12
|
+
sales: (baseUrl) => { return `${baseUrl}/sales`; }
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
const apiInventory = require("./../../../src/client").createApiClient({
|
|
17
|
-
baseURL: `http://localhost:${portInventory}`,
|
|
16
|
+
const apiInventory = require("./../../../src/client.js").createApiClient({
|
|
17
|
+
baseURL: `http://localhost:${portInventory}`,
|
|
18
18
|
baseURLOverride: {
|
|
19
|
-
inventory: (baseUrl) => `${baseUrl}/inventory
|
|
19
|
+
inventory: (baseUrl) => { return `${baseUrl}/inventory`; }
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
const { matchHeaders, statusCode } = require("./../../test-integration-helpers");
|
|
25
|
-
|
|
26
|
-
describe("sales/order", function() {
|
|
27
|
-
|
|
23
|
+
describe("sales/order", () => {
|
|
28
24
|
function loadCart() {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
fetchStations = apiInventory.inventory.stations.all({ token}),
|
|
33
|
-
fetchFares = apiInventory.inventory.fares.all({ token });
|
|
25
|
+
const fetchProducts = apiInventory.inventory.products.all({token, query: {isParcel: true}});
|
|
26
|
+
const fetchStations = apiInventory.inventory.stations.all({token});
|
|
27
|
+
const fetchFares = apiInventory.inventory.fares.all({token});
|
|
34
28
|
|
|
35
29
|
return Promise.all([fetchProducts, fetchStations, fetchFares])
|
|
36
|
-
.then(([
|
|
30
|
+
.then(([_resProducts, _resStations, _resFares]) => {
|
|
37
31
|
const cart = {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
32
|
+
operationId: randomUUID(),
|
|
33
|
+
items: {
|
|
34
|
+
parcel: [{
|
|
35
|
+
productId: "590c7009e425b05b36373b66",
|
|
36
|
+
declaredValue: 250000,
|
|
37
|
+
applyInsurance: true,
|
|
38
|
+
from: {
|
|
39
|
+
_id: "5819f48c7e39ec3a1a2a5fbc"
|
|
40
|
+
},
|
|
41
|
+
to: {
|
|
42
|
+
_id: "5819f4967e39ec3a1a2a5fbd"
|
|
43
|
+
},
|
|
44
|
+
parcels: [
|
|
45
|
+
{weight: {unit: "gr", value: 10}, fareId: "593569302d0ec8c976890fa4"},
|
|
46
|
+
{weight: {unit: "gr", value: 20}, fareId: "593569302d0ec8c976890fa4"}
|
|
47
|
+
]
|
|
48
|
+
}]
|
|
49
|
+
}
|
|
50
|
+
};
|
|
57
51
|
return apiSales.sales.cart.create({token, jwtToken, cart});
|
|
58
52
|
});
|
|
59
53
|
}
|
|
60
54
|
|
|
61
|
-
it("should not get an order that does not exist",
|
|
55
|
+
it("should not get an order that does not exist", () => {
|
|
62
56
|
const orderId = "thisOrderIdShouldNotExistAnyWherePlease";
|
|
63
|
-
return apiSales.sales.order.get({
|
|
57
|
+
return apiSales.sales.order.get({token, orderId})
|
|
64
58
|
.catch((err) => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
})
|
|
59
|
+
assert.ok(err);
|
|
60
|
+
assert.deepStrictEqual(err.response.status, 400);
|
|
61
|
+
assert.deepStrictEqual(err.response.data.code, "WRONG_ORDER_ID");
|
|
62
|
+
assert.deepStrictEqual(err.response.data.message, "OrderID is not valid");
|
|
63
|
+
});
|
|
70
64
|
});
|
|
71
65
|
|
|
72
|
-
it.skip("should create an order",
|
|
66
|
+
it.skip("should create an order", () => {
|
|
73
67
|
const order = {
|
|
74
68
|
cartId: null,
|
|
75
69
|
payments: [
|
|
@@ -100,8 +94,6 @@ describe("sales/order", function() {
|
|
|
100
94
|
.then((cart) => {
|
|
101
95
|
order.cartId = cart.data.cartId;
|
|
102
96
|
return apiSales.sales.order.create({token, jwtToken, order});
|
|
103
|
-
})
|
|
104
|
-
|
|
97
|
+
});
|
|
105
98
|
});
|
|
106
|
-
|
|
107
|
-
});
|
|
99
|
+
});
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
const port = process.env.SALES_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
|
-
sales: (baseUrl) => `${baseUrl}/sales
|
|
7
|
+
sales: (baseUrl) => { return `${baseUrl}/sales`; }
|
|
8
8
|
}
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
const {
|
|
11
|
+
const {matchHeaders, statusCode} = require("./../../test-integration-helpers.js");
|
|
12
12
|
|
|
13
13
|
describe("sales/payment-providers", () => {
|
|
14
|
-
|
|
15
14
|
it("should list the enabled payment providers", () => {
|
|
16
15
|
const query = {
|
|
17
16
|
enabled: true
|
|
18
17
|
};
|
|
19
|
-
return api.sales.paymentProviders.all({
|
|
20
|
-
.then(matchHeaders(
|
|
21
|
-
.then(statusCode(200))
|
|
18
|
+
return api.sales.paymentProviders.all({token, query})
|
|
19
|
+
.then(matchHeaders("x-api-key"))
|
|
20
|
+
.then(statusCode(200));
|
|
22
21
|
});
|
|
23
|
-
|
|
24
22
|
});
|
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
const port = process.env.SALES_API_PORT
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
describe("sales/redeemable-items", function() {
|
|
1
|
+
const port = process.env.SALES_API_PORT;
|
|
2
|
+
const token = process.env.API_TOKEN;
|
|
3
|
+
const {matchHeaders, statusCode} = require("./../../test-integration-helpers.js");
|
|
4
|
+
const api = require("./../../../src/client.js").createApiClient({
|
|
5
|
+
baseURL: `http://localhost:${port}`,
|
|
6
|
+
baseURLOverride: {
|
|
7
|
+
sales: (baseUrl) => { return `${baseUrl}/sales`; }
|
|
8
|
+
}
|
|
9
|
+
});
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
describe("sales/redeemable-items", () => {
|
|
12
|
+
it("should get a redeemable item by id", () => {
|
|
13
|
+
const redeemableItemId = "5b2cfe091def7f93187a4a2a";
|
|
14
|
+
const query = {
|
|
15
|
+
providerId: "595f9c7007ee12686d000032"
|
|
16
|
+
};
|
|
17
|
+
return api.sales.redeemableItems.get({token, redeemableItemId, query})
|
|
18
|
+
.then(matchHeaders("x-api-key"))
|
|
20
19
|
.then(statusCode(200));
|
|
21
20
|
});
|
|
22
|
-
|
|
23
21
|
});
|
|
@@ -1,31 +1,29 @@
|
|
|
1
|
-
const
|
|
1
|
+
const assert = require("node:assert/strict");
|
|
2
2
|
|
|
3
3
|
const port = process.env.SALES_API_PORT;
|
|
4
4
|
const token = process.env.API_TOKEN;
|
|
5
|
-
const jwtToken = process.env.JWT_TOKEN;
|
|
6
5
|
|
|
7
|
-
const api = require("./../../../src/client").createApiClient({
|
|
8
|
-
baseURL: `http://localhost:${port}`,
|
|
6
|
+
const api = require("./../../../src/client.js").createApiClient({
|
|
7
|
+
baseURL: `http://localhost:${port}`,
|
|
9
8
|
baseURLOverride: {
|
|
10
|
-
sales: (baseUrl) => `${baseUrl}/sales
|
|
9
|
+
sales: (baseUrl) => { return `${baseUrl}/sales`; }
|
|
11
10
|
}
|
|
12
11
|
});
|
|
13
12
|
|
|
14
|
-
const { matchHeaders, statusCode } = require("./../../test-integration-helpers");
|
|
15
13
|
|
|
16
|
-
describe("sales/voucher",
|
|
17
|
-
it("should get a voucher",
|
|
14
|
+
describe("sales/voucher", () => {
|
|
15
|
+
it("should get a voucher", () => {
|
|
18
16
|
const voucher = {
|
|
19
17
|
number: "VC-L2AVT4GM",
|
|
20
18
|
firstName: "lucas",
|
|
21
19
|
lastName: "ferraro",
|
|
22
20
|
cartId: "59b2e67c76e5b7b30b5151f0"
|
|
23
21
|
};
|
|
24
|
-
return api.sales.voucher.get({
|
|
22
|
+
return api.sales.voucher.get({token, voucher})
|
|
25
23
|
.then((response) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
})
|
|
24
|
+
assert.ok(response.data);
|
|
25
|
+
assert.deepStrictEqual(response.data.internalId, "VC-L2AVT4GM");
|
|
26
|
+
assert.deepStrictEqual(response.data.balance, 3000000);
|
|
27
|
+
});
|
|
30
28
|
});
|
|
31
|
-
});
|
|
29
|
+
});
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
const port = process.env.SEATMAPS_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
|
-
seatmaps: (baseUrl) => `${baseUrl}/seatmaps
|
|
7
|
+
seatmaps: (baseUrl) => { return `${baseUrl}/seatmaps`; }
|
|
8
8
|
}
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
const {
|
|
11
|
+
const {matchHeaders, statusCode} = require("./../../test-integration-helpers.js");
|
|
12
12
|
|
|
13
13
|
describe("seatmaps/access-ticket", () => {
|
|
14
|
-
|
|
15
14
|
it("should list fees", () => {
|
|
16
|
-
return api.seatmaps.accessTicket.create({
|
|
17
|
-
.then(matchHeaders(
|
|
15
|
+
return api.seatmaps.accessTicket.create({token})
|
|
16
|
+
.then(matchHeaders("x-api-key"))
|
|
18
17
|
.then(statusCode(200));
|
|
19
18
|
});
|
|
20
|
-
|
|
21
|
-
});
|
|
19
|
+
});
|
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
const port = process.env.SEATMAPS_API_PORT
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const port = process.env.SEATMAPS_API_PORT;
|
|
2
|
+
const token = process.env.API_TOKEN;
|
|
3
|
+
const jwtToken = process.env.JWT_TOKEN;
|
|
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
|
-
seatmaps: (baseUrl) => `${baseUrl}/seatmaps
|
|
8
|
+
seatmaps: (baseUrl) => { return `${baseUrl}/seatmaps`; }
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
const {
|
|
12
|
+
const {statusCode} = require("./../../test-integration-helpers.js");
|
|
13
13
|
|
|
14
14
|
describe("seatmaps/seat", () => {
|
|
15
|
-
|
|
16
15
|
it("should remove the seat", () => {
|
|
17
16
|
const params = {
|
|
18
17
|
"op": "remove",
|
|
19
18
|
"seatmap_id": "123",
|
|
20
19
|
"seat_id": "section-5c13c12d062bb938026c3161-row-0-seat-0"
|
|
21
20
|
};
|
|
22
|
-
return api.seatmaps.seat.update({
|
|
21
|
+
return api.seatmaps.seat.update({token, jwtToken, params})
|
|
23
22
|
.then(statusCode(200));
|
|
24
23
|
});
|
|
25
|
-
|
|
26
24
|
});
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
const
|
|
1
|
+
const assert = require("node:assert/strict");
|
|
2
2
|
const FormData = require("form-data");
|
|
3
3
|
const fs = require("fs");
|
|
4
4
|
const jwtToken = process.env.JWT_TOKEN;
|
|
5
5
|
const port = process.env.UPLOADS_API_PORT;
|
|
6
6
|
const token = process.env.API_TOKEN;
|
|
7
7
|
|
|
8
|
-
const api = require("./../../../src/client").createApiClient({
|
|
8
|
+
const api = require("./../../../src/client.js").createApiClient({
|
|
9
9
|
baseURL: `http://localhost:${port}`,
|
|
10
10
|
baseURLOverride: {
|
|
11
|
-
uploads: (baseUrl) => `${baseUrl}/uploads
|
|
11
|
+
uploads: (baseUrl) => { return `${baseUrl}/uploads`; }
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
describe("uploads/files", () => {
|
|
17
|
-
it("should upload a Journey Prices CSV file", () => {
|
|
18
|
-
const formData = new FormData()
|
|
19
|
-
|
|
17
|
+
it("should upload a Journey Prices CSV file", {timeout: 10000}, () => {
|
|
18
|
+
const formData = new FormData();
|
|
19
|
+
const fileStream = fs.createReadStream(`${__dirname}/sample_journey_prices_upload.csv`);
|
|
20
20
|
|
|
21
21
|
formData.append("file", fileStream);
|
|
22
22
|
formData.append("type", "journey-prices");
|
|
@@ -28,11 +28,11 @@ describe("uploads/files", () => {
|
|
|
28
28
|
formData
|
|
29
29
|
})
|
|
30
30
|
.then(({status, data: response}) => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
})
|
|
37
|
-
})
|
|
38
|
-
});
|
|
31
|
+
assert.deepStrictEqual(status, 200);
|
|
32
|
+
assert.deepStrictEqual(response.type, "journey-prices");
|
|
33
|
+
assert.deepStrictEqual(response.apiKey, token);
|
|
34
|
+
assert.strictEqual(response.dataMapResults.length, 1);
|
|
35
|
+
assert.strictEqual(response.inQueue, true);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
});
|