btrz-api-client 9.1.1 → 9.3.0
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/.githooks/pre-commit +18 -0
- package/lib/client-standalone-min.js +5 -5
- package/lib/client.js +4 -0
- package/lib/endpoints/accounts/customers.js +28 -1
- package/lib/endpoints/endpoints_helpers.js +1 -1
- package/lib/endpoints/inventory/events.js +41 -0
- package/lib/endpoints/inventory/parcel-zones.js +26 -2
- package/lib/endpoints/inventory/zone-prices.js +31 -2
- package/package.json +3 -2
- package/src/client.js +1 -0
- package/src/endpoints/accounts/customers.js +18 -1
- package/src/endpoints/endpoints_helpers.js +1 -1
- package/src/endpoints/inventory/events.js +28 -0
- package/src/endpoints/inventory/parcel-zones.js +18 -2
- package/src/endpoints/inventory/zone-prices.js +21 -2
- package/test/endpoints/accounts/customers.js +6 -0
- package/test/endpoints/inventory/events.test.js +19 -0
- package/test/endpoints/inventory/parcel-zones.test.js +13 -0
- package/test/endpoints/inventory/zone-prices.test.js +17 -0
- package/types/endpoints/inventory/events.d.ts +16 -0
- package/types/endpoints/inventory/parcel-zones.d.ts +2 -1
- package/types/endpoints/inventory/zone-prices.d.ts +2 -1
package/lib/client.js
CHANGED
|
@@ -135,6 +135,10 @@ function createInventory({
|
|
|
135
135
|
client,
|
|
136
136
|
internalAuthTokenProvider
|
|
137
137
|
}),
|
|
138
|
+
events: require("./endpoints/inventory/events.js")({
|
|
139
|
+
client,
|
|
140
|
+
internalAuthTokenProvider
|
|
141
|
+
}),
|
|
138
142
|
externalPasses: require("./endpoints/inventory/external-passes.js")({
|
|
139
143
|
client,
|
|
140
144
|
internalAuthTokenProvider
|
|
@@ -23,7 +23,7 @@ const {
|
|
|
23
23
|
* @param {Object} deps
|
|
24
24
|
* @param {import("axios").AxiosInstance} deps.client
|
|
25
25
|
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
26
|
-
* @returns {{ put: function, all: function, create: function, signIn: function, signInCas: function, update: function, merge: function }}
|
|
26
|
+
* @returns {{ put: function, all: function, get: function, create: function, signIn: function, signInCas: function, update: function, merge: function }}
|
|
27
27
|
*/
|
|
28
28
|
function customersFactory({
|
|
29
29
|
client,
|
|
@@ -91,6 +91,32 @@ function customersFactory({
|
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
/**
|
|
95
|
+
* GET /customers/:customerId - get a customer by id.
|
|
96
|
+
* @param {Object} opts
|
|
97
|
+
* @param {string} [opts.token] - API key
|
|
98
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
99
|
+
* @param {string} opts.customerId - Customer id (24-char hex ObjectId)
|
|
100
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
101
|
+
* @returns {Promise<import("axios").AxiosResponse<{ _id: string, customerNumber: string, ... }>>}
|
|
102
|
+
*/
|
|
103
|
+
function get({
|
|
104
|
+
customerId,
|
|
105
|
+
token,
|
|
106
|
+
jwtToken,
|
|
107
|
+
headers
|
|
108
|
+
}) {
|
|
109
|
+
return client({
|
|
110
|
+
url: `/customers/${customerId}`,
|
|
111
|
+
headers: authorizationHeaders({
|
|
112
|
+
token,
|
|
113
|
+
jwtToken,
|
|
114
|
+
internalAuthTokenProvider,
|
|
115
|
+
headers
|
|
116
|
+
})
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
94
120
|
/**
|
|
95
121
|
* POST /customer - create a customer. Body: { customer }. If password is included, activation token is created and activation email sent. Side effect: may emit customer.created webhook.
|
|
96
122
|
* @param {Object} opts
|
|
@@ -247,6 +273,7 @@ function customersFactory({
|
|
|
247
273
|
return {
|
|
248
274
|
put,
|
|
249
275
|
all,
|
|
276
|
+
get,
|
|
250
277
|
create,
|
|
251
278
|
signIn,
|
|
252
279
|
signInCas,
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const {
|
|
2
|
+
authorizationHeaders
|
|
3
|
+
} = require("./../endpoints_helpers.js");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Factory for inventory event endpoint (btrz-api-inventory).
|
|
7
|
+
* @param {Object} deps
|
|
8
|
+
* @param {import("axios").AxiosInstance} deps.client
|
|
9
|
+
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
10
|
+
* @returns {{ get: function }}
|
|
11
|
+
*/
|
|
12
|
+
function eventsFactory({
|
|
13
|
+
client,
|
|
14
|
+
internalAuthTokenProvider
|
|
15
|
+
}) {
|
|
16
|
+
/**
|
|
17
|
+
* GET /event/:eventId - get event by id.
|
|
18
|
+
* @param {Object} opts
|
|
19
|
+
* @param {string} opts.eventId - Event id
|
|
20
|
+
* @param {string} [opts.token] - API key
|
|
21
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
22
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
23
|
+
*/
|
|
24
|
+
function get({
|
|
25
|
+
eventId,
|
|
26
|
+
token,
|
|
27
|
+
headers
|
|
28
|
+
}) {
|
|
29
|
+
return client.get(`/event/${eventId}`, {
|
|
30
|
+
headers: authorizationHeaders({
|
|
31
|
+
token,
|
|
32
|
+
internalAuthTokenProvider,
|
|
33
|
+
headers
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
get
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
module.exports = eventsFactory;
|
|
@@ -13,7 +13,7 @@ const {
|
|
|
13
13
|
* @param {Object} deps
|
|
14
14
|
* @param {import("axios").AxiosInstance} deps.client
|
|
15
15
|
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
16
|
-
* @returns {{ all: function, create: function, update: function }}
|
|
16
|
+
* @returns {{ all: function, create: function, update: function, bucket: function }}
|
|
17
17
|
*/
|
|
18
18
|
function parcelZonesFactory({
|
|
19
19
|
client,
|
|
@@ -103,10 +103,34 @@ function parcelZonesFactory({
|
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* GET /parcel-zones/bucket - get matching parcel bucket.
|
|
109
|
+
* @param {Object} opts
|
|
110
|
+
* @param {string} [opts.token] - API key
|
|
111
|
+
* @param {Object} [opts.query] - Query params for bucket lookup
|
|
112
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
113
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
114
|
+
*/
|
|
115
|
+
function bucket({
|
|
116
|
+
token,
|
|
117
|
+
query = {},
|
|
118
|
+
headers
|
|
119
|
+
}) {
|
|
120
|
+
return client.get("/parcel-zones/bucket", {
|
|
121
|
+
params: query,
|
|
122
|
+
headers: authorizationHeaders({
|
|
123
|
+
token,
|
|
124
|
+
internalAuthTokenProvider,
|
|
125
|
+
headers
|
|
126
|
+
})
|
|
127
|
+
});
|
|
128
|
+
}
|
|
106
129
|
return {
|
|
107
130
|
all,
|
|
108
131
|
create,
|
|
109
|
-
update
|
|
132
|
+
update,
|
|
133
|
+
bucket
|
|
110
134
|
};
|
|
111
135
|
}
|
|
112
136
|
module.exports = parcelZonesFactory;
|
|
@@ -17,7 +17,7 @@ const {
|
|
|
17
17
|
* @param {Object} deps
|
|
18
18
|
* @param {import("axios").AxiosInstance} deps.client
|
|
19
19
|
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
20
|
-
* @returns {{ all: function, get: function, create: function, update: function, remove: function }}
|
|
20
|
+
* @returns {{ all: function, get: function, create: function, update: function, remove: function, forParcels: function }}
|
|
21
21
|
*/
|
|
22
22
|
function zonePriceFactory({
|
|
23
23
|
client,
|
|
@@ -156,12 +156,41 @@ function zonePriceFactory({
|
|
|
156
156
|
}
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* POST /zone-prices-for-parcels - calculate zone prices for parcel payload.
|
|
162
|
+
* @param {Object} opts
|
|
163
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
164
|
+
* @param {string} [opts.token] - API key
|
|
165
|
+
* @param {Object} opts.payload - Parcel pricing payload
|
|
166
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
167
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
168
|
+
*/
|
|
169
|
+
function forParcels({
|
|
170
|
+
jwtToken,
|
|
171
|
+
token,
|
|
172
|
+
payload,
|
|
173
|
+
headers
|
|
174
|
+
}) {
|
|
175
|
+
return client({
|
|
176
|
+
url: "/zone-prices-for-parcels",
|
|
177
|
+
method: "post",
|
|
178
|
+
headers: authorizationHeaders({
|
|
179
|
+
token,
|
|
180
|
+
jwtToken,
|
|
181
|
+
internalAuthTokenProvider,
|
|
182
|
+
headers
|
|
183
|
+
}),
|
|
184
|
+
data: payload
|
|
185
|
+
});
|
|
186
|
+
}
|
|
159
187
|
return {
|
|
160
188
|
all,
|
|
161
189
|
get,
|
|
162
190
|
create,
|
|
163
191
|
update,
|
|
164
|
-
remove
|
|
192
|
+
remove,
|
|
193
|
+
forParcels
|
|
165
194
|
};
|
|
166
195
|
}
|
|
167
196
|
module.exports = zonePriceFactory;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "btrz-api-client",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.3.0",
|
|
4
4
|
"description": "Api client for Betterez endpoints",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"transpile": "node ./node_modules/@babel/cli/bin/babel.js -d lib/ src/",
|
|
15
15
|
"preversion": "npm test && npm run transpile && npm run esbuild && npm run commit-transpile",
|
|
16
16
|
"postversion": "git push origin master && git push --tags",
|
|
17
|
-
"version": "git tag $1"
|
|
17
|
+
"version": "git tag $1",
|
|
18
|
+
"prepare": "git config core.hooksPath .githooks"
|
|
18
19
|
},
|
|
19
20
|
"repository": {
|
|
20
21
|
"type": "git",
|
package/src/client.js
CHANGED
|
@@ -72,6 +72,7 @@ function createInventory({baseURL, headers, timeout, overrideFn, internalAuthTok
|
|
|
72
72
|
customFields: require("./endpoints/inventory/custom-fields.js")({client, internalAuthTokenProvider}),
|
|
73
73
|
docs: require("./endpoints/inventory/docs.js")({client}),
|
|
74
74
|
documentTypes: require("./endpoints/inventory/document-types.js")({client, internalAuthTokenProvider}),
|
|
75
|
+
events: require("./endpoints/inventory/events.js")({client, internalAuthTokenProvider}),
|
|
75
76
|
externalPasses: require("./endpoints/inventory/external-passes.js")({client, internalAuthTokenProvider}),
|
|
76
77
|
externalWallets: require("./endpoints/inventory/external-wallets.js")({client, internalAuthTokenProvider}),
|
|
77
78
|
fareTypeModifiers: require("./endpoints/inventory/fare-type-modifiers.js")({client, internalAuthTokenProvider}),
|
|
@@ -18,7 +18,7 @@ const {
|
|
|
18
18
|
* @param {Object} deps
|
|
19
19
|
* @param {import("axios").AxiosInstance} deps.client
|
|
20
20
|
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
21
|
-
* @returns {{ put: function, all: function, create: function, signIn: function, signInCas: function, update: function, merge: function }}
|
|
21
|
+
* @returns {{ put: function, all: function, get: function, create: function, signIn: function, signInCas: function, update: function, merge: function }}
|
|
22
22
|
*/
|
|
23
23
|
function customersFactory({client, internalAuthTokenProvider}) {
|
|
24
24
|
/**
|
|
@@ -59,6 +59,22 @@ function customersFactory({client, internalAuthTokenProvider}) {
|
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* GET /customers/:customerId - get a customer by id.
|
|
64
|
+
* @param {Object} opts
|
|
65
|
+
* @param {string} [opts.token] - API key
|
|
66
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
67
|
+
* @param {string} opts.customerId - Customer id (24-char hex ObjectId)
|
|
68
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
69
|
+
* @returns {Promise<import("axios").AxiosResponse<{ _id: string, customerNumber: string, ... }>>}
|
|
70
|
+
*/
|
|
71
|
+
function get({customerId, token, jwtToken, headers}) {
|
|
72
|
+
return client({
|
|
73
|
+
url: `/customers/${customerId}`,
|
|
74
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
62
78
|
/**
|
|
63
79
|
* POST /customer - create a customer. Body: { customer }. If password is included, activation token is created and activation email sent. Side effect: may emit customer.created webhook.
|
|
64
80
|
* @param {Object} opts
|
|
@@ -168,6 +184,7 @@ function customersFactory({client, internalAuthTokenProvider}) {
|
|
|
168
184
|
return {
|
|
169
185
|
put,
|
|
170
186
|
all,
|
|
187
|
+
get,
|
|
171
188
|
create,
|
|
172
189
|
signIn,
|
|
173
190
|
signInCas,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const {authorizationHeaders} = require("./../endpoints_helpers.js");
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Factory for inventory event endpoint (btrz-api-inventory).
|
|
5
|
+
* @param {Object} deps
|
|
6
|
+
* @param {import("axios").AxiosInstance} deps.client
|
|
7
|
+
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
8
|
+
* @returns {{ get: function }}
|
|
9
|
+
*/
|
|
10
|
+
function eventsFactory({client, internalAuthTokenProvider}) {
|
|
11
|
+
/**
|
|
12
|
+
* GET /event/:eventId - get event by id.
|
|
13
|
+
* @param {Object} opts
|
|
14
|
+
* @param {string} opts.eventId - Event id
|
|
15
|
+
* @param {string} [opts.token] - API key
|
|
16
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
17
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
18
|
+
*/
|
|
19
|
+
function get({eventId, token, headers}) {
|
|
20
|
+
return client.get(`/event/${eventId}`, {
|
|
21
|
+
headers: authorizationHeaders({token, internalAuthTokenProvider, headers})
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return {get};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = eventsFactory;
|
|
@@ -11,7 +11,7 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
|
|
|
11
11
|
* @param {Object} deps
|
|
12
12
|
* @param {import("axios").AxiosInstance} deps.client
|
|
13
13
|
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
14
|
-
* @returns {{ all: function, create: function, update: function }}
|
|
14
|
+
* @returns {{ all: function, create: function, update: function, bucket: function }}
|
|
15
15
|
*/
|
|
16
16
|
function parcelZonesFactory({client, internalAuthTokenProvider}) {
|
|
17
17
|
/**
|
|
@@ -66,10 +66,26 @@ function parcelZonesFactory({client, internalAuthTokenProvider}) {
|
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
/**
|
|
70
|
+
* GET /parcel-zones/bucket - get matching parcel bucket.
|
|
71
|
+
* @param {Object} opts
|
|
72
|
+
* @param {string} [opts.token] - API key
|
|
73
|
+
* @param {Object} [opts.query] - Query params for bucket lookup
|
|
74
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
75
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
76
|
+
*/
|
|
77
|
+
function bucket({token, query = {}, headers}) {
|
|
78
|
+
return client.get("/parcel-zones/bucket", {
|
|
79
|
+
params: query,
|
|
80
|
+
headers: authorizationHeaders({token, internalAuthTokenProvider, headers})
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
69
84
|
return {
|
|
70
85
|
all,
|
|
71
86
|
create,
|
|
72
|
-
update
|
|
87
|
+
update,
|
|
88
|
+
bucket
|
|
73
89
|
};
|
|
74
90
|
}
|
|
75
91
|
|
|
@@ -17,7 +17,7 @@ const {
|
|
|
17
17
|
* @param {Object} deps
|
|
18
18
|
* @param {import("axios").AxiosInstance} deps.client
|
|
19
19
|
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
20
|
-
* @returns {{ all: function, get: function, create: function, update: function, remove: function }}
|
|
20
|
+
* @returns {{ all: function, get: function, create: function, update: function, remove: function, forParcels: function }}
|
|
21
21
|
*/
|
|
22
22
|
function zonePriceFactory({client, internalAuthTokenProvider}) {
|
|
23
23
|
/**
|
|
@@ -111,12 +111,31 @@ function zonePriceFactory({client, internalAuthTokenProvider}) {
|
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
/**
|
|
115
|
+
* POST /zone-prices-for-parcels - calculate zone prices for parcel payload.
|
|
116
|
+
* @param {Object} opts
|
|
117
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
118
|
+
* @param {string} [opts.token] - API key
|
|
119
|
+
* @param {Object} opts.payload - Parcel pricing payload
|
|
120
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
121
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
122
|
+
*/
|
|
123
|
+
function forParcels({jwtToken, token, payload, headers}) {
|
|
124
|
+
return client({
|
|
125
|
+
url: "/zone-prices-for-parcels",
|
|
126
|
+
method: "post",
|
|
127
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
|
|
128
|
+
data: payload
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
114
132
|
return {
|
|
115
133
|
all,
|
|
116
134
|
get,
|
|
117
135
|
create,
|
|
118
136
|
update,
|
|
119
|
-
remove
|
|
137
|
+
remove,
|
|
138
|
+
forParcels
|
|
120
139
|
};
|
|
121
140
|
}
|
|
122
141
|
|
|
@@ -29,6 +29,12 @@ describe("accounts/customers", () => {
|
|
|
29
29
|
return api.accounts.customers.all({jwtToken, token, query});
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
+
it("should GET a customer by id", () => {
|
|
33
|
+
const customerId = "66f6d6d5f57d8b6eb95a1122";
|
|
34
|
+
axiosMock.onGet(`/customers/${customerId}`).reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
35
|
+
return api.accounts.customers.get({jwtToken, token, customerId});
|
|
36
|
+
});
|
|
37
|
+
|
|
32
38
|
it("should POST a customer", () => {
|
|
33
39
|
const customer = {
|
|
34
40
|
firstName: "someFirstName",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const {axiosMock, expectRequest} = require("./../../test-helpers.js");
|
|
2
|
+
const api = require("./../../../src/client.js").createApiClient({baseURL: "http://test.com"});
|
|
3
|
+
|
|
4
|
+
describe("inventory/events", () => {
|
|
5
|
+
const token = "I owe you a token";
|
|
6
|
+
|
|
7
|
+
afterEach(() => {
|
|
8
|
+
axiosMock.reset();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("should get an event by id", () => {
|
|
12
|
+
const eventId = "event123";
|
|
13
|
+
axiosMock.onGet(`/event/${eventId}`).reply(expectRequest({statusCode: 200, token}));
|
|
14
|
+
return api.inventory.events.get({
|
|
15
|
+
token,
|
|
16
|
+
eventId
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -24,4 +24,17 @@ describe("inventory/parcel-zones", () => {
|
|
|
24
24
|
axiosMock.onPut(`/parcel-zone/${parcelZoneId}`).reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
25
25
|
return api.inventory.parcelZones.update({jwtToken, token, parcelZoneId, parcelZone: {productId: "6789"}});
|
|
26
26
|
});
|
|
27
|
+
|
|
28
|
+
it("should get bucket for parcel zone", () => {
|
|
29
|
+
axiosMock.onGet("/parcel-zones/bucket").reply(expectRequest({statusCode: 200, token}));
|
|
30
|
+
return api.inventory.parcelZones.bucket({
|
|
31
|
+
token,
|
|
32
|
+
query: {
|
|
33
|
+
productId: "product1",
|
|
34
|
+
fromId: "origin1",
|
|
35
|
+
toId: "destination1",
|
|
36
|
+
faresAndWeights: "[{\"fare\":\"adult\",\"weight\":1000}]"
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
});
|
|
27
40
|
});
|
|
@@ -73,4 +73,21 @@ describe("inventory/zone-prices", () => {
|
|
|
73
73
|
zonePriceId
|
|
74
74
|
});
|
|
75
75
|
});
|
|
76
|
+
|
|
77
|
+
it("should get zone prices for parcels", () => {
|
|
78
|
+
const payload = {
|
|
79
|
+
providerId: "provider1",
|
|
80
|
+
originId: "origin1",
|
|
81
|
+
destinationId: "destination1",
|
|
82
|
+
productId: "product1"
|
|
83
|
+
};
|
|
84
|
+
axiosMock.onPost("/zone-prices-for-parcels").reply(expectRequest({
|
|
85
|
+
statusCode: 200, token, jwtToken
|
|
86
|
+
}));
|
|
87
|
+
return api.inventory.zonePrices.forParcels({
|
|
88
|
+
jwtToken,
|
|
89
|
+
token,
|
|
90
|
+
payload
|
|
91
|
+
});
|
|
92
|
+
});
|
|
76
93
|
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export = eventsFactory;
|
|
2
|
+
/**
|
|
3
|
+
* Factory for inventory event endpoint (btrz-api-inventory).
|
|
4
|
+
* @param {Object} deps
|
|
5
|
+
* @param {import("axios").AxiosInstance} deps.client
|
|
6
|
+
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
7
|
+
* @returns {{ get: function }}
|
|
8
|
+
*/
|
|
9
|
+
declare function eventsFactory({ client, internalAuthTokenProvider }: {
|
|
10
|
+
client: import("axios").AxiosInstance;
|
|
11
|
+
internalAuthTokenProvider?: {
|
|
12
|
+
getToken: () => string;
|
|
13
|
+
};
|
|
14
|
+
}): {
|
|
15
|
+
get: Function;
|
|
16
|
+
};
|
|
@@ -8,7 +8,7 @@ export = parcelZonesFactory;
|
|
|
8
8
|
* @param {Object} deps
|
|
9
9
|
* @param {import("axios").AxiosInstance} deps.client
|
|
10
10
|
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
11
|
-
* @returns {{ all: function, create: function, update: function }}
|
|
11
|
+
* @returns {{ all: function, create: function, update: function, bucket: function }}
|
|
12
12
|
*/
|
|
13
13
|
declare function parcelZonesFactory({ client, internalAuthTokenProvider }: {
|
|
14
14
|
client: import("axios").AxiosInstance;
|
|
@@ -19,6 +19,7 @@ declare function parcelZonesFactory({ client, internalAuthTokenProvider }: {
|
|
|
19
19
|
all: Function;
|
|
20
20
|
create: Function;
|
|
21
21
|
update: Function;
|
|
22
|
+
bucket: Function;
|
|
22
23
|
};
|
|
23
24
|
declare namespace parcelZonesFactory {
|
|
24
25
|
export { InventoryParcelZonesQuery };
|
|
@@ -8,7 +8,7 @@ export = zonePriceFactory;
|
|
|
8
8
|
* @param {Object} deps
|
|
9
9
|
* @param {import("axios").AxiosInstance} deps.client
|
|
10
10
|
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
11
|
-
* @returns {{ all: function, get: function, create: function, update: function, remove: function }}
|
|
11
|
+
* @returns {{ all: function, get: function, create: function, update: function, remove: function, forParcels: function }}
|
|
12
12
|
*/
|
|
13
13
|
declare function zonePriceFactory({ client, internalAuthTokenProvider }: {
|
|
14
14
|
client: import("axios").AxiosInstance;
|
|
@@ -21,6 +21,7 @@ declare function zonePriceFactory({ client, internalAuthTokenProvider }: {
|
|
|
21
21
|
create: Function;
|
|
22
22
|
update: Function;
|
|
23
23
|
remove: Function;
|
|
24
|
+
forParcels: Function;
|
|
24
25
|
};
|
|
25
26
|
declare namespace zonePriceFactory {
|
|
26
27
|
export { InventoryZonePricesQuery };
|