btrz-api-client 8.66.1 → 8.68.2
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 +3 -3
- package/lib/client.js +1 -0
- package/lib/endpoints/accounts/agencies.js +34 -7
- package/lib/endpoints/accounts/network.js +25 -1
- package/lib/endpoints/inventory/fare-type-modifiers.js +167 -0
- package/lib/endpoints/notifications/notify.js +55 -19
- package/package.json +2 -1
- package/src/client.js +1 -0
- package/src/endpoints/accounts/agencies.js +23 -1
- package/src/endpoints/accounts/network.js +19 -1
- package/src/endpoints/inventory/fare-type-modifiers.js +140 -0
- package/src/endpoints/notifications/notify.js +28 -1
- package/test/all.test.js +1 -0
- package/test/endpoints/accounts/agencies.test.js +28 -0
- package/test/endpoints/accounts/network.test.js +16 -0
- package/test/endpoints/inventory/fare-type-modifiers.test.js +76 -0
- package/test/endpoints/notifications/notify.test.js +18 -0
- package/types/endpoints/accounts/network.d.ts +2 -1
package/test/all.test.js
CHANGED
|
@@ -88,6 +88,7 @@ require("./endpoints/inventory/external-wallets.test.js");
|
|
|
88
88
|
require("./endpoints/inventory/fallback-codes.test.js");
|
|
89
89
|
require("./endpoints/inventory/fare-classes.test.js");
|
|
90
90
|
require("./endpoints/inventory/fares.test.js");
|
|
91
|
+
require("./endpoints/inventory/fare-type-modifiers.test.js");
|
|
91
92
|
require("./endpoints/inventory/fees.test.js");
|
|
92
93
|
require("./endpoints/inventory/filtered-trips-v2.test.js");
|
|
93
94
|
require("./endpoints/inventory/filtered-trips.test.js");
|
|
@@ -14,6 +14,34 @@ describe("accounts/agencies", () => {
|
|
|
14
14
|
axiosMock.reset();
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
+
it("should POST an agency", () => {
|
|
18
|
+
const agency = {
|
|
19
|
+
seller: {
|
|
20
|
+
name: "Agency One",
|
|
21
|
+
domain: "agency-one",
|
|
22
|
+
email: "admin@agency-one.com",
|
|
23
|
+
password: "password",
|
|
24
|
+
confirmPassword: "password"
|
|
25
|
+
},
|
|
26
|
+
network: {
|
|
27
|
+
productIds: ["productId"]
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
axiosMock.onPost("/agencies").reply(expectRequest({
|
|
32
|
+
statusCode: 200,
|
|
33
|
+
token,
|
|
34
|
+
jwtToken,
|
|
35
|
+
body: {agency}
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
return api.accounts.agencies.create({
|
|
39
|
+
token,
|
|
40
|
+
jwtToken,
|
|
41
|
+
agency
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
17
45
|
it("should PUT credit limit for an agency", () => {
|
|
18
46
|
const agencyId = "507f1f77bcf86cd799439011";
|
|
19
47
|
const data = {
|
|
@@ -101,4 +101,20 @@ describe("accounts/interline", () => {
|
|
|
101
101
|
token, jwtToken, fareId
|
|
102
102
|
});
|
|
103
103
|
});
|
|
104
|
+
|
|
105
|
+
it("should GET banks for agency by providerId", () => {
|
|
106
|
+
const providerId = "6410ad00d02bf9068d7345e5";
|
|
107
|
+
axiosMock.onGet("/network/agencies/banks").reply((config) => {
|
|
108
|
+
assert.strictEqual(config.params.providerId, providerId);
|
|
109
|
+
return [200, {banks: []}];
|
|
110
|
+
});
|
|
111
|
+
return api.accounts.network.agencies.banks({
|
|
112
|
+
token,
|
|
113
|
+
jwtToken,
|
|
114
|
+
providerId
|
|
115
|
+
}).then((httpResponse) => {
|
|
116
|
+
assert.deepStrictEqual(httpResponse.status, 200);
|
|
117
|
+
assert.deepStrictEqual(httpResponse.data.banks, []);
|
|
118
|
+
});
|
|
119
|
+
});
|
|
104
120
|
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const {
|
|
2
|
+
axiosMock, expectRequest
|
|
3
|
+
} = require("../../test-helpers.js");
|
|
4
|
+
const api = require("../../../src/client.js").createApiClient({baseURL: "http://test.com"});
|
|
5
|
+
|
|
6
|
+
describe("inventory/fare-type-modifiers", () => {
|
|
7
|
+
const token = "I owe you a token";
|
|
8
|
+
const jwtToken = "I owe you a JWT token";
|
|
9
|
+
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
axiosMock.reset();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("should create a fare-type modifier", () => {
|
|
15
|
+
axiosMock.onPost("/fare-type-modifiers").reply(expectRequest({
|
|
16
|
+
statusCode: 200, token, jwtToken
|
|
17
|
+
}));
|
|
18
|
+
return api.inventory.fareTypeModifiers.create({
|
|
19
|
+
jwtToken,
|
|
20
|
+
token,
|
|
21
|
+
fareTypeModifier: {
|
|
22
|
+
name: "My fare-type modifier"
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("should get all fare-type modifiers", () => {
|
|
28
|
+
axiosMock.onGet("/fare-type-modifiers").reply(expectRequest({
|
|
29
|
+
statusCode: 200, token, jwtToken
|
|
30
|
+
}));
|
|
31
|
+
return api.inventory.fareTypeModifiers.all({
|
|
32
|
+
jwtToken,
|
|
33
|
+
token,
|
|
34
|
+
query: {}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("should update a fare-type modifier", () => {
|
|
39
|
+
const fareTypeModifierId = "1234";
|
|
40
|
+
axiosMock.onPut(`/fare-type-modifiers/${fareTypeModifierId}`).reply(expectRequest({
|
|
41
|
+
statusCode: 200, token, jwtToken
|
|
42
|
+
}));
|
|
43
|
+
return api.inventory.fareTypeModifiers.update({
|
|
44
|
+
jwtToken,
|
|
45
|
+
token,
|
|
46
|
+
fareTypeModifierId,
|
|
47
|
+
fareTypeModifier: {
|
|
48
|
+
name: "My Updated fare-type modifier it"
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("should get a fare-type modifier", () => {
|
|
54
|
+
const fareTypeModifierId = "1234";
|
|
55
|
+
axiosMock.onGet(`/fare-type-modifiers/${fareTypeModifierId}`).reply(expectRequest({
|
|
56
|
+
statusCode: 200, token, jwtToken
|
|
57
|
+
}));
|
|
58
|
+
return api.inventory.fareTypeModifiers.get({
|
|
59
|
+
jwtToken,
|
|
60
|
+
token,
|
|
61
|
+
fareTypeModifierId
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("should delete a fare-type modifier", () => {
|
|
66
|
+
const fareTypeModifierId = "12345";
|
|
67
|
+
axiosMock.onDelete(`/fare-type-modifiers/${fareTypeModifierId}`).reply(expectRequest({
|
|
68
|
+
statusCode: 200, token, jwtToken
|
|
69
|
+
}));
|
|
70
|
+
return api.inventory.fareTypeModifiers.remove({
|
|
71
|
+
jwtToken,
|
|
72
|
+
token,
|
|
73
|
+
fareTypeModifierId
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
});
|
|
@@ -60,6 +60,24 @@ describe("notifications/notify-child-user", () => {
|
|
|
60
60
|
axiosMock.reset();
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
+
it("should post send an email for new seller welcome", () => {
|
|
64
|
+
axiosMock.onPost("/notify-new-seller").reply(({headers}) => {
|
|
65
|
+
if (headers["x-api-key"] === token && headers.authorization === `Bearer ${jwtToken}`) {
|
|
66
|
+
return [200];
|
|
67
|
+
}
|
|
68
|
+
return [403];
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
return api.notifications.notify.newSeller.create({
|
|
72
|
+
token,
|
|
73
|
+
jwtToken,
|
|
74
|
+
sellerEmail: "admin@agency.com",
|
|
75
|
+
sellerDomain: "my-agency",
|
|
76
|
+
providerAdminEmail: "provider@test.com",
|
|
77
|
+
lang: "en-us"
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
63
81
|
it("should post send an email with child user created", () => {
|
|
64
82
|
axiosMock.onPost("/notify-child-user").reply(({headers}) => {
|
|
65
83
|
if (headers["x-api-key"] === token && headers.authorization === `Bearer ${jwtToken}`) {
|
|
@@ -4,7 +4,7 @@ export = networkFactory;
|
|
|
4
4
|
* @param {Object} deps
|
|
5
5
|
* @param {import("axios").AxiosInstance} deps.client
|
|
6
6
|
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
7
|
-
* @returns {{ agencies: { all: function, get: function, update: function, create: function, removeProduct: function, removeFare: function } }}
|
|
7
|
+
* @returns {{ agencies: { all: function, get: function, update: function, create: function, removeProduct: function, removeFare: function, banks: function } }}
|
|
8
8
|
*/
|
|
9
9
|
declare function networkFactory({ client, internalAuthTokenProvider }: {
|
|
10
10
|
client: import("axios").AxiosInstance;
|
|
@@ -19,5 +19,6 @@ declare function networkFactory({ client, internalAuthTokenProvider }: {
|
|
|
19
19
|
create: Function;
|
|
20
20
|
removeProduct: Function;
|
|
21
21
|
removeFare: Function;
|
|
22
|
+
banks: Function;
|
|
22
23
|
};
|
|
23
24
|
};
|