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
|
@@ -2,10 +2,10 @@ const port = process.env.NOTIFICATIONS_API_PORT;
|
|
|
2
2
|
const token = process.env.API_TOKEN;
|
|
3
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
|
-
notifications: (baseUrl) => `${baseUrl}/notifications
|
|
8
|
+
notifications: (baseUrl) => { return `${baseUrl}/notifications`; }
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
const
|
|
1
|
+
const assert = require("node:assert/strict");
|
|
2
2
|
|
|
3
3
|
const port = process.env.OPERATIONS_API_PORT;
|
|
4
4
|
const token = process.env.API_TOKEN;
|
|
5
5
|
const jwtToken = process.env.JWT_TOKEN;
|
|
6
6
|
|
|
7
|
-
const api = require("./../../../src/client").createApiClient({
|
|
8
|
-
baseURL: `http://localhost:${port}`,
|
|
7
|
+
const api = require("./../../../src/client.js").createApiClient({
|
|
8
|
+
baseURL: `http://localhost:${port}`,
|
|
9
9
|
baseURLOverride: {
|
|
10
|
-
operations: (baseUrl) => `${baseUrl}/operations
|
|
10
|
+
operations: (baseUrl) => { return `${baseUrl}/operations`; }
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
describe("operations/appliedInsurances",
|
|
15
|
-
|
|
16
|
-
it("empty array for unexistent transaction", function() {
|
|
14
|
+
describe("operations/appliedInsurances", () => {
|
|
15
|
+
it("empty array for unexistent transaction", () => {
|
|
17
16
|
const trxId = "NOT_EXISTING_TRX";
|
|
18
|
-
return api.operations.appliedInsurance.all({
|
|
17
|
+
return api.operations.appliedInsurance.all({token, jwtToken, trxId})
|
|
19
18
|
.then((res) => {
|
|
20
|
-
|
|
21
|
-
})
|
|
19
|
+
assert.strictEqual(res.data.appliedInsurances.length, 0);
|
|
20
|
+
});
|
|
22
21
|
});
|
|
23
|
-
|
|
24
22
|
});
|
|
@@ -1,34 +1,33 @@
|
|
|
1
|
-
const
|
|
1
|
+
const assert = require("node:assert/strict");
|
|
2
2
|
|
|
3
3
|
const port = process.env.OPERATIONS_API_PORT;
|
|
4
4
|
const token = process.env.API_TOKEN;
|
|
5
5
|
const jwtToken = process.env.JWT_TOKEN;
|
|
6
6
|
|
|
7
|
-
const api = require("./../../../src/client").createApiClient({
|
|
8
|
-
baseURL: `http://localhost:${port}`,
|
|
7
|
+
const api = require("./../../../src/client.js").createApiClient({
|
|
8
|
+
baseURL: `http://localhost:${port}`,
|
|
9
9
|
baseURLOverride: {
|
|
10
|
-
operations: (baseUrl) => `${baseUrl}/operations
|
|
10
|
+
operations: (baseUrl) => { return `${baseUrl}/operations`; }
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
describe("operations/manifest",
|
|
15
|
-
|
|
16
|
-
it("should not get a manifest that does not exist", function() {
|
|
14
|
+
describe("operations/manifest", () => {
|
|
15
|
+
it("should not get a manifest that does not exist", () => {
|
|
17
16
|
const query = {routeId: "51ed2be3cf2c819d00000000", scheduleId: "Morning", date: "2017-08-21"};
|
|
18
|
-
return api.operations.manifest.get({
|
|
17
|
+
return api.operations.manifest.get({token, jwtToken, query})
|
|
19
18
|
.catch((err) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
assert.ok(err);
|
|
20
|
+
assert.deepStrictEqual(err.response.status, 404);
|
|
21
|
+
assert.deepStrictEqual(err.response.data.code, "MANIFEST_NOT_FOUND");
|
|
22
|
+
assert.deepStrictEqual(err.response.data.message, "manifest not found");
|
|
24
23
|
});
|
|
25
24
|
});
|
|
26
25
|
|
|
27
|
-
it("should get the manifest",
|
|
26
|
+
it("should get the manifest", () => {
|
|
28
27
|
const query = {routeId: "51ed2be3cf2c819d5e000010", scheduleId: "Morning", date: "2017-08-21"};
|
|
29
|
-
return api.operations.manifest.get({
|
|
28
|
+
return api.operations.manifest.get({token, jwtToken, query})
|
|
30
29
|
.then((res) => {
|
|
31
|
-
|
|
30
|
+
assert.deepStrictEqual(res.data.manifest._id, "5997315d8efff74052000005");
|
|
32
31
|
});
|
|
33
32
|
});
|
|
34
33
|
|
|
@@ -45,30 +44,29 @@ describe("operations/manifest", function() {
|
|
|
45
44
|
date: "2020-01-14"
|
|
46
45
|
}]
|
|
47
46
|
};
|
|
48
|
-
const {data: response} = await api.operations.manifest.getMany({
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
const {data: response} = await api.operations.manifest.getMany({token, jwtToken, providerId, data: payload});
|
|
48
|
+
assert.ok(Array.isArray(response));
|
|
49
|
+
assert.strictEqual(response.length, 2);
|
|
51
50
|
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
//
|
|
56
|
-
|
|
51
|
+
// Note: These expectations probably fail even on a successful response. Edit these once the POST /manifests endpoint is complete.
|
|
52
|
+
assert.deepStrictEqual(response[0].routeId, "5c50e32e62da38d275000001");
|
|
53
|
+
assert.deepStrictEqual(response[0].schedule, "ef83faaa-b58f-43bb-8c5c-92e2bfa476c0");
|
|
54
|
+
// Note: Particularly the date format is probably incorrect
|
|
55
|
+
assert.deepStrictEqual(response[0].date, "2019-02-27");
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
assert.deepStrictEqual(response[0].routeId, "528cdd9c61c78c2f2d000066");
|
|
58
|
+
assert.deepStrictEqual(response[0].schedule, "711-b58f-43bb-8c5c-92e2bfa476c0");
|
|
59
|
+
assert.deepStrictEqual(response[0].date, "2020-01-14");
|
|
61
60
|
});
|
|
62
61
|
|
|
63
|
-
it("should patch a manifest with add_tickets operation",
|
|
64
|
-
const providerId = "5997315d8efff74052000005"
|
|
65
|
-
|
|
66
|
-
return api.operations.manifest.patch({
|
|
62
|
+
it("should patch a manifest with add_tickets operation", () => {
|
|
63
|
+
const providerId = "5997315d8efff74052000005";
|
|
64
|
+
const operations = [{op: "add_tickets", tickets: ["576989208f86028739fef256"]}];
|
|
65
|
+
return api.operations.manifest.patch({token, jwtToken, query: {providerId}, operations})
|
|
67
66
|
.then((res) => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
assert.strictEqual(res.data.results.length, 1);
|
|
68
|
+
assert.deepStrictEqual(res.data.results[0].op, "add_tickets");
|
|
69
|
+
assert.deepStrictEqual(res.data.results[0].status, "success");
|
|
71
70
|
});
|
|
72
71
|
});
|
|
73
|
-
|
|
74
72
|
});
|
|
@@ -1,62 +1,60 @@
|
|
|
1
|
-
const
|
|
1
|
+
const assert = require("node:assert/strict");
|
|
2
2
|
|
|
3
3
|
const port = process.env.OPERATIONS_API_PORT;
|
|
4
4
|
const token = process.env.API_TOKEN;
|
|
5
5
|
const jwtToken = process.env.JWT_TOKEN;
|
|
6
6
|
|
|
7
|
-
const api = require("./../../../src/client").createApiClient({
|
|
8
|
-
baseURL: `http://localhost:${port}`,
|
|
7
|
+
const api = require("./../../../src/client.js").createApiClient({
|
|
8
|
+
baseURL: `http://localhost:${port}`,
|
|
9
9
|
baseURLOverride: {
|
|
10
|
-
operations: (baseUrl) => `${baseUrl}/operations
|
|
10
|
+
operations: (baseUrl) => { return `${baseUrl}/operations`; }
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
describe("operations/parcel",
|
|
15
|
-
|
|
16
|
-
it("should not get a parcel that does not exist", function() {
|
|
14
|
+
describe("operations/parcel", () => {
|
|
15
|
+
it("should not get a parcel that does not exist", () => {
|
|
17
16
|
const parcelId = "5967e3da1b7dfb3047e5ac81";
|
|
18
|
-
return api.operations.parcel.get({
|
|
17
|
+
return api.operations.parcel.get({token, jwtToken, id: parcelId})
|
|
19
18
|
.catch((err) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
})
|
|
19
|
+
assert.ok(err);
|
|
20
|
+
assert.deepStrictEqual(err.response.status, 404);
|
|
21
|
+
assert.deepStrictEqual(err.response.data.code, "PARCEL_NOT_FOUND");
|
|
22
|
+
assert.deepStrictEqual(err.response.data.message, "Parcel not found");
|
|
23
|
+
});
|
|
25
24
|
});
|
|
26
25
|
|
|
27
|
-
it("should not get any parcel from a trx that does not exist",
|
|
26
|
+
it("should not get any parcel from a trx that does not exist", () => {
|
|
28
27
|
const trxId = "5967e3da1b7dfb3047e5ac81";
|
|
29
|
-
return api.operations.parcel.all({
|
|
28
|
+
return api.operations.parcel.all({token, jwtToken, query: {trxId}})
|
|
30
29
|
.catch((err) => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
})
|
|
30
|
+
assert.ok(err);
|
|
31
|
+
assert.deepStrictEqual(err.response.status, 401);
|
|
32
|
+
assert.deepStrictEqual(err.response.data.code, "PARCEL_NOT_FOUND");
|
|
33
|
+
assert.deepStrictEqual(err.response.data.message, "Parcel not found");
|
|
34
|
+
});
|
|
36
35
|
});
|
|
37
36
|
|
|
38
|
-
it("should not update parcel that not exists",
|
|
39
|
-
const parcelId = "596e33cea74c7dd74c2f8572"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return api.operations.parcel.update({
|
|
37
|
+
it("should not update parcel that not exists", () => {
|
|
38
|
+
const parcelId = "596e33cea74c7dd74c2f8572";
|
|
39
|
+
const parcel = {_id: parcelId, status: "delivered"};
|
|
40
|
+
const locationData = {latitude: 9876, longitude: 123};
|
|
41
|
+
return api.operations.parcel.update({token, jwtToken, id: parcelId, parcel, locationData})
|
|
43
42
|
.catch((err) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
})
|
|
43
|
+
assert.ok(err);
|
|
44
|
+
assert.deepStrictEqual(err.response.status, 404);
|
|
45
|
+
assert.deepStrictEqual(err.response.data.code, "TICKET_NOT_FOUND");
|
|
46
|
+
assert.deepStrictEqual(err.response.data.msg, "parcel not found for id: 596e33cea74c7dd74c2f8572");
|
|
47
|
+
});
|
|
49
48
|
});
|
|
50
49
|
|
|
51
|
-
it("should not add a comment in a parcel that not exists",
|
|
50
|
+
it("should not add a comment in a parcel that not exists", () => {
|
|
52
51
|
const parcelId = "596e33cea74c7dd74c2f8552";
|
|
53
|
-
return api.operations.parcel.addComment({
|
|
52
|
+
return api.operations.parcel.addComment({token, jwtToken, id: parcelId, comment: "A comment"})
|
|
54
53
|
.catch((err) => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
})
|
|
54
|
+
assert.ok(err);
|
|
55
|
+
assert.deepStrictEqual(err.response.status, 404);
|
|
56
|
+
assert.deepStrictEqual(err.response.data.code, "PARCEL_NOT_FOUND");
|
|
57
|
+
assert.deepStrictEqual(err.response.data.msg, "We could not found a Parcel with the given ID");
|
|
58
|
+
});
|
|
60
59
|
});
|
|
61
|
-
|
|
62
60
|
});
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
const { expect } = require("chai");
|
|
2
1
|
|
|
3
2
|
const port = process.env.OPERATIONS_API_PORT;
|
|
4
3
|
const token = process.env.API_TOKEN;
|
|
5
4
|
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
|
-
operations: (baseUrl) => `${baseUrl}/operations
|
|
9
|
+
operations: (baseUrl) => { return `${baseUrl}/operations`; }
|
|
11
10
|
}
|
|
12
11
|
});
|
|
13
12
|
|
|
14
|
-
describe("operations/redemptions",
|
|
15
|
-
|
|
16
|
-
it("should create a redemption for the parcel", function() {
|
|
13
|
+
describe("operations/redemptions", () => {
|
|
14
|
+
it("should create a redemption for the parcel", () => {
|
|
17
15
|
const redemption = {
|
|
18
16
|
"itemCode": "PA-59e60182bc6ef25a2cfd6b6f",
|
|
19
17
|
"options": {
|
|
@@ -24,12 +22,11 @@ describe("operations/redemptions", function() {
|
|
|
24
22
|
"operationType": "received"
|
|
25
23
|
},
|
|
26
24
|
"redemptions": {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
"items": [],
|
|
26
|
+
"scannedPurchases": [],
|
|
27
|
+
"externalPasses": []
|
|
30
28
|
}
|
|
31
29
|
};
|
|
32
|
-
return api.operations.redemption.create({
|
|
30
|
+
return api.operations.redemption.create({token, jwtToken, redemption});
|
|
33
31
|
});
|
|
34
|
-
|
|
35
32
|
});
|
|
@@ -2,20 +2,18 @@ const port = process.env.OPERATIONS_API_PORT;
|
|
|
2
2
|
const token = process.env.API_TOKEN;
|
|
3
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
|
-
operations: (baseUrl) => `${baseUrl}/operations
|
|
8
|
+
operations: (baseUrl) => { return `${baseUrl}/operations`; }
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
describe("operations/segments",
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return api.operations.segments.all({ token, jwtToken, productId, ticketId, providerId });
|
|
12
|
+
describe("operations/segments", () => {
|
|
13
|
+
it("should get segments for product and ticket", () => {
|
|
14
|
+
const productId = "595f9c7007ee12686d000033";
|
|
15
|
+
const ticketId = "5bad3ef2b726b6716b9567df";
|
|
16
|
+
const providerId = "595f9c7007ee12686d000032";
|
|
17
|
+
return api.operations.segments.all({token, jwtToken, productId, ticketId, providerId});
|
|
19
18
|
});
|
|
20
|
-
|
|
21
19
|
});
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
/* eslint-disable arrow-parens */
|
|
3
3
|
/* eslint-disable prefer-arrow-callback */
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const assert = require("node:assert/strict");
|
|
6
6
|
|
|
7
7
|
const port = process.env.OPERATIONS_API_PORT;
|
|
8
8
|
const token = process.env.API_TOKEN;
|
|
9
9
|
const jwtToken = process.env.JWT_TOKEN;
|
|
10
10
|
|
|
11
|
-
const api = require("./../../../src/client").createApiClient({
|
|
11
|
+
const api = require("./../../../src/client.js").createApiClient({
|
|
12
12
|
baseURL: `http://localhost:${port}`,
|
|
13
13
|
baseURLOverride: {
|
|
14
14
|
operations: (baseUrl) => {
|
|
@@ -43,9 +43,9 @@ describe("operations/tickets", function () {
|
|
|
43
43
|
|
|
44
44
|
return api.operations.tickets.patch({token, jwtToken, id, operations: [op1], warningsEnabled})
|
|
45
45
|
.then((res) => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
assert.strictEqual(res.data.results.length, 1);
|
|
47
|
+
assert.deepStrictEqual(res.data.results[0].op, "move");
|
|
48
|
+
assert.deepStrictEqual(res.data.results[0].status, "success");
|
|
49
49
|
});
|
|
50
50
|
});
|
|
51
51
|
|
|
@@ -62,12 +62,12 @@ describe("operations/tickets", function () {
|
|
|
62
62
|
return api.operations.tickets.patch({token, jwtToken, id, operations: [op1], warningsEnabled})
|
|
63
63
|
.catch((err) => {
|
|
64
64
|
/* eslint-disable-next-line no-unused-expressions */
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
assert.ok(err);
|
|
66
|
+
assert.deepStrictEqual(err.response.status, 404);
|
|
67
|
+
assert.strictEqual(err.response.data.results.length, 1);
|
|
68
|
+
assert.deepStrictEqual(err.response.data.results[0].op, "move");
|
|
69
|
+
assert.deepStrictEqual(err.response.data.results[0].status, "error");
|
|
70
|
+
assert.deepStrictEqual(err.response.data.results[0].error.code, "TICKET_NOT_FOUND");
|
|
71
71
|
});
|
|
72
72
|
});
|
|
73
73
|
});
|
|
@@ -2,7 +2,7 @@ const port = process.env.OPERATIONS_API_PORT;
|
|
|
2
2
|
const token = process.env.API_TOKEN;
|
|
3
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
8
|
operations: (baseUrl) => {
|
|
@@ -14,7 +14,7 @@ const api = require("./../../../src/client.js").createApiClient({
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
|
-
const
|
|
17
|
+
const assert = require("node:assert/strict");
|
|
18
18
|
|
|
19
19
|
describe("operations/transactions", function () {
|
|
20
20
|
describe("companion", function () {
|
|
@@ -34,7 +34,7 @@ describe("operations/transactions", function () {
|
|
|
34
34
|
const transactionId = "5ce2d7d4c16f0e5827069f13";
|
|
35
35
|
return api.operations.transactions.expireAll({jwtToken, transactionId})
|
|
36
36
|
.then((res) => {
|
|
37
|
-
|
|
37
|
+
assert.strictEqual(res.data.transactionIds.length, 1);
|
|
38
38
|
});
|
|
39
39
|
});
|
|
40
40
|
});
|
|
@@ -2,23 +2,21 @@ const port = process.env.OPERATIONS_API_PORT;
|
|
|
2
2
|
const token = process.env.API_TOKEN;
|
|
3
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
|
-
operations: (baseUrl) => `${baseUrl}/operations
|
|
8
|
+
operations: (baseUrl) => { return `${baseUrl}/operations`; }
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
describe("operations/trip-change-info",
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return api.operations.tripChangeInfo.get({ token, jwtToken, productId, params });
|
|
12
|
+
describe("operations/trip-change-info", () => {
|
|
13
|
+
it("should get the trip to change info", () => {
|
|
14
|
+
const productId = "5a61f76266d8da4c4200000b";
|
|
15
|
+
const params = {
|
|
16
|
+
ticketNumber: "V6H6BH",
|
|
17
|
+
lastName: "Ferraro",
|
|
18
|
+
providerId: "595f9c7007ee12686d000032"
|
|
19
|
+
};
|
|
20
|
+
return api.operations.tripChangeInfo.get({token, jwtToken, productId, params});
|
|
22
21
|
});
|
|
23
|
-
|
|
24
22
|
});
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
const assert = require("node:assert/strict");
|
|
2
|
+
const port = process.env.REPORTS_API_PORT;
|
|
3
|
+
const token = process.env.API_TOKEN;
|
|
4
|
+
const jwtToken = process.env.JWT_TOKEN;
|
|
5
|
+
const api = require("./../../../src/client.js").createApiClient({
|
|
6
|
+
baseURL: `http://localhost:${port}`,
|
|
7
|
+
baseURLOverride: {
|
|
8
|
+
reports: (baseUrl) => { return `${baseUrl}/reports`; }
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
11
|
|
|
12
|
-
describe("reports/custom-report",
|
|
13
|
-
it("should return 200",
|
|
12
|
+
describe("reports/custom-report", () => {
|
|
13
|
+
it("should return 200", () => {
|
|
14
14
|
const customReport = {
|
|
15
15
|
name: "customReportName",
|
|
16
16
|
reportTypeId: "5a99c3055c44c49c5a000001",
|
|
@@ -48,24 +48,24 @@ describe("reports/custom-report", function() {
|
|
|
48
48
|
prefixForFile: "greatReport"
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
return api.reports.customReports.create({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
return api.reports.customReports.create({jwtToken, token, customReport})
|
|
52
|
+
.catch((err) => {
|
|
53
|
+
assert.deepStrictEqual(err.response.status, 200);
|
|
54
|
+
assert.deepStrictEqual(err.response.data.customReport.name, customReport.name);
|
|
55
|
+
});
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
it("should not get any custom reports",
|
|
58
|
+
it("should not get any custom reports", () => {
|
|
59
59
|
return api.reports.customReports.all({token, jwtToken, query: {}})
|
|
60
60
|
.catch((err) => {
|
|
61
|
-
|
|
61
|
+
assert.deepStrictEqual(err.response.status, 401);
|
|
62
62
|
});
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
it("should not delete a custom report",
|
|
65
|
+
it("should not delete a custom report", () => {
|
|
66
66
|
return api.reports.customReports.remove({token, jwtToken, customReportId: "5a959a4aa7114ffd7f000001"})
|
|
67
67
|
.catch((err) => {
|
|
68
|
-
|
|
68
|
+
assert.deepStrictEqual(err.response.status, 401);
|
|
69
69
|
});
|
|
70
70
|
});
|
|
71
71
|
});
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
const assert = require("node:assert/strict");
|
|
2
|
+
const port = process.env.REPORTS_API_PORT;
|
|
3
|
+
const token = process.env.API_TOKEN;
|
|
4
|
+
const jwtToken = process.env.JWT_TOKEN;
|
|
5
|
+
const api = require("./../../../src/client.js").createApiClient({
|
|
6
|
+
baseURL: `http://localhost:${port}`,
|
|
7
|
+
baseURLOverride: {
|
|
8
|
+
reports: (baseUrl) => { return `${baseUrl}/reports`; }
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
11
|
|
|
12
|
-
describe("reports/types",
|
|
13
|
-
it("should return 404 for a wrong id",
|
|
12
|
+
describe("reports/types", () => {
|
|
13
|
+
it("should return 404 for a wrong id", () => {
|
|
14
14
|
const reportTypeId = "reportTypeId";
|
|
15
|
-
return api.reports.reportTypes.get({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
return api.reports.reportTypes.get({token, jwtToken, id: reportTypeId})
|
|
16
|
+
.catch((err) => {
|
|
17
|
+
assert.deepStrictEqual(err.response.status, 404);
|
|
18
|
+
assert.deepStrictEqual(err.response.data.code, "TYPE_NOT_FOUND");
|
|
19
|
+
assert.deepStrictEqual(err.response.data.message, "Report type not found");
|
|
20
|
+
});
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
it("should return empty success",
|
|
23
|
+
it("should return empty success", () => {
|
|
24
24
|
const reportTypeName = "reportTypeName";
|
|
25
|
-
return api.reports.reportTypes.getByName({
|
|
25
|
+
return api.reports.reportTypes.getByName({token, jwtToken, name: reportTypeName})
|
|
26
26
|
.then((result) => {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
assert.deepStrictEqual(result.status, 200);
|
|
28
|
+
assert.deepStrictEqual(result.data, []);
|
|
29
29
|
});
|
|
30
30
|
});
|
|
31
31
|
});
|
|
@@ -1,14 +1,14 @@
|
|
|
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({
|
|
4
|
+
const api = require("./../../../src/client.js").createApiClient({
|
|
5
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/bundles", () => {
|
|
14
14
|
it("should list bundles", () => {
|
|
@@ -16,8 +16,8 @@ describe("sales/bundles", () => {
|
|
|
16
16
|
providerId: "595f9c7007ee12686d000032",
|
|
17
17
|
type: "bundles"
|
|
18
18
|
};
|
|
19
|
-
return api.sales.bundles.all({
|
|
20
|
-
.then(matchHeaders(
|
|
19
|
+
return api.sales.bundles.all({token, query})
|
|
20
|
+
.then(matchHeaders("x-api-key"))
|
|
21
21
|
.then(statusCode(200));
|
|
22
22
|
});
|
|
23
23
|
});
|