btrz-api-client 9.2.0 → 9.4.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/lib/client-standalone-min.js +3 -3
- package/lib/endpoints/accounts/customers.js +28 -1
- package/lib/endpoints/notifications/pdf-data.js +2 -1
- package/lib/endpoints/notifications/pdfs.js +2 -1
- package/package.json +1 -1
- package/src/endpoints/accounts/customers.js +18 -1
- package/src/endpoints/notifications/pdf-data.js +2 -1
- package/src/endpoints/notifications/pdfs.js +2 -1
- package/test/endpoints/accounts/customers.js +6 -0
- package/test/endpoints/notifications/pdf-data.test.js +15 -0
- package/test/endpoints/notifications/pdfs.test.js +15 -0
- package/types/endpoints/notifications/pdf-data.d.ts +1 -1
- package/types/endpoints/notifications/pdfs.d.ts +1 -1
|
@@ -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,
|
|
@@ -7,7 +7,7 @@ const {
|
|
|
7
7
|
* Query params for GET pdf-templates-processing routes (btrz-api-notifications). Client uses type/family to resolve path.
|
|
8
8
|
* @typedef {Object} PdfDataGetQuery
|
|
9
9
|
* @property {string} type - Document type; determines path (e.g. product, giftCertificate, voucher, transaction, ssr, manifest, passengersManifest, order, order_confirmation, cancellation, change, shift, invoice, parcelManifest, startingBalance, partialShiftDeposits, bankDepositSlip, terminalVoucher, manualTickets, etc.). For pre_trip_notification and post_trip_notification the request uses GET /queue-notifications/manifest-notification-data/{itemId}.
|
|
10
|
-
* @property {string} [family] - When type is "product": "ticket" | "reservation" | "paid in" | "paid out" | "parcel" | "flexpass" | "bundle"
|
|
10
|
+
* @property {string} [family] - When type is "product": "ticket" | "reservation" | "paid in" | "paid out" | "parcel" | "flexpass" | "bundle" | "open-return"
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -61,6 +61,7 @@ function pdfDataFactory({
|
|
|
61
61
|
url = `/pdf-flexpasses/${itemId}`;
|
|
62
62
|
break;
|
|
63
63
|
case "bundle":
|
|
64
|
+
case "open-return":
|
|
64
65
|
url = `/pdf-redeemable-items/${itemId}`;
|
|
65
66
|
break;
|
|
66
67
|
default:
|
|
@@ -7,7 +7,7 @@ const {
|
|
|
7
7
|
* Query params for GET pdf-templates-processing binary routes (btrz-api-notifications). Client uses type/family to resolve path.
|
|
8
8
|
* @typedef {Object} PdfGetQuery
|
|
9
9
|
* @property {string} type - Document type (e.g. product, giftCertificate, voucher, transaction, ssr, manifest, passengersManifest, order, shift, remainderSlip, exchange, invoice, locationClosure, parcelManifest, startingBalance, partialShiftDeposits, shiftLocationClosure, bankDepositSlip, terminalVoucher, manualTickets, externalWalletVoucher)
|
|
10
|
-
* @property {string} [family] - When type is "product": "ticket" | "reservation" | "paid in" | "paid out" | "parcel" | "flexpass" | "bundle"
|
|
10
|
+
* @property {string} [family] - When type is "product": "ticket" | "reservation" | "paid in" | "paid out" | "parcel" | "flexpass" | "bundle" | "open-return"
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -63,6 +63,7 @@ function pdfFactory({
|
|
|
63
63
|
url = `/pdf-flexpasses/${itemId}`;
|
|
64
64
|
break;
|
|
65
65
|
case "bundle":
|
|
66
|
+
case "open-return":
|
|
66
67
|
url = `/pdf-redeemable-items/${itemId}`;
|
|
67
68
|
break;
|
|
68
69
|
default:
|
package/package.json
CHANGED
|
@@ -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,
|
|
@@ -7,7 +7,7 @@ const {
|
|
|
7
7
|
* Query params for GET pdf-templates-processing routes (btrz-api-notifications). Client uses type/family to resolve path.
|
|
8
8
|
* @typedef {Object} PdfDataGetQuery
|
|
9
9
|
* @property {string} type - Document type; determines path (e.g. product, giftCertificate, voucher, transaction, ssr, manifest, passengersManifest, order, order_confirmation, cancellation, change, shift, invoice, parcelManifest, startingBalance, partialShiftDeposits, bankDepositSlip, terminalVoucher, manualTickets, etc.). For pre_trip_notification and post_trip_notification the request uses GET /queue-notifications/manifest-notification-data/{itemId}.
|
|
10
|
-
* @property {string} [family] - When type is "product": "ticket" | "reservation" | "paid in" | "paid out" | "parcel" | "flexpass" | "bundle"
|
|
10
|
+
* @property {string} [family] - When type is "product": "ticket" | "reservation" | "paid in" | "paid out" | "parcel" | "flexpass" | "bundle" | "open-return"
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -61,6 +61,7 @@ function pdfDataFactory({
|
|
|
61
61
|
url = `/pdf-flexpasses/${itemId}`;
|
|
62
62
|
break;
|
|
63
63
|
case "bundle":
|
|
64
|
+
case "open-return":
|
|
64
65
|
url = `/pdf-redeemable-items/${itemId}`;
|
|
65
66
|
break;
|
|
66
67
|
default:
|
|
@@ -7,7 +7,7 @@ const {
|
|
|
7
7
|
* Query params for GET pdf-templates-processing binary routes (btrz-api-notifications). Client uses type/family to resolve path.
|
|
8
8
|
* @typedef {Object} PdfGetQuery
|
|
9
9
|
* @property {string} type - Document type (e.g. product, giftCertificate, voucher, transaction, ssr, manifest, passengersManifest, order, shift, remainderSlip, exchange, invoice, locationClosure, parcelManifest, startingBalance, partialShiftDeposits, shiftLocationClosure, bankDepositSlip, terminalVoucher, manualTickets, externalWalletVoucher)
|
|
10
|
-
* @property {string} [family] - When type is "product": "ticket" | "reservation" | "paid in" | "paid out" | "parcel" | "flexpass" | "bundle"
|
|
10
|
+
* @property {string} [family] - When type is "product": "ticket" | "reservation" | "paid in" | "paid out" | "parcel" | "flexpass" | "bundle" | "open-return"
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -63,6 +63,7 @@ function pdfFactory({
|
|
|
63
63
|
url = `/pdf-flexpasses/${itemId}`;
|
|
64
64
|
break;
|
|
65
65
|
case "bundle":
|
|
66
|
+
case "open-return":
|
|
66
67
|
url = `/pdf-redeemable-items/${itemId}`;
|
|
67
68
|
break;
|
|
68
69
|
default:
|
|
@@ -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",
|
|
@@ -274,6 +274,21 @@ describe("notifications/pdf-data", () => {
|
|
|
274
274
|
});
|
|
275
275
|
});
|
|
276
276
|
|
|
277
|
+
it("should return the proper data for an open-return redeemableItem", () => {
|
|
278
|
+
const itemId = "12345";
|
|
279
|
+
const query = {
|
|
280
|
+
type: "product",
|
|
281
|
+
family: "open-return"
|
|
282
|
+
};
|
|
283
|
+
axiosMock.onGet(`/pdf-redeemable-items/${itemId}`)
|
|
284
|
+
.reply(expectRequest({
|
|
285
|
+
statusCode: 200, token
|
|
286
|
+
}));
|
|
287
|
+
return api.notifications.pdfData.get({
|
|
288
|
+
token, query, itemId
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
|
|
277
292
|
it("should return the proper data for a gift-certificates", () => {
|
|
278
293
|
const itemId = "12345";
|
|
279
294
|
const query = {
|
|
@@ -203,6 +203,21 @@ describe("notifications/pdfs", () => {
|
|
|
203
203
|
});
|
|
204
204
|
});
|
|
205
205
|
|
|
206
|
+
it("should return the proper data for an open-return redeemableItem", () => {
|
|
207
|
+
const itemId = "12345";
|
|
208
|
+
const query = {
|
|
209
|
+
type: "product",
|
|
210
|
+
family: "open-return"
|
|
211
|
+
};
|
|
212
|
+
axiosMock.onGet(`/pdf-redeemable-items/${itemId}`)
|
|
213
|
+
.reply(expectRequest({
|
|
214
|
+
statusCode: 200, token
|
|
215
|
+
}));
|
|
216
|
+
return api.notifications.pdfs.get({
|
|
217
|
+
token, query, itemId
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
|
|
206
221
|
it("should return the proper data for a gift-certificates", () => {
|
|
207
222
|
const itemId = "12345";
|
|
208
223
|
const query = {
|
|
@@ -2,7 +2,7 @@ export = pdfDataFactory;
|
|
|
2
2
|
/**
|
|
3
3
|
* @typedef {Object} PdfDataGetQuery
|
|
4
4
|
* @property {string} type - Document type; determines path. E.g. "product", "giftCertificate", "voucher", "transaction", "ssr", "manifest", "passengersManifest", "order", "order_confirmation", "cancellation", "change", "shift", "invoice", "parcelManifest", "parcel_confirmation", "redeemable_items_confirmation", "sold_item_confirmation", "customer_card_membership", "user_password_reset", "new_account", "operator_manifest_capacity", "reaccomodation", "ticket_movement", "manifest_notification", "startingBalance", "partialShiftDeposits", "shiftLocationClosure", "bankDepositSlip", "terminalVoucher", "manualTickets", etc.
|
|
5
|
-
* @property {string} [family] - When type is "product": "ticket" | "reservation" | "paid in" | "paid out" | "parcel" | "flexpass" | "bundle"
|
|
5
|
+
* @property {string} [family] - When type is "product": "ticket" | "reservation" | "paid in" | "paid out" | "parcel" | "flexpass" | "bundle" | "open-return"
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
8
8
|
* Factory for PDF data (JSON) endpoints (btrz-api-notifications). Resolves URL by query.type (and query.family when type is "product").
|
|
@@ -2,7 +2,7 @@ export = pdfFactory;
|
|
|
2
2
|
/**
|
|
3
3
|
* @typedef {Object} PdfGetQuery
|
|
4
4
|
* @property {string} type - Document type: "product" | "giftCertificate" | "voucher" | "transaction" | "ssr" | "manifest" | "passengersManifest" | "order" | "shift" | "remainderSlip" | "exchange" | "invoice" | "locationClosure" | "parcelManifest" | "startingBalance" | "partialShiftDeposits" | "shiftLocationClosure" | "bankDepositSlip" | "terminalVoucher" | "manualTickets"
|
|
5
|
-
* @property {string} [family] - When type is "product": "ticket" | "reservation" | "paid in" | "paid out" | "parcel" | "flexpass" | "bundle"
|
|
5
|
+
* @property {string} [family] - When type is "product": "ticket" | "reservation" | "paid in" | "paid out" | "parcel" | "flexpass" | "bundle" | "open-return"
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
8
8
|
* Factory for PDF binary endpoints (btrz-api-notifications). Resolves URL by query.type (and query.family when type is "product").
|