btrz-api-client 3.33.0 → 3.40.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/lib/client-standalone-min.js +1 -1
- package/lib/client.js +9 -5
- package/lib/endpoints/accounts/accounts.js +3 -2
- package/lib/endpoints/accounts/application-settings.js +15 -10
- package/lib/endpoints/accounts/application.js +3 -2
- package/lib/endpoints/accounts/applications.js +6 -4
- package/lib/endpoints/accounts/current-shifts.js +3 -2
- package/lib/endpoints/accounts/customers.js +15 -10
- package/lib/endpoints/accounts/domains.js +57 -0
- package/lib/endpoints/accounts/email-settings.js +15 -10
- package/lib/endpoints/accounts/exchange-rates.js +6 -4
- package/lib/endpoints/accounts/interline.js +27 -18
- package/lib/endpoints/accounts/lexicons.js +12 -8
- package/lib/endpoints/accounts/print-settings.js +12 -8
- package/lib/endpoints/accounts/printers.js +3 -2
- package/lib/endpoints/accounts/shifts.js +3 -2
- package/lib/endpoints/accounts/travellers.js +15 -10
- package/lib/endpoints/accounts/trusted-machines.js +3 -2
- package/lib/endpoints/accounts/users.js +6 -4
- package/lib/endpoints/btrzpay/customerCards.js +12 -8
- package/lib/endpoints/btrzpay/customers.js +9 -7
- package/lib/endpoints/btrzpay/payment-methods.js +18 -12
- package/lib/endpoints/btrzpay/payments.js +6 -4
- package/lib/endpoints/btrzpay/reference-numbers.js +3 -2
- package/lib/endpoints/btrzpay/referenced-payments.js +6 -4
- package/lib/endpoints/btrzpay/square.js +6 -4
- package/lib/endpoints/coltrane/paths.js +3 -2
- package/lib/endpoints/endpoints_helpers.js +28 -6
- package/lib/endpoints/gps/scanner-app-location.js +3 -2
- package/lib/endpoints/inventory/amenities.js +12 -8
- package/lib/endpoints/inventory/amenity-groups.js +12 -8
- package/lib/endpoints/inventory/bare-routes.js +6 -4
- package/lib/endpoints/inventory/brands.js +12 -8
- package/lib/endpoints/inventory/bundle-fares.js +3 -2
- package/lib/endpoints/inventory/bundles.js +6 -4
- package/lib/endpoints/inventory/companies.js +3 -2
- package/lib/endpoints/inventory/countries.js +3 -2
- package/lib/endpoints/inventory/custom-content.js +15 -10
- package/lib/endpoints/inventory/fare-classes.js +9 -6
- package/lib/endpoints/inventory/fares.js +6 -4
- package/lib/endpoints/inventory/fees.js +3 -2
- package/lib/endpoints/inventory/filtered-trips-v2.js +3 -2
- package/lib/endpoints/inventory/filtered-trips.js +3 -2
- package/lib/endpoints/inventory/gift-certificate-definitions.js +3 -2
- package/lib/endpoints/inventory/healthcheck.js +22 -0
- package/lib/endpoints/inventory/insurances.js +15 -10
- package/lib/endpoints/inventory/insurancesCost.js +3 -2
- package/lib/endpoints/inventory/items.js +3 -2
- package/lib/endpoints/inventory/journey-prices.js +9 -6
- package/lib/endpoints/inventory/marketplace-modifiers.js +15 -10
- package/lib/endpoints/inventory/operating-companies.js +12 -8
- package/lib/endpoints/inventory/operation-messages.js +18 -12
- package/lib/endpoints/inventory/parcel-zones.js +9 -6
- package/lib/endpoints/inventory/payment-terminals.js +15 -10
- package/lib/endpoints/inventory/products.js +6 -4
- package/lib/endpoints/inventory/promos.js +21 -14
- package/lib/endpoints/inventory/routes.js +21 -14
- package/lib/endpoints/inventory/schedules.js +3 -2
- package/lib/endpoints/inventory/seatfees.js +12 -8
- package/lib/endpoints/inventory/seatmaps.js +3 -2
- package/lib/endpoints/inventory/service-numbers.js +12 -8
- package/lib/endpoints/inventory/service-types.js +15 -10
- package/lib/endpoints/inventory/ssrs.js +3 -2
- package/lib/endpoints/inventory/station-groups.js +3 -2
- package/lib/endpoints/inventory/stations-zones.js +3 -2
- package/lib/endpoints/inventory/stations.js +6 -4
- package/lib/endpoints/inventory/taxes.js +12 -8
- package/lib/endpoints/inventory/traveller-card-providers-types.js +3 -2
- package/lib/endpoints/inventory/traveller-card-providers.js +12 -8
- package/lib/endpoints/inventory/traveller-card-types.js +15 -10
- package/lib/endpoints/inventory/trips.js +6 -4
- package/lib/endpoints/inventory/zone-price-overages.js +15 -10
- package/lib/endpoints/inventory/zone-prices.js +15 -10
- package/lib/endpoints/invoices/emails.js +3 -2
- package/lib/endpoints/invoices/infile.js +3 -2
- package/lib/endpoints/invoices/pdfs.js +3 -2
- package/lib/endpoints/invoices/providers.js +15 -10
- package/lib/endpoints/invoices/tax-ids.js +30 -0
- package/lib/endpoints/loyalty/movements.js +9 -6
- package/lib/endpoints/loyalty/programs.js +9 -6
- package/lib/endpoints/notifications/customers.js +3 -2
- package/lib/endpoints/notifications/email.js +3 -2
- package/lib/endpoints/notifications/manifest-notifications.js +7 -4
- package/lib/endpoints/notifications/printed-tickets.js +3 -2
- package/lib/endpoints/operations/accounting_items.js +8 -4
- package/lib/endpoints/operations/applied_insurance.js +3 -2
- package/lib/endpoints/operations/calendar_entries.js +3 -2
- package/lib/endpoints/operations/flexpasses.js +3 -2
- package/lib/endpoints/operations/loans.js +8 -4
- package/lib/endpoints/operations/manifest.js +24 -16
- package/lib/endpoints/operations/movements.js +3 -2
- package/lib/endpoints/operations/outlook-trips.js +27 -0
- package/lib/endpoints/operations/parcels.js +9 -6
- package/lib/endpoints/operations/redemption.js +6 -4
- package/lib/endpoints/operations/scheduled_notifications.js +15 -10
- package/lib/endpoints/operations/segments.js +3 -2
- package/lib/endpoints/operations/tickets.js +9 -6
- package/lib/endpoints/operations/transaction.js +3 -2
- package/lib/endpoints/operations/transactions.js +21 -14
- package/lib/endpoints/operations/trip_change_info.js +3 -2
- package/lib/endpoints/operations/waitlists.js +12 -9
- package/lib/endpoints/reports/custom-reports.js +9 -6
- package/lib/endpoints/reports/report-types.js +6 -4
- package/lib/endpoints/sales/bundles.js +3 -2
- package/lib/endpoints/sales/cart-promo.js +6 -4
- package/lib/endpoints/sales/cart.js +18 -12
- package/lib/endpoints/sales/custom-fields.js +3 -2
- package/lib/endpoints/sales/flexpasses.js +3 -2
- package/lib/endpoints/sales/gift-certificates.js +3 -2
- package/lib/endpoints/sales/order.js +6 -4
- package/lib/endpoints/sales/payment-providers.js +3 -2
- package/lib/endpoints/sales/redeemable-items.js +6 -4
- package/lib/endpoints/sales/sync-entry.js +3 -2
- package/lib/endpoints/sales/voucher.js +3 -2
- package/lib/endpoints/seatmaps/access-ticket.js +3 -2
- package/lib/endpoints/seatmaps/seat.js +3 -2
- package/lib/endpoints/uploads/files.js +3 -2
- package/lib/endpoints/uploads/images.js +3 -2
- package/lib/endpoints/webhooks/events.js +3 -2
- package/lib/endpoints/webhooks/subscriptions.js +15 -10
- package/lib/endpoints/webhooks/undelivered.js +15 -10
- package/lib/endpoints/webhooks/webhooks.js +3 -2
- package/package.json +1 -1
- package/src/client.js +9 -5
- package/src/endpoints/accounts/accounts.js +2 -2
- package/src/endpoints/accounts/application-settings.js +10 -10
- package/src/endpoints/accounts/application.js +2 -2
- package/src/endpoints/accounts/applications.js +4 -4
- package/src/endpoints/accounts/current-shifts.js +2 -2
- package/src/endpoints/accounts/customers.js +10 -10
- package/src/endpoints/accounts/domains.js +38 -0
- package/src/endpoints/accounts/email-settings.js +10 -10
- package/src/endpoints/accounts/exchange-rates.js +4 -4
- package/src/endpoints/accounts/interline.js +18 -18
- package/src/endpoints/accounts/lexicons.js +12 -8
- package/src/endpoints/accounts/print-settings.js +8 -8
- package/src/endpoints/accounts/printers.js +2 -2
- package/src/endpoints/accounts/shifts.js +2 -2
- package/src/endpoints/accounts/travellers.js +10 -10
- package/src/endpoints/accounts/trusted-machines.js +2 -2
- package/src/endpoints/accounts/users.js +4 -4
- package/src/endpoints/btrzpay/customerCards.js +8 -8
- package/src/endpoints/btrzpay/customers.js +6 -7
- package/src/endpoints/btrzpay/payment-methods.js +12 -12
- package/src/endpoints/btrzpay/payments.js +4 -4
- package/src/endpoints/btrzpay/reference-numbers.js +2 -2
- package/src/endpoints/btrzpay/referenced-payments.js +4 -4
- package/src/endpoints/btrzpay/square.js +4 -4
- package/src/endpoints/coltrane/paths.js +2 -2
- package/src/endpoints/endpoints_helpers.js +25 -6
- package/src/endpoints/gps/scanner-app-location.js +2 -2
- package/src/endpoints/inventory/amenities.js +8 -8
- package/src/endpoints/inventory/amenity-groups.js +8 -8
- package/src/endpoints/inventory/bare-routes.js +4 -4
- package/src/endpoints/inventory/brands.js +8 -8
- package/src/endpoints/inventory/bundle-fares.js +2 -2
- package/src/endpoints/inventory/bundles.js +4 -4
- package/src/endpoints/inventory/companies.js +2 -2
- package/src/endpoints/inventory/countries.js +2 -2
- package/src/endpoints/inventory/custom-content.js +11 -10
- package/src/endpoints/inventory/fare-classes.js +6 -6
- package/src/endpoints/inventory/fares.js +4 -4
- package/src/endpoints/inventory/fees.js +2 -2
- package/src/endpoints/inventory/filtered-trips-v2.js +2 -2
- package/src/endpoints/inventory/filtered-trips.js +2 -2
- package/src/endpoints/inventory/gift-certificate-definitions.js +2 -2
- package/src/endpoints/inventory/healthcheck.js +16 -0
- package/src/endpoints/inventory/insurances.js +10 -10
- package/src/endpoints/inventory/insurancesCost.js +2 -2
- package/src/endpoints/inventory/items.js +2 -2
- package/src/endpoints/inventory/journey-prices.js +6 -6
- package/src/endpoints/inventory/marketplace-modifiers.js +11 -10
- package/src/endpoints/inventory/operating-companies.js +8 -8
- package/src/endpoints/inventory/operation-messages.js +12 -12
- package/src/endpoints/inventory/parcel-zones.js +6 -6
- package/src/endpoints/inventory/payment-terminals.js +11 -10
- package/src/endpoints/inventory/products.js +4 -4
- package/src/endpoints/inventory/promos.js +14 -14
- package/src/endpoints/inventory/routes.js +14 -14
- package/src/endpoints/inventory/schedules.js +2 -2
- package/src/endpoints/inventory/seatfees.js +9 -8
- package/src/endpoints/inventory/seatmaps.js +2 -2
- package/src/endpoints/inventory/service-numbers.js +8 -8
- package/src/endpoints/inventory/service-types.js +11 -10
- package/src/endpoints/inventory/ssrs.js +2 -2
- package/src/endpoints/inventory/station-groups.js +2 -2
- package/src/endpoints/inventory/stations-zones.js +2 -2
- package/src/endpoints/inventory/stations.js +4 -4
- package/src/endpoints/inventory/taxes.js +8 -8
- package/src/endpoints/inventory/traveller-card-providers-types.js +2 -2
- package/src/endpoints/inventory/traveller-card-providers.js +8 -8
- package/src/endpoints/inventory/traveller-card-types.js +10 -10
- package/src/endpoints/inventory/trips.js +4 -4
- package/src/endpoints/inventory/zone-price-overages.js +11 -10
- package/src/endpoints/inventory/zone-prices.js +11 -10
- package/src/endpoints/invoices/emails.js +2 -2
- package/src/endpoints/invoices/infile.js +2 -2
- package/src/endpoints/invoices/pdfs.js +2 -2
- package/src/endpoints/invoices/providers.js +10 -10
- package/src/endpoints/invoices/tax-ids.js +18 -0
- package/src/endpoints/loyalty/movements.js +6 -6
- package/src/endpoints/loyalty/programs.js +6 -6
- package/src/endpoints/notifications/customers.js +2 -2
- package/src/endpoints/notifications/email.js +2 -2
- package/src/endpoints/notifications/manifest-notifications.js +6 -4
- package/src/endpoints/notifications/printed-tickets.js +2 -2
- package/src/endpoints/operations/accounting_items.js +7 -4
- package/src/endpoints/operations/applied_insurance.js +2 -2
- package/src/endpoints/operations/calendar_entries.js +2 -2
- package/src/endpoints/operations/flexpasses.js +2 -2
- package/src/endpoints/operations/loans.js +7 -4
- package/src/endpoints/operations/manifest.js +16 -16
- package/src/endpoints/operations/movements.js +2 -2
- package/src/endpoints/operations/outlook-trips.js +17 -0
- package/src/endpoints/operations/parcels.js +6 -6
- package/src/endpoints/operations/redemption.js +4 -4
- package/src/endpoints/operations/scheduled_notifications.js +10 -10
- package/src/endpoints/operations/segments.js +2 -2
- package/src/endpoints/operations/tickets.js +6 -6
- package/src/endpoints/operations/transaction.js +2 -2
- package/src/endpoints/operations/transactions.js +14 -14
- package/src/endpoints/operations/trip_change_info.js +2 -2
- package/src/endpoints/operations/waitlists.js +8 -9
- package/src/endpoints/reports/custom-reports.js +6 -6
- package/src/endpoints/reports/report-types.js +4 -4
- package/src/endpoints/sales/bundles.js +2 -2
- package/src/endpoints/sales/cart-promo.js +4 -4
- package/src/endpoints/sales/cart.js +12 -12
- package/src/endpoints/sales/custom-fields.js +2 -2
- package/src/endpoints/sales/flexpasses.js +2 -2
- package/src/endpoints/sales/gift-certificates.js +2 -2
- package/src/endpoints/sales/order.js +4 -4
- package/src/endpoints/sales/payment-providers.js +2 -2
- package/src/endpoints/sales/redeemable-items.js +4 -4
- package/src/endpoints/sales/sync-entry.js +2 -2
- package/src/endpoints/sales/voucher.js +2 -2
- package/src/endpoints/seatmaps/access-ticket.js +2 -2
- package/src/endpoints/seatmaps/seat.js +2 -2
- package/src/endpoints/uploads/files.js +2 -2
- package/src/endpoints/uploads/images.js +2 -2
- package/src/endpoints/webhooks/events.js +2 -2
- package/src/endpoints/webhooks/subscriptions.js +10 -10
- package/src/endpoints/webhooks/undelivered.js +10 -10
- package/src/endpoints/webhooks/webhooks.js +2 -2
- package/test/client.test.js +0 -6
- package/test/endpoints/accounts/domains.test.js +61 -0
- package/test/endpoints/endpoints_helpers.test.js +54 -0
- package/test/endpoints/operations/outlook-trips.js +28 -0
|
@@ -2,46 +2,46 @@ const { authorizationHeaders } = require("./../endpoints_helpers");
|
|
|
2
2
|
|
|
3
3
|
function undeliveredFactory({ client, internalAuthTokenProvider }) {
|
|
4
4
|
|
|
5
|
-
function all({ token, jwtToken, context, query = {} }) {
|
|
5
|
+
function all({ token, jwtToken, context, query = {}, headers }) {
|
|
6
6
|
const queryObj = Object.assign({}, query, { context });
|
|
7
7
|
|
|
8
8
|
return client({
|
|
9
9
|
url: "/undelivered",
|
|
10
10
|
params: queryObj,
|
|
11
|
-
headers: authorizationHeaders({ token, jwtToken, internalAuthTokenProvider })
|
|
11
|
+
headers: authorizationHeaders({ token, jwtToken, internalAuthTokenProvider, headers })
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
function getById({ token, jwtToken, id }) {
|
|
15
|
+
function getById({ token, jwtToken, id, headers }) {
|
|
16
16
|
return client({
|
|
17
17
|
url: `/undelivered/${id}`,
|
|
18
18
|
method: "get",
|
|
19
|
-
headers: authorizationHeaders({ token, jwtToken, internalAuthTokenProvider })
|
|
19
|
+
headers: authorizationHeaders({ token, jwtToken, internalAuthTokenProvider, headers })
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
function patch({ token, jwtToken, operation }) {
|
|
23
|
+
function patch({ token, jwtToken, operation, headers }) {
|
|
24
24
|
return client({
|
|
25
25
|
url: "/undelivered",
|
|
26
26
|
method: "patch",
|
|
27
|
-
headers: authorizationHeaders({ token, jwtToken, internalAuthTokenProvider }),
|
|
27
|
+
headers: authorizationHeaders({ token, jwtToken, internalAuthTokenProvider, headers }),
|
|
28
28
|
data: operation
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
function resend({ token, jwtToken, id }) {
|
|
32
|
+
function resend({ token, jwtToken, id, headers }) {
|
|
33
33
|
return client({
|
|
34
34
|
url: `/undelivered/${id}/retry`,
|
|
35
35
|
method: "put",
|
|
36
|
-
headers: authorizationHeaders({ token, jwtToken, internalAuthTokenProvider })
|
|
36
|
+
headers: authorizationHeaders({ token, jwtToken, internalAuthTokenProvider, headers })
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
function resendAll({ token, jwtToken }) {
|
|
40
|
+
function resendAll({ token, jwtToken, headers }) {
|
|
41
41
|
return client({
|
|
42
42
|
url: `/undelivered/retry-all`,
|
|
43
43
|
method: "put",
|
|
44
|
-
headers: authorizationHeaders({ token, jwtToken, internalAuthTokenProvider })
|
|
44
|
+
headers: authorizationHeaders({ token, jwtToken, internalAuthTokenProvider, headers })
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -2,11 +2,11 @@ const { authorizationHeaders } = require("./../endpoints_helpers");
|
|
|
2
2
|
|
|
3
3
|
function webhooksFactory({ client, internalAuthTokenProvider }) {
|
|
4
4
|
|
|
5
|
-
function emit({ token, jwtToken, webhook }) {
|
|
5
|
+
function emit({ token, jwtToken, webhook, headers }) {
|
|
6
6
|
return client({
|
|
7
7
|
url: "/emit",
|
|
8
8
|
method: "post",
|
|
9
|
-
headers: authorizationHeaders({ token, jwtToken, internalAuthTokenProvider }),
|
|
9
|
+
headers: authorizationHeaders({ token, jwtToken, internalAuthTokenProvider, headers }),
|
|
10
10
|
data: webhook
|
|
11
11
|
});
|
|
12
12
|
}
|
package/test/client.test.js
CHANGED
|
@@ -130,8 +130,6 @@ describe("client", () => {
|
|
|
130
130
|
httpsAgent: new https.Agent({keepAlive: true})
|
|
131
131
|
};
|
|
132
132
|
const api = createApiClient({baseURL: "http://localhost:8888", timeout: 0, agents});
|
|
133
|
-
const mock = new MockAdapter(api._cleanClient);
|
|
134
|
-
mock.restore();
|
|
135
133
|
const promises = new Array(100).fill().map((i) => {
|
|
136
134
|
return api._cleanClient({url: `/test/${i}`, method: "get"});
|
|
137
135
|
});
|
|
@@ -172,8 +170,6 @@ describe("client", () => {
|
|
|
172
170
|
httpsAgent: new https.Agent({keepAlive: true})
|
|
173
171
|
};
|
|
174
172
|
const api = createApiClient({baseURL: "http://localhost:8888", timeout: 0, agents});
|
|
175
|
-
const mock = new MockAdapter(api._cleanClient);
|
|
176
|
-
mock.restore();
|
|
177
173
|
const promises = new Array(100).fill().map(() => {
|
|
178
174
|
return api.inventory.products.all({token: "I owe you a token"});
|
|
179
175
|
});
|
|
@@ -207,8 +203,6 @@ describe("client", () => {
|
|
|
207
203
|
|
|
208
204
|
it("should socket no more than 100 sockets to perform 100 concurrent requests", async () => {
|
|
209
205
|
const api = createApiClient({baseURL: "http://localhost:8888", timeout: 0});
|
|
210
|
-
const mock = new MockAdapter(api._cleanClient);
|
|
211
|
-
mock.restore();
|
|
212
206
|
const promises = new Array(100).fill().map((i) => {
|
|
213
207
|
return api._cleanClient({url: `/test/${i}`, method: "get"});
|
|
214
208
|
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const {axiosMock, expectRequest} = require("../../test-helpers");
|
|
2
|
+
const api = require("../../../src/client").createApiClient({baseURL: "http://test.com"});
|
|
3
|
+
const {
|
|
4
|
+
expect
|
|
5
|
+
} = require("chai");
|
|
6
|
+
|
|
7
|
+
describe("accounts/domains", () => {
|
|
8
|
+
const token = "I owe you a token";
|
|
9
|
+
const jwtToken = "I owe you a JWT token";
|
|
10
|
+
|
|
11
|
+
afterEach(() => {
|
|
12
|
+
axiosMock.reset();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("should GET a list of domains", () => {
|
|
16
|
+
axiosMock.onGet("/domains").reply(expectRequest({
|
|
17
|
+
statusCode: 200,
|
|
18
|
+
token
|
|
19
|
+
}));
|
|
20
|
+
return api.accounts.domains.all({
|
|
21
|
+
token
|
|
22
|
+
}).then((httpResponse) => {
|
|
23
|
+
expect(httpResponse.status).eql(200);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("should POST a new domains", () => {
|
|
28
|
+
const data = {
|
|
29
|
+
domain: "example1"
|
|
30
|
+
};
|
|
31
|
+
axiosMock.onPost("/domains").reply(expectRequest({
|
|
32
|
+
statusCode: 200,
|
|
33
|
+
token,
|
|
34
|
+
jwtToken
|
|
35
|
+
}));
|
|
36
|
+
return api.accounts.domains.create({
|
|
37
|
+
token,
|
|
38
|
+
jwtToken,
|
|
39
|
+
data
|
|
40
|
+
}).then((httpResponse) => {
|
|
41
|
+
expect(httpResponse.status).eql(200);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("should DELETE a domain", () => {
|
|
46
|
+
const domain = "example1";
|
|
47
|
+
|
|
48
|
+
axiosMock.onDelete(`/domains/${domain}`).reply(expectRequest({
|
|
49
|
+
statusCode: 204,
|
|
50
|
+
token,
|
|
51
|
+
jwtToken
|
|
52
|
+
}));
|
|
53
|
+
return api.accounts.domains.remove({
|
|
54
|
+
domain,
|
|
55
|
+
token,
|
|
56
|
+
jwtToken
|
|
57
|
+
}).then((httpResponse) => {
|
|
58
|
+
expect(httpResponse.status).eql(204);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -56,5 +56,59 @@ describe("endpoints helpers", () => {
|
|
|
56
56
|
"x-api-key": token
|
|
57
57
|
});
|
|
58
58
|
});
|
|
59
|
+
|
|
60
|
+
describe("specifing new headers with an object", () => {
|
|
61
|
+
it("should not override the provided 'token' in the 'x-api-key' field when provided in the headers object", () => {
|
|
62
|
+
const token = "E7excc6eXRKarIONB2gA";
|
|
63
|
+
const newHeaders = {
|
|
64
|
+
"test-header": "123",
|
|
65
|
+
"x-api-key": "overwritten?"
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const headers = authorizationHeaders({token, headers: newHeaders});
|
|
69
|
+
|
|
70
|
+
expect(headers).to.deep.equal({
|
|
71
|
+
"x-api-key": token,
|
|
72
|
+
"test-header": "123"
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("should add the arbitrary headers passed by argument", () => {
|
|
77
|
+
const newHeaders = {
|
|
78
|
+
"test-header": "123",
|
|
79
|
+
"x-amzn-trace-id": "25342352"
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const headers = authorizationHeaders({headers: newHeaders});
|
|
83
|
+
|
|
84
|
+
expect(headers).to.deep.equal({
|
|
85
|
+
"test-header": "123",
|
|
86
|
+
"x-amzn-trace-id": "25342352"
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("should not add anything if headers is not an object", () => {
|
|
91
|
+
const token = "E7excc6eXRKarIONB2gA";
|
|
92
|
+
const headers = authorizationHeaders({token, headers: 123});
|
|
93
|
+
|
|
94
|
+
expect(headers).to.deep.equal({
|
|
95
|
+
"x-api-key": token
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("should ignore x-amzn-trace-id if empty", () => {
|
|
100
|
+
const newHeaders = {
|
|
101
|
+
"test-header": "123",
|
|
102
|
+
"x-amzn-trace-id": ""
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const headers = authorizationHeaders({headers: newHeaders});
|
|
106
|
+
|
|
107
|
+
expect(headers).to.not.haveOwnProperty("x-amzn-trace-id");
|
|
108
|
+
expect(headers).to.deep.equal({
|
|
109
|
+
"test-header": "123"
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
});
|
|
59
113
|
});
|
|
60
114
|
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const {axiosMock, expectRequest} = require("./../../test-helpers.js");
|
|
2
|
+
const api = require("./../../../src/client.js")
|
|
3
|
+
.createApiClient({baseURL: "http://test.com"});
|
|
4
|
+
|
|
5
|
+
describe("operations/outlook-trips", () => {
|
|
6
|
+
const apiKey = "yourAccountAPIKey";
|
|
7
|
+
|
|
8
|
+
afterEach(() => {
|
|
9
|
+
axiosMock.reset();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("should GET some trips", () => {
|
|
13
|
+
const routeId = "myRoute";
|
|
14
|
+
const scheduleId = "myScheduleId";
|
|
15
|
+
const from = "2020-01-01";
|
|
16
|
+
const to = "2020-01-01";
|
|
17
|
+
const productId = "myProductId";
|
|
18
|
+
const query = {
|
|
19
|
+
routeId,
|
|
20
|
+
scheduleId,
|
|
21
|
+
from,
|
|
22
|
+
to,
|
|
23
|
+
productId
|
|
24
|
+
};
|
|
25
|
+
axiosMock.onGet("/outlook-trips").reply(expectRequest({statusCode: 200, token: apiKey}));
|
|
26
|
+
return api.operations.outlookTrips.get({token: apiKey, query});
|
|
27
|
+
});
|
|
28
|
+
});
|